Skip to content

Instantly share code, notes, and snippets.

View nchelluri's full-sized avatar

Narsimham Chelluri nchelluri

  • Halifax, NS
View GitHub Profile
Mongoid Version: 3.1.4
Created documents with IDs ["5222a0a673197f377f000001", "5222a0a673197f377f000002", "5222a0a673197f377f000003"]
Looking In IDs ["5222a0a673197f377f000001", "5222a0a673197f377f000002"] and then calling #find
Find Result: 5222a0a673197f377f000003
@nchelluri
nchelluri / gem-version.rb
Last active January 2, 2016 21:09
Gem Versioning
#!/usr/bin/env ruby
puts [Gem::Version.new('4.0.0'), Gem::Version.new('4.0.0.alpha1'), Gem::Version.new('4.0.0.alpha2'), Gem::Version.new('4.0.1'), Gem::Version.new('4.1.0'), Gem::Version.new('4.1.1'), Gem::Version.new('4.1'), Gem::Version.new('4.0.0.gamma1'), Gem::Version.new('4.0.0.a1'), Gem::Version.new('4.0.0.zeta1')].sort
puts "\n\nComparing 4.0.0.alpha1 to 4.0.0: #{(Gem::Version.new('4.0.0.alpha1') <=> Gem::Version.new('4.0.0')).inspect}"
puts "\n\n4.0.0.alpha1 approximately equals: #{Gem::Version.new('4.0.0.alpha1').approximate_recommendation}"
puts "4.0.0 approximately equals: #{Gem::Version.new('4.0.0').approximate_recommendation}"
puts "4.0.1 approximately equals: #{Gem::Version.new('4.0.1').approximate_recommendation}"
puts "4.1.0 approximately equals: #{Gem::Version.new('4.1.0').approximate_recommendation}"
dev $ brew --config
HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew.git
HEAD: 4b55aa5742d8f9fe1cef1c5b81f1826fcf047072
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: quad-core 64-bit haswell
OS X: 10.9.4-x86_64
Xcode: 5.1.1
CLT: 5.1.0.0.1.1396320587
@nchelluri
nchelluri / priv
Created September 3, 2014 22:38
private storage using gpg
#!/bin/bash
gpg_id='my@email.address.ca'
inv_dir="$HOME/.priv"
gpg_cmd='gpg'
edit_cmd='emacs'
pager_cmd='less'
if [ $# -ge 2 ]; then
op=$1
@nchelluri
nchelluri / gist:acf6f1db524848e21b92
Last active September 23, 2023 21:25
Ch. 2 of Full Catastrophe Living by Jon Kabat-Zinn

Chapter 2: The Foundations of Mindfulness Practice: Attitudes and Commitment

To cultivate the healing power of mindfulness requires much more than mechanically following a recipe or a set of instructions. No real process of learning is like that. It is only when the mind is open and receptive that learning and seeing and change can occur. In practicing mindfulness you will have to bring your whole being to the process. You can't just assume a meditative posture and think something will happen or play a tape and think that the tape is going to "do something" for you.

The attitude with which you undertake the practice of paying attention and being in the present is crucial. It is the soil in which you will be cultivating your ability to calm your mind and to relax your body, to concentrate and to see more clearly. If the attitudinal soil is depleted, that is, if your energy and commitment to practice are low, it will be hard to develop calmness and relaxation with any consistency. If the soil is really

@nchelluri
nchelluri / secure_headers.rb
Created September 28, 2015 06:07
Annotated SecureHeaders Rails initializer
::SecureHeaders::Configuration.configure do |config|
# Quick reference: https://github.com/twitter/secureheaders
# <redacted-issue-num> - HSTS will be set by Ops in a downstream proxy
# if a user has visited the HTTPS version of this site, when they visit the HTTP version, their browser will edit the
# URL and use the HTTPS version instead
# https://tools.ietf.org/html/rfc6797
config.hsts = false # false disables setting the header
# <redacted-issue-num> - HPKP will be set by Ops in a downstream proxy
@nchelluri
nchelluri / gist:c8b5c565230730800fdac3e9779c810d
Last active August 12, 2016 15:45
Mailer Exceptions not showing
Using Rails 5. Why won't my Mailer show exceptions in the log?
- ActionMailer Config from development.rb:
[...]
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.logger = Logger.new($stdout) # this is experimental, doesn't seem to make a difference
config.action_mailer.perform_caching = false
default: &default
adapter: mysql2
pool: 5
encoding: utf8mb4
charset: utf8mb4
collation: utf8mb4_unicode_ci
socket: /tmp/mysql.sock
development:
<<: *default
@nchelluri
nchelluri / word-soup-hack.pl
Created June 13, 2017 14:59
Finds all words that can be made with a given string of letters
#!/usr/bin/env perl
use Modern::Perl '2015';
use autodie;
use experimental 'signatures';
use List::MoreUtils qw(uniq);
unless (@ARGV == 1) {
say "usage: $0 letters";
@nchelluri
nchelluri / gist:3694eddf8e5280bdfe63e97358660c38
Last active June 19, 2017 15:14
Single character multiple byte emoji
👨🏼‍💻