Skip to content

Instantly share code, notes, and snippets.

View kxhitiz's full-sized avatar
:octocat:
{ hello: world }

Kshitiz Gurung kxhitiz

:octocat:
{ hello: world }
View GitHub Profile

Querying your jsonb column It’s time to use some query operators. PostgreSQL has many others, so read the documentation for a complete list.

Also, always remember to EXPLAIN the queries you’re executing; that way you can adapt your indexes for a better performance.

Users that opt-in newsletter

# preferences->newsletter = true
User.where('preferences @> ?', {newsletter: true}.to_json)
@kxhitiz
kxhitiz / git-commit-log-stats.md
Created April 12, 2019 17:43 — forked from eyecatchup/git-commit-log-stats.md
Some commands to get git commit log statistics for a repository on the command line.

git commit stats

Commands to get commit statistics for a Git repository from the command line -
using git log, git shortlog and friends.




@kxhitiz
kxhitiz / california_local_tax.csv
Last active October 1, 2018 19:59
sample tax data for admin import
City Rate County State TaxableCategory Country
Acampo 7.75% San Joaquin California digital-subscriptions US
Acton 9.50% Los Angeles California digital-subscriptions US
Adelaida 7.25% San Luis Obispo California digital-subscriptions US
Adelanto* 7.75% San Bernardino California digital-subscriptions US
Adin 7.25% Modoc California digital-subscriptions US
Agoura 9.50% Los Angeles California digital-subscriptions US
Agoura Hills* 9.50% Los Angeles California digital-subscriptions US
Agua Caliente 8.13% Sonoma California digital-subscriptions US
Agua Caliente Springs 7.75% San Diego California digital-subscriptions US
#!/usr/bin/env bash
curl https://s3.amazonaws.com/heroku-jvm-buildpack-vi/vim-7.3.tar.gz --output vim.tar.gz
mkdir vim && tar xzvf vim.tar.gz -C vim
export PATH=$PATH:/app/vim/bin
@kxhitiz
kxhitiz / prepare-commit-msg
Created May 10, 2017 22:19 — forked from jasonmerino/prepare-commit-msg
Prepend branch name to every git commit message unless on master.
#!/bin/sh
#
# Prepend the branch name to the commit message
#
# Add this file as [repo]/.git/hooks/prepare-commit-msg
#
# A couple notes:
# 1. The file must be executable (chmod +x prepare-commit-msg)
# 2. This works on a per-repo basis (unless you follow this guide https://coderwall.com/p/jp7d5q/create-a-global-git-commit-hook)
**GIT**
git fetch -p
git branch --merged | grep -v master | xargs -n 1 git branch -d
> db.tasks.find({"deleted_at" : null, "worker_id": ObjectId("52fb3ee0863a995e8d004bac"), "completed_at":{"$gte":ISODate("2014-04-11 00:00:00.000Z"), "$lte":ISODate("2014-07-13 23:59:59.999Z")}, "status":"completed"}).hint({deleted_at: 1, worker_id: 1, completed_at: 1, status: 1}).explain()
{
"cursor" : "BtreeCursor deleted_at_1_worker_id_1_completed_at_1_status_1",
"isMultiKey" : false,
"n" : 5035,
"nscannedObjects" : 5035,
"nscanned" : 6228,
"nscannedObjectsAllPlans" : 5035,
"nscannedAllPlans" : 6228,
@kxhitiz
kxhitiz / headless_crawl.js
Last active August 29, 2015 13:58
phantom js usage example
var page = require('webpage').create(),
system = require('system'),
url = "http://localhost:3000";
page.onConsoleMessage = function(msg) {
console.log(msg);
};
if (system.args.length < 2) {
console.log("Usage: headless_crawl.js [url]");
@kxhitiz
kxhitiz / Gemfile
Created August 14, 2013 05:52 — forked from geemus/Gemfile
source "http://rubygems.org"
gem 'fog'
@kxhitiz
kxhitiz / gist:5977559
Last active December 19, 2015 15:38
Playing with PSQL

Create .pgpass in home directory with db config options in format

hostname:port:database:username:password

Dump db:

pg_dump faves_development -U faves -h localhost -F c > mysql.dump

Restore db:

psql faves_development -h localhost -U faves < mysql.dump