Skip to content

Instantly share code, notes, and snippets.

@zaphar
zaphar / date_util.erl
Created May 1, 2009 06:07
set of utility functions that wrap the calendar module and erlangs now() date() and time() functions
-module(date_util).
-compile(export_all).
epoch() ->
now_to_seconds(now())
.
epoch_hires() ->
now_to_seconds_hires(now())
.
@nifl
nifl / grok_vi.mdown
Created August 29, 2011 17:23
Your problem with Vim is that you don't grok vi.

Answer by Jim Dennis on Stack Overflow question http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118

Your problem with Vim is that you don't grok vi.

You mention cutting with yy and complain that you almost never want to cut whole lines. In fact programmers, editing source code, very often want to work on whole lines, ranges of lines and blocks of code. However, yy is only one of many way to yank text into the anonymous copy buffer (or "register" as it's called in vi).

The "Zen" of vi is that you're speaking a language. The initial y is a verb. The statement yy is a simple statement which is, essentially, an abbreviation for 0 y$:

0 go to the beginning of this line. y yank from here (up to where?)

@ahpook
ahpook / gist:1182243
Created August 30, 2011 22:14
Use a generic client certificate with puppet

The problem

There's enough trouble with puppet's ssl model (mandatory client certs) that people go and do odd things to get around it. The primary problem is that for lab/preproduction environments, if you reinstall machines frequently, you lose access to the private key that generated the original cert but (absent some puppet cert --clean [node] operation) the cert still exists, leading to the dreaded Retrieved certificate doesn't match private key error.

A solution

Generate a single client certificate which all your nodes use, and have the master determine node names from facter rather than the SSL DN. This way you can re-install nodes with impunity and as long as your bootstrap plops down the correct config and the cert+key, you don't have any more SSL issues.

The caveats

If you have autosign turned on, this change represents a shift in security tradeoffs: you can turn off autosign and therefore more tightly control which clients can talk to your server because they need to have your clie

@jaredhanson
jaredhanson / gist:2559730
Created April 30, 2012 16:20
Restify and Passport /cc Hal Robertson
// Based off example code from Hal Robertson
// https://github.com/halrobertson/test-restify-passport-facebook
// See discussion: https://groups.google.com/forum/?fromgroups#!topic/passportjs/zCz0nXB_gao
var restify = require('restify')
// config vars
var FB_LOGIN_PATH = '/api/facebook_login'
var FB_CALLBACK_PATH = '/api/facebook_callback'
var FB_APPID = '<<YOUR APPID HERE>>'
@tetsuok
tetsuok / whitecolor.gp
Created May 8, 2012 22:26
Code to change colors of various components in Gnuplot
# Change colors of elements in Gnuplot
# change a color of border.
set border lw 3 lc rgb "white"
# change text colors of tics
set xtics textcolor rgb "white"
set ytics textcolor rgb "white"
# change text colors of labels
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active April 27, 2024 00:18
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@kevinswiber
kevinswiber / hal.json
Created July 7, 2012 14:56
JSON Siren vs. HAL Representations
{
"_links": {
"self": { "href": "/orders" },
"next": { "href": "/orders?page=2" },
"find": { "href": "/orders{?id}", "templated": true }
},
"_embedded": {
"orders": [{
"_links": {
"self": { "href": "/orders/123" },
@mahata
mahata / eshell-path-env.el
Created September 15, 2012 19:47
eshell-path-env and PATH
(defun eshell-mode-hook-func ()
(setq eshell-path-env (concat "/usr/local/bin:" eshell-path-env))
(setenv "PATH" (concat "/usr/local/bin:" (getenv "PATH")))
(define-key eshell-mode-map (kbd "M-s") 'other-window-or-split))
(add-hook 'eshell-mode-hook 'eshell-mode-hook-func)
@mattratleph
mattratleph / vimdiff.md
Last active April 24, 2024 11:28 — forked from roothybrid7/vimdiff_cheet.md
vimdiff cheat sheet

vimdiff cheat sheet

##git mergetool

In the middle file (future merged file), you can navigate between conflicts with ]c and [c.

Choose which version you want to keep with :diffget //2 or :diffget //3 (the //2 and //3 are unique identifiers for the target/master copy and the merge/branch copy file names).

:diffupdate (to remove leftover spacing issues)

:only (once you’re done reviewing all conflicts, this shows only the middle/merged file)