Skip to content

Instantly share code, notes, and snippets.

View rawsyntax's full-sized avatar

Eric Himmelreich rawsyntax

View GitHub Profile
require "rubygems"
require 'compass' #must be loaded before sinatra
require 'sinatra'
require 'builder'
require 'haml'
require 'sass'
require File.join(File.dirname(__FILE__), *%w[lib cache])
require File.join(File.dirname(__FILE__), *%w[lib config])
require File.join(File.dirname(__FILE__), *%w[lib models])
/^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
@rawsyntax
rawsyntax / gist:1032030
Created June 17, 2011 18:50
function that sets the gui up just like I like it
;;default display position/size based on display resolution
;;warning: assumption that the 24/22 " displays are oriented
;; above the laptop's display
;; Haven't found a way to check multiple monitor
;; relative orientation via emacs yet...
;; NOTE: try integrating with applescript for this?
(defun reset-ui ()
(interactive)
(delete-other-windows)
(color-theme-merbivore)
# before align-regexp, not super easy to read
var = 5
another_value = 10
assignment = 5
very_long_var_name = 25
# after align-regexp =, readability improved!
var = 5
(defun delete-file-and-buffer ()
"Deletes the current file and buffer, assumes file exists"
(interactive)
(delete-file buffer-file-name)
(kill-buffer (buffer-name)))
;; make zap-to-char act like zap-up-to-char
(defadvice zap-to-char (after my-zap-to-char-advice (arg char) activate)
"Kill up to the ARG'th occurence of CHAR, and leave CHAR.
The CHAR is replaced and the point is put before CHAR."
(insert char)
(forward-char -1))
(require 'color-theme)
;;;###autoload
(defun color-theme-merbivore ()
(interactive)
(color-theme-install
'(color-theme-merbivore
((background-color . "black")
(background-mode . dark)
(cursor-color . "deeppink")
(foreground-color . "#E6E1DC"))
;;resurrect *scratch* buffer
;; FROM: Morten Welind
;;http://www.geocrawler.com/archives/3/338/1994/6/0/1877802/
(save-excursion
(set-buffer (get-buffer-create "*scratch*"))
(lisp-interaction-mode)
(make-local-variable 'kill-buffer-query-functions)
(add-hook 'kill-buffer-query-functions 'kill-scratch-buffer))
(defun kill-scratch-buffer ()
@rawsyntax
rawsyntax / rsync-retry.sh
Created October 26, 2011 20:20 — forked from jmar71n/rsync-retry.sh
Runs rsync, retrying on errors up to a maximum number of tries.
#!/bin/bash
### ABOUT: See: http://gist.github.com/366269
### Runs rsync, retrying on errors up to a maximum number of tries.
### On failure script waits for internect connection to come back up by pinging google.com before continuing.
###
### Usage: $ ./rsync-retry.sh source destination
### Example: $ ./rsync-retry.sh [email protected]:~/* ~/destination/path/
###
### INPORTANT:
@rawsyntax
rawsyntax / bash-history.sh
Created November 1, 2011 16:21
on removing commands from history
# say we start with an empty bash command history
bash-3.2$ history
1 history
# enter a command that requires a password
bash-3.2$ sudo rm -i some_file
Password:
# accidentally ^C and type your password
# into the prompt and hit enter