Skip to content

Instantly share code, notes, and snippets.

View h0lyalg0rithm's full-sized avatar

Suraj Shirvankar h0lyalg0rithm

View GitHub Profile
@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
@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: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:()->
/***
* 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 / 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
# 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 / Cheffile
Last active August 29, 2015 14:01
Cheffile for lamp stack
# File Cheffile
#!/usr/bin/env ruby
#^syntax detection
site 'http://community.opscode.com/api/v1'
cookbook 'apt'
cookbook 'php'
cookbook 'apache2'
@h0lyalg0rithm
h0lyalg0rithm / twitter.rb
Last active August 29, 2015 14:01
Twitter gem
require 'twitter'
require 'unirest'
client = Twitter::REST::Client.new do |config|
config.consumer_key = "CONSUMER KEY"
config.consumer_secret = "CONSUMER SECRET"
config.access_token_secret = "ACCESS TOKEN SECRET"
config.access_token = "ACCESS TOKEN"
end
@h0lyalg0rithm
h0lyalg0rithm / .htaccess
Created August 3, 2014 19:10
Routing example with Toro
FallbackResource /index.php
FROM nginx
RUN rm /etc/nginx/conf.d/default.conf
COPY default.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]