Skip to content

Instantly share code, notes, and snippets.

@jclosure
jclosure / 0_reuse_code.js
Last active August 29, 2015 14:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jclosure
jclosure / tar_piping_transfer_script
Created March 14, 2015 04:06
1 liner shell command that tars a directory, pipes it through 2 ssh connections, and untars it
/usr/bin/sshpass -p mypass ssh myuser@myhost1.com -o UserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no 'tar zcf - ./scratch/in' | \
/usr/bin/sshpass -p mypass ssh myuser@myhost2.com -o UserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no 'tar xzf - -C ./scratch/out'
@jclosure
jclosure / copyright
Created April 5, 2015 18:04
Standard Copyright for top of files
@jclosure
jclosure / suds_example
Created April 7, 2015 07:52
Consume a Soap Service in Python with suds
import logging
import traceback as tb
import suds.metrics as metrics
from suds import WebFault
from suds.client import Client
errors = 0
logging.getLogger('suds.client').setLevel(logging.DEBUG)
@jclosure
jclosure / windows_emacs_git_pass
Last active August 29, 2015 14:18
Windows + Emacs + Git push via http and hangs because waiting on password
Workaround to issue with CMD.exe inside emacs not prompting for password when "git push" command is issued.
1. download and run git-credential-winstore.exe - https://gitcredentialstore.codeplex.com
2. add this to the .gitconfig in C:\Users\<youruser> - http://emacs.stackexchange.com/questions/478/magit-push-hangs-on-windows
[credential]
helper = "winstore"
Now when inside emacs, do M-x, shell.
Try pushing through https to github, you'll get a graphical login that allows you to input user/pass.
@jclosure
jclosure / emacs_find_keys
Created April 28, 2015 06:03
Get Emacs Keys for Function or Function for Keys
You can get help for a command by typing
C-h f function-name
This will usually tell you if it has a standard key binding. Conversely, given a key sequence, you can type
C-h k key-sequence
To get the command that would run. For more help on getting help, you can type
@jclosure
jclosure / undo-tree-hints
Last active August 29, 2015 14:20
Emacs undo-tree hints
Active undoo-tree with C-x u
Move up,down,left, and right the tree with up/down/left/right arrow
In the tree window you can enable timestamps and diffs with t and d
;; t (`undo-tree-visualizer-toggle-timestamps')
;; Toggle display of time-stamps.
;;
;; d (`undo-tree-visualizer-toggle-diff')
@jclosure
jclosure / jetty-in-nrepl
Created May 28, 2015 05:09
starting and stopping jetty from inside an nrepl session
(use 'ring.adapter.jetty)
(defn app-handler [request]
{:status 200
:headers {"Content-Type" "text/html"}
:body (str request)})
(defonce server (run-jetty #'app-handler {:port 3000 :join? false}))
(.start server)
@jclosure
jclosure / trim_es_index_by_date.sh
Created June 4, 2015 20:50
Bash Script to Trim Elasticsearch By Date Indexes
#!/bin/bash
DAYS_AGO=$1
TARGET_INDEX=logstash-`date --date="$DAYS_AGO days ago" +%Y.%m.%d`;
if [[ "$DAYS_AGO" ]]; then
# echo "computed target index: $TARGET_INDEX"
curl -XDELETE "http://localhost:9200/$TARGET_INDEX"
else
@jclosure
jclosure / gist:67c27ebf0747c95f3e4a
Last active August 29, 2015 14:27
install emacs from src HEAD via homebrew
brew install -v emacs --HEAD --use-git-head --with-cocoa --srgb