Skip to content

Instantly share code, notes, and snippets.

# Use vim keybindings in copy mode
setw -g mode-keys vi
unbind p
bind p paste-buffer
bind -T copy-mode-vi 'v' send -X begin-selection
bind -T copy-mode-vi 'C-v' send -X rectangle-toggle
# Pre-tmux 2.3 vi bindings
#bind-key -t vi-copy 'v' begin-selection
# Use vim keybindings in copy mode
setw -g mode-keys vi
unbind p
bind p paste-buffer
bind -T copy-mode-vi 'v' send -X begin-selection
bind -T copy-mode-vi 'C-v' send -X rectangle-toggle
# Pre-tmux 2.3 vi bindings
#bind-key -t vi-copy 'v' begin-selection
package main
import "fmt"
func main() {
for i := 1 ; i <= 100 ; i++ {
if i % 15 == 0 {
fmt.Println("FizzBuzz")
} else if i % 5 == 0 {
fmt.Println("Buzz")
@dafyddcrosby
dafyddcrosby / preprocessor_fun.h
Last active August 29, 2015 14:27 — forked from aras-p/preprocessor_fun.h
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1) /'
}
function git_unadded_new {
if git rev-parse --is-inside-work-tree &> /dev/null
then
if [[ -z $(git ls-files --other --exclude-standard 2> /dev/null) ]]
then
echo ""
@dafyddcrosby
dafyddcrosby / gist:6719934
Created September 26, 2013 20:18
Microsoft HTTP headers
$ curl -I http://microsoft.com
HTTP/1.1 301 Moved Permanently
Content-Length: 148
Content-Type: text/html; charset=UTF-8
Location: http://www.microsoft.com/
Server: Microsoft-IIS/7.5
P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"
X-Powered-By: ASP.NET
X-UA-Compatible: IE=EmulateIE7
Date: Thu, 26 Sep 2013 20:16:47 GMT
@dafyddcrosby
dafyddcrosby / gist:6719816
Created September 26, 2013 20:08
HireRight headers
$ curl -I http://www.hireright.com/Data-Security.aspx
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 19625
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/7.5
Set-Cookie: ASP.NET_SessionId=tn0hxauue4ksp155tfvwwm55; path=/; HttpOnly
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Thu, 26 Sep 2013 19:55:51 GMT
@dafyddcrosby
dafyddcrosby / validatemongocolls.js
Created September 3, 2013 17:43
Validate all collections in MongoDB
conn = new Mongo();
dblist = conn.getDBs();
dblist.databases.forEach(function(x){
db = db.getSiblingDB(x.name);
db.getCollectionNames().forEach(function(c){
printjson(db.getCollection(c).validate())
})
})
#!/usr/bin/env python
import os
import re
import subprocess
import sys
modified = re.compile('^(?:M|A)(\s+)(?P<name>.*)')
CHECKS = [
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
//Sort an array A using insertion sort. Notice it is to be passed by reference.
void sort(int* A, int n){
int tmp;
int i;
int j;