Skip to content

Instantly share code, notes, and snippets.

@mping
mping / build.boot
Created May 27, 2017 11:57 — forked from bartojs/build.boot
gmail rest api java/clojure example with oauth2 and labels
;; 1) first goto https://console.developers.google.com/start/api?id=gmail
;; -- to turn on gmail api for your account
;; 2) then create a oauth consent with app name
;; 3) then add oauth clientid and download to ./clientsecret.json
;; 4) boot run
;; -- when running first time a browser will open to accept authorizaton
(set-env! :dependencies '[[com.google.apis/google-api-services-gmail "v1-rev34-1.21.0"]
[com.google.api-client/google-api-client "1.20.0"]
[com.google.oauth-client/google-oauth-client-jetty "1.20.0"]])
@mping
mping / hosts.sh
Created April 17, 2017 14:03
hosts.sh
#!/bin/bash
echo "172.217.7.228 www.miguelping.com" >> /etc/hosts
@mping
mping / cgd.js
Last active February 9, 2017 12:47
Nightmarejs to fetch ebank data
var electron = require("electron")
var Nightmare = require("nightmare")
require('nightmare-inline-download')(Nightmare)
//$ node xxx.js USER PW
// ^ in some shells, that space prevents the cmd to be saved in shell history
@mping
mping / .tmux.conf
Created January 11, 2017 17:27
tmux
set -g default-terminal "screen-256color"
# use C-q for tmux
unbind-key C-b
set -g prefix 'C-q'
# ctrl+arrow up/down in emacs for history
set-window-option -g xterm-keys on
# Allows for faster key repetition
@mping
mping / makepr.sh
Last active September 26, 2016 15:14
"Make" a PR on the current branch for another branch (github only)
#
# https://gist.github.com/mping/29e779669071baa88c4c
# make a url like this, for PRs:
# https://github.com/Company/repo/compare/master...BRANCH?expand=1
# https://repo.gitlab.com/Company/repomerge_requests/new?utf8=%E2%9C%93&merge_request%5Bsource_project_id%5D=25&merge_request%5Bsource_branch%5D=BRANCh&merge_request%5Btarget_project_id%5D=25&merge_request%5Btarget_branch%5D=master
#
# > makepr master
# will generate the url for a PR from the current branch to master
@mping
mping / .bashrc
Last active September 7, 2016 08:26
Bash and Zsh dot.rc files
#
# shared history: http://unix.stackexchange.com/questions/1288/preserve-bash-history-in-multiple-terminal-windows#3055135
#
HISTCONTROL=ignoredups:erasedups # no duplicate entries
HISTSIZE=100000 # big big history
HISTFILESIZE=100000 # big big history
shopt -s histappend # append to history, don't overwrite it
#st should be a function to pass args
st(){ sublime-text $*
@mping
mping / zsh.md
Last active September 1, 2016 21:26 — forked from tsabat/zsh.md
Getting oh-my-zsh to work in Ubuntu

Prereq:

apt-get install zsh
apt-get install git-core

installation

Getting zsh to work in ubuntu is weird, since sh does not understand the source command. So, you do this to install zsh

@mping
mping / remove-image.rb
Last active August 25, 2016 14:27
Remove image from docker registry
def deleteImageWithTagAndHash(registryHost, imageName, tag, hash)
puts "Deleting..."
res = `curl -X DELETE -I http://#{registryHost}/v2/#{imageName}/manifests/#{hash}`
puts "curl -X DELETE -I http://#{registryHost}/v2/#{imageName}/manifests/#{hash}"
puts "Deleted image with tag #{tag}"
end
def getDigestForImageAndTag(registryHost, imageName, tag)
puts 'Processing...'
digestHash = `curl -s -I -X HEAD -H 'Accept: application/vnd.docker.distribution.manifest.v2+json' http://#{registryHost}/v2/#{imageName}/manifests/#{tag} | sed -n 's/Docker-Content-Digest://p'`
@mping
mping / tcpflow.sh
Created August 1, 2016 11:37
tcpflow
# outbound, actually all
sudo tcpflow -C -i any -e all port 80
@mping
mping / mongodb.js
Last active July 19, 2016 13:07
mongodb common ops
// drop all non-system colls
db.getCollectionNames().forEach(function(c) { if (c.indexOf("system.") == -1) db[c].drop(); })
// clear old profiles
db.setProfilingLevel(0); db.system.profile.drop(); db.setProfilingLevel(1, 100)
// view top profile queries
db.getCollection('system.profile').find({}, {ns: 1, query:1, millis:1, command: 1}).sort({millis:-1})
//slow queries starting from a given date