Skip to content

Instantly share code, notes, and snippets.

@dayyan
dayyan / micropush_fetch.rb
Created Feb 6, 2018
Fetch Micropsuh Tokens
View micropush_fetch.rb
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
View gist:22ff4076e796910faeb1
args */**/*.coffee
argdo %s/find/replace/ge
wqal
View gist:14080e5a3e682ad5e619
▶ 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
View gist:e62bddc65ce1af735f0f
  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>
View .irbrc
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
Replace double quotes in all non-interpolated strings to single quotes in vim.
View gist:5556332
/\%(#\)\@!\zs"\(.\{-}\)"
View append sha1sum
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 Nov 8, 2012
Remove incorrect varnish and install correct version
View gist:4040897
// 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 Nov 8, 2012
Regular Expression Vim: Capistrano role from server IP paste with comments for internal IPs from Chef
View gist:4035715
:'<,'> 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
Pinterest urls in Javascript
View pinterest_urls.js
/* 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));