This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # outbound, actually all | |
| sudo tcpflow -C -i any -e all port 80 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| echo "172.217.7.228 www.miguelping.com" >> /etc/hosts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; 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"]]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |


