RSS
 

Could Dancing Have an Algorithm

13 Jun

This Choreography qualifies as a technical post. I really want to tag it as programming.

Source: https://www.youtube.com/watch?v=HHwVfO1hvs0

 

What is this PRISM, of which you speak?

08 Jun

Dear obi-akubue.org users,

You may be aware of reports alleging that obi-akubue.org and several other Internet companies have joined a secret U.S. government program called PRISM to give the National Security Agency direct access to our servers. We would like to respond to the press reports, and give you the facts.

obi-akubue.org is not and has never been part of any program to give the US or any other government direct access to our servers. We have never received a blanket request or court order from any government agency asking for information or metadata in bulk, like the one Verizon reportedly received. We hadn’t even heard of PRISM before yesterday.

When governments ask obi-akubue.org for data, we review each request carefully to make sure they always follow the correct processes and all applicable laws, and then only provide the information if is required by law. We will continue fighting aggressively to keep your information safe and secure. Any suggestion that obi-akubue.org is disclosing information about our users’ Internet activity on such a scale is completely false.

We strongly encourage all governments to be much more transparent about all programs aimed at keeping the public safe. It’s the only way to protect everyone’s civil liberties and create the safe and free society we all want over the long term. We here at obi-akubue.org understand that the U.S. and other governments need to take action to protect their citizens’ safety—including sometimes by using surveillance. But the level of secrecy around the current legal procedures undermines the freedoms we all cherish.

Source: One-stop PRISM Deny generator for your startup – http://colingourlay.github.io/deny-prism/

 
No Comments

Posted in Business

 

Tear-able cloth in Javascript

23 Apr

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

 
 

Invalid JSON in CouchDB

03 Dec

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.

 
 

Finding Nemo with Google Maps

26 Sep

Google is like a mad scientist with $50 Billion in the bank. They did Google Earth but that wasn’t enough for them. Now they are doing seaview, you can browse underwater, follow a clown fish in search of Nemo. I’m sure someone is working on “spaceview”.



View Larger Map
Try swimming with the sea turtles.

Source: http://googleblog.blogspot.com/2012/09/dive-into-great-barrier-reef-with-first_25.html

 
 

JavaScript: 2011 Technology of the Year

01 Feb

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:

  •  The Open Source community:  For all the awesome  wizardry.
  • Google: For moving the open web forward, supporting the FOSS community and releasing great open source technologies like Google Chrome and V8.
  • The Webkit Open Source project and Apple.
  •  Steve Jobs for excluding Flash on iDevices and selling HTML5 as the future of the open web.

Let’s have a toast for JavaScript.
 

Hey programmer, what is it that you do?

01 Dec

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

 

How to do a barrell roll

06 Nov

We have all seen Google’s barrel roll trick. The coolest thing about it is that, its done with simple CSS. To see the same effect, place your mouse over this blog post.

Source code for the Barrel roll:

.barrel_roll {
-moz-animation-name: roll; 
	-moz-animation-duration: 4s; 
	-moz-animation-iteration-count: 1; 
	-o-animation-name: roll; 
	-o-animation-duration: 4s; 
	-o-animation-iteration-count: 1; 
	-webkit-animation-name: roll; 
	-webkit-animation-duration: 4s; 
	-webkit-animation-iteration-count: 1; 
}
 
@-moz-keyframes roll { 
	100% { 
		-moz-transform: rotate(360deg);
	}
} 
@-o-keyframes roll { 
	100% { 
		-o-transform: rotate(360deg); 
	} 
} 
@-webkit-keyframes roll {
	100% { 
		-webkit-transform: rotate(360deg); 
	} 
}

Only works in modern browsers like Chrome, Firefox, Opera and Safari. I hope IE will catch up.
Source: http://www.metaltoad.com/blog/how-does-google-do-barrel-roll

 
 

When in doubt, do a barrel roll

04 Nov

So business guy is looking for a programmer to build his app. Here’s how the interview went.

Programmer: “I built a nosql database that uses javascript for queries. It even supports map/reduce. I also wrote a h264 decoder in javascript. I can build your twitter/google+/facebook social app.”

Business guy: “hmm I don’t think so. I’m looking for a rockstar ninja Rails and .net programmer.”

Programmer: “Ok watch this.”

Programmer opens his web browser, goes to google and types do a barrel roll.

Business guy: “Wow that is awesome!”

Programmer: “Hit refresh”

Business guy: “Wow dude, you’re HIRED!”

(Note: “do a barrel roll” works only on Chrome, Safari, Opera and Firefox. Try it when your pitch is failing. Good luck.)

 
 

CouchDB Security in Ruby

30 Oct

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.

 
 
 
Premium Wordpress Plugin