Skip to content

Instantly share code, notes, and snippets.

@dayyan
dayyan / micropush_fetch.rb
Created February 6, 2018 18:46
Fetch Micropsuh Tokens
require 'aws-sdk'
# This assumes you have ~/.aws/credentials with a profile called production
# granting you read access to the DynamoDB resource.
client = Aws::DynamoDB::Client.new(region: 'us-west-2', profile: 'production')
MC_4501 = %w(
4fd39d51-07c4-4b26-b5e6-e3f486017580
0e626b9d-6cd7-4d45-b4d6-ff5c1e1389a7
cb57c61c-d2f6-4331-aab2-40e9af9d075a
@dayyan
dayyan / gist:22ff4076e796910faeb1
Created November 20, 2014 00:21
vim replace all
args */**/*.coffee
argdo %s/find/replace/ge
wqal
▶ brew list -1 | while read line; do brew unlink $line; brew link $line; done
Unlinking /usr/local/Cellar/appledoc/2.2... 0 links removed
Linking /usr/local/Cellar/appledoc/2.2... 1 symlinks created
Unlinking /usr/local/Cellar/autoconf/2.69... 0 links removed
Linking /usr/local/Cellar/autoconf/2.69... 18 symlinks created
Unlinking /usr/local/Cellar/bash-completion/1.3... 184 links removed
Linking /usr/local/Cellar/bash-completion/1.3... 182 symlinks created
Unlinking /usr/local/Cellar/bgrep/0.2... 0 links removed
Linking /usr/local/Cellar/bgrep/0.2... 1 symlinks created
Unlinking /usr/local/Cellar/binutils/2.24... 49 links removed
  1. Configure Gmail in you gitconfig:
[sendemail]
  smtpserver = smtp.gmail.com
  smtpserverport = 587
  smtpencryption = tls
  smtpuser = <gmail email address>
  from = <email address for From: field>
@dayyan
dayyan / .irbrc
Created September 13, 2013 23:05
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 99999
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history"
@dayyan
dayyan / gist:5556332
Created May 10, 2013 18:20
Replace double quotes in all non-interpolated strings to single quotes in vim.
/\%(#\)\@!\zs"\(.\{-}\)"
find . -name '*.*' -type f -print | while read file; do
hash=$(sha1sum $file | awk '{print $1}');
mkdir -p hashed;
cp $file hashed/${file%.*}-$hash.${file/*.};
done
@dayyan
dayyan / gist:4040897
Created November 8, 2012 19:17
Remove incorrect varnish and install correct version
// chef recipe installed latest varnish by default which is broken, revert to 2.10
for i in {list of servers}; do ssh root@$i "export DEBIAN_FRONTEND=noninteractive; sudo apt-get -q -y remove varnish; sudo apt-get -q -y install libvarnish1=2.1.0-2ubuntu0.1; sudo apt-get -q -y install varnish=2.1.0-2ubuntu0.1"; done;
// may want to remove varnish config files prior if defaults are going to be used
@dayyan
dayyan / gist:4035715
Created November 8, 2012 00:57
Regular Expression Vim: Capistrano role from server IP paste with comments for internal IPs from Chef
:'<,'> s/x\(.*ACTIVE | \)\(.\{-}\d\)\s*| \(.*\)/role :app, '\2', # \1 \3/
turns
x| 1111 | yyy-yyy-staging-app83 | ACTIVE | 192.168.0.1 | 10.10.10.10 |
to
role :app, '192.168.0.1' # | 1111 | xxx-xxx-staging-app83 | ACTIVE | 10.10.10.10 |
@dayyan
dayyan / pinterest_urls.js
Created May 15, 2012 21:11
Pinterest urls in Javascript
/* Pinterest urls need to be URI encoded, then URI component encoded.
*/
replace('{shareUrl}', escape(shareObj.shareUrl)).replace('{imageUrl}', encodeURIComponent(encodeURI(shareObj.imageUrl))).replace('{shareText}', escape(shareObj.shareText));