In past few months, I worked on a project developed entirely on linux. Previously, I mostly did rails development on mac with textmate. I had a brief period of rails and perl where I did vim and screen…oh maybe 4 years ago. Anyways, so I didn’t forget much vim over the years, but I had forgotten how to use screen. I looked some documentation to refresh my memory and this post is mainly notes for me :)

Most commands start with CTRL-a
I refer to each spawning of a new screen in the current session as a window.

Detach
One things i really like about screen is I can detach it on one computer… then log in somewhere else and reattach. Also handy when you are on a wifi card on the train and you get disconnected. (doh!)

ctrl-a d to detach
then start with -r to reattach: screen -r

Create window
This creates a new terminal window

ctrl-a c

Name that window
Name your window, so its easier to keep organized
ctrl-a A (Yep, ctrl-a then SHIFT-a)

List the windows
See a list of your sessions and their number (this is why you name them) and you can use arrows to select)
ctrl-a “

Navigating Windows
You can flip through the windows in order or specify the number:
ctrl-a p previous window
ctrl-a n, ctrl-a [spacebar] next window
ctrl-a # the number you want to go to (starts at 0).

multiple regions in one
ctrl-a S create a split, creates a new region
ctrl-a TAB switch to next region
ctrl-a c create a terminal session in region
ctrl-a X close the region
ctrl-a C clear, this is like typing clear at the prompt to clear the screen

Closing
To exit a window, simply type exit. To exit and kill all windows do
ctrl-a ctrl-\

Scrolling
Using terminal on mac or linux won’t capture the scroll back…. so you must do it through screen
ctrl-a [ use the arrow key to navigate up

Refresh
ctrl-a l refresh the current display

HELP!!
To see the two (!!) pages of screen commands type:
ctrl-a ?

Command mode
Do you like typing?
ctrl-a : to get to command mode, then you can type commands instead of the ctrl foo jibberish

Need the time?
ctrl-a t ….displays the current system time

Named Screen Sessions
Maybe you are working on two separate projects at once, give each one its own screen session
screen -S ProjectOne
screen -S ProjectTwo
screen -list

then later you can do
screen -r ProjectOne

to reattach it and continue

One thing you can do it make it easier is to add this to your .screenrc

hardstatus alwayslastline “%?%{yk}%-Lw%?%{wb}%n*%f %t%?(%u)%?%?%{yk}%+Lw%?”

It will show the names of the windows you have and highlight the current one. You can see the numbers too so you can do ctrl-a # quickly to jump around.

Anyways, hope this was useful to someone. Let me know any suggestions or anything I can do better!

Sources:

I never really used a debugger until I did Java. Before that I did what was called “PHP Debugging” which is littering your code with print statements until you figure out what you need to know, then going back and making sure you deleted them! I sometimes would put a unique string like

print “QWE” . $myawesomevar

Or something like that, then going back and searching your code for QWE (just picked something that was easy to type!). But all that gets rather annoying. They might have nice debuggers for PHP now, I haven’t really done php in 4-5 years. I really didn’t understand the power of breakpoints until I did java and I thought that was pretty cool. Now that I do all ruby, I sort of miss eclipse (I didn’t actually think I’d ever say that…) since all I use right now is textmate and vi which don’t have the built debugger support that eclipse does. Some of the newer ruby editors might, I haven’t spent any research on them.

I found ruby-debug and it works great! You can set a breakpoint and then climb inside your application and peek around and see what is going on. I’ve done this in controllers and even in test mode.

If you use passenger, you can still use it but its a little tricky to setup. This blog post from duckpunching.com has some neat tips and a rake task to make it easier. Be sure to start the rdebug -c from the console after you have set a breakpoint and reloaded your page.

If you are using passenger, you can’t use the irb command inside of the ruby-debug console, but I found that most of the time just being able to poke around the variable space inside my app has been enough for me to understand what is going on.

There are quite a few commands available in the debug console, but these are the ones I’ve used:

help - view the list of commands
l list - this shows context around the current line the debugger is on
n next - moves to the next line
p print - print a variable
irb jump to console - I dont use this very often and it doesn’t work if you are using passenger
c cont - continue to end of breakpoint or end of page load, after I have seen what I want to see I do this to get out of the console

Resources

Anyways, hope some of you find it useful and happy debugging :)

Update: I wrote this in preparation for a short talk at AustinOnRails while giving the talk, the group had some suggestions:

put in a ~/.rdebugrc

set autoeval
set autolist

autolist - will run list command when you enter
autoeval - will eval each line, so instead of “eval @profile” to get it to print, it will automatically eval

doing m [object] can show methods in a nice table format. Thats cool, i have often gone to irb and did String.methods.sort but that is kinda hard to read.

Anyways, good stuff!

Yesterday I went to the Texas Javascript conference! Its was held in Austin, TX. I had bought the ticket probably about 3 months ago. In part, I wanted to learn more javascript and I wanted to check out Austin. Now, through a series of events, I have moved to Austin from Chicago recently. I really like the smaller local conferences, I’ve really liked attending Windy City Rails in Chicago and the YAPC (Perl) when we had it in Chicago.

There were 2 tracks of speakers and one track of impromptu talks/discussions in a third room. It was sometimes hard to choose, but here’s what I attended:

Douglas Crockford: Really, JavaScript?
I really liked this talk, he spoke very frank about the language and highlighted the good parts and bad parts. ECMAScript5 was passed and he said most people working on the language have never used it. He went over parts of the language explaining what is new. He said “Mashups are the most interesting thing in decades, taking components and wiring them together for the benefit of the user” ..which he followed with “A Mashup is a self inflicting XSS attack.” XSS attacks were first invented in 1995 and we have made no progress in 14 yrs to solve it. He talked about HTML5, stating that its a big step in the wrong direction. Its not correcting the problem. He recommends scrapping it and starting over, its terrible for security. It increased the attack surface and gives attackers new modes of attack, such as access to local database and inter-process communication. His final slide was “IE6 MUST DIE” in huge letters. Several people including myself snapped a photo. He said IE6 won’t die because we keep supporting it and coding around its flaws. He doesn’t think its unreasonable to ask people to update their software once a decade! So this talk was very informative and had some funny parts.

John Resig: JavaScript on the Mobile Web
I expected this to be more of how to make your javascript run on mobile phones, but it was an overview of all the platforms that are used and which ones have what browsers. He graded all the phones and their browsers with A, B or C scale. Some have very good emulators but some things are hard to test in an emulator, like interactions with the touch screen. That was pretty interesting…and now I know I need to spend about 5k to have all the phones I need to test on :)

Joe McCann: Rapid Prototyping with JavaScript
I watched this for about 25 mins, wasn’t sure its usefulness to me. So I went to Dan Webs talk.

Dan Webb: Building @anywhere: A Client-side Interface to Twitter
I walked in as he was talking about how twitter does communication when you give a site access to your login. It was pretty interesting. I wish I had seen all of this talk.

Paul Irish: 10 Things I Learned from the jQuery Source
I debated between going to “Eugene Lazutkin: Dojo for Programmers” because I think I know more about jQuery than Dojo, but since I don’t plan on doing Dojo at work, I decided to check out Paul Irish. I really like him on the yayQuery Podcast and his blogs. He gave a great presentation and it was my favorite of the day! He basically talked about javascript and looked up things in the jQuery source and explained what the javascript was doing. He was pretty funny and I really enjoyed it. I tried taking notes, but it was pretty fascinating to watch him code.

Alex Sexton: Breaking The Cross Domain Barrier
Another person from the yayQuery Podcast. He talked about different ways to get around the cross domain barrier. It was interesting, many things are new since I last did alot of javascript where I needed to load from another domain. He was pretty funny too.

Tom Hughes-Croucher: JavaScript Everywhere! Creating a 100% JavaScript web stack
I meant to go to this talk, but was in the hall talking to a guy from Facebook, swapping stories of working for Facebook vs Google and how I use facebook. I also talked to Jason Huggins a bit, creator of Selenium. I knew him from Chicago and we chatted about what was going on in Chicago and caught up a bit… and talked about testing. We share some of the same opinions and it was great to catch up.

Jason Huggins: JavaScript Frameworks & Functional Testing
This Jason leading a discussion with the creators of jQuery, Dojo and extJS talking about how we can standardize a way to test. It was pretty interesting, but they ran out of time.

JavaScript Tim Caswell: Writing a real-time game with NodeJS
I have looked at nodejs few times but never tried it. Now, I am going to have to try it. The speaker was very good and it was interesting.

Kyle Simpson: Web Performance & UI Architecture
I didn’t find this too interesting nor the other talk, so I basically talked to a few people in the lobby and headed home. Long day but I learned some cool stuff. :)

So, a great conference and made some new friends and saw some old ones! :)

For this years Finding Ada post, I would like to highlight several members of DevChix and their contributions and inspirations to the group.

Desi McAdam - One of the co-founders of DevChix. She is always there to put some perspective on things and teach me about diplomacy. Sometimes I get frustrated and speak without thinking things though :)

Susan Potter - Very technical and has very good reasons for why and how she does things. Whenever I see her post on DevChix mailing list, I will pay close attention to what she says.

Jen Stander - Another of the co-founders of DevChix, always a good friend to listen to me and helps me plan DevChix activities in Chicago.

Ginny Hendry- Member of Chicago Ruby group, she has been instrumental in planning Hack Nights for the group and enthusiastic about learning!

Sarah Allen - Inspired me to learn more about mobile development and I am amazed at the variety of things she is doing!

Sarah Mei - Along with Sarah Allen, they both have inspired me to do something for women in Chicago. A one-day workshop or something, the Chicago DevChix have a meeting in a few weeks to plan this!

And I would like to thank all of DevChix, veterans and newcomers alike! We are nearing 400 members and really I don’t know how to explain how supportive and inspiring they are!

/tear You Ladies Rock!!!

A few weeks ago I set out to compare Blueprint and YUI Grid. I built a page with blueprint. Then built it with YUI2 Grid and then thought about it awhile.

At first I was sold on blueprints CSS. Thats cool, thats tight! It just seemed to be so clever. But when i read the following blog I realized, hey blueprint's syntax "span-4, span-20" was putting the implementation into the markup and why is that much different than doing

which we all run in horror when someone uses a table to layout a page.

I quote from:
http://foohack.com/2007/08/blueprint-css-framework-vs-yui-grids/

If it is important enough to define your grid layout in the markup, then you should be using a table. The whole point of CSS layouts is to separate the layout information from the structural semantic markup

.. yuck!! I much prefer YUI2 grid and they have a nifty generator layout generator. I like that, I want to be able to define my basic layout and get on with life! I don't want to figure out how many "columns" this is and that. The class names for YUI are kind of non-intuitive (ie: yui-t7 and yui-g), but thats ok. They do use "hd" for head, "bd" for body, and "ft" for footer. So that is good enough for me!

You can easily assign accessibility tag of "role" to your layout too in the generator, by clicking on the regions drop downs and selecting things like banner, navigation, main, etc.

The following is a 75/25 two column layout

HTML:
  1. <div id="doc" class="yui-t7">
  2.    <div id="hd" role="banner">
  3.      <h1>Header</h1>
  4.    </div>
  5.    <div id="bd" role="navigation">
  6.      <div class="yui-ge">
  7.        <div role="main" class="yui-u first">
  8.       <!-- YOUR DATA GOES HERE -->
  9.       </div>
  10.       <div role="complementary" class="yui-u">
  11.      <!-- YOUR DATA GOES HERE -->
  12.       </div>
  13.     </div>
  14.    </div>
  15.    <div id="ft" role="contentinfo">
  16.      <p>Footer</p>
  17.    </div>
  18. </div>
  19. </body>

And the same converted to haml:

HTML:
  1. #doc.yui-t7
  2.     #hd{ :role => "banner" }
  3.       %h1
  4.         Header
  5.     #bd{ :role => "navigation" }
  6.       .yui-ge
  7.         .yui-u.first{ :role => "main" }
  8.           <!– YOUR DATA GOES HERE –>
  9.         .yui-u{ :role => "complementary" }
  10.           <!– YOUR DATA GOES HERE –>
  11.     #ft{ :role => "contentinfo" }
  12.       %p
  13.         Footer

Pretty slick, huh?

I did flash about 9-10 yrs ago. But I haven't used it since, so when I saw Flash Camp 2010 was being held in downtown Chicago, I thought why not! I like to have at least a passing knowledge of all web tech and I didn't know what Flex was all about. It was $20 and included lunch and beer at 4pm! It was very interesting, I thoroughly enjoyed seeing more about Flex. While watching the presentations, I was like, whoa... this seems like it does the same thing as GWT. Except, there is documentation! :)

James Ward, from Adobe gave the keynote. He went through the top 10 things he likes about Flex. That was really interesting. He showed how a pdf had an embedded swf that was a report that loaded live data. I asked a question, "Will other readers like Foxit be able to do this?" he said it was part of the PDF standard, so its up to other readers to implement it. But it is possible. He said they are working on a flash plugin for Android. I went up and asked him later in the day "why did it take so long? android has been out 2+ years?" He said they weren't sure about the hardware and what it would support, and they had to do alot of rewriting to make the binary small enough. Ok so I guess it was a lets wait and see what will happen then we will implement flash. IMHO i still think they are missing the wagon... but what do I know, I'm just a coder!

Jeff Tapper talked about Flex 4 for Flex 3 developers. I didn't know Flex at all but I still was fascinated by this talk. Kept thinking to the days of pain with GWT... i quick did a search on amazon for flex books..and there is alot.. so I was like, ok I am going to check this out. GWT is often frustrating because of the lack of documentation. Some books were written by Jeff!

Kevin Schmidt talked about accessing remote data in flex. During this talk i looked up flex builder and installed it. He accessed data in three ways so that was interesting.

Ben Schmidke talked about keeping your data grid healthy. He talked about how the datagrid is rendered and how you can optimize it for speed. I think he also showed an optimizer.

Adam Flater talked about Building RIAs with Style. He talked about styling your flex apps with some kinda of css-like syntax. Its not css exactly but looks similar.

Michael Labriola talked about Flex 4 Component Development. He explained why composition is better than inheritance. He showed how to make a circle layout. Custom layouts! ..this was really cool. I am anxious to learn more about Flex.

All in all, it was a good use of time and I won a book! Foundation ActionScript 3.0 for Flash and Flex. Be sure and watch as I do some poking around with flex and see if really I can do the same things as I might use with GWT.

In the past few weeks I've been doing alot of Git and alot more collaboration with people on projects! So i wanted to point out some of the things i've learned and some handy tips I picked up.

I was aimee remotely and she showed me how to "stage" a commit. Which is a way to indicate "HEY this is going to be commited when you do git commit!" I used to always do commit -a which adds all the files not currently in the staging. I used perforce for awhile and learned how nice it was to have a "change list" and how you can commit only certain files at a time. Git seems like you can only have one "change list" at a time but that is fine in most cases.

git add -p

It will go through each changed file and ask if you want to stage this hunk. We were able to see what files we had changed as it showed a diff. You can confirm or deny chunk by chunk. today I like to run it to make sure I didn't accidentally change a file. I have a habit of leaving a file open, walking away and coming back and adjusting the spacing. Probably not something I need to in a commit.

git status

This is really cool command, not only does it show you what is in staging it tells you what to do with the other files to either add/remove etc to get the commit in the shape you want. After working with git more, i went back and re-watched the peepcode screencast on git. I understand it better now!

After we committed, we realized we made a mistake in log message, so we did

git commit --amend

It will amend the last message in your git repo. I recently tried this with one of my commits, but I had already pushed to origin. I was kind of confused, so I asked aimee, she said

no If you have already pushed, you can git push --force to update, but be careful because it destroys references, so if there's a chance someone else may have pulled the commit in the meantime you won't want to go pulling the rug from under their feet, y'know! ;)

Ahh, makes sense aimee!!

Another sticky point for me was -- what is inverse of git add? git rm?I keep a git repo of code I am working on as I to learn stuff, practice etc. Most if it is probably not really worth browsing, but i like to point my friends there when I talk about what I am doing. I wanted to clean up some stuff that I don't want to keep and mistakenly thought if I git rm it would remove it from the staging. Nope, it removes it! Well, to revert a file back to what you use this:

git checkout -- file.txt

more on this Why is "git rm" not the inverse of "git add"?

Anyways, a few tidbits of information I've learned recently, hope this can help you git better at git :)

sources I found helpful

Seems like Pair Programming is "all the rage" lately in my circles. I haven't exactly done it before but after hearing about the success and rapid knowledge growth amongst those that pair program...I was almost dying to try it! Especially after i saw David Chelimsky and Corey Haines at WindyCityRails in Sept 2009. I saw them pair and do BDD with Rspec/Cucumber and it was so fascinating, It was like I was watching a ballet as they hopped from RSpec to Cucumber and back and forth. I was like, wow...I wish I was that good! I would have paid good money for a recording of that so I could watch it again and again! I see Corey Haines traveling around pairing with people too. Some people get together and play cards, but Corey gets together to code!

So ok, I like code, I like people, I want to try it! I live a little south of Chicago so its a long commute and it seemed everyone was so busy to pair in person when I asked. I asked on Devchix mailing list for suggestions on how to do pairing online. I had found a few, and the group had some good suggestions. I even had a volunteer to try it with me! This week aimee and I set a few hours aside to try it and see if we could do it!

This article was also sort of "paired" as it was written from my perspective with input and suggestions from aimee!

We asked on Devchix mailing list for suggestions on how to do pairing online. I had found a few, and the group had some good suggestions. I even had a volunteer to try it with me! This week aimee and I set a few hours aside to try it and see if we could do it!

After introductions on Skype we set about getting a shared environment in which to code together. Ideally, we wanted some kind of desktop sharing so we could run tests, console and editor.

We had heard of a few tools and got suggestions from the devchix list:

IChat desktop sharing - we couldn't get this to work, we did different things and it would appear to connect but then it failed. I tried to mess with settings for Sharing on mac, but nothing doing.

Rio seems to be a library to make collaborative apps, not to use in a pair programming environment.

BeSpin was hard to use.. we couldn't figure out exactly how to use it. It almost seemed to offer to import the git repository we were working on, but then it said it only supports Subversion and Mercurial, not git.

SubEthaEdit worked but we would have to open each file individually and share each file... unless I was missing something. This would be fine for collaborating on a single file but then we could not share the test runs, terminal commands or view the browser together.

Etherpad - we didn't end up trying this but I have used it before to debug some code or try out ideas with a friend. They recently got bought by Google, so it would be interesting to see what they do with it. This would suffer the same limitations as SubEthaEdit in that it's just a text editor.

GoToMeeting (which is $40-50/month) its a little steep for the open source work I want to do. But people say it works really well.

VNC and Unix Screen - aimee had used this successfully before but since we weren't on the same network, just our laptops at home, we weren't sure it how we could make it work easily.

Then we came to TeamViewer which worked brilliantly! We shared desktop and I could type in aimee's console window, see the tests running and type in textmate. Even with aimee on her Dvorak keyboard and I on Qwerty! I could type fine but couldn't copy/paste with keyboard shortcuts so I used the mouse to copy/paste and it worked fine.

All in all, it was an awesome experience and I picked up on a few tidbits of knowledge from aimee on git, and rake! I had some bits of code from another project i was able to quickly copy/paste and get us rolling. We had a few discussions about coding style as we went.

Since aimee was more familiar with the codebase, she mainly wrote the behavioral specs and I wrote the code to satisfy them. We plan to switch around next time, when we pair on a different project that I've been developing for a while.

Its been a crazy December through January and I haven't written much!

I'm glad the GWT posts helped some of you from the comments. I spent some time on figuring them out from the limited docs on google's GWT site, mostly I think it helps to have complete examples since they dont make it real clear what file each snippit of code goes in. I'm glad the pain I went through to figure them out help some of you :) A few of you had problems but i haven't gotten around to seeing what is wrong. I was using the trunk version of GWT, so if you are using 2.0 then you might have some differences.

I've been diving my head back into rails after spending a spell in perl/mason and GWT in some projects for work. I think other languages are neat but I really love ruby. So I've been re-watching some of my episodes of PeepCode.com and RailsCasts.com those guys are awesome. I love this stuff. Why else would I be spending my Saturday night with Ruby vs watching a movie or playing a game!

I've also been playing with android a bit, its pretty fun to see my app on a phone! Working on a TODO List app, which seems almost like "hello world" but it has a twist... more later when i have something to show.

Been working learning jQuery. I had seen it before, but saw class names mixed with programming and having a ugghhhh feeling. But.. I decided to give it a shot and dang! I would have given my right arm to have this 5 years ago when i was experimenting with ajax (though it wasn't called that...) with setting the src of a script tag with a php url to load and save data. Anyways, its cool and neat. I think the name is horrible since you aren't really quering anything... IMHO :) Maybe if I can think of a better one I can suggest it, but seems like it is here to stay since there are stay since there are 4 books already about it!

To help with reviewing ruby I have been working through Ruby Koans. Hats off to EdgeCase. I have already written them and thanked them! This goes along with my post How To Get Better At Programming where I wrote about how i was working at getting better at programming. It all comes down to practice! ... I think when I finish the rubykoans exercises, i will revert and start going through them again. Almost like doing pushups every day (I push up to get more coffee at least 3x a day!).

Git ... I did my first pull request on github, very cool how that works.

Have some ideas for some more substantial posts... coming soon :)

I've have been pondering in the past 6 months - How do I get better at programing? What is the best way? do I need more books? At my current company, we whole heartedly engage in peer reviews, nothing gets checked in the repository without at least one person going over it. In that process, i've learned more about coding then I could from 10 books. I used to be a book fiend. I had about 10 books on every subject. Did I learn? yeah, some! But I think I've learned more from doing and practice. Practice, practice, practice! When the Chicago Ruby User Group offered this book in exchange for a review, I jumped at the chance.

“Refactoring in Ruby” written by William C. Wake and Kevin Rutherford.
Published by Addison-Wesley

"Refactoring in Ruby" is more like a "workbook" then a "how to write awesome code" book. If you download the code from github http://github.com/kevinrutherford/rrwb-code you have tests already written for the exercises.

The book is arranged in three parts, The Art of Refactoring, Code Smells, and Programs to Refactor.

There are explanations of "code smells" which are one characteristic of code that could be improved. Some of them are long parameter lists, unnecessarily complex, global variable, feature envy sections, etc. One thing I find interesting is the "How did it get this way?" section. It gives some insight into the thought process and reasoning behind the smell. I think this is good, as programmers our ego may be rather miffed to hear "This code stinks" but with some reasoning, it makes the pain less and I think firms up in our minds when this happens again, to do it this other way. I always want to know why when someone says I could do such and such thing better.

In addition to the code smell examples there are three programs to refactor in the end of the book. In a conversational tone, it walks through and gives some hints on what needs refactoring. Its almost as if you had a pair programming buddy working with you and identifying in small chunks what can be improved. This is definitely something I want to work through more carefully.

What I find odd, is that not all the code smells have code examples. The inspiration for the book I think is the Martin Fowler book "Refactoring Improving the design of Existing Code" which has examples for every code smell. Maybe Ruby smells less than Java? Or those fixes are really trivial? I don't know. Overall, this is a great book and is certainly worth the price and investment and you will be a better programmer because of it!

There are explanations of "code smells" which are one characteristic of code that could be improved. Some of them are long parameter lists, unnecessarily complex, global variable, feature envy sections, etc. One thing I find interesting is the "How did it get this way?" section. It gives some insight into the thought process and reasoning behind the smell. I think this is good, as programmers our ego may be rather miffed to hear "This code stinks" but with some reasoning, it makes the pain less and I think firms up in our minds when this happens again, to do it this other way. I always want to know why when someone says I could do such and such thing better.

In addition to the code smell examples there are three programs to refactor in the end of the book. In a conversational tone, it walks through and gives some hints on what needs refactoring. Its almost as if you had a pair programming buddy working with you and identifying in small chunks what can be improved. This is definitely something I want to work through more carefully.

What I find odd, is that not all the code smells have code examples. The inspiration for the book I think is the Martin Fowler book "Refactoring Improving the design of Existing Code" which has examples for every code smell. Maybe Ruby smells less than Java? Or those fixes are really trivial? I don't know. Overall, this is a great book and is certainly worth the price and investment and you will be a better programmer because of it!

Next Page »