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 gist:47a10baeebc6ecc5d4ef7919b77db026
The following below are what *I* think are best principles (after going through the last dozen mostly commented PRs):
1. Principle of least astonishment: does every single line follow principle of least astonishment?
This means if you, as a "reasonable" Rails programmer would be confused about this change, then this code either needs to be refactored or documented properly (there are situations that require us to break best practices, but these situations are very, very rare).
2. Readability: can I understand everything in PR (title, description, comments, code and tests) without having to ask the PR author to explain to me what it means?
And if there are edge case, are they documented properly?
3. Are edge cases, user input errors accounted for?
If the code relies on user input, what happens if the user is trying to sabotage? ie https://xkcd.com/327/
@sent-hil
sent-hil / suitesync_wipe_metadata_fields.rb
Created Jul 3, 2017 — forked from iloveitaly/suitesync_wipe_metadata_fields.rb
Wipe all metadata fields from Stripe used by http://SuiteSync.io/ when a sandbox refresh is performed
View suitesync_wipe_metadata_fields.rb
# Mike Bianco <mike@suitesync.io>
# Description: Wipe all metadata fields from Stripe used by SuiteSync.
# Helpful after a sandbox refresh.
#
# Usage:
# export STRIPE_KEY=sk_test_
# ruby suitesync_wipe_metadata_fields.rb
require 'stripe'
View keybase.md

Keybase proof

I hereby claim:

  • I am sent-hil on github.
  • I am senthil196 (https://keybase.io/senthil196) on keybase.
  • I have a public key ASCi9RUVVKDkkW-LPPaJ_N6h6jccWFLmO5DaoSyUVc4sJAo

To claim this, I am signing this object:

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 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)
@sent-hil
sent-hil / go_vroom
Last active Dec 21, 2015
First vim plugin
View go_vroom
" Vim plugin for running the current test under cursor. I wrote it on a friday night
" when I was bored and sort of curious about vim plugin development. Needless to say
" I don't want to write any more vim plugins.
if exists("g:loaded_go_vroom")
finish
endif
if &compatible
echohl ErrorMsg
@sent-hil
sent-hil / gist:6259773
Created Aug 18, 2013
Run go test under cursor
View gist:6259773
function RunGoTestUnderLine()
let line_text = getline(".")
let raw_test_name = matchstr(getline("."), "Test.*\(")
if raw_test_name != -1
let test_name = substitute(raw_test_name, "\(", "", "")
exec '!go test -run ' . test_name
endif
endfunction
autocmd FileType go nnoremap <leader>s :call RunGoTestUnderLine()<cr>
View go_style.txt
1. Comments prefixed with // & space.
// right
//wrong
2. No blank lines between for & next line.
for _, name := range notAllowedSuffixes {
if strings.HasSuffix(sourceName, name) || strings.HasSuffix(targetName, name) {
@sent-hil
sent-hil / rvm
Last active Dec 17, 2015
Fish shell config
View rvm
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)
end
@sent-hil
sent-hil / gist:4641437
Last active Dec 11, 2015
zsh function to show specs to code ratio in a rails folder, anything over 0.75 is good.
View gist:4641437
prompt_rspec_stats() {
if [[ ((-d app || -d lib) && -d spec) ]]; then
if [[ (-d app) ]]; then
local app=`wc -l app/**/*.rb | grep -oE "[0-9]+" | tail -n 1`
else
local app=`wc -l lib/**/*.rb | grep -oE "[0-9]+" | tail -n 1`
fi
local spec=$((`wc -l spec/**/*.rb | grep -oE "[0-9]+" | tail -n 1`))+0.01
local ratio=`printf "%.2f\n" $((spec/app))`
You can’t perform that action at this time.