Skip to content

Instantly share code, notes, and snippets.

@jdsumsion
jdsumsion / Cassandra.xml
Created September 13, 2014 18:15
Cassandra code base codestyle for IntelliJ 13
<?xml version="1.0" encoding="UTF-8"?>
<code_scheme name="Cassandra">
<option name="RIGHT_MARGIN" value="160" />
<XML>
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
</XML>
<codeStyleSettings language="JAVA">
<option name="BRACE_STYLE" value="2" />
<option name="CLASS_BRACE_STYLE" value="2" />
<option name="METHOD_BRACE_STYLE" value="2" />
function ssh-agent-launch
echo "Initializing new SSH agent ..."
ssh-agent -c | sed 's/^echo/#echo/' > $SSH_ENV
echo "succeeded"
chmod 600 $SSH_ENV
. $SSH_ENV > /dev/null
ssh-add
end
function ssh-agent-test
@jdsumsion
jdsumsion / git-root
Last active December 21, 2015 09:09
git-root script that prints the root of a git repository
#!/bin/bash
GIT_DIR=`git rev-parse --git-dir` &&
(
if [ `basename $GIT_DIR` = ".git" ]; then
# handle normal git repos (with a .git dir)
cd $GIT_DIR/..
else
# handle bare git repos (the repo IS a xxx.git dir)
cd $GIT_DIR
fi
@jdsumsion
jdsumsion / xcl
Last active December 14, 2015 12:09
X Clipboard helper script
#!/bin/bash
#
# While 'xclip' is helpful, it's way too verbose,
# and the defaults are unhelpful for common
# "Ctrl-C/V" type usages.
#
# This 'xcl' utility transforms 'xclip' into a
# helpful cmdline friend.
#
@jdsumsion
jdsumsion / xclip-cleanse
Created November 27, 2012 18:17
X Clipboard Cleaner
#!/bin/bash
xclip -o -selection clipboard > /tmp/clipboard
cat /tmp/clipboard | xclip -i -selection clipboard
rm -f /tmp/clipboard
@jdsumsion
jdsumsion / 00-NOTE.md
Created January 16, 2012 16:18
Argable example

The whole intent of this gist is subsumed by this awesome-looking gem:

The following things don't appear to be supported by cli yet (as of 24 Jan. 2012):

  1. multiple short options like "-rf"
  2. git-like concatenated option/value combinations like "-Spattern"
  3. any kind of sub-command support (not supported by this gist either)
@jdsumsion
jdsumsion / foo.rb
Created January 10, 2012 15:39
Commandable example
require 'commandable'
require 'optparse'
class Foo
extend Commandable
# the :default param is optional, and can only be on one method
command "hello", :default
def hello(world="world") # the default value is expressed inline in real ruby
puts "hello #{world.inspect}"
@jdsumsion
jdsumsion / gist:1325447
Created October 30, 2011 03:54
Backward Names
def backwards_name(name)
name.split(/ +/)
.map { |piece| piece = piece.reverse; "#{piece[0].upcase}#{piece[1..-1].downcase}" }
.join(" ")
end
>> backwards_name "John Sumsion"
=> "Nhoj Noismus"
@jdsumsion
jdsumsion / dot-functions.sh
Created September 16, 2011 15:57
Useful bash helper for invoking dot
#!/bin/bash
echo $0 | grep -q "dot-functions.sh" && {
echo "usage: source dot-functions.sh, then run 'dot foo.dot' and the PNG will show"
exit 1
}
produce_image_type() {
for arg in "$@"; do
[[ "$arg" =~ -T[-_a-z]+ ]] && echo ${arg#-T} && return 0
done
@jdsumsion
jdsumsion / example_note_keeping_app.rb
Created May 20, 2010 20:03 — forked from pietern/example_note_keeping_app.rb
fixed redis-1.2.6 incompatibilities
require 'rubygems'
require 'sinatra'
require 'redis'
# To use, simply start your Redis server and boot this
# example app with:
# ruby example_note_keeping_app.rb
#
# Point your browser to http://localhost:4567 and enjoy!
#