Skip to content

Instantly share code, notes, and snippets.

@jclosure
jclosure / emacs_path_to_shell_path
Created October 29, 2014 02:17
Set your emacs PATH to match shell PATH
;;ADD THIS TO INIT.EL
;; set the path as terminal path [http://lists.gnu.org/archive/html/help-gnu-emacs/2011-10/msg00237.html]
(setq explicit-bash-args (list "--login" "-i"))
;; fix the PATH variable for GUI [http://clojure-doc.org/articles/tutorials/emacs.html#osx]
(defun set-exec-path-from-shell-PATH ()
(let ((path-from-shell
@jclosure
jclosure / excel_range_locking
Created December 20, 2014 21:13
Excel Range Locking For Functions
To keep Excel from dynamically moving the target range for a function, use the $ in front of the col and row references.
On a windows machine, you can toggle through the "lock down" methods with the F4 key.
A '$' will lock down the reference to an absolute one versus a relative one. You can lock down the column, row or both. Here is a locked down absolute reference for your example.
(A1-MIN($A$1:$A$30))/(MAX($A$1:$A$30)-MIN($A$1:$A$30))
@jclosure
jclosure / tar_copy
Created December 27, 2014 01:38
Delta Fold-In File Copying With tar
(cd /opt/jboss-fuse && tar c .) | (cd /mnt/lastbackup/jboss-fuse && tar xf -)
@jclosure
jclosure / gist:b3c7b3c8e455533de1fb
Created January 16, 2015 02:44
Use PowerShell to Create WinForms on the Fly
$firstName = New-Object System.Windows.Forms.textBox
$firstName.add_KeyUp({ $fullName.Text = $firstName.text + " " + $lastName.text})
$lastName = New-Object System.Windows.Forms.textBox
$lastName.top += 50
$lastName.add_KeyUp({ $fullName.Text = $firstName.text + " " + $lastName.text})
$fullName = New-Object System.Windows.Forms.textBox
$fullName.top += 100
@jclosure
jclosure / cli_data_hacks
Created February 3, 2015 03:26
CLI Big Data Hacks
# Count the number of lines in a file
cat file.txt | wc -l
# Jump to a line with less
less +392800g file.txt
# View the top of a file (eg. view the column headers of a csv file)
head file.txt
# Grab the first 8 fields of a delimeted file and save to another
@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 [email protected] -o UserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no 'tar zcf - ./scratch/in' | \
/usr/bin/sshpass -p mypass ssh [email protected] -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.