Skip to content

Instantly share code, notes, and snippets.

View dhruvasagar's full-sized avatar

Dhruva Sagar dhruvasagar

View GitHub Profile
import Data.List (intercalate)
import Data.Maybe (fromJust, fromMaybe)
import Debug.Trace (trace)
data Point = Point Int Int
deriving (Show, Eq)
parsePoint :: String -> Point
parsePoint as = Point x y
where
name: Deploy Dev
on:
workflow_run:
workflows: ["CI"]
types:
- completed
branches:
- develop
job:
#!/bin/bash
# GistID: 87c59acf3b53cf1911bc6e3a8055afbf
_call_func () {
declare -f -F "$1" && $1
}
typeset -A _dirsh_cache
_dirsh_hook () {
#!/usr/bin/env bash
# GistID: 6db76639d8874eb9ffd091021bedba8e
set -e
info () {
tput setaf 6; echo "$1"; tput sgr0
}
if [ ! -x "$(command -v aws)" ]; then
echo 'Please install following dependencies: '
echo '* jq'
echo '* cfssl'
echo '* aws cli'
exit 1
fi
usage () {
echo "Usage: $0 [tag]"

Keybase proof

I hereby claim:

  • I am dhruvasagar on github.
  • I am dhruvasagar (https://keybase.io/dhruvasagar) on keybase.
  • I have a public key ASBD9lLidgpCJG8sfmBDLu6RRxz15Kn6koyCJspFa_jQWgo

To claim this, I am signing this object:

@dhruvasagar
dhruvasagar / zshrc
Last active April 14, 2019 03:48
Simple trick to profile ZSH
if [[ "$ZPROF" = true ]]; then
zmodload zsh/zprof
fi
# ... your ZSHRC with all your scripts
if [[ "$ZPROF" = true ]]; then
zprof
fi
@dhruvasagar
dhruvasagar / damerau_levenshtein_distance.rb
Last active March 3, 2019 21:34 — forked from dimus/damerau_levenshtein distance for ruby
Damerau-Levenshtein distance for ruby in C
#!/usr/bin/env ruby1.9
# encoding: UTF-8
require 'rubygems'
require 'inline'
require 'time'
class DamerauLevenshtein
def distance(str1, str2, block_size=2, max_distance=10)
res = distance_utf(str1.unpack("U*"), str2.unpack("U*"), block_size, max_distance)
(res > max_distance) ? nil : res
@dhruvasagar
dhruvasagar / add_missing_master_variants.rb
Last active June 20, 2018 19:20
Script to add master variants for spree_products that are missing them
puts "Rails environment is #{Rails.env}"
products_without_master = Spree::Product.joins('left outer join spree_variants sv on sv.product_id = spree_products.id and sv.is_master = 1').where('sv.id is null').all
ids_without_master = products_without_master.map(&:id)
puts "Spree products without master variants are #{ids_without_master.count} in number and have ids #{ids_without_master}"
updated_at_values = products_without_master.map(&:updated_at)
ActiveRecord::Base.transaction do
puts "Creating missing master variants inside a transaction..."
if exists('g:loaded_pairify')
finish
endif
let g:loaded_pairify = 1
let g:pairs = {
\ "left": {
\ "[": "]",
\ "(": ")",
\ "{": "}",