Skip to content

Instantly share code, notes, and snippets.

View sunkencity's full-sized avatar

Joel Westerberg sunkencity

  • Stockholm, Sweden
View GitHub Profile
:vimgrep /pattern/ path/**
:cope #to open quickfix list
xrdb -merge .Xresources

i3 Window Manager Cheat Sheet

$mod refers to the modifier key (alt by default)

General

  • startx i3 start i3 from command line
  • $mod+<Enter> open a terminal
  • $mod+d open dmenu (text based program launcher)
  • $mod+r resize mode ( or to leave resize mode)
  • $mod+shift+e exit i3
nmap <F2> :!bin/command.sh<CR>
__BEGIN__
*vimtips.txt* For Vim version 7.3.
------------------------------------------------------------------------------
" new items marked [N] , corrected items marked [C]
" *best-searching*
/joe/e : cursor set to End of match
3/joe/e+1 : find 3rd joe cursor set to End of match plus 1 [C]
/joe/s-2 : cursor set to Start of match minus 2
/joe/+3 : find joe move cursor 3 lines down
/^joe.*fred.*bill/ : find joe AND fred AND Bill (Joe at start of line)
@sunkencity
sunkencity / gist:a69488e0b630d48fa287
Last active August 29, 2015 14:02
exit on error in shellscript
set -e: Enables checking of all commands. If a command exits with an error and the
caller does not check such error, the script aborts immediately. Enabling this will
make your scripts more robust. But don't wait until your script is "complete" to set
the flag as an afterthought, because it will be a nightmare to fix the scrip to work
with this feature enabled. Just write set -e as the very first line of your code;
well... after the shell bang.
set -x: If you are writing simple scripts that are meant to, well, script the execution
of a few tasks (as opposed of being full-flown programs written in shell), set this
flag to trace the execution of all commands. This will make the interpreter print
@sunkencity
sunkencity / gist:3736683
Created September 17, 2012 10:55
compojure test
(defn
^{:doc "Action that shows the help and about page."
:path "/help"
:http_method :get}
action-show
[account member]
(normal-layout account
[:div
[:h1 "Title"]
[:p "lorem")
@sunkencity
sunkencity / mapreduce
Created May 14, 2012 07:48
A simple mapreduce example
A little tutorial on mapreduce.
This is a short tutorial on what mapreduce is. It'll do a process first sequentially and then with multiple mapper jobs As a silly example we will try to get a list of prime numbers in a big corpus of random numbers. Let's first start out with creating some test data that has good behaviour. We'll do this in the a terminal shell using ruby.
$ruby -e "(1..100).each { |x| puts x }" > data_1..100.txt
Look at the file with the "cat" utility:
$ cat data_1..100.txt
1
@sunkencity
sunkencity / gist:2225386
Created March 28, 2012 10:54
Validera personnummer
# encoding: utf-8
class SocialSecurityNumber
def initialize str
if str =~ /(\d{2})(\d{2})(\d{2})(\d{4})/
@str = str
@year,@month,@day,@last_four = $1,$2,$3,$4
current_year = Time.now.year % 100
century = @year.to_i > current_year ? "19" : "20"
@full_year = "#{century}#{@year}"
@sunkencity
sunkencity / database.yml
Created April 26, 2011 06:45
nice tip for testing #rails with #postgresql to file to get rid of NOTICE messages for primary keys
min_messages: WARNING