Skip to content

Instantly share code, notes, and snippets.

View nexneo's full-sized avatar

Niket Patel nexneo

View GitHub Profile
#!/usr/bin/env ruby -wKU
require 'rubygems'
require 'json'
json = `curl -s #{ARGV}`
puts JSON.pretty_generate(JSON.parse(json))
>> h.to_json
=> "{\"testing\":\"Hello World\"}"
>> JSON::parse(h.to_json)
dyld: lazy symbol binding failed: Symbol not found: _RHASH_TBL
Referenced from: /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.1/universal-darwin9.5/json/ext/parser.bundle
Expected in: flat namespace
dyld: Symbol not found: _RHASH_TBL
Referenced from: /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.1/universal-darwin9.5/json/ext/parser.bundle
Expected in: flat namespace
;; javasound
(import '(javax.sound.sampled AudioSystem Line DataLine DataLine$Info SourceDataLine TargetDataLine AudioFormat))
(defn get-audio-format [samplerate bitsize channels]
(new AudioFormat samplerate bitsize channels true false))
(defn get-source-data-line-info [audioformat]
(new DataLine$Info SourceDataLine audioformat))
(defn get-source-data-line [datalineinfo]
SC.InlineTextAreaView = SC.InlineTextFieldView.extend({
isTextArea: YES,
// needed to override this because original view has,
// $('input') doesn't take care of both the case
willRemoveFromParent: function() {
this.$input()[0].blur();
},
// needed to override this because original view has,
module Jobs
module ScheduledJob
def self.included(base)
base.extend(ClassMethods)
end
def perform_with_schedule
Delayed::Job.enqueue self, 0, self.class.schedule.from_now.getutc
perform_without_schedule
end
<li data-foreach-category="subject.categories">
<input class="new-item" placeholder="Add category title" data-bind="category.name" />
<input class="new-item" placeholder=" Weight age" data-bind="category.weightage" />
<a data-event-click="subject.removeCat">Remove</a>
</li>
@nexneo
nexneo / latency.txt
Created May 31, 2012 16:50 — forked from jboner/latency.txt
Latency numbers every programmer should know
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns
Mutex lock/unlock 25 ns
Main memory reference 100 ns
Compress 1K bytes with Zippy 3,000 ns
Send 2K bytes over 1 Gbps network 20,000 ns
Read 1 MB sequentially from memory 250,000 ns
Round trip within same datacenter 500,000 ns
Disk seek 10,000,000 ns
@nexneo
nexneo / vim-plugins-list.txt
Created June 12, 2012 20:07
Vim useful plugins - bundles
https://github.com/jeffkreeftmeijer/vim-numbertoggle
@nexneo
nexneo / turl.go
Created August 7, 2012 18:56
Twitter Search
package turl
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
"errors"
Let me create some sample data, to show you why:
mid :: mday_no :: something
1 :: 37 :: apple
2 :: 37 :: banana
2 :: 38 :: canteloupe
Now consider the first query:
SELECT * FROM cb_main WHERE mid = '1' AND mday_no=(select max(mday_no))