Skip to content

Instantly share code, notes, and snippets.

View sunkencity's full-sized avatar

Joel Westerberg sunkencity

  • Stockholm, Sweden
View GitHub Profile
@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
__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)
nmap <F2> :!bin/command.sh<CR>

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
mrxvt*font:-mixc-fixed-medium-r-normal-20-200-75-75-c-50-iso8859-1
mrxvt*foreground: #eeeeee
mrxvt*background: #1a1a1a
mrxvt*geometry: 100x30
mrxvt*visualBell: True
mrxvt*saveLines: 1000
mrxvt*termName: terminal
mrxvt*loginShell: True
#mrxvt*fullscreen: True
mrxvt*scrollbarStyle: next
(filter #(re-find #"\?$" (name (first %))) (ns-publics 'clojure.core))
namespace :delayed_job do
task :ensure, :roles => :app do
pid_from_file = capture("cat #{current_path}/tmp/pids/delayed_job.pid").strip
running_pids = capture("ps -ef | grep [d]elayed_job").split("\n").map { |x| x.split[1] }
if pid_from_file != running_pids.first || running_pids.size != 1
puts ("-"*80).console_purple
puts "Something is terribly wrong with delayed job!".console_red
puts "Running_pid: #{pid_from_file}"
puts "Running delayed job processes: #{capture("ps -ef | grep [d]elayed_job")}"
puts ("-"*80).console_purple
#!/usr/bin/env ruby
# backup script for postgresql databases
# connects via ssh and copies the file to a local path
@ssh_host = ""
@ssh_user = ""
@ssh_pass = ""
@db_name = ""
xrdb -merge .Xresources
@sunkencity
sunkencity / gist:704976
Created November 18, 2010 13:38
weird id behaviour
diff --git a/js/jquery.mobile.js b/js/jquery.mobile.js
index 86f8472..c9c7e3c 100644
--- a/js/jquery.mobile.js
+++ b/js/jquery.mobile.js
@@ -478,7 +478,7 @@
}
to
- .attr( "id", fileUrl )
+ .attr( "id", fileUrl.replace(".", "") )