Skip to content

Instantly share code, notes, and snippets.

@mping
mping / instructions.md
Last active June 14, 2016 11:34 — forked from nicerobot/jstatd.sh
Run jstatd w/o error 'access denied (java.util.PropertyPermission java.rmi.server.ignoreSubClasses write)'

Socks Proxy

image

Add Remote Host

image

Add Jstad Connection

image

@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
@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 / 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 / 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 / .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 / 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 / hosts.sh
Created April 17, 2017 14:03
hosts.sh
#!/bin/bash
echo "172.217.7.228 www.miguelping.com" >> /etc/hosts
@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 / Main.scala
Created July 3, 2017 09:46 — forked from sujoyu/Main.scala
Scala parser combinator sample like HTML tag.
import scala.util.parsing.combinator._
import scala.language.postfixOps
object Main {
def main(args:Array[String]) = {
val sc = new java.util.Scanner(System.in)
val input = collection.mutable.ListBuffer[String]()
while(sc.hasNextLine) {
input += sc.nextLine