Skip to content

Instantly share code, notes, and snippets.

Senthil Arivudainambi sent-hil

Block or report user

Report or block sent-hil

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View fish.config
#My fish prompt that I stole from somewhere and don't remember where to give credit. Sorry :(
#It's rather simple `senthil:~/p/es_console:master$`, shows current git branch if in a git repo.
function fish_prompt --description 'Write out the prompt'
# Just calculate these once, to save a few cycles when displaying the prompt
if not set -q __fish_prompt_hostname
# set -g __fish_prompt_hostname (hostname|cut -d . -f 1)
end
if not set -q __fish_prompt_normal
set -g __fish_prompt_normal (set_color normal)
View named_var.go
//An experiment using `runtime/debug` package to see what info can
//be gotten in runtime.
package main
import (
"log"
"runtime/debug"
"strings"
)
View gist:882659
We all have the drum major instinct. We all want to be important, to surpass others, to
achieve distinction, to lead the parade…. And the great issue of life is to harness the drum
major instinct. It is a good instinct if you don’t distort it and pervert it.
Don’t give it up. Keep feeling the need for being important. Keep feeling the need for
being first. But I want you to be the first in love. I want you to be the first in moral
excellence. I want you to be the first in generosity.
View open_auth2.rb
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'active_support/inflector'
module OpenAuth2
module Provider
class Base
attr_accessor :client_id
def initialize
View iteration.rb
module BackwardIteration
def self.included(base)
if base.ancestors.include?(ForwardIteration)
instance_methods.each do |method|
base.class_eval do
alias_method "#{method}_reverse", method
define_method method do
unbound = ForwardIteration.instance_method(method)
unbound.bind(self).call
View method_missing_iteration.rb
module Iteration
def map
each[0]
end
def to_a
each.split("")
end
end
@sent-hil
sent-hil / webapp_folder_structure
Created Mar 21, 2012
Rearrangement of Rails folder structure based on 'Architecture the Lost Years'
View webapp_folder_structure
# Rearrangement of Rails folder structure based on Robert Martins' Keynote: Architecture the Lost Years.
# This structure was meant to say 'I am a web app that does x and y and only incidentally uses Rails'.
# I'm interested in knowing if:
# 1. Is this viable in the long run?
# 2. Can you tell what the app does?
|── Gemfile
├── Gemfile.lock
├── Readme
View api_versions.rb
# Problem: Divide api into version to provide a consistent experience to developers.
require 'goliath'
require 'active_support/all'
module V01
class Hello
def self.call(env)
[200, {}, {'response' => 'V01'}]
end
@sent-hil
sent-hil / gist:3418572
Created Aug 21, 2012
River (getriver.com): Install Ruby, MongoDb on clean Ubuntu server.
View gist:3418572

Ideally this process should be automated via Puppet/Chef, I just haven't gotten around to it.

Upload local SSH keys to server for password less login

Create ssh dir on server

mkdir .ssh

Upload local key from laptop

local> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'

@sent-hil
sent-hil / goliath.markdown
Created Aug 21, 2012
River (getriver.com): HaProxy rules that matches based on api versions, http verbs and paths.
View goliath.markdown
frontend http
  bind *:8000

  # match http verbs
  acl is_post method POST

  # match api versions
  acl one hdr(Accept) -i application/v0.1
  acl two hdr(Accept) -i application/v0.2
You can’t perform that action at this time.