Code Shop

Code Shop

Abhi Yerra  //  An entity composed of reality and pseudo-reality who enjoys coding, news, photography and wasting time.

Oct 17 / 9:30pm

NFS on (Snow) Leopard

I setup NFS4 on my home server to host my mp3s for iTunes to access.
However, I had trouble getting the Mac GUI to mount the NFS drives. So
I instead decided to use the command line.

 
sudo /sbin/mount_nfs -o resvport krusty:/home/abhi/iTunes MusicMount/ 

This should mount a nfs mount. Just set that MusicMount to be where
you want iTunes to store your files. So far this has been working out
great.

Filed under  //  linux   mac   nfs  

Comments (2)

Oct 1 / 10:21pm

Simple Vim Posterous Plugin

I like writing in Vim! It is one of those things that I am so used to
that every other text editor feels unnatural and going against the
grain. So I thought I'd write a small plugin to post to Posterous. Add
the following code to your .vimrc. Also make sure you have python
enabled in vim as well as have markdown2 for python installed.

The following need to be changed: blog_email, blog_password, and
site_id. site_id can be grabbed by running the following on the
terminal:

 
curl -u my@email.com:mYpA$$W0RD http://posterous.com/api/getsites 

Substitute the email and password. You will get a list of your blogs
so choose the id of the blog you want to post to.

The format of the text should be as follows: the first line is the
title and the proceeding lines are the body:

 
This is the title of the post 
 
This is the body of the post. 

This code is pretty straightforward and sparse because I am using this
to post code snippets to a private blog. Check out the Posterous API to add more
options and whatnot. Also take this as a start and expand upon it.

Filed under  //  code   plugin   posterous   vim  

Comments (1)

Oct 1 / 3:24am

Simple Clojure Http Client

I'm learning Clojure and needed a simple http client. Here is the one
I have written using the java libraries.

 
(import '(java.net URL HttpURLConnection) 
 '(java.io InputStreamReader BufferedReader)) 
 
(defn http-client-get-content [reader content] 
 (let [line (.readLine reader)] 
 (if (nil? line) 
 content 
 (recur reader (str content "\n" line))))) 
 
(defn http-client-get [url] 
 (let [connection (.openConnection (URL. url))] 
 (doto connection 
 (.setRequestMethod "GET") 
 (.setDoOutput true) 
 (.setReadTimeout 10000) 
 (.connect)) 
 (http-client-get-content (BufferedReader. (InputStreamReader. 
(.getInputStream connection))) ""))) 
Filed under  //  clojure   code  

Comments (0)

Sep 18 / 10:27pm

xterm Scheme

I found this xterm schema to be quite nice. Put in ~/.Xdefaults file.

 

 
XTerm*background: #000000 
XTerm*foreground: #9f9f9f 
XTerm*color0: #000000 
XTerm*color1: #9e1828 
XTerm*color2: #aece92 
XTerm*color3: #968a38 
XTerm*color4: #414171 
XTerm*color5: #963c59 
XTerm*color6: #418179 
XTerm*color7: #bebebe 
XTerm*color8: #666666 
XTerm*color9: #cf6171 
XTerm*color10: #c5f779 
XTerm*color11: #fff796 
XTerm*color12: #4186be 
XTerm*color13: #cf9ebe 
XTerm*color14: #71bebe 
XTerm*color15: #ffffff 
Filed under  //  linux   x11  

Comments (0)

Sep 14 / 9:05pm

Increasing Swap Space

Lately, I've been trying to compile Chromium on my desktop and I had been constantly getting an error associated with linking:

collect2: ld terminated with signal 9 [Killed]

After Googling around apparently the problem had to do with running out of swap space which causes the linking to fail. Chromium needs almost 700mb more memory to link than I was providing so it was failing. Interestingly, Linux has a really clean solution to increase the swap space.

sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576
sudo mkswap /swapfile
sudo swapon /swapfile

These three commands will create an empty file of 1gb, make that a swap file, and turn it on to be used.

 

Filed under  //  code   linux  

Comments (0)

Sep 4 / 7:40am

JRuby Deployment with Glassfish

It's early in the morning so I thought I'd write some thoughts before I continue on with my day. I've been working on abooklog as a side project to help keep track of reading for school. When deploying it I decided to go with JRuby as I really like its speed as well as its native threaded nature.

When choosing a deployment option mod_passenger does not work as it relies on the native MRI interpreter. So I decided to go with a combination of nginx and the glassfish gem. By using the glassfish gem I can avoid having to use a full blown Java Application Server. So basically deployment is relatively boring in that it's really similar to how you would deploy a mongrel application.

I am using Capistrano to deploy my application so here is the deploy.rb script:

Filed under  //  deployment   jruby  

Comments (1)

Sep 3 / 12:05am

Arora Browser

I'm getting a bit tired of using Firefox on Linux. It tends to be slow and bloated and though I would like to use Chrome it is not compiling on my Arch system. I think it has something to do with a lack of memory to link the various object files (I only have 512mb of ram on my desktop). So I'm using this lightweight WebKit based browser called Arora which is pretty fast. I mean the pages render ridiculously fast compared to Firefox. I recommend it to anyone on Linux, that is until Chrome comes out for Linux.
Filed under  //  browser   linux  

Comments (0)

Aug 6 / 12:55am

Economist Mailer Bot

There is one thing I have to admit Posterous has taught me and that is that email can be a powerful medium. I spend a lot of time in email even if I don't realize it and usually always have my Gmail window open.

Anyways, I enjoy reading the Economist, but it's quite difficult to figure out how much of the magazine is left other then a wild guess so I wrote an Economist Mailer Bot which essentially sends out a bunch of emails (one email per article) based on a cron schedule that you set (careful if you set it too soon your'll get a lot of duplicates).

The nice thing about this is that you can see you progress through your article queue (especially if you use filters) as well as being able to read the articles on my iPhone email client when on Bart. Yay, no need to write an app. 
Filed under  //  bot   code   news  

Comments (0)

Jul 31 / 10:40pm

Loading images from the Application Directory on iPhone

This is how you load an Image from the local application directory on the iPhone.

 

 
 [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Polareye" ofType:@"jpg" inDirectory:@""]]; 
Filed under  //  code   iphone   tips  

Comments (0)

Jul 28 / 9:42pm

Twitcures

When I last wrote about my NCurses Twitter client Twitcurses I just sort of glaced over it. So here is a bit more detailed usage of the app. It basically looks something like this.


The client refreshes after a set amount of time as set in the config file. I have set the default to 2 minutes which can be reset to whatever you please. But note there is a limit of 140 requests an hour (hey I just got why they limit it to 140...). To refresh your tweets press a capital R.

Sending a tweet is as easy as pressing a cap T. Which should pop up a message requesting you for a tweet.



If you want to cancel just enter a blank line.

Also the cool thing I added is using the Mac 'say' command to speak your new Tweets from the last time you refreshed. So basically whenever it refreshes it speaks any new tweets that have been created after the last time you refreshed. (This means it won't speak the first time you load the app since that will result in it speaking all of the tweets). I will add a mute feature promptly for the time when you don't want it to speak, also a config option for this would be useful.
Filed under  //  code   ncurses   twitter  

Comments (0)