Skip to content

Instantly share code, notes, and snippets.

View hamin's full-sized avatar

Haris Amin hamin

  • Currently ionq.co. Previously symbiont.io, getpager.com, itsglimpse.com, dailburn.com
  • New York,NY
View GitHub Profile
@hamin
hamin / rounded_corners.m
Created March 23, 2012 21:20
Cocoa (OS X) rounded corners
NSBezierPath *roundedRect = [NSBezierPath bezierPathWithRoundedRect:[self bounds] xRadius:6.0 yRadius:6.0];
[roundedRect fill];
@hamin
hamin / twilio_conf.rb
Created February 25, 2012 16:09
twilio call into existing conf
get '/queue_song' do
@client = Twilio::REST::Client.new ENV['TWILIO_ACCOUNT_SID'], ENV['TWILIO_AUTH_TOKEN']
@call = @client.account.calls.create(
:from => '+13473144879',
:to => '+13158491034',
:url => 'http://173.204.223.126/play_song'
)
end
post '/play_song' do
@hamin
hamin / inject_performance.rb
Created January 31, 2012 00:31
Inject performance
require 'benchmark'
n = 100
Benchmark.bm do |x|
x.report("each") { num=0;[1..n].each{ |i| num+= 1} }
x.report("inject") { [1..n].inject(0){ |s,i| s+= 1} }
end
@hamin
hamin / ruby_hero_2012_nomination.txt
Created January 30, 2012 20:59
My Ruby Heroes 2012 nomination Evan Light (@elight)
Evan has authored coulda, which is a cool integration testing framework. But more importantly, and the reason for my nomination, is that he is tirelessly trying to help others get into ruby. RubyDCamp which is a free uncoference event he runs annually. The amount of effort he spends trying to get quality people to attend this free event pales in comparison to the effort he spends getting such a free event sponsored for an awesomely fun, educational, and philanthropic event that any programming community can have.
def fizzbuzz(n)n%15==0?"FizzBuzz": n%5==0?"Buzz": n%3==0?"Fizz": n.to_s end
@hamin
hamin / mongoose.coffee
Created August 21, 2011 07:21
mongoose.coffee
Message = new Schema({content: String,nickname: String,created_at: Date})
Picture = new Schema({user: ObjectId,title: String,url: String,start_at: Date,end_at: Date,messages: [Message],created_at: Date,updated_at: Date})
PhotoAccount = new Schema({token: String,token_secret: String,provider: String,username: String,domain: String,avatar: String})
User = new Schema({token: String,token_secret: String,username: String,domain: String,avatar: String,created_at: Date,updated_at: Date,photo_accounts: [PhotoAccount]})
picture = mongoose.model('Picture', Picture)
@hamin
hamin / canvas_arrows.html
Created May 9, 2011 22:44
Drawing HTML5 Up and Down Arrows
<p>
<canvas id="downArrow" style="border:0px solid;background-color:#ffecb0;" width="20" height="22">Your web browser does not supports HTML5!</canvas>
<canvas id="upArrow" style="border:0px solid;background-color:#ffecb0;" width="20" height="22">Your web browser does not supports HTML5!</canvas>
</p>
<script type="text/javascript" charset="utf-8">
function drawDownArrow() {
var canvas = document.getElementById('downArrow');
var context = canvas.getContext('2d');
@hamin
hamin / bdsm_nginx_error.log
Created April 28, 2011 02:47
bdsm_nginx_error.log
> modules/bash/core/cli 203 $ [[ -n '' ]]
> modules/bash/core/cli 203 $ [[ -n '' ]]
> modules/bash/core/cli 9 $ (( 2 > 0 ))
> modules/bash/core/cli 11 $ token=nginx
> modules/bash/core/cli 11 $ shift
> modules/bash/core/cli 13 $ case "$token" in
> modules/bash/core/cli 85 $ [[ -z '' ]]
> modules/bash/core/cli 86 $ [[ -d /usr/local/bdsm/extensions/nginx ]]
> modules/bash/core/cli 87 $ extension=nginx
> modules/bash/core/cli 185 $ (( parse_break == 1 ))
@hamin
hamin / pub_sub_able.rb
Created March 21, 2011 21:50
A convenience lib for dealing with PubSub with XMPP4R
require "xmpp4r"
require "xmpp4r/pubsub"
module PubSubAble
include Jabber
def anon_connect_to_server(anonymous_user,host,port)
jid = Jabber::JID.new("#{anonymous_user}@#{host}")
client = Client.new(jid)
client.connect(host,port)
@hamin
hamin / mongomapper_rails3_template.rb
Created January 20, 2011 22:41
A Rails 3 Application template for MongoMapper
# Some basic flags
use_mongomapper = false
use_compass = false
use_simplenavigation = false
rails3_branch = false
run "cp config/database.yml config/database.example.yml"
# Remove redundant files
remove_file "public/index.html"