Skip to content

Instantly share code, notes, and snippets.

@dpaluy
dpaluy / git.sh
Last active June 26, 2020 05:34
Remove trailing whitespace of all files recursively
# Git repository-specific solution
# Source: http://unix.stackexchange.com/questions/36233/how-to-skip-file-in-sed-if-it-contains-regex/36240#36240
git grep -I --name-only -z -e '' | xargs -0 sed -i -e 's/[ \t]\+\(\r\?\)$/\1/'
@rapimo
rapimo / gist:3250341
Created August 3, 2012 18:44
count occurrences of array values in postgres using hstore
SELECT hstore(array_agg(v), array_agg(c::text)) FROM (
SELECT v, COUNT(*) as c ,1 as agg from unnest(ARRAY['foo','bar','baz','foo']) v GROUP BY v) t
GROUP BY agg
--> "bar"=>"1", "baz"=>"1", "foo"=>"2"
@jboner
jboner / latency.txt
Last active June 1, 2024 18:05
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@williscool
williscool / useful_commands.md
Last active October 30, 2023 11:31
Commands that I've found to be useful. Mostly general command line, bash, and rails stuff

Useful commands:

TODO: rearrange this to bottom = oldest and top = newst (2-27-2020) below dashed line

fix tmux resurrect

ln -f -s $(/bin/ls -t tmux_resurrect_*.txt | head -n 1) last

tmux useful comands

@williscool
williscool / .bashrc
Last active April 27, 2018 01:20
my general bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# enable forward search
# http://ruslanspivak.com/2010/11/25/bash-history-incremental-search-forward/
# https://bugs.launchpad.net/ubuntu/+source/bash/+bug/80635/comments/12
stty -ixon
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@henrik242
henrik242 / p4merge
Last active January 5, 2023 22:23
Helper script for p4merge and Git on MacOSX
#!/bin/bash
for arg; do [[ $arg = /* ]] || arg=$PWD/$arg; absargs+=("$arg"); done;
/Applications/P4Merge.app/Contents/Resources/launchp4merge "${absargs[@]}"
@brow
brow / redis.markdown
Created October 26, 2011 10:13 — forked from bdotdub/redis.markdown
Running redis using upstart on Ubuntu

Running redis using upstart on Ubuntu

I've been trying to understand how to setup systems from the ground up on Ubuntu. I just installed redis onto the box and here's how I did it and some things to look out for.

To install:

@simme
simme / Install_tmux
Created October 19, 2011 07:55
Install and configure tmux on Mac OS X
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/
@metaskills
metaskills / wait_until.rb
Last active May 2, 2024 01:51
Never sleep() using Capybara!
# WAIT! Do consider that `wait` may not be needed. This article describes
# that reasoning. Please read it and make informed decisions.
# https://www.varvet.com/blog/why-wait_until-was-removed-from-capybara/
# Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations?
describe 'Modal' do
should 'display login errors' do
visit root_path