Showing posts with label development. Show all posts
Showing posts with label development. Show all posts

20140605

pow and byebug - staying in the web app dev env heaven: an update for ruby 2.1

The previous version (for ruby 1.9) is here.

It seems ruby-debug has fallen out of favour with the community and the replacement is byebug.
So here's my follow-up on the old post.

The steps to enable byebugging in your app dev env:
  1. echo export POW_WORKERS=1 >> ~/.powconfig  # make sure pow runs only one app process — globally
  2. cd <your project directory>
  3. Add byebug to your bundle (and remove ruby-debug if exists).
  4. Paste the following snippet at the end of your config/environments/development.rb — for rails, or in the appropriate development environment initialisation module — for the platform of your choice:
  5. echo export RUBY_DEBUG_PORT=10007 >> .powenv  # make sure we enable debugging with a machine-unique port, e.g. 10007 (you should pick different ports for different projects)
  6. touch tmp/restart.txtThen make any request to actually restart your server.
  7. byebug -R localhost:10007 -d  # you're back in business, go wild with debugger's in your code

20120403

pow, guard and rdebug - staying in the web app dev env heaven: for ruby 1.9 only

The new version (for ruby 2.1) is here.

If you, like me, use pow and guard (with spork of Rails 3 standard setup) for the perfect web app development environment, you might have stumbled upon a problem of debugging the server with rdebug -c which tends to connect to a wrong process even when working on just one project (and that's because spork itself starts the remote debug server by default).

So, firstly, you will probably want to limit your server instances run by pow to 1 by
echo export POW_WORKERS=1 >> ~/.powconfig

Then, to actually enable remote debugging you should place the following in your ./config/environments/development.rb:


And finally, to set the port of your choice for the project,
echo export RUBY_DEBUG_PORT=10007 >> ./.powenv

Now, you are welcome to
touch tmp/restart.txt
and (after a bunch of your CPU's cycles)
rdebug -c -p 10007

You're back in heaven, have a happy stay!

20100720

lvalue tip

while — very unfortunately — this

irb(main):042:0> x,y=0,0
=> [0, 0]
irb(main):044:0> if nil then x else y end = 1
SyntaxError: compile error
(irb):44: syntax error, unexpected '=', expecting $end
if nil then x else y end = 1
                          ^
    from (irb):44
    from :0
does not work, this
irb(main):048:0> x,y=[],[]
=> [[], []]
irb(main):049:0> if nil then x else y end << 1
=> [1]
irb(main):050:0> x
=> []
irb(main):051:0> y
=> [1]
performs nicely.

i know the difference, but it's still controversial to me.

20090719

in-cwd web serving

I've come across a simple need to serve some (static) files temporarily, for the development. I didn't find anything on the surface for this purpose, though the need may be quite common, hence the note.
The obvious choice for the server is lighttpd, and the scripting goes along the lines of lighthere.sh.

If anyone is aware of another known-good solution, please share.

20090604

programming as an evolutionary advantage

It might just happen that the ability to program – spanning informational pattern recognition through behaviour formalisation – is the next woman's skill along the line of the commonly accepted ones, in our information-driven civilisation.
The human brain processing capacity – acknowledged evolutionary advantage of our species – will most probably not increase any time soon, but rather re-utilised by outsourcing particular activities to individually programmable computer systems.
What this might do to our culture – I can only guess. Let's not live in denial then, my hopes are for good.

Some related, but practical stuff of mine coming soon.