Skip to content

Instantly share code, notes, and snippets.

View dhruvasagar's full-sized avatar

Dhruva Sagar dhruvasagar

View GitHub Profile
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')]
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
#!/usr/bin/env ruby
def fizz(num)
num % 3 == 0 ? "Fizz" : nil
end
def buzz(num)
num % 5 == 0 ? "Buzz" : nil
end
@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..."
{
"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,
nnoremap g> <ESC>vap:Twrite bottom-right<CR>
xnoremap g> :Twrite bottom-right<CR>
# Why is this change necessary ?
# How does it address the issue ?
# What side effects does this change have ?
# References
@dhruvasagar
dhruvasagar / WebRTC Outline.md
Created October 13, 2016 04:28
WebRTC Outline
  • Introduction to WebRTC
  • Why WebRTC ?
  • WebRTC underpinnings : Signaling, STUN, TURN
  • Open Source Libraries & Tools available
  • Building your own Signaling Server
  • Demo
alert('test');
if exists('g:loaded_pairify')
finish
endif
let g:loaded_pairify = 1
let g:pairs = {
\ "left": {
\ "[": "]",
\ "(": ")",
\ "{": "}",