Last month I launched http://scaffoldhub.org, a gallery of different Rails scaffolding generators. Initially I posted three scaffolds myself to get the site started.
I just updated the site now to allow anyone to login and contribute new scaffolds… if you like the idea please think about contributing a scaffold! I hope it can someday become a helpful resource for the Rails community. If you do decide to try to write and contribute a scaffold: thanks! Please contact me anytime and I’ll try my best to answer any questions, improve the process or fix bugs…
Today I was trying to connect to SQL Server from my OSx Mac and I was getting "
Unable to connect: Adaptive Server is unavailable or does not exist".
I was able to connect to another sql server in the same farm from laptop.
Found out by default --> TCP connectivity is disabled for SQL Server.
Microsoft SQL Server 2008 R2 > Configuration Tools > SQL Server Configuration Manager > SQL Server Network Configuration > Protocols for MSSQLSERVERProtocol Name: TCP/IP (Enable)Thats all :))
A new Socialtext customer, a government organization, is in the process of launching Socialtext for collaboration within and across project teams implementing a major set of environmental initiatives. Today they asked me a fundamental question: "Should we create a separate...
Who knew Le Peep had so many locations around the country from Colorado to Texas to New Jersey?! They are famous for their breakfast and lunch. The place tends to have that diner type feel which shows up in the quantity of the food as well, though I think the experience is not as casual. [...]
This is one of most common error, you will find when you start working with rails3. But the solution is really simple. Just change the gemname to mysql2 instead mysql in the Gemfile. By now we know, that Gemfile is like a repository of the gems we need for the application, somewhat like unpacking a gem, so that we do not need to install manually the huge list of gems in each environment and bite our nails if we miss something.
The entry in Gemfile is something like this,
gem 'mysql2'
from the command propmt, go to the directory where your app is, and execute the following command to install all the gems in gemfile
bundle install
That;s it your gem mysql2 has been installed.
Now you need to change the database.yml adapter from mysql to mysql2.
run rake db:create
and see your app up and running in http://localhost:3000 (ofcourse you need to start the server , if not started yet ;)
rails server
Happy Rails-ing :)
Lately I am trying to get hold of version control tool git. I have worked with svn but git has whole of other options and believe me it is not so bad as your first impression if you are an svn user. First Impression is not the last impression, always. Actually this is not the first, as we need to unlearn certain things which sometimes makes it tough. Got hold of the below link in case you use both, like me and often get confuse with the syntax.
http://git.or.cz/course/svn.html
- Download git on windows from http://code.google.com/p/msysgit/downloads/
- Use git
- Ssh-keygen –t rsa –C hello@gmail.com
- git config --global user.email hello@gmail.com
- git config --global user.name “Hi Hello“
- git config --global github.user hi-hello
- git config --global github.token 0987654321yourf0123456789
For some advanced concepts in gitMigrate from svn to git
Do a SVN Export of the repository you want to migrate to GIT.
• Goto the Directory
• git init
• git add .
• git commit –m ‘Migration from SVN to GIT’
• git remote add origin git@repository_location.com
• git push origin master
Git Stash
Very often while committing or pushing or pulling our changes in/from remote repository, we get the error message, like "you have local changes, please stash your changes or remove them before pushing". Now that means the local changes are nor allowing them to pull the things (sometimes wither you will have a conflict which you can edit later ) or the stash them. Now what does 'stash' means in git, same as the dictionary meaning To hide or store away in a secret place.
Commands
• git stash save “your message for the stash” --> This command will save your changes away to the stash, and reset your working tree and the index to match the tip of your current branch.
• git stash list --> you can see which stashes you have saved
• git stash pop --> you like to pop out the last stash, similar to pop out an element from a linked-list.
• git stash apply stash@{0} -->you can go back to what you were working on with git stash apply: stash@{0} part? That's your stash ID. The stash ID changes with every stash you make. stash@{0} refers to the last stash you made.
• git stash show -p | git apply –reverse
•
• git stash clear --> you like to clear out all the stashes.
References:
For using git with Windows this link is really useful :
http://nathanj.github.com/gitguide/tour.html
enjoy !!


ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
oci8.c:270:in oci8lib.so
I encountered this problem in my local machine while I an trying to start a Ruby on Rails application using oracleXE as a database. Check first whether the oracle XE service was running. If not do the following.
In order to start the service
--> goto Contol Panel
--> Administrative Tools
--> start OracleSevice XE
That's it...type local:3000/ to see your app up and running !!
I have big data problems.
I need to analyze 100s of millions of rows of data and tried hard for 2 weeks to see if I can use R for this. My assessment so far from the experiments...
1) R is best for data that fits a computer's RAM (so get more RAM if you can).
2) R can be used for datasets that don't fit into RAM using Bigmemory and ff packages. However, this technique works well for datasets less than 15 GB. This is in line with the
excellent analysis done by Ryan. Another
good tutorial for Bigmemory.
3) If we need to analyze datasets larger than 15 GB, then SAS, MapReduce and RDBMS :( seem like the only option as they store data on file system and access it as needed.
Since MapReduce implementations are clumsy and not business friendly yet, I wonder if its time to explore commercial analytics tools like SAS for big data analytics.
Can Stata, Matlab or RevolutionR analyse datasets in the range of 50 - 100GB effectively?
References
http://www.bytemining.com/2010/07/taking-r-to-the-limit-part-i-parallelization-in-r/
http://www.austinacl.blogspot.com (image)


VMWare launched Colud foundry, an open extensible PaaS cloud built entirely on Ruby. VMWare is focusing on the following 3 key differentiators
- Multi-cloud - Enables seamless transition between Private, public and hybrid clouds
- Multi-framework - Spring (Java), Rails (Ruby) and Node.js - extensible to other frameworks
- Multiple applications
Checkout this quick intro
VMWare is pitching the Cloud Foundry directly to the developer community. This strategy is well summarized by this quote by one of the VMWare developers "Developers should write code, not IT trouble tickets"..
Time will tell how well the developer community adopts this new service. Nonetheless, VMWare has managed to set itself apart from the multitudes of 'also ran's (read other run of the mill cloud service providers).
It is never too late to contribute. Following on my year 2009 post - sinatra - web application framework in ruby, I recently pushed that code to github @http://github.com/NiranjanSarade/LogFileTailer
Most of us are bitten by the bug of standardization/social conditioning. We believe in certain things because everybody else does or it looks good or makes us look good. We don't ever try to live life but spend our lives in planning/collecting resources for it whereas it is happening now... we don't ever try to understand/feel love but spend our lives in showing others that we love because when
In one of my earlier projects, I faced an issue with newline characters in csv file. The csv file generated on a unix system was uploaded to Windows system through sftp. However, the program on the Windows server was not able to parse the file properly as the csv file contained Unix newlines (LF) instead of Windows newlines (CR\LF) at the end of each line.
The problem is UNIX/Linux uses a Line Feed character (\n) as a line terminator while Windows uses Carriage Return\Line Feed pairs (\r\n).
For those who want to know what is the exact difference between CR, LF and EOL characters, here is a brief description :-
The Carriage Return (CR) character (0x0D, \r) moves the cursor to the beginning of the line without advancing to the next line. This character is used as a new line character in Commodore and Early Macintosh operating systems (OS-9 and earlier).
The Line Feed (LF) character (0x0A, \n) moves the cursor down to the next line without returning to the beginning of the line. This character is used as a new line character in UNIX based systems (Linux, Mac OSX, etc)
The End of Line (EOL) character (0x0D0A, \r\n) is actually two ASCII characters and is a combination of the CR and LF characters. It moves the cursor both down to the next line and to the beginning of that line. This character is used as a new line character in most other non-Unix operating systems including Microsoft Windows, Symbian OS and others.
I was able to resolve this issue with 'Sed' (Stream Editor). (http://www.grymoire.com/Unix/Sed.html)
The command matches the regexp pattern ($ - ending position of line or the position just before a string-ending newline) and replaces it with '\r' (Carriage Return). So the end result would be conversion from '\n' to '\r\n' which will support windows new line format.
Ken Collins from EngineYard released
TinyTds, a ruby gem that uses dblib to connect to MS SQL server. It has no hassles of managing ODBC connection. Read the
blog for detailed explanation.
Before TinyTDS:
The steps for setting libraries to connect to MS SQL on *nix environment. Follow the steps religiously to succeed.
Enter TinyTDS:
TinyTDS helps ODBC-less connection which means no pain of installing all the ODBC libraries.
It took a min to set-up the connection using the steps.
Goodies: Steps on Mac OSx Snow Leopard
We have been using "
Capistrano" to automate the deployment of our Rails apps. Capistrano is very powerful helps to execute any command on the remote machines. It has before/after "callback" hooks that helps to execute commands your application might depend on before running "cap deploy".
Capistrano assumes all the remote machines have the same credentials. Imagine you want to run commands on different remote machines each having different credentials.
Added a small extension for capistrano to prompt for password again when connecting to another server.
Drop the code in your
Rails.root/lib directory.
You will have to add:
in you recipes to force capistrano to prompt.
Bonus: Create ssh public keys and enjoy password-less deployment.
Next step: fork capistrano to add method for connecting to multiple servers
I recently pushed 'database_initializer.rb' to github @http://github.com/NiranjanSarade/oracle_xe_database_initializer. Please check its README for more information.
This can be used to set up your schema and other database objects in your local Oracle XE database. The script assumes that you have following set up on your machine :-
1. Oracle client
2. activerecord-oracle_enhanced-adapter gem
3. Oracle XE (http://www.oracle.com/technetwork/database/express-edition/downloads/index.html)
Found the following link to be an interesting read.
http://blog.fosstrading.com/2011/03/moving-from-excel-to-r.html
India and Pakistan have intense rivalry. They are siblings, who like each other deep down but fight often.
Their love isn't apparent. You see it in their appreciation of each other's culture, entertainers and sportsmen, and even politicians e.g. Indian movies and movie stars are popular in Pakistan and Benazir was popular in India. You also see their love when Indian and Pakistani people meet in a 3rd country, where their media and politicians don't brainwash them. Their they get to know each other really well. I'm from India and one of my best friends is from Pakistan.
Their fights on the other hand are much more evident. Their fights have translated into wars (1965, 1971, 1999), political battles (UN, US/USSR, local politics), movies (Border) and sport rivalries (Cricket, Hockey). We compete in sporting events with fanaticism and millions follow it closely.
One such battle took place in Cricket World Cup 2011.
It started with Pakistan's inspiring performance in preliminary rounds and then them knocking out West Indies (the weakest team in quarter finals) in quarter finals easily.
India was expected to make it to final eight and did. India had to play Australia (4 time world champions) in quarter finals. Australian cricket isn't as strong anymore with many superstars retiring Gilchrist, Hayden, Warne and McGrath). In a thrilling contest, India beat Australia in Motera, Ahmedabad. Indian bowlers restricted Aussies to 260 and the batsmen scored 261.
This setup up a thrilling contest between India and Pakistan for a place in finals.
I was in India during Cricket World Cup 2011 and got to witness this battle in Mohali, Chandigarh. This is my travelog for this particular contest.
60 HOURS OF INDIA-PAKISTAN WORLD CUP CRICKET THRILL
Mar 29
- Baroda to Mumbai by air (12:30pm - 2pm)
- Pick brother from office at 6pm and head to the airport
- Dinner at Mumbai airport at 7pm while watching Sri Lanks vs. New Zealand semi-final match
- Mumbai to Delhi by air (9:30pm - 11:30pm)
Note: There were no direct flights from Baroda to Chandigarh, so I had to go to Mumbai. And then to Delhi from Mumbai as all direct flights from Mumbai to Chandigarh were sold out
Mar 30
- Delhi to Panipat by car (12 midnite to 2:30am)
- Dinner at dhaba (street restaurant) in Murthal - yummy food
- Slept for 2 hrs. Woke up at 5:30pm. Dressed in Indian team T-shirt and shorts. Grabbed my lucky Indian flag that I bought in Motera, Ahmedabad during India-Australia game
- Panipat to Chandigarh by car (6:30am to 10am)
- Collected tickets at 10:30am
- Drove to Mohali stadium by car
- Found entrance 1C (11am) after driving around the stadium twice (need better instructions on the road for stadium gates)
- Easy checkin into stadium (20 mins in general first-level security and 2 mins in 1C gate security)
- Sat in block A Pavillion Terrace on south side (11:30am). Good luck with seats: no direct sunlight, beautiful weather
- Watched preparations (wicket and field care, opening cermony preparations, team preparations)
- Toss@2pm
- India started batting at 2:30pm
- We were snacking, hydrating thru out the innings
- Our section was filled with top-brass from Chandigarh, Delhi, Mumbai. Beautiful girls from Delhi, Mumbai, and Chandigarh
-
Celebrity sighting: Arbaaz Khan was sitting in our section. Amir Khan, Preity Zinta, Indian PM Manmohan Singh and Indian businessmen were sitting in stands above us. Amir acknowledged the crowd, enjoyed the match thruout.
- Requested others with camera phones to click our pics and email it to us (eagerly awaiting those pics). I guess its time for me to upgrade my Blackberry and get one with a good camera.
- Duel with Pakistani fans sitting above us (noisy, beautiful girl, Afridi's brother, 4 adults, 4 - 6 kids). "Jeetega bhai jeetega India jeetega" would always overshadow "Jeetega bhai jeetega Pakistan jeetega".
- Good gesture from crowd: no booing, no Pakistan hai-hai, friendly, sporting, knowledgeable crowd
- Indian PM, Manmohan singh and Pak PM, Ghelani, met with the teams during opening. Everyone clapped. No one shouted anything bad! Indians love Sachin a lot and everything he does, so the focus was on him instead of the 2 head of states. Someone even shouted "Sachin for Prime Minister"
- India scored less than anticipated batting first (260 instead of 300+). Started well with Sehwag's blisterning (though short) knock but others could not capitalize. Even Tendulkar's inning wasn't impeccable (4 dropped catches)
Innings break
- Pakistanis start well but wickets keep falling afterwards to push them towards defeat
- Pakistani tails crumbles but not before giving the crowd a few anxious moments (Misbah's 6s)
- Exciting match, tense crowd. Anyone could've won till 90th over in the match!
- Sporting behavior on-field as well. No fights, no verbal duels. Nehra dismissed a close floored catch
- Great gestures off-field: India-Pakistan PMs; Players joking, laughing, shaking hands; Pakistan fan holding the Indian flag after Pakistan lost
- Match presentations: Sachin man of the match. Stadium acoustics suck. No one could hear the captains during the toss, interviews in the presentation ceremony (it was bad in Motera, Ahmedabad too).
Punjab Cricket Association please fix it
- Peaceful exit at 11:30pm, decent, helpful crowd. Found car in 10 mins (quite amazing given the number of people and cars)
Mar 31
- Chandigarh to Panipat by car (12 midnite)
- Dinner@dhaba (line hotel) 2am - 2:40am. Yummy tandoori parathe (hail Punjab and Haryana for such great places to eat all along the road)
- Reached Panipat at 3:30am and crashed for 7 hours
- Panipat to Delhi by car (11:30am to 1:45pm)
- Remebered and thanked god for bringing us back safely. Car driving in Delhi, Punjab, Haryana highways is no joke. Its like playing a video game - you play chicken all the time, you expect others to brake for you, lanes have no meaning. If you're tempted to drive yourself, I would advise against it. These roads, laws (or lack thereof) are best known and handled by seasoned drivers in these conditions.
- Watched highlights of the game at the airport (thx Hyundai for sponsoring big screens)
- Delhi to Mumbai by air (3pm to 5pm)
- Mumbai airport to home by car (5:30pm - 6:30pm)
Next up, is watching the finale between India and Sri Lanka at Wankhede stadium in Mumbai.


Just wanted to quickly share the awesome new ActiveRecord Relational Algebra. I am sure there are many others but this one is a gem.
For long conditions like these:
Post.where("(body like ? OR subject like ?) AND comment_count > ? AND created_at > ?", criteria, criteria, 5, 3.days.ago)
It becomes really difficult to match the order of parameters.
Welcome to ARel, the same query can be written as:
Post.where("(body like :criteria OR subject like :criteria) AND comment_count > :count AND created_at > created_date", :criteria => criteria, :count => 5, :created_date => 3.days.ago)
See the binding variables in place of hard to remember question marks. It is important to note, in case the same variable is repeated multiple times, passing the variable once is sufficient.
More goodies to come !!
Run the 'bundle install' command on your terminal and wait for bundler to install the gems. It is pathetically slow.
It appears that RubyGems is slow. This is because of how Rubygems manages index of gems . It has 3 indexes:
1) Index of new version of the gem
2) Index of all the versions
3) Index of pre release
Doing "gem install
, fetches the index of the latest version of the gem. Apparently, bundler downloads #2, all the indexes. These indexes are gzipped and Marshal'd array of gem name, version and platform. Parsing this huge array is the first spot of slow down.
Now as we know bundler has intelligent algorithm for dependency management, which means when we do "bundle install", it will install all dependencies of the gem. This is achieved via .gemspec file which bundler downloads unzips and "UnMarshal's".
To reduce the slowness there few options, lets explore them:
1) "bundle pack" the .gems inside vendor/cache - force bundler to install from local cache then going across the wire
2) have your gems in "Gemfile" to be locked to a version or use PessimisticVersionConstraint.
I have used a combination of both and found substantial improvement in the time taken by "bundle install/update".
There are few other options like - MirrorBrain, rubygems-mirror, murder etc. Keeping a watch on gemcutter mailing list for better ways of doing this.
Today while doing "bundle update" my server started to throw weird error.

Somehow I was not able to relate it to bundler and doing
# gem update
updating installed gems
ERROR: While executing gem … (ArgumentError)
marshal data too short
explained that gem specs on the server is corrupted. I still need to figure out the reason why that happened in first place.
This error kept popping up – no matter what commands I wanted to run with rubygems (update, update –system, install…)
Googling did not give any solution on this topic. I had a feeling it is messing with ~/.gems directory - and found out to be true.
I deleted all entries inside the ~/.gems directory. I had to just just reinstall all my gems.
Any better ways to solve this problem ?