Uncategorized


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:

Lately, I have been fascinated with Google Web Toolkit as of late. What you say, you love ruby but doing java?!!? My ruby friends will probably smack me but really i love all languages. The widgets and rpc stuff, that is pretty cool as well as learning how to do MVP. There are some new features in trunk that will be released “this fall” but I don’t want to wait that long, so last night i set about to checkout and compile trunk and try it out!

1. I installed the latest version of eclipse Galileo, with the Google plugin
http://code.google.com/eclipse/

2. Checkout the source code
http://code.google.com/webtoolkit/makinggwtbetter.html#workingoncode
Make sure you have ant installed. It takes awhile, i think maybe 20 mins or so on my macbook.

3. Setup the API directory in the Preferences for GWT
It took a while (and many searches) of messing around to figure out how to switch to the trunk version of the API.

Go to Eclipse > Preferences. Find the Google Web Toolkit on the left. It has an interface to add/remove APIs. Click add, add the path like so:
~/gwt/trunk/build/lib
I named it “trunk”

4. Create project
Create a new Web Application Project, select “trunk” as the version of API. And now you are on your way!

Once i’ve done a little more with it, I’ll write about some of the new features that are really awesome.

It been months since I went…but I was missing my ruby peeps! I didn’t see too many of the old faces and they have started a new tradition of going out for a beer afterwards which is always a good time when I can talk code over a Guniness! Good times!

The talk was about something I had not heard of before — Sinatra. It seems like it would be nice for a lightweight site that you didn’t need alot of the power of rails. It has a testing framework too. It is able to use the data mapper ORM which was also new for me. I’ve always wondered what it was like, it seems pretty cool.

Man i want to really work on some ruby now!!!

Wow, its been a long time since I wrote anything. I guess I haven’t done too much cool lately in programming or really much coding to think of it. But I have been working on some things…

Android! — I’ve been working on an android app with a friend … soon we can talk about it I think. Its kinda fun to program and actually see it on a device. I’ve been bored with web programming, so this is actually something different and interesting.

School! — I’m starting a masters program in computer science. First class? … Java … Though I am not superexcited about java, it what I need at work now. SO, java it is. I took my ruby books off my desk so I wouldn’t have to be reminded of them. ::sniff:: ::sniff:: (Don’t slap me Obie!)

Haskell! — Yeah, I’m learning Haskell … I am reading Real World Haskell which is available free but I also ordered the book. Nothing like flipping through pages of a book… but its also nice to have it online too! I’ve always “heard” it makes you think differently and so I am looking forward to that since I’ve been bored with programming really the past 6 months.

Well, thats all for now … look for some tidbits about haskell and android in upcoming weeks.

I am not not not not doing it! I am not getting an iphone. The lower price is very very tempting… but I am not doing it. A friend of mine signed up for an apple developer account like hours after it opened — I asked him yesterday if he was approved and he said ONLY 4 PEOPLE ARE! out of 200k … huh? what? where are all the HUNDREDS of apps that Apple thought would magically appear when they let the SDK loose on eager developers. Hello?

What is going on Apple? I love my mac… and would like to have a phone that would integrate with it ….

Meanwhile I haven’t done too much with Andriod development but I keep up reading blogs about it. I don’t feel like I have all the restrictions and “Steve Jobs says …”

I’m holding out for an android phone…and by the rate things are going with the iphone developers.. my app will be done before yours.

I’ve been doing a variety of things lately:

Playing with Android
I got the “Hello Android” beta book from Pragmatic Programmers — I am trying to remember its beta but its sort of hard to follow. Be prepared to download the source code for the book and compare to what the book has to see what is missing, so you can get your thing to run. I am going to look at some other tutorials at the moment to get more familiar. Maybe the author assumes the reader knows more than me! Which is possible since I haven’t done much java programming.

Wordpress 2.5.1 and EngineYard

The DevChix.com blog is a wordpress blog and hosted at DreamHost. We got a free slice for DevChix from the kind folks at EngineYard. They were nice enough to set it all up for us with wordpress and giving us a deploy.rb file ready to go! Their support is pretty fast too and I was able to get some help from the irc chat as well. The new wordpress has some neat features and looks nicer. I want to install a captcha though for blog comments, even with Akesmet I get tired of sorting through them! I was able to get all our plugins installed and seems good.

Playing with App Engine
I worked on this last week while on an airplane. I wasn’t sure it would work offline — but it did. Even the database…err..yeah whatever it is. I was able to add data ..but where is that data?

Django your mango
Yes, been checking it by doing the bundled tutorials. I haven’t gotten back to it since my last post. Need to get back to it before I forget what I was doing. haha.

Git ‘er done
Finally, I am going to learn git and try it on a project with a friend. I am hoping it proves useful since I often code on the go with no internet access. I sometimes have to do a poor mans cvs and save things as myfile1.rb myfile2.rb to try out things and then able able to “go back”. Rock and roll.

I’ve been hankering to try out programming for a device. I did a hello world app for my pocketpc with c++ years ago. Apparently it didn’t hold my interest cuz I never did much with it. I am not enthusiastic about the iphone and its developer requirements and restrictions (way to piss on the developers Apple). So I’ve been wanting to try out Android for awhile now.

I was excited to see a new beta book out by Pragmatic Programmers — on Android! hot dog! I bought it the same day and installed the SDK, Eclipse and the Eclipse plugins on my macbook. I installed an emulator too. It worked without a hitch — which I kinda expected there to be some goofy java error or some nonsense that would frustrate and discourage me. Nope — worked real easy.

The intro was real easy to understand and explained the different components. The book tells you about a soduko game that you will develop over the course of the book. I like that idea and I think its an excellent way to learn.

I do the Hello World application following the instructions in the book (yeah I know there are hello world tutorials on the google site). Whoo hoo! It worked! Excited I move on.

The next example I had some problems with. I think some code is missing from the book. I looked high and low and emailed the author and logged a issue at PragProg.com … no response yet, but I figured out if I just removed that part of the code then it worked. Just didn’t have a background color set. Oh well — I’ll be patient to see if someone gets back to me or its fixed in the next version of the book.

Moving on, I see code snippits that should be in certain files but not sure where in the file they go and I think sometime they are missing some import statements. I get errors and I poke around to figure it out ..and I give up for the moment … :(

Its a beta book.. so.. guess we’ll have to wait till the next version comes out..

Meanwhile I checked out some of the examples that Google has on their site.

The author got back to me and told me to check out the source code for the sample program….and he’d try to make it more clear about the background color.

I will keep plugging on!

I am writing a rails application for my mom to enter her bakery orders for her business. The Order page has a form to search or add a new customer, so i can streamline the process as much as possible. In the Order create method, I either get a customer array or a customer ID.

Here's the order create method in the controller:

RUBY:
  1. def create
  2.    
  3.     new_customer = params[:order][:customer_id].blank? ? true : false
  4.    
  5.     if new_customer
  6.       @customer = Customer.create(params[:customer])
  7.       if @customer.valid?
  8.         @customer.orders.create(params[:order])       
  9.         flash[:notice] = 'New customer was added and order was created successfully'
  10.         redirect_to orders_url
  11.       else
  12.         flash[:notice] = 'Please fill in all required fields'
  13.         render :action => 'new'
  14.       end
  15.     else
  16.       @customer = Customer.find params[:order][:customer_id]
  17.       @customer.orders.create(params[:order])
  18.       flash[:notice] = 'Order was successfully created.'
  19.       redirect_to orders_url
  20.     end
  21.  
  22.  end

Ok? anybody see a better way to do that? It took me awhile to figure out the right branching. Now for my rspec tests. This can take two paths -- new customer or existing customer.

Test for New Customer:

RUBY:
  1. describe OrdersController, "handling POST /orders with a new customer" do
  2.  
  3.   before do
  4.     @order = mock_model(Order, :to_param => "1")
  5.    
  6.     Order.stub!(:create).and_return(@order)
  7.    
  8.     @params = {:customer_id => nil}
  9.    
  10.     @customer = mock_model(Customer, :to_param => "1")
  11.     @customer.stub!(:orders).and_return(Order)
  12.     Customer.stub!(:create).and_return(@customer)
  13.   end
  14.  
  15.   def post_with_successful_save
  16.     @customer.should_receive(:valid?).and_return(true)
  17.     post :create, :order => @params
  18.   end
  19.  
  20.   def post_with_failed_save
  21.     @customer.should_receive(:valid?).and_return(false)
  22.     post :create, :order => @params
  23.   end
  24.  
  25.   it "should create a new customer" do
  26.     Customer.should_receive(:create).with(anything()).and_return(@customer)   
  27.     post_with_successful_save
  28.   end
  29.  
  30.   it "should create a new order" do
  31.     Order.should_receive(:create).with(anything()).and_return(@order) 
  32.     post_with_successful_save
  33.   end
  34.  
  35.   it "should redirect to the new order on successful save" do
  36.     post_with_successful_save
  37.     response.should redirect_to(orders_url)
  38.   end
  39.  
  40.   it "should re-render 'new' on failed save" do
  41.     post_with_failed_save
  42.     response.should render_template('new')
  43.   end
  44. end

Hows that look? do I catch all the cases for the New Customer scenario?

My friend David did a fun thing, Oscar Picks!

You can even get a widget and display on your blog:

Here are my picks:

I finally made it to a ruby related conference! I almost went to the past two rails confs but something always came up (like -- new jobs!). Looking forward to meeting lots of people..

So far the session on Advanced Class Design is awesome... more updates to come

Next Page »