Awesome effect with no proprietary plugin, no flash, java applet, or silverlight, just HTML,CSS & javascript.
Check out this Pen!
Source: http://codepen.io/stuffit/pen/KrAwx
And HN thread here: https://news.ycombinator.com/item?id=5592679
Awesome effect with no proprietary plugin, no flash, java applet, or silverlight, just HTML,CSS & javascript.
Check out this Pen!
Source: http://codepen.io/stuffit/pen/KrAwx
And HN thread here: https://news.ycombinator.com/item?id=5592679
I recently upgraded from Ubuntu 12.04 to 12.10 and Ubuntu automatically upgraded my CouchDB installation from 1.0.1 to 1.2.0. After the upgrade I started getting the error message “Bad request… Invalid JSON” anytime I try to add or query an existing design document.
A lot my code depends on CouchDB so this was a big deal, after hours of googling, still no solution until I found the JSONlint test. I realized that the old JSON parser in CouchDB 1.0.1 would parse invalid JSON with no problems but the parser in CouchDB 1.2.0 would throw an error.
This code below is invalid JSON but works fine on CouchDB 1.0.1. It will throw the ‘Invalid JSON’ error on CouchDB 1.2.0
{ "language" : "javascript", "views" :{ "age" : { "map" : "function(doc){ if(doc.age) emit(doc.age,doc); }" } } }
To work on CouchDB 1.2.0 it has to be valid JSON like the code below
{ "language": "javascript", "views": { "age": { "map": "function(doc){ if(doc.age) emit(doc.age,doc); }" } } }
This small change fixes the problem. You can always test your JSON for validity here: jsonlint.com.
JavaScript had a great year in 2011. Here are some of the best moments for JavaScript last year, in no particular order:
-Adobe killed Flash on mobile devices and will start the transition of their web technologies to HTML5/CSS/JavaScript here.
-Microsoft killed Silverlight as their cross platform runtime environment to focus on HTML5/CSS/JavaScript here.
-Microsoft announced that “metro style” apps for Windows 8 will be built in JavaScript/CSS/HTML. More about it here.
-Adobe acquired Nitobi (Creator of PhoneGap), and donated PhoneGap to Apache Foundation. This move could make PhoneGap a standard for mobile development here.
-Rails 3.1 adopted CoffeeScript causing great controversy and the most colorful Github page ever here.
-There was always a cool new JavaScript project on the first page of Hacker News. Here’s some of the best I remember:
J-OS – JavaScript operating system
JS Linux – Boot a Linux kernel right in the browser.
Broadway.js – H264 decoder in JavaScript.
pdf.js – PDF reader in JavaScript.
JavaScript IDE- Create web apps in JavaScript right from your browser.
There you have it and jQuery was everywhere. I write this as a Ruby/Unix guy, who thinks JavaScript had an extra-ordinarily great year. I may have missed other important moments. Feel free to add more in the comments.
It’s equally important to give credit to the players that helped make JavaScript the Technology of the Year. I will list them below:
Sometimes, I simply can’t put a price on what I do.
Two years ago, I was kidnapped by monkeys, who appeared to be in a trance. They took me to the top of the Swayambhunath Buddhist complex, in Kathmandu. I was told that this was the Monkey Temple. As a monk translated the wishes of the holy monkeys, I discovered that I was required to rewrite the OS of their ancient computer, which had failed to reboot, back in 1839. Since then, they had searched the world for a programmer competent to handle the situation. They were about to give up, as they stumbled onto me, and realized that I was the reincarnation of ChiChu Gomptar, the lead programmer for the CS monkey gang, which had served their monkey king, the creator of this computer. I was flummoxed by its design, as it was made of smooth stones, uniform beads, colored sand, and wooden levers inlaid with gold. I told them that I couldn’t remember anything from my past life. They gave me something to smoke, saying that it would connect me, through the eternal ether, to my previous memories.
It did, and after 25 days of extreme programming, of which I recall no details, I had completed the monumental task. I stood up, and ceremoniously dropped the special IPL bead onto the machine, which then awoke from its 170-year slumber with a mighty roar. The holy monkeys were pleased. They handed over a small golden box, with mysterious carvings. It seemed empty, and I was told not to open it unless my circumstances had become truly dire. I thanked them, both for the box, and for the tremendous experience. Unfortunately, I was not able to sell them continued maintenance for their new OS, but that was mostly due to their language not having the word “maintenance”. Anyway, I have those memories, and this box to use when things go really bad, plus the always-present hope of future adventure.
This was a comment on hacker news. Original source: http://news.ycombinator.com/item?id=3146786
To get some background on couchDB security read here.
All the code samples below, require the Restclient rubygem. You can install it with the command:
gem install rest-client
And Require it in your code with:
require 'rest_client'
Let’s say your couchDB is in Admin Party mode. To end the admin party and add an admin user:
RestClient.put 'http://127.0.0.1:5984/_config/admins/james', '"ssstepin"',{:content_type => :json}
james is the name of the new admin, and his password is ssstepin. The password needs to be enclosed in double quote,to denote a string in the couchDB configuration.
To authenticate the admin user:
response = RestClient.post 'http://127.0.0.1:5984/_session', 'name=james&password=ssstepin',{:content_type => 'application/x-www-form-urlencoded'} puts response.cookies # => {"AuthSession"=>"b2tlOjRFQUJCNzE0OkXtpl9cxR_zbIxvlvW2J60txIwT", "Version"=>"1", "Path"=>"%2F"}
This returns the authentication token for making future requests, on behalf of the authenticated user.
To add a new admin user:
RestClient.put 'http://127.0.0.1:5984/_config/admins/david', '"wuzz234"',{:cookies => {"AuthSession" => "b2tlOjRFQUJCNzE0OkXtpl9cxR_zbIxvlvW2J60txIwT"}}
We added a new admin david with password wuzz234, we made the request on behalf of james (see the AuthSession token, we are using the same token generated for james).
To delete the new admin user:
RestClient.delete 'http://127.0.0.1:5984/_config/admins/david',{:cookies => {"AuthSession" => "b2tlOjRFQUJCNzE0OkXtpl9cxR_zbIxvlvW2J60txIwT"}}
We deleted the admin david, we made the request on behalf of james (see the AuthSession token). If you delete all admins CouchDB will switch back to Admin Party.
To create a non-admin user:
salt = "somerandomstring123" password = "seenow109" password_sha = Digest::SHA1.hexdigest(password + salt) user_hash = { :type => "user", :name => "nancy", :password_sha => password_sha, :salt => salt, :roles => [] } str = Yajl::Encoder.encode(user_hash) RestClient.put "http://127.0.0.1:5984/_users/org.couchdb.user:nancy", str, {:content_type => :json, :accept => :json}
We created the non-admin user nancy with password seenow109. The above code implements in ruby code the security features explained here. Note that non-admins are authenticated with the same API call as admins.
To create a new database with the authenticated admin user:
RestClient.put 'http://127.0.0.1:5984/contacts', {:content_type => :json},{:cookies => {"AuthSession" => "b2tlOjRFQUJCNzE0OkXtpl9cxR_zbIxvlvW2J60txIwT"}}
We created a new database called contacts. This request was made by the user james, notice the AuthSession token in the request.
To add a security object to the contacts database:
security_hash = { :admins => {"names" => ["nancy"], "roles" => ["admin"]}, :readers => {"names" => ["nancy"],"roles" => ["admin"]} } security = Yajl::Encoder.encode(security_hash) response = RestClient.put 'http://127.0.0.1:5984/contacts/_security',security,{:cookies => {"AuthSession" => "b2tlOjRFQUJCNzE0OkXtpl9cxR_zbIxvlvW2J60txIwT"}}
The above example uses the yajl-ruby gem to encode the ruby hash to JSON.
To add a new document to the contacts database with the authenticated user session
data = { :name => 'sunny', :email => 'sunny@winter.com' } str = Yajl::Encoder.encode(data) RestClient.put "http://127.0.0.1:5984/contacts/sunny", str, {:cookies => {"AuthSession" => "b2tlOjRFQUJCNzE0OkXtpl9cxR_zbIxvlvW2J60txIwT"}}
We added a document with _id sunny to the contacts database. The above example also uses the yajl-ruby gem for json encoding.
I hope this was helpful. If you find any errors or have suggestions please let me know in the comments.
Whats the point of Hackathons? You sit down and code for 24 hours. Eat junk food all night, drink lots of soda and red bull. Then end up writing a lot of bad code.
At hackathons, your M.O. is to write code that appears to work, it doesn’t matter how it works. Once you get a feature appear to be working, you move on to code other features. The problem with this type of code is that it doesn’t scale. It makes you feel like you have a working product, but you really don’t. It works fine when you have 10 users but it starts to fall apart when you get to 1000+ users and becomes huge mess when you get to 10000+ users. I think this is a pointless way to build software. You write a lot of code in 24 hours but you end up with a lot of code you can’t use later. You also learn a ton of bad coding habits.
The best thing to do at a hackathon if you must go, is to socialize with people while you work on your long term side project. Its a great place to meet new people and share ideas with them.

At the Techcrunch Disrupt hackathon.
I have started testing design ideas for Ragios version 0.5+. Ragios started as a fun way to play with Linux servers and hack the Ruby language. Since then I started using Ragios to monitor web services for my business. Ragios is still very much in alpha stage but its slowly getting somewhere* and I am really enjoying the journey.
Below are some design goals for version 0.5+
Goals
I have started working on the first goal. In the new design all monitors are plugins. These plugins are simple ruby classes that can monitor URLs, system processes, Mail servers etc.
I hope to keep the same simple syntax for Ragios
monitoring = { :monitor => 'url', :every => '5m', :test => 'video datafeed test', :url => 'http://www.datafeed.com/resources/videos/1', :contact => 'admin@mail.com', :via => 'gmail', :notify_interval => '6h' }, {:monitor =>'http', :every => '30s', :test => 'Http connection to client A website', :domain => 'www.clientA.com', :contact => 'admin@mysite.com', :via => 'twitter', :notify_interval => '6h' } Ragios::Monitor.start monitoring
Below is a Gist I created to test design ideas for the new plugin system. I will be updating the Gist as I code in real time. The end result will be the bare bones design for the new system. After I get a workable design I will update the Github Repo here.
This is cool stuff. Nuff said. See more here: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/
I wrote a script that installs Ruby 1.9.2 with RubyGems, Rails 3 and sqlite on Ubuntu with a single command. This script makes it very easy to get started developing Rails applications on Ubuntu. Its also an easy way for non-ruby developers to run popular Rails applications.
This is a script I originally wrote, a while ago for Ruby 1.8.7 and Rails 2, I recently realized that most of the traffic coming to my blog were people looking to setup Rails on Ubuntu. So I decided to update the script for Rails 3 and Ruby 1.9.2. So please enjoy.
I remember about 2 years ago, when I got kicked out of a shared hosting account because I was using too much CPU time, I was forced to move my high traffic web service to EC2. I was still new to Linux, it was my first time deploying a Rails app in production, and I was going to go live with thousands of users instantly. It was a nightmarish weekend. That’s why I write scripts like this, to help new users from Windows and OS X get comfortable with the Linux world. Although Ubuntu 10 is much easier than 8.10, and Ruby 1.9.2 is a big improvement, Rails 3 with bundler is also a big relief, this is a script I wish I had 2 years ago while deploying my first Rails app.
Assumptions Made by the script
The script assumes you don’t have an older version of Ruby like (1.8.7) installed on the system. If you already have an older version of Ruby installed, use RVM instead of this script. To check if you have an older version of Ruby installed type
ruby -v
Installing and setting up Rails with a single command
Step 1: Install Git if you don’t already have it
sudo apt-get install git-core
Step 2: Download the script from Github
git clone git://github.com/obi-a/speedtrain.git
Step 3: Change to the speedtrain directory (the script is called speedtrain)
cd speedtrain
Step 4. Make the script executable
chmod +x speedtrain
Step 5. Run the script
./speedtrain
This will install Ruby 1.9.2,RubyGems, Rails 3 and Sqlite. It will create a folder in your $HOME directory for your Apps called rails_apps. It will also create a sample Rails App called testapp.
To run the sample Rails app. Type…
cd $HOME/rails_apps/testapp rails server
To view the app, open a browser and type http://localhost:3000/
To create a new Rails app. Type..
cd $HOME/rails_apps rails new myapp
Who should use this script
Related Posts:
Ubuntu, Ruby, RVM, Rails and You
Source code for the script: https://github.com/obi-a/speedtrain/blob/master/speedtrain