Skip to content

Instantly share code, notes, and snippets.

View h0lyalg0rithm's full-sized avatar

Suraj Shirvankar h0lyalg0rithm

View GitHub Profile
# Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "precise32"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
config.vm.network :forwarded_port, guest: 80, host: 8888
end
@h0lyalg0rithm
h0lyalg0rithm / pg_hstore.rb
Last active August 29, 2015 14:01
Postgres HStore
# /db/migrate/20140119134739_add_hstore.rb
class AddHstore < ActiveRecord::Migration
def up
enable_extension 'hstore'
end
def down
disable_extension 'hstore'
end
end
/***
* Handles uploading an image to a specified url
*/
class ImageUploaderTask extends AsyncTask<Void, Void, Boolean> {
private String mUrl;
public ImageUploaderTask(String url) {
mUrl = url;
}
@Override
@h0lyalg0rithm
h0lyalg0rithm / gist:10383189
Created April 10, 2014 13:38
Queues in CoffeeScript
class Queue
constructor:()->
@dataStore = []
enqueue:(element)->
@dataStore.push(element)
dequeue:(element)->
@dataStore.shift()
front:()->
@dataStore[0]
back:()->
@h0lyalg0rithm
h0lyalg0rithm / gist:10373924
Last active August 29, 2015 13:58
Stacks in CoffeeScript
class Stack
constructor:()->
@dataStore = []
@top = 0
push:(element)->
@dataStore[++@top] = element
pop:()->
@dataStore[--@top]
peek:()->
@dataStore[@top-1]
@h0lyalg0rithm
h0lyalg0rithm / gist:10365543
Last active August 29, 2015 13:58
Lists in Coffeescript
class List
constructor:()->
@dataStore=[]
@pos=0
@listSize = 0
length:()->
@listSize
clear:()->
@dataStore = []
@listSize = @pos = 0