Skip to content

Instantly share code, notes, and snippets.

View dhruvasagar's full-sized avatar

Dhruva Sagar dhruvasagar

View GitHub Profile
# Why is this change necessary ?
# How does it address the issue ?
# What side effects does this change have ?
# References
nnoremap g> <ESC>vap:Twrite bottom-right<CR>
xnoremap g> :Twrite bottom-right<CR>
{
"customer_name": "Girish ",
"customer_phone_number": "8345657321",
"amount": 199,
"placement_date": "16/06/2016",
"line_items": [
{
"variant_sku": "TIWD2571_M",
"quantity": 1,
"lmdn_enabled": true,
@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..."
#!/usr/bin/env ruby
def fizz(num)
num % 3 == 0 ? "Fizz" : nil
end
def buzz(num)
num % 5 == 0 ? "Buzz" : nil
end
if exists('g:loaded_dash')
finish
endif
let g:loaded_dash = 1
function! s:Dash(search)
exec 'silent !open "dash://' . join(split(a:search), ':') . '"'
redraw!
endfunction
function! s:RandomNumber(limit)
let components = split(reltimestr(reltime()), '\.')
let microseconds = components[-1] + 0
return microseconds % a:limit
endfunction
function! s:RandomScheme()
let choices = []
for fname in globpath(&runtimepath, 'colors/*.vim', 1)
let choices += [fnamemodify(fname, ':t:r')]
#!/usr/bin/env bash
set -u
set -e
export GIT_WORK_TREE="/var/www/example.com"
export NODE_VERSION="0.10"
echo "--> Checking out..."
git checkout -f
@dhruvasagar
dhruvasagar / gist:2cde7e4f5490fdda3efa
Last active August 29, 2015 14:03
SSH Public Key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCZH/9G6dnwQRu0Rtij382bIIjIE7Eb/1Ja1w9kBN3DwPXMZsfY22XYNJHCspcoyhHpwUR1ZxMoCs4cmh3PVv1Gq9PHX9ogsO0ufeoZdHeoFv53L2yU9nRVtPAqZfkQxrlXQWmDFFHWpld7i4tNZp9j0KW1SS91a9wvttnSo4FwWi8BrUprN9iECaYPgPwwiRybQ37D4grTjbr3SdMev+vCYKVpTQftC7HzRvTJXTO/vHm+16sEOjM+LwqnGipGuBfQjHJnHVwlAT+aF8JxCseitI9TD+52e+5ZJ4oPzStRiccVdFJEkmGglo5n2ZVoN9Di6RL6PJ/SUzAKF8lbpxlf dhruvasagar@dhruvasagar
@dhruvasagar
dhruvasagar / gist:b56f52c416f1e8a15a61
Last active August 29, 2015 14:01
Get a list of first n primes
(defn prime-nth [n]
(take n
(filter
(fn [x]
(nil? (some #(zero? (mod x %)) (range 2 (inc (int (/ x 2)))))))
(iterate inc 2))))