Skip to content

Instantly share code, notes, and snippets.

Avatar
🍻
explicit is better than implicit

Ron Toland mindbat

🍻
explicit is better than implicit
View GitHub Profile
View vimrc
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 Dec 11, 2015
emacs startup file
View emacs
(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 Jan 29, 2013
sample virtual host entry for drupal on apache
View drupal-vhost
<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 Jun 7, 2013
Quickly run php lint against a directory of files
View php-lint-script
find <directory> -type f -name '*php' -print0 | xargs -0 -n1 -P10 php -l
@mindbat
mindbat / format.sd
Last active Dec 18, 2015
Sed script for re-formatting php files Use: sed -r -f format.sd -i <path/to/file/to/reformat>
View format.sd
# 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 Jun 28, 2013
Git pre-commit script to run all the modified files through php-lint. Won't let you commit php file with a syntax error.
View pre-commit.lint
#!/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 Jul 28, 2013
Bash script to rename project gutenberg ebooks to their document titles.
View rename_gutenberg.sh
#!/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 Dec 21, 2015
Versions of the head, tail, etc functions that are safe to use on empty lists
View safe.hs
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 Oct 15, 2016
Elm Day 2: Mouse Position
View elm-day-2-mouse-position.elm
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 Oct 15, 2016
Elm Day 2: Count Mouse Moves
View elm-day-2-count-mouse-moves.elm
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 }