Skip to content

Instantly share code, notes, and snippets.

View sairam's full-sized avatar
🏠
Working from home

Sai Ram Kunala sairam

🏠
Working from home
View GitHub Profile
@sairam
sairam / amazon.md
Created October 10, 2020 18:59 — forked from terabyte/amazon.md
Amazon's Build System

Prologue

I wrote this answer on stackexchange, here: https://stackoverflow.com/posts/12597919/

It was wrongly deleted for containing "proprietary information" years later. I think that's bullshit so I am posting it here. Come at me.

The Question

Amazon is a SOA system with 100s of services (or so says Amazon Chief Technology Officer Werner Vogels). How do they handle build and release?

@sairam
sairam / deep-merge-directories.rb
Created December 26, 2019 18:03
Deep Merge Directories on Linux and Mac
#!/usr/bin/env ruby
require 'fileutils'
require 'readline'
# Usage: (Interactive) ruby deep-merge-directories.rb dir1 dir2 dir3 new_dir
# Usage: (Non Interactive) CREATE_DIRECTORIES=yes MOVE_FILES=yes ruby deep-merge-directories.rb dir1 dir2 dir3 new_dir
# NOTE: empty directories will be created from source directories. files already present in new_dir may be overridden
# LICENSE: MIT
@sairam
sairam / stubby.yml
Created April 1, 2018 16:39
Add CloudFlare as a provider in stubby config
upstream_recursive_servers:
- address_data: 1.0.0.1
tls_auth_name: "cloudflare-dns.com"
tls_pubkey_pinset:
- digest: "sha256"
value: yioEpqeR4WtDwE9YxNVnCEkTxIjx6EEIwFSQW+lJsbc=
@sairam
sairam / open-file-in-github.sh
Created June 1, 2017 19:41
open file from CLI in github
#!/bin/bash
# Usage: open-file-in-github.sh filepath
# Usage: open-file-in-github.sh dirpath develop
# Usage: open-file-in-github.sh filepath feature/test
# works in any subdirectory. does not check if path is tracked or not.
filepath=$1
branch=$2
if [[ -d $filepath ]]; then
@sairam
sairam / lib-tasks-custom_assets.rake
Created May 20, 2017 13:54
Merge custom assets with webpack assets
namespace :assets do
task add_custom_assets: :environment do
source_manifest_file = "#{ActionView::Base.assets_manifest.dir}/custom-manifest.json"
unless File.exists?(source_manifest_file)
puts "source manifest file not found at #{source_manifest_file}"
else
# make sure the file exists and has content. better to use the below approach
# rails_manifest_file = Sprockets::ManifestUtils.find_directory_manifest(ActionView::Base.assets_manifest.dir)
# assets = JSON.parse(open(rails_manifest_file).read)
@sairam
sairam / fetch-mailgun-logs.rb
Created April 10, 2017 12:47
Fetches logs/events from Mailgun based on event type like 'failure'
# Script to fetch failed records from mailgun
# see https://documentation.mailgun.com/api-events.html to customize
require 'rest-client'
require 'json'
api_key = "key-abcdefabcdef" # get your API key from https://app.mailgun.com/app/account/security
domain_name = "mg.example.com" # fill in your domain from your mailgun account
def get_data(url, send_params, events)
@sairam
sairam / generate-banner.sh
Last active April 9, 2017 13:55
Generate a Banner with an Image
# Usage generate_banner "Read Later Tools are Productivity Killers"
function generate_banner() {
wget -O header-plain.jpg "https://source.unsplash.com/featured/1200x630/?mountains"
echo -n $1| convert -size 1200 -font BrushScriptI -pointsize 80 -gravity center -background rgba\(0,0,0,0.5\) -fill white caption:'@-' text.png
composite -channel rgba -alpha set -gravity south text.png header-plain.jpg header-title.jpg
open header-title.jpg
echo "copy header-title.png to your destination"
echo "rm header-title.jpg header-plain.jpg text.png"
}
@sairam
sairam / hammerspoon-init.lua
Created April 9, 2017 06:45
Blog - Hammer Spoon
# find the latest configuration at https://github.com/sairam/dotfiles/blob/master/hammerspoon/init.lua
hs.hotkey.bind({"alt"}, "C", function() hs.eventtap.keyStrokes(hs.pasteboard.getContents()) end)
hs.hotkey.bind({"command"}, "I", function() hs.eventtap.rightClick(hs.mouse.getAbsolutePosition()) end)
hs.hotkey.bind({"command"}, "J", function() hs.eventtap.scrollWheel({0, -50}, {}, "pixel") end, nil, function() hs.eventtap.scrollWheel({0, -50}, {}, "pixel") end)
hs.hotkey.bind({"command"}, "K", function() hs.eventtap.scrollWheel({0, 50}, {}, "pixel") end, nil, function() hs.eventtap.scrollWheel({0, 50}, {}, "pixel") end)
@sairam
sairam / cron.v2.patch
Created April 8, 2017 09:09
Git Notify Patch for gopkg.in/robfig/cron.v2
diff --git a/spec.go b/spec.go
index 3dfd3e0..f895f42 100644
--- a/spec.go
+++ b/spec.go
@@ -114,7 +114,7 @@ WRAP:
for 1<<uint(t.Hour())&s.Hour == 0 {
if !added {
added = true
- t = t.Truncate(time.Hour)
+ t = time.Date(t.Year(), t.Month(), t.Day(), t.Hour(), 0, 0, 0, s.Location)
@sairam
sairam / 0_reuse_code.js
Created March 24, 2017 04:02
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console