Skip to content

Instantly share code, notes, and snippets.

@re5et
re5et / gist:4550500
Created January 16, 2013 20:18
Make magit not alter the branch name you are checking out when creating a local tracking branch.
;; M-x customize-variable RET magit-default-tracking-name-function RET
;; Set "other" to magit-tracking-name-unfucked-with
(defun magit-tracking-name-unfucked-with (remote branch)
branch)
@re5et
re5et / magit-quick-stash.el
Created January 31, 2013 23:31
magit quick stash
(defun magit-quick-stash ()
"Immediately stash with mesage
WIP on branchname: short-sha commit-message"
(interactive)
(magit-stash ""))
(add-hook
'magit-status-mode-hook
(lambda ()
class Foo
# always works
def read_instance_property
bar
end
# assigns thing, but not Foo instance thing
def write_instance_property
thing = 'baz'
Namespaced = {}
class Foo
constructor: ->
@property = 'i am Foo'
class Namespaced.Foo
constructor: ->
(defun prettify-json ()
"NOTE: requires ruby in $PATH. Replace a valid json region with
pretty printed json By default uses the jj method to print,
uses pp if there is a prefix argument"
(interactive)
(let* ((print-method (if current-prefix-arg "pp" "jj"))
(cmd (format
"ruby -e 'require \"json\"; require \"pp\"; %s JSON.parse(gets)'" print-method)))
(shell-command-on-region
(region-beginning)
@re5et
re5et / git_repo_sync.sh
Created March 7, 2013 01:26
git repo sync
#! /usr/bin/env bash
checkout_dir=$1
from_remote=$2
to_remote=$3
cd $checkout_dir
#! /bin/bash
case "$1" in
'' | -h | --help)
NOARGS=1 ;;
-d)
DRY=1; FIND=$2 ;;
*)
DRY=0; FIND=$1 ;;
esac
@re5et
re5et / node_https.js
Created July 1, 2013 19:34
node https server
const crypto = require('crypto'),
fs = require("fs"),
http = require("http");
var privateKey = fs.readFileSync('privatekey.pem').toString();
var certificate = fs.readFileSync('certificate.pem').toString();
var credentials = crypto.createCredentials({key: privateKey, cert: certificate});
var handler = function (req, res) {
# RSpec matcher for validates_with.
# https://gist.github.com/2032846
# Usage:
#
# describe User do
# it { should validate_with CustomValidator }
# end
RSpec::Matchers.define :validate_with do |validator, options = {}|
match do |subject|
@re5et
re5et / force-save.el
Created August 27, 2013 21:59
Save a buffer, even if it hasn't been modified. I use this to touch / save a buffer when I want a test to run, etc.
(global-set-key (kbd "C-x C-s") 'force-save)
(defun force-save ()
(interactive)
(not-modified 1)
(save-buffer))