Skip to content

Instantly share code, notes, and snippets.

@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 / docker_reverting
Created June 5, 2015 08:07
How to revert a docker container to a previous commit
$ docker history imagename
IMAGE CREATED CREATED BY SIZE
f770fc671f11 12 seconds ago apt-get install -y curl 21.3 MB
28445c70c2b3 39 seconds ago apt-get install ping 11.57 MB
8dbd9e392a96 7 months ago 131.5 MB
$ docker tag 2844 imagename # <-- that's the secret right there
$ docker history imagename
IMAGE CREATED CREATED BY SIZE
@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
@jclosure
jclosure / compile_sql_lite_w_gem_install_windows
Created September 4, 2015 04:47
How to compile sqlite3 in windows and install gem
1. Download the SQLite source amalgamation from
http://sqlite.org/download.html
2. unpack the source in a directory of your choice (e.g. C:\sqlite3)
3. be sure to have the Ruby DevKit installed and enabled the DevKit
environment
4. compile the DLL, I used following command:
gcc -Os -O2 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE
-DSQLITE_ENABLE_COLUMN_METADATA --shared sqlite3.c -o sqlite3.dll
@jclosure
jclosure / multi-threading with perl example
Created September 17, 2015 16:47
multi-threading with perl example
#!/opt/local/bin/perl -w
use threads;
use strict;
use warnings;
# SOURCE REF: http://chicken.genouest.org/perl/multi-threading-with-perl/
my @a = ();
my @b = ();
@jclosure
jclosure / bash-file-ensure-skeleteon.sh
Created September 17, 2015 20:00
skeletal starter for scripts that require files in fs as args
#!/bin/bash
FILE=$1
##################################################################################
function usage(){
echo "usage: $(basename $0) /path/to/java-rpm-file.rpm"
}
##################################################################################
@jclosure
jclosure / proper-way-to-install-java-in-rhel
Created September 21, 2015 19:20
This is the proper way to install java in rhel/centos
# installation via rpm
jdk-8u60-linux-x64.rpm
rpm -Uvh jdk-8u60-linux-x64.rpm
alternatives --config java
alternatives --config javaws
alternatives --config libjavaplugin.so
alternatives --config libjavaplugin.so.x86_64