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 / 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-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 }
@mindbat
mindbat / elm-day-2-count-mouse-clicks.elm
Created Oct 15, 2016
Elm Day 2: Count Mouse Clicks
View elm-day-2-count-mouse-clicks.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 }
@mindbat
mindbat / elm-day-2-track-click-position.elm
Created Oct 15, 2016
Elm Day 2: Track Click Position
View elm-day-2-track-click-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-echo-text.elm
Created Oct 16, 2016
Elm Day 2: Echoing Text
View elm-day-2-echo-text.elm
import Html exposing (Html, text, input, div)
import Html.App as App
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
import String
main = App.program { init = init,
view = view, update = update, subscriptions = \_ -> Sub.none }
-- Model