Skip to content

Instantly share code, notes, and snippets.

View scottjacobsen's full-sized avatar

Scott Jacobsen scottjacobsen

View GitHub Profile
url.sub /_normal(\.[[:alnum:]]+)?$/, '\\1'
#!/bin/bash
if [[ -d /mnt/yavin/hoth ]]; then
nice -n15 /usr/bin/rdiff-backup --exclude=/boot --exclude=/dev --exclude=/**/.gvfs --exclude=/media --exclude=/mnt --exclude=/proc --exclude=/sys --exclude=/lib/udev --exclude=/tmp --exclude=/home/scott/.mozilla/firefox/jxg17tdp.default/Cache --exclude=/usr/portage/distfiles --exclude=/var/tmp/portage --exclude=/var/run --exclude=/home/scott/.VirtualBox/HardDisks/SQLData.vdi / /mnt/yavin/hoth/current
fi
@scottjacobsen
scottjacobsen / dervied_private.rb
Created February 13, 2013 22:54
Derived classes can call a private method on a base class.
class MyBase
private
def priv
puts "private"
end
end
class MyDerived < MyBase
def foo
priv
@scottjacobsen
scottjacobsen / git-grep.el
Last active January 24, 2020 16:53
A more convenient git-grep. By default this will grep all files in the repository from the root of the git repository. I find these defaults more convenient than those used by vc-git-grep in the emacs version control library.
;; derived from rails-project:root from
;; https://github.com/remvee/emacs-rails
(defun git-root ()
"Return GIT_ROOT if this file is a part of a git repo,
else return nil"
(let ((curdir default-directory)
(max 10)
(found nil))
(while (and (not found) (> max 0))
(progn
@scottjacobsen
scottjacobsen / backup.sh
Created December 20, 2012 20:24
sort of time machine like backup using rdiff-backup
#!/bin/bash
if [[ -d /mnt/yavin/hoth ]]; then
nice -n15 /usr/bin/rdiff-backup --exclude=/boot --exclude=/dev --exclude=/**/.gvfs --exclude=/media --exclude=/mnt --exclude=/proc --exclude=/sys --exclude=/lib/udev --exclude=/tmp --exclude=/home/scott/.mozilla/firefox/jxg17tdp.default/Cache --exclude=/usr/portage/distfiles --exclude=/var/tmp/portage --exclude=/var/run --exclude=/home/scott/.VirtualBox/HardDisks/SQLData.vdi / /mnt/yavin/hoth/current
fi
@scottjacobsen
scottjacobsen / git+clone+ssh+agent+forward+sudo
Created December 14, 2012 00:07
Git clone using ssh agent forwarding and sudo
SSH agent forwarding is great. It allows you to ssh from one server to
another all the while using the ssh-agent running on your local
workstation. The benefit is you don't need to generate ssh key pairs
on the servers you are connecting to in order to hop around.
When you ssh to a remote machine the remote machine talks to your
local ssh-agent through the socket referenced by the SSH_AUTH_SOCK
environment variable.
So you the remote server you can do something like:
@scottjacobsen
scottjacobsen / post_gis_1204.txt
Created November 20, 2012 17:58
Install postgis on ubuntu 12.04
* aptitude purge postgresql-9.1-postgis2
* aptitude purge libgeos-3.3.3
* sudo aptitude install postgresql-server-dev-9.1
* sudo aptitude install checkinstall
* sudo aptitude install libproj-dev
@scottjacobsen
scottjacobsen / hsb.txt
Created November 8, 2012 22:46
holy shit bash!
The following paragraphs describe how bash executes
its startup files. If any of the files exist but
cannot be read, bash reports an error. Tildes are
expanded in file names as described below under
Tilde Expansion in the EXPANSION section.
When bash is invoked as an interactive login shell,
or as a non-interactive shell with the --login
option, it first reads and executes commands from
@scottjacobsen
scottjacobsen / ruby-flymake.el
Created August 27, 2012 16:54
Emacs flymake mode for ruby
(require 'flymake)
;; I don't like the default colors :)
(set-face-background 'flymake-errline "red4")
(set-face-background 'flymake-warnline "dark slate blue")
;; Invoke ruby with '-c' to get syntax checking
(defun flymake-ruby-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
#log loghost local0 info
maxconn 4096
#chroot /usr/share/haproxy
user haproxy
group haproxy
daemon
debug