Skip to content

Instantly share code, notes, and snippets.

View abdollar's full-sized avatar

Abdul Chaudhry abdollar

View GitHub Profile
@abdollar
abdollar / gist:1504697
Created December 21, 2011 05:19 — forked from dgrijalva/gist:1198745
openssl notes
# Convert ssh-rsa key to pem
ssh-keygen -f infile.pub -e -m PKCS8 > outfile.pem
# Encrypt a file using public key pem
openssl rsautl -encrypt -inkey public.pem -pubin -in file.txt -out file.ssl
# Decrypt using private key
openssl rsautl -decrypt -inkey private.pem -in file.ssl -out decrypted.txt
@abdollar
abdollar / sroot.rb
Created December 21, 2011 06:10 — forked from peterc/sroot.rb
Square root calculation using Newton-Raphson
# Square root calculation using Newton-Raphson
# from Practical Programming (1968)
a = 256
x = (1 + a) / 2.0
loop do
ox = x
x = (x + a.to_f / x) / 2.0
@abdollar
abdollar / fib.rb
Created December 21, 2011 06:11 — forked from peterc/fib.rb
fib=->(n){_=5**0.5;(((1+_)**n-(1-_)**n)/(2**n*_)).to_i}
@abdollar
abdollar / Bench
Created January 8, 2012 18:42 — forked from igrigorik/Bench
# ruby getimage.rb -e production -c config/getimage.rb
@abdollar
abdollar / gist:1590755
Created January 10, 2012 19:44 — forked from jstorimer/hilong.rb
hilong -- A simply utility to show character counts for each line of input and highlight lines longer than 80 characters.
#!/usr/bin/env ruby
# A simply utility to show character counts for each line of input and
# highlight lines longer than 80 characters.
#
# Written as an example for http://jstorimer.com/2011/12/12/writing-ruby-scripts-that-respect-pipelines.html
#
# Examples:
#
# $ hilong Gemfile
@abdollar
abdollar / client.rb
Created January 23, 2012 20:24 — forked from igrigorik/client.rb
chunked file stream with goliath
require 'bundler'
Bundler.require
url = 'http://0.0.0.0:9000/images/avatar.png'
EM.run do
http = EventMachine::HttpRequest.new(url).get
http.stream {|chunk| print [:chunk, chunk.size] }
http.headers {|h| p [:headers, h] }
@abdollar
abdollar / astar.rb
Created February 25, 2013 06:11 — forked from mburst/astar.rb
require 'priority_queue'
require 'set'
class Node
def initialize(x, y)
@x = x
@y = y
@obstacle = false
@g_score = Float::INFINITY
end
require 'fileutils'
start_time = Time.now
SOURCE_DB = {
:name => 'db_name',
:user => 'db_user',
:password => 'db_pass',
:host => 'localhost'
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
@abdollar
abdollar / app.js
Created February 8, 2014 01:40 — forked from auser/app.js
angular.module('myApp',
['ngRoute', 'myApp.services', 'myApp.directives']
)
.config(function(AWSServiceProvider) {
AWSServiceProvider.setArn('arn:aws:iam::<ACCOUNT_ID>:role/google-web-role');
})
.config(function(StripeServiceProvider) {
StripeServiceProvider.setPublishableKey('pk_test_YOURKEY');
})
.config(function($routeProvider) {