Skip to content

Instantly share code, notes, and snippets.

@makevoid
makevoid / csv.rb
Created October 20, 2011 22:08
Convert Hashes to CSV easily
# Convert Hashes to CSV easily
# source.rb
#
# { valid: "ruby", hash: "" }
# { another: "valid", ruby: "hash" }
# { etc...
# usage:
#
@textarcana
textarcana / git-log2json.sh
Last active March 1, 2024 05:26
Convert Git logs to JSON. The first script (git-log2json.sh) is all you need, the other two files contain only optional bonus features 😀THIS GIST NOW HAS A FULL GIT REPO: https://github.com/context-driven-testing-toolkit/git-log2json
#!/usr/bin/env bash
# Use this one-liner to produce a JSON literal from the Git log:
git log \
--pretty=format:'{%n "commit": "%H",%n "author": "%aN <%aE>",%n "date": "%ad",%n "message": "%f"%n},' \
$@ | \
perl -pe 'BEGIN{print "["}; END{print "]\n"}' | \
perl -pe 's/},]/}]/'
@kyanny
kyanny / simple_queue.rb
Created October 27, 2011 07:25
SimpleQueue
#!/usr/bin/env ruby
class SimpleQueue
def initialize(max)
@max = max
@queue = Array.new(max)
end
def clear
@queue = []
@yano3
yano3 / gist:1378948
Created November 19, 2011 15:17
git commit --amend --reset-author
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name "Your Name"
git config --global user.email you@example.com
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author
@valvallow
valvallow / .stumpwmrc.lisp
Last active December 6, 2019 22:21
.stumpwmrc
(in-package :stumpwm)
;;
;; settings
;;
(set-focus-color "DarkRed")
(set-unfocus-color "black")
(set-win-bg-color "black")
(set-fg-color "white")
(set-bg-color "black")
@jsvnm
jsvnm / infrubystuff.el
Created November 24, 2011 08:24
making pry work with inf-ruby
(add-to-list 'inf-ruby-implementations '("pry" . "pry"))
(setq inf-ruby-default-implementation "pry")
(setq inf-ruby-first-prompt-pattern "^\\[[0-9]+\\] pry\\((.*)\\)> *")
(setq inf-ruby-prompt-pattern "^\\[[0-9]+\\] pry\\((.*)\\)[>*\"'] *")
#!/usr/bin/env ruby
require 'csv'
require 'json'
if ARGV.size != 2
puts 'Usage: csv_to_json input_file.csv output_file.json'
puts 'This script uses the first line of the csv file as the keys for the JSON properties of the objects'
exit(1)
end
@incanus
incanus / gist:1439684
Created December 6, 2011 19:56
Script to export Heroku environment variables to the local shell
#!/bin/sh
for x in `heroku config`; do
if [[ $x == HUBOT* ]]; then
name=$x
elif [ $x != '=>' ]; then
value=$x
export $name=$value
fi
done
@daveray
daveray / seesaw-repl-tutorial.clj
Created December 7, 2011 04:55
Seesaw REPL Tutorial
; A REPL-based, annotated Seesaw tutorial
; Please visit https://github.com/daveray/seesaw for more info
;
; This is a very basic intro to Seesaw, a Clojure UI toolkit. It covers
; Seesaw's basic features and philosophy, but only scratches the surface
; of what's available. It only assumes knowledge of Clojure. No Swing or
; Java experience is needed.
;
; This material was first presented in a talk at @CraftsmanGuild in
; Ann Arbor, MI.
@wridgers
wridgers / .tmux.conf
Created February 7, 2012 16:05
tmux config file
# Make it use C-a, similar to screen..
unbind C-b
unbind l
set -g prefix C-a
bind-key C-a last-window
# Reload key
bind r source-file ~/.tmux.conf
set -g history-limit 1000