Skip to content

Instantly share code, notes, and snippets.

View utkarshkukreti's full-sized avatar

Utkarsh Kukreti utkarshkukreti

View GitHub Profile
def setup()
Mongoid.configure do |config|
config.master = Mongo::Connection.new.db("testbooks")
end
@book = Books.create(title: 'Turn of a Screw', author: "Henry James", barcode: '666')
end
def test_barcode
# Test for uniqueness of each book barcode
@utkarshkukreti
utkarshkukreti / gist:1009030
Created June 5, 2011 15:04
Trying to inherit a module from a parent.
require 'httparty'
class HTTP
include HTTParty
def initialize uri
self.class.base_uri uri
end
end
class Dropbox < HTTP
@utkarshkukreti
utkarshkukreti / rbenv-install-system-wide.sh
Created September 27, 2011 03:22
rbenv install and system wide install on Ubuntu 10.04 LTS.
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential
apt-get -y install git-core
# Install rbenv
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv
# Add rbenv to the path:
<?php
/**
* Check for post format type, apply filter based on post format name for easy modification.
*
* @since 1.0
*/
function chimps_post_formats_content() {
$format = get_post_format();
$root = get_template_directory_uri();
function authors_orderBy($data, $field){
$code = "if (\$a['$field'] == \$b['$field']) {return 0;} return (\$a['$field'] < \$b['$field']) ? 1 : -1;";
usort($data, create_function('$a,$b', $code));
return $data;
}
function author_list(){
if(is_page('the-team')) {
$blogusers = get_users_of_blog();
if ($blogusers) {
$au = array();
@utkarshkukreti
utkarshkukreti / ncurses.diff
Created October 30, 2012 13:41 — forked from gcatlin/ncurses.diff
Homebrew Ncurses clang patch
diff --git a/ncurses.rb b/ncurses.rb
index 1067083..8cc12bc 100644
--- a/ncurses.rb
+++ b/ncurses.rb
@@ -23,4 +23,9 @@ class Ncurses < Formula
system "make"
system "make install"
end
+
+ def patches
> module Main where
First, import all the needed modules.
> import Text.Parsec hiding (State)
> import Text.Parsec.Indent
> import Control.Monad.State
Next, define our new Parser type. This replaces the Identity monad
with the (State SourcePos) monad.
from fabric.api import env, task, run, sudo, cd, local
from fabric.decorators import with_settings
from fabric.operations import put
env.user = 'ec2-user'
env.hosts = [
'ec2-your-address-1.us-west-2.compute.amazonaws.com',
'ec2-your-address-2.us-west-2.compute.amazonaws.com',
'ec2-your-address-3.us-west-2.compute.amazonaws.com',
'ec2-your-address-4.us-west-2.compute.amazonaws.com',
/* Solarized Dark
For use with Jekyll and Pygments
http://ethanschoonover.com/solarized
SOLARIZED HEX ROLE
--------- -------- ------------------------------------------
base03 #002b36 background
base01 #586e75 comments / secondary content
enum Result<S, R, F> {
Success(R, ~[S]),
Failure(F)
}
struct Parser<'a, S, R, F> { parse : 'a |&[S]| -> Result<S,R,F> }
trait Composable {
fn Or(Self, Self) -> Self;
}