Skip to content

Instantly share code, notes, and snippets.

View underhilllabs's full-sized avatar

Bart Lantz underhilllabs

View GitHub Profile
@underhilllabs
underhilllabs / category.rb
Created May 14, 2012 06:51 — forked from josegonzalez/category.rb
Category plugin for Jekyll
module Jekyll
class CategoryIndex < Page
def initialize(site, base, dir, category)
@site = site
@base = base
@dir = dir
@name = 'index.html'
self.process(@name)
self.read_yaml(File.join(base, '_layouts'), 'category_index.html')
@underhilllabs
underhilllabs / vim-map.md
Created May 18, 2012 20:20
Map vim keybinding to spec

vim command

:map ,t :w\|!spec %<cr>

  • vim maps ",t" to the following command

    • :w (write, ie save file)
  • | (also)

@underhilllabs
underhilllabs / include_math.md
Created May 20, 2012 20:40
gcc #include <math.h>

from gcc FAQ

gcc faq

14.3: I'm trying to do some simple trig, and I am #including <math.h>, but I keep getting "undefined: sin" compilation errors.

A: Make sure you're actually linking with the math library. For instance, due to a longstanding bug in Unix and Linux systems, you usually need to use an explicit -lm flag, at the end of

@underhilllabs
underhilllabs / ebook_fix.bash
Created May 20, 2012 23:59
Add an extra line to separate paragraphs in ebook
perl -e 'while(<>) { if (length($_) < 65) { print $_ . "\n";} else { print $_;}}' ebook.txt > ebook2.txt
@underhilllabs
underhilllabs / vim-regex.md
Created May 21, 2012 02:08
Vim Regular Expressions to Remember

vim substitutions

add two newlines to any quotation that should end a paragaph

%s/\[.?!]”/.”\r\r/

Surround Chapters with

%s/CHAPTER \(\(w*\).*\)/<h1>CHAPTER \1<\/h1>/

@underhilllabs
underhilllabs / drush-delete-spam.md
Created May 22, 2012 22:07
Deleting Comment Spam

delete obvious spammy subjects

drush sqlq "delete from comment where subject like '%viagra%'" drush sqlq "delete from comment where subject like '%payday loan%'"

or if you know the last good comment id, ie > 3002 and < 4005

first look at the list

drush sqlq "select name,subject from comment where cid > 3002 and cid < 4005"

@underhilllabs
underhilllabs / scpit.bash
Created June 2, 2012 06:24
shortcut script to scp a file to your personal server
#!/bin/bash
SERVER=""
USER=""
if [ -f $1 ] ; then
echo "scping $1 to /home/${USER} on ${SERVER}!"
scp $1 ${USER}@${SERVER}:
fi
@underhilllabs
underhilllabs / gist:2869824
Created June 4, 2012 17:51
Server alias from Paul Irish
#!/usr/bin/env python
function server() {
local port="${1:-8000}"
open "http://localhost:${port}/"
python SimpleHTTPServer "$port"
}
@underhilllabs
underhilllabs / tag.rb
Created June 10, 2012 23:16
get count of bookmarks tagged by each distinct tag
def index
# select name, count(1) from tags GROUP BY name;
@tags = Tag.count(:all, :group => 'name', :order => 'count_all DESC')
respond_with @tags
end
@underhilllabs
underhilllabs / rm-first-5-chars.vim
Created June 11, 2012 16:57
delete first 5 characters of each line in vim
:%s/^.\{5}//