Skip to content

Instantly share code, notes, and snippets.

View gosuri's full-sized avatar

Greg Osuri gosuri

View GitHub Profile
app = node[:rails][:app]
rails_base app[:name] do
ruby_ver app[:ruby_ver]
gemset app[:gemset]
end
%w{config log pids cached-copy bundle system}.each do |dir|
directory "#{app[:app_root]}/shared/#{dir}" do
owner app[:deploy_user]
require 'sinatra'
require 'oauth2'
require 'rest_client'
require 'json'
get '/' do
redirect client.auth_code.authorize_url(:redirect_uri => 'http://localhost:4567/callback', :state => 'your_api_is_crap')
end
get '/callback' do
# Converting Still Images to Video
# ================================
# depends on ImageMagick and ffmpeg
#
mkdir temp
cp *.jpg temp/.
mogrify -resize 800x800 temp/*.jpg
convert temp/*.jpg -delay 10 -morph 10 temp/%05d.jpg
ffmpeg -r 25 -qscale 2 -i temp/%05d.jpg output.mp4
# rm -R temp
@gosuri
gosuri / dfs.asm
Last active September 21, 2016 22:27
Depth-first search (DFS) is an algorithm for traversing or searching a tree, tree structure, or graph. One starts at the root (selecting some node as the root in the graph case) and explores as far as possible along each branch before backtracking. A graph can be represented by its adjacency matrix G, where G[i][j] == 1 if there is an edge betwe…
.data
Graph: .word 0,1,1,0,0,1,1,0,0
.word 1,0,0,0,0,0,0,0,0
.word 1,0,0,0,0,0,0,0,0
.word 0,0,0,0,1,1,0,0,0
.word 0,0,0,1,0,1,1,0,0
.word 1,0,0,1,1,0,0,0,0
.word 1,0,0,0,1,0,0,0,0
.word 0,0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0,0
@gosuri
gosuri / dfs.rb
Last active December 14, 2015 17:59
Recursive depth-first search (DFS) for traversing a graph in ruby.
# Depth-first search (DFS) is an algorithm for traversing or
# searching a tree, tree structure, or graph. One starts at
# the root (selecting some node as the root in the graph case)
# and explores as far as possible along each branch before backtracking.
#
# A graph can be represented by its adjacency matrix G,
# where G[i][j] == 1 if there is an edge between
# vertices i and j and 0 otherwise.
#
# Below Graph in diagram http://i.imgur.com/sV1UzUn.png
@gosuri
gosuri / wikiscraper.rb
Created March 7, 2013 22:19
The Wikipedia API blows, writing this was faster
require 'open-uri'
require 'nokogiri'
# Scrapes wikipedia content for stack
# The API blows, writing this was faster
class WikiImporter
# Words rejected will excluded from the results
REJECT_WORDS = [
"Comparison of web application frameworks",
@gosuri
gosuri / add.s
Last active December 13, 2015 22:08
SAL code to add real numbers FloatX and FloatY using only fixed point operations.
.data
# Inputs
FloatX: .float 134.0625
FloatY: .float 2.25
# Result
Float_X_plus_Y: .float
@gosuri
gosuri / setup.md
Last active December 13, 2015 19:39
Mountain Lion Setup with RVM + Homebrew

Instructions for setting up RVM on Mountain Lion

Homebrew and RVM

Install XCode

  • Update to the latest XCode 4.4 from the App Store
  • Install the Command Line Tools
@gosuri
gosuri / gist:2969634
Created June 22, 2012 01:06 — forked from dalibor/gist:1534053
Stop words
a
about
above
across
after
afterwards
again
against
all
almost
$(document).ready(function(){
$("#new.btn").live("click",function(event){
event.preventDefault();
window.router.newNote();
});
$("#delete.btn").live("click",function(event){
event.preventDefault();
window.currentNote.destroy();
window.router.index();