open source


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!!!

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 Screenaimee 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.

Note: as of right now, you can only get this feature in Trunk. see here for how to download the source and use it More Info on release

One of the great new features coming out of GWT 2.0 is UiBinder, a way to make a declarative UI without making tons of objects. Reminding you of swing? Yeah, I didn't sign up to be a Swing developer. I was sort of disturbed when I started doing gwt and was writing tons of java to just do simple HTML things.

Full Source

JAVA:
  1. CheckBox rubyCheck = new CheckBox("Ruby");
  2. rubyCheck.setFormValue("ruby");
  3. boxes.add(rubyCheck);
  4.  
  5. CheckBox pythonCheck = new CheckBox("Python");
  6. pythonCheck.setFormValue("python");
  7. boxes.add(pythonCheck);
  8.  
  9. CheckBox javaCheck = new CheckBox("Java");
  10. javaCheck.setFormValue("java");
  11. boxes.add(javaCheck);
  12.  
  13. CheckBox phpCheck = new CheckBox("PHP");
  14. phpCheck.setFormValue("php");
  15. boxes.add(phpCheck);
  16.  
  17. // set up panel
  18. Panel panel = new VerticalPanel();
  19. panel.add(new Label("Choose a language:"));

Compare to the UiBinder code:

XML:
  1. <ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
  2.     xmlns:g='urn:import:com.google.gwt.user.client.ui'>
  3.     <g:VerticalPanel>
  4.       <g:Label>Choose a language:</g:Label>
  5.       <g:CheckBox ui:field="rubyCheck" formValue="ruby">Ruby</g:CheckBox>
  6.       <g:CheckBox ui:field="pythonCheck" formValue="python">Python</g:CheckBox>
  7.       <g:CheckBox ui:field="javaCheck" formValue="java">Java</g:CheckBox>
  8.       <g:CheckBox ui:field="phpCheck" formValue="php">PHP</g:CheckBox>
  9.       <g:Button ui:field="button">Submit</g:Button>
  10.     </g:VerticalPanel>
  11. </ui:UiBinder>

It is somewhat like HTML, each item with attribute "ui:field=" is the reference to the object that gets created in Java. Here's the Java code that uses this:

Full Source

JAVA:
  1. public class LanguageList extends Composite {
  2.  
  3.   interface MyUiBinder extends UiBinder<Widget, LanguageList> {}
  4.   private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
  5.  
  6.   @UiField CheckBox rubyCheck;
  7.   @UiField CheckBox pythonCheck;
  8.   @UiField CheckBox javaCheck;
  9.   @UiField CheckBox phpCheck;
  10.   @UiField Button button;
  11.  
  12.   public LanguageList() {
  13.       // bind XML file of same name of this class to this class
  14.       initWidget(uiBinder.createAndBindUi(this));
  15.       
  16.       final ArrayList<CheckBox> boxes = new ArrayList<CheckBox>();
  17.       boxes.add(rubyCheck);
  18.       boxes.add(pythonCheck);
  19.       boxes.add(javaCheck);
  20.       boxes.add(phpCheck);
  21.   }

We still have to add them to the Array (which is use to display checked results) but doesn't that look so much better? And you are able to add the values of the checkboxes to the xml too.

When using UiBinder, make sure you add it as inherits to the xml for the module (i forgot at first and had errors with gwt trying to find UiBinder!)

I didn't do exactly one-to-one comparison between UiBinder and not, but i do have two complete gwt apps you can look at. I find it really helpful when learning something to look at complete apps rather than just snippits of code.

There is some documentation on Ui:Binder on Google Code, but at first I found it hard to follow since it doesn't say what files each piece goes in, it took me awhile to figure it out. Maybe its just me though. :)

Before UiBinder
After Ui Binder

Anyways, just a quick example that might help some people out there. I want to explore more about patterns in GWT and I'll write them up here.

Sometime ago a co-worker asked me what my github name was. I had forgotten..I hadn't used it in so long! He was surprised that I didn't have any open source code out there! I said, umm..i haven't written anything I think someone would want!

I tend to start projects, work a bit on them and leave them. I find something new and exciting. I get busy with school, work, and life. But I really want to make something that I can release as open source and work with people. At work, I am on a team of developers and its nice, when I am stuck or not sure if this thing is good idea, I can ask. In previous jobs, I was mostly the sole developer, or at least only one on my project.

How do I get better at programming? I've been thinking about this alot as I am trying to learn java (I have the syntax pretty well but there is more to a language than syntax). Well, its practice! practice and practice. Having someone review your code and get better because of it. I want to get better at Java. I want to make an android app. So I finally started one .. with someone!

I am part of this great group of ladies in DevChix. A group me and 3 others started sometime ago. I had the idea (and this has always been in the back of my mind when I started DevChix) to start a project with someone and commit to 2-4 hours a week. I posted to the list, found someone with some experience in android and also the same desires as me. We started a really simple app (a todo list, how original!) but its a start. I threw something together which was really a collection of all my started and not finished android apps rolled into one. I had listing of tasks, add tasks didn't work quite right. I uploaded what I had and Jessica checked it out and made it work. There is a long way to go ... but... hey we started it!

Our rough design:
http://wiki.devchix.com/index.php?title=Android_Project:_Daily_ToDo_List

Our project:
http://code.google.com/p/devchix/source/browse/