Skip to content

Instantly share code, notes, and snippets.

View metacritical's full-sized avatar
Creating Black holes.

Pankaj Doharey metacritical

Creating Black holes.
View GitHub Profile
@metacritical
metacritical / Ruby Inheritance Doubt
Created August 30, 2011 21:18
My Doubts in ruby Inheritance let the Cat help us out.
class Cat
def self.speak # this is a class method
puts "Meow"
end
end
class Lion < Cat
def roar
puts "Roar Roar !!!!" #now this is just an ordinary method.
@metacritical
metacritical / play.rb
Created November 28, 2011 20:06
Ruby video player implemented using HornetsEye
require 'rubygems'
require 'hornetseye_ffmpeg'
require 'hornetseye_xorg'
require 'hornetseye_alsa'
include Hornetseye
input = AVInput.new 'sintel.mp4'
alsa = AlsaOutput.new 'default:0', input.sample_rate, input.channels
audio_frame = input.read_audio
X11Display.show 600, :output => XVideoOutput do |display|
img = input.read
@metacritical
metacritical / gist:1404985
Created November 29, 2011 14:30 — forked from seanlilmateus/gist:1386468
Macruby Face Detection in Mac OS X Lion
framework 'Cocoa'
framework 'QuartzCore'
class NSColor
def toCGColor
colorRGB = self.colorUsingColorSpaceName NSCalibratedRGBColorSpace
components = Array.new(4){Pointer.new(:double)}
colorRGB.getRed components[0], green:components[1], blue:components[2], alpha:components[3]
@metacritical
metacritical / csv_parser_csv_gem_benchmark.rb
Created November 29, 2011 15:39 — forked from bytesource/csv_parser_csv_gem_benchmark.rb
Simple CSV Parser vs. CSV Gem Benchmark
require 'open-uri'
require 'nokogiri'
require 'parslet'
require 'csv'
# --------------------------------------------------
# Auxiliary code
class String
@metacritical
metacritical / gist:1418398
Created December 1, 2011 17:29
Just A mock file
require 'spec_helper'
describe "Mock User object" do
let(:user) do
mock_model User, :find => "pankaj"
end
it "Should validate" do
#@user = User.find(1)
#User.find(:all)
@metacritical
metacritical / widget.rb
Created December 8, 2011 22:54 — forked from maccman/widget.rb
MacRuby Webkit Interface
framework "WebKit"
class Widget
class RPC
class << self
public :include
end
def initialize(widget)
@widget = widget
@metacritical
metacritical / .htaccess
Created December 9, 2011 23:11 — forked from BrandonMathis/.htaccess
sinatra htaccess for bluehost
# General Apache options
AddHandler fcgid-script .fcgi
AddHandler cgi-script .cgi
#Options +FollowSymLinks +ExecCGI
# If you don't want Rails to look in certain directories,
# use the following rewrite rules so that Apache won't rewrite certain requests
#
# Example:
# RewriteCond %{REQUEST_URI} ^/notrails.*
@metacritical
metacritical / gist:1663075
Created January 23, 2012 13:18
An Interactive menu in .bash_profile using shell script.
[[ -s "/Users/pankajdoharey/.rvm/scripts/rvm" ]] && source "/Users/pankajdoharey/.rvm/scripts/rvm"
#PS1='\033[7h\033[37m\W ∑\033[0m\033[31m™\033[0m»'
echo "$(tput setaf 7)$(tput setab 1)Select an app:$(tput sgr0)"
tput setaf 3
select i in irb emacs macirb rubinius jruby node.js gnu-smalltalk gnu-lisp cmucl io-lang bash opt vim source
do
tput bold
tput setaf 3
case $i in
irb) irb --simple-prompt;;
@metacritical
metacritical / emacs24SNL10.6.8Fullscreen.sh
Created February 4, 2012 00:23
Most Perfect Emacs 24 With Fullscreen patch build for Mac OSX SnowLeopard 10.6.8+ build script.
git clone git://git.savannah.gnu.org/emacs.git
cd emacs
curl -O http://cloud.github.com/downloads/typester/emacs/feature-fullscreen.patch
patch -p1 -i feature-fullscreen.patch
cd ..
curl -O http://ftp.gnu.org/gnu/m4/m4-1.4.13.tar.gz
tar -xzvf m4-1.4.13.tar.gz
cd m4-1.4.13
./configure --prefix=/usr/local
make
@metacritical
metacritical / gist:1773136
Created February 8, 2012 20:24
Some CGI dispatch file for use ...
require 'rubygems'
require 'fcgi'
ENV['RAILS_ENV'] ||= 'development'
ENV['GEM_HOME'] ||= '/home/user/.gems'
require 'rubygems'
Gem.clear_paths
require File.join(File.dirname(__FILE__), '../config/environment')