Skip to content

Instantly share code, notes, and snippets.

View deepak's full-sized avatar

Deepak Kannan deepak

View GitHub Profile
@deepak
deepak / example nginx config.txt
Last active February 22, 2019 22:11
example nginx config with SSL from LetsEncrypt for a rails app (see steps.txt)
# rails config needs `force_ssl`
# example:
# Force all access to the app over SSL, use Strict-Transport-Security,
# and use secure cookies.
# config.force_ssl = true
# and rails needs some headers to be set, otherwise will be trapped in a redirect loop
# nginx config for headers:
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto https;
@deepak
deepak / running overcommit hooks.23-feb-2016.txt
Created February 23, 2016 07:13
running overcommit hooks
git commit
/usr/local/opt/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/overcommit-0.32.0/lib/overcommit/git_version.rb:12: warning: Insecure world writable dir /usr in PATH, mode 040777
Running pre-commit hooks
Check for trailing whitespace....................[TrailingWhitespace] OK
✓ All pre-commit hooks passed
/usr/local/opt/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/overcommit-0.32.0/lib/overcommit/git_version.rb:12: warning: Insecure world writable dir /usr in PATH, mode 040777
Running commit-msg hooks
Check subject line................................[SingleLineSubject] OK
@deepak
deepak / overcommit hooks.md
Last active February 11, 2016 18:20
overcommit hooks
  • add overcommit. to catch things like, long commit messages

    echo "2.3.0" > .ruby-version gem install overcommit overcommit --install overcommit --sign run overcommit --list (to see list of hooks) run overcommit --run (to test it out once)

some interesting hooks to try out, but not enabled:

@deepak
deepak / ip-address-shell-alias.sh
Last active January 21, 2016 15:00
find IP address from CLI
# http://apple.stackexchange.com/questions/20547/how-do-i-find-my-ip-address-from-the-command-line
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias localip="ipconfig getifaddr en0"
@deepak
deepak / https-client.js
Last active January 20, 2016 06:08
node project to compare https and request. task is to consume https apis while ignoring ssl errors
#!/usr/bin/env node --trace-sync-io
// curl command to test:
// curl --insecure -X GET -v https://localhost:3000/
// something similar in node using the https module
// works with:
// strictSSL: false, // allow us to use our self-signed cert for testing
// rejectUnauthorized: false
// no need to add
@deepak
deepak / ruby_ping.rb
Last active May 6, 2019 01:47
ruby ping
# let us say you want to check if a host is reachable
# sometimes you need to be behind a private VPN or the host is just down
# and you want to do this on your local-machine and on Heroku
# can open your terminal and use ping on your local
# And can get a bash shell on Heroku as well - by `heroku run bash`
# but there is no `ping` binary there
# ```bash
@deepak
deepak / ls-on-file-watch.js
Created January 14, 2016 07:06
do not understand how to pass arguments to node's child_process.spawn
"use strict";
const fs = require('fs'),
spawn = require('child_process').spawn,
fileName = process.argv[2],
spawnCmd = process.argv[3],
spawnArgs = process.argv.slice(4, process.argv.length);
console.log([typeof spawnArgs, spawnArgs]);
if (!fileName) {
@deepak
deepak / file-watcher.js
Created January 14, 2016 04:37
nodejs error stack trace is obtuse
const fs = require('fs'),
fileName = process.argv[2];
if (!fileName) {
throw Error("need to specify file to watch!");
}
fs.watch(fileName, function() {
console.log("file '"+ fileName + "' just changed");
});
@deepak
deepak / Generic Classes and Subtyping in Java.md
Last active January 6, 2016 08:36
Generic Classes and Subtyping in Java
@deepak
deepak / how to find if a method is overridden.rb
Last active January 5, 2016 08:17
how to find if a method is overridden
# http://stackoverflow.com/questions/11462430/can-i-detect-that-a-method-has-been-overridden
module Ponger
def pong
"ping"
end
end
class HealthCheck
include Ponger