Skip to content

Instantly share code, notes, and snippets.

Avatar
Creating Black holes.

Pankaj Doharey metacritical

Creating Black holes.
View GitHub Profile
@metacritical
metacritical / Ruby Inheritance Doubt
Created Aug 30, 2011
My Doubts in ruby Inheritance let the Cat help us out.
View Ruby Inheritance Doubt
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 Nov 28, 2011
Ruby video player implemented using HornetsEye
View play.rb
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 Nov 29, 2011 — forked from seanlilmateus/gist:1386468
Macruby Face Detection in Mac OS X Lion
View gist:1404985
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]
View csv_parser_csv_gem_benchmark.rb
require 'open-uri'
require 'nokogiri'
require 'parslet'
require 'csv'
# --------------------------------------------------
# Auxiliary code
class String
View gist:1418398
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 Dec 8, 2011 — forked from maccman/widget.rb
MacRuby Webkit Interface
View widget.rb
framework "WebKit"
class Widget
class RPC
class << self
public :include
end
def initialize(widget)
@widget = widget
@metacritical
metacritical / .htaccess
Created Dec 9, 2011 — forked from BrandonMathis/.htaccess
sinatra htaccess for bluehost
View .htaccess
# 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 Jan 23, 2012
An Interactive menu in .bash_profile using shell script.
View gist:1663075
[[ -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 Feb 4, 2012
Most Perfect Emacs 24 With Fullscreen patch build for Mac OSX SnowLeopard 10.6.8+ build script.
View emacs24SNL10.6.8Fullscreen.sh
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 Feb 8, 2012
Some CGI dispatch file for use ...
View gist:1773136
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')