Skip to content

Instantly share code, notes, and snippets.

Avatar

Jai Kumar jvkumar

  • San Francisco bay area, CA
View GitHub Profile
View nginx
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid
@jvkumar
jvkumar / slug_error
Created Aug 18, 2012
Mongoid_slug is not installed
View slug_error
I have gem mongoid (3.0.4, 3.0.1)
My Gemfile looks like:
----------------------
source 'https://rubygems.org'
gem 'rails', '3.2.6'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
View gfile
My Gemfile
----------
source 'https://rubygems.org'
gem 'rails', '3.2.6'
gem "mongoid", "~> 3.0.0"
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'execjs'
View mkf
Model: posts.rb
-----------
class Post
include Mongoid::Document
include Mongoid::Slug
field :name, type: String
field :title, type: String
field :content, type: String
validates :title, :presence => true, :length => { :minimum => 10 }
@jvkumar
jvkumar / postcard.go
Created Sep 14, 2012
Image postcard
View postcard.go
Today is my second day of golang learning. I have gone through all the exercises of go tutorial on http://tour.golang.org/ and I am trying to write a simple program to overlap one image on another. My goal is to have an image (called background image) and then paste two images on top of it with given x, y, and z axis value with some angle (rotation).
I have skeleton of my first golang code below. I am freaking out as how to proceed. Any help or example of code will be greatly appreciated.
===========================================
package main
func main() {
//ASSUMPTION: All images will be jpg and much smaller compare to background image and they will never go outside the background image
@jvkumar
jvkumar / date.rb
Created Oct 9, 2012
date monkey patching
View date.rb
require 'date'
class Date
class << self
alias_method :original_parse, :parse
end
def self.parse(str='-4712-01-01', comp=true,start=ITALY)
if str == '0000-00-00 00:00:00'
str = '1970-01-01 00:00:00'
end
self.original_parse(str, comp, start)
@jvkumar
jvkumar / hook.sh
Created Oct 10, 2012
github hook
View hook.sh
On Mac OS (or, likely, any BSD), the sed command parameters have to be slightly different. Try this:
#!/bin/sh
if git-rev-parse --verify HEAD >/dev/null 2>&1 ; then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
View api.json
GET /packages/latest?os=windows
-------------------------------
[{
"required": "1.0.0.80",
"product": "thoragent",
"target": "testing",
"os": "windows",
"id": 327,
"requiredurl": "http://com.memeo.magni.dl.s3.amazonaws.com/thoragent/MemeoC1Agent-1.0.0.80.zip",
View schema.jason
template {
id: hash of (name,country,text,language,unixtimestamp)
name:
text:
html:
subject:
description:
country:
language:
is_active:
View comt
Jais-MacBook-Pro:bifrost jai$ git log
commit 8b84f41f52fb4e4c77d559b734af1a4ef825262d
Author: Jai Kumar <jai.kumar@memeo-inc.com>
Date: Mon Dec 3 11:29:30 2012 -0800
added orgid in id hash building
commit 3d2fbed2303d5015d1bbcf34ba4c3f64b60cfdf4
Author: Jai Kumar <jai.kumar@memeo-inc.com>
Date: Mon Dec 3 11:12:18 2012 -0800