Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'mechanize'
cert_store = OpenSSL::X509::Store.new
cert_store.add_file 'cacert.pem' #get it at https://dl.dropboxusercontent.com/u/947497/cacert.pem
a = Mechanize.new do |agent|
agent.cert_store = cert_store
end
@mping
mping / project.clj
Last active February 23, 2016 10:44
server.clj
(defproject jetty-async "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.7.0"]
[com.ninjudd/ring-async "0.2.0"]])
(def ^:dynamic *indent* 0)
(alter-var-root
#'clojure.core/load
(fn [orig]
(fn [& paths]
(let [t (System/nanoTime)
r (binding [*indent* (inc *indent*)]
(apply orig paths))]
(binding [*out* *err*]
(println (apply str (repeat *indent* " ")) (/ (- (System/nanoTime) t) 1000000.0) paths)
(ns skynet.main
(:require
[co.paralleluniverse.pulsar
[core :refer :all]
[actors :refer :all]])
(:refer-clojure :exclude [promise await])
(:gen-class))
(declare skynet)
@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 / .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 $*