Skip to content

Instantly share code, notes, and snippets.

View mindbat's full-sized avatar
🍻
explicit is better than implicit

Ron Toland mindbat

🍻
explicit is better than implicit
View GitHub Profile
@mindbat
mindbat / vimrc
Created January 29, 2013 23:00
vimrc file
set number
set ts=2
set expandtab
nnoremap <tab> %
vnoremap <tab> %
nnoremap ; :
let mapleader = ","
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
@mindbat
mindbat / emacs
Last active December 11, 2015 22:18
emacs startup file
(setq make-backup-files nil)
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq standard-indent 4)
(setq tab-stop-list '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80))
(setq c-basic-offset 4)
(autoload 'paredit-mode "paredit"
"Minor mode for pseudo-structurally editing Lisp code." t)
@mindbat
mindbat / drupal-vhost
Created January 29, 2013 23:09
sample virtual host entry for drupal on apache
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName drupal
DocumentRoot /var/www/drupal
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
@mindbat
mindbat / php-lint-script
Created June 7, 2013 00:12
Quickly run php lint against a directory of files
find <directory> -type f -name '*php' -print0 | xargs -0 -n1 -P10 php -l
@mindbat
mindbat / format.sd
Last active December 18, 2015 05:29
Sed script for re-formatting php files Use: sed -r -f format.sd -i <path/to/file/to/reformat>
# swap tabs for spaces
s/\t/ /g
# ensure spaces around =>
s/([^ ])=>([^ ])/\1 => \2/g
# remove trailing whitespace
s/ +$//g
# ensure spaces around .
@mindbat
mindbat / pre-commit.lint
Created June 28, 2013 22:19
Git pre-commit script to run all the modified files through php-lint. Won't let you commit php file with a syntax error.
#!/bin/sh
#
# Hook script to check the changed files with php lint
# Called by "git commit" with no arguments.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
@mindbat
mindbat / rename_gutenberg.sh
Created July 28, 2013 18:43
Bash script to rename project gutenberg ebooks to their document titles.
#!/bin/bash
# Bash script to pull document titles from
# Project Gutenberg ebooks.
# Invoke using command like:
# find ./ -type f -name "*.txt" | xargs -n 1 ./process.sh ~/Documents/
# pull the first line of the file
FIRST_LINE=`head -n 1 $2`
@mindbat
mindbat / safe.hs
Last active December 21, 2015 08:18
Versions of the head, tail, etc functions that are safe to use on empty lists
safeHead :: [a] -> [a]
safeHead x = take 1 x
safeTail :: [a] -> [a]
safeTail x = drop 1 x
safeInit :: [a] -> [a]
safeInit x = take ((length x) - 1) x
safeLast :: [a] -> [a]
@mindbat
mindbat / elm-day-2-mouse-position.elm
Created October 15, 2016 19:28
Elm Day 2: Mouse Position
import Html exposing (Html, text, div)
import Html.App as App
import Mouse exposing (..)
main = App.program { init = init,
view = view, update = update, subscriptions = subscriptions }
-- Model
type alias Model = { x: Int, y: Int }
@mindbat
mindbat / elm-day-2-count-mouse-moves.elm
Created October 15, 2016 19:49
Elm Day 2: Count Mouse Moves
import Html exposing (Html, text, div)
import Html.App as App
import Mouse exposing (..)
main = App.program { init = init,
view = view, update = update, subscriptions = subscriptions }
-- Model
type alias Model = { count: Int }