Skip to content

Instantly share code, notes, and snippets.

View erochest's full-sized avatar

Eric Rochester erochest

View GitHub Profile
nnoremap <leader><leader> <c-^>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" OPEN FILES IN DIRECTORY OF CURRENT FILE
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
cnoremap %% <C-R>=expand('%:h').'/'<cr>
map <leader>e :edit %%
map <leader>v :view %%
" Apparently, he no longer uses the trick where the window heights jump around,
@erochest
erochest / gist:3782413
Created September 25, 2012 14:52
More SQL that should not exist....
update omeka_element_texts
set text=concat('POINT(', insert(text, instr(text, '/'), 0, ')'))
where element_id=38 and text not like 'POINT(%';
@erochest
erochest / add_item_snippet.rb
Created September 26, 2012 18:18 — forked from waynegraham/add_item_snippet.rb
Geocoding in Omeka
add_item_page.form_with(:method => 'POST') do |item_form|
item_form['public'] = 1
item_form['Elements[50][0][text]'] = line[:address]
# This should really be KML, but it will recognize WKT too.
item_form['Elements[38][0][geo]'] = line[:point]
item_form['Elements[38][0][zoom]'] = 10
item_form['Elements[38][0][mapon]'] = 1
item_form['Elements[38][0][center_lon]'] = line[:lon]
item_form['Elements[38][0][center_lat]'] = line[:lat]
@erochest
erochest / rake-task.rb
Created November 7, 2012 18:48
abusing blocks
def update_subm(name, &block)
puts "Updating submodules for '#{name}'...."
if block.nil?
sh %{cd #{name} ; #{GIT_SM_UP}}
else
sh %{cd #{name} ; #{GIT_SM_UP}} do |o, r|
block.call(o, r)
end
end
end
@erochest
erochest / upgrade-postgis.rb
Created November 14, 2012 14:00
Upgrade PostGIS tables.
def pg_restore(dbname)
filename = "#{DUMP_DIR}/#{dbname}.dump"
vm_dump_file = "/vagrant/#{DUMP_DIR}/#{dbname}.dump"
log_file = "/vagrant/#{DUMP_DIR}/#{dbname}.log"
puts "Restoring/Upgrading #{filename} (#{vm_dump_file}) => #{dbname}"
start = Time.now
env = Vagrant::Environment.new
@erochest
erochest / Rakefile
Created November 14, 2012 21:41
Look at rake dumps:all. It's meant to work with Vagrant, but should be easy to move off that.
require 'etc'
require 'fileutils'
require 'peach'
require 'vagrant'
DUMP_DIR = 'dumps/todo'
GIS_ARCHIVE = 'data/geoserver1-20110908-1547.tar.gz'
ROLE_FILE = 'roles'
@erochest
erochest / spec.md
Created November 28, 2012 19:03
Specification for Jotto game

This will be a Jotto game for one player. See the Wikipedia article for details on the rules.

A typical interaction might look like this:

I'm thinking of a five-letter word. Guess what it is.
Guess 1 of 10: think
1 jot.
Guess 2 of 10: burnt

2 jots.

@erochest
erochest / jotto.rb
Created November 28, 2012 21:41
Jotto
# http://www.ruby-doc.org/stdlib-1.9.3/libdoc/set/rdoc/Set.html
require 'set'
class Dictionary
attr_reader :words
def initialize
@words = Set.new []
end
@erochest
erochest / tc.bash
Created December 4, 2012 15:32
Script to copy from the tmux clipboard to the OS X system clipboard
#!/bin/sh
tmux saveb - | pbcopy
-- Geonetwork migration
CREATE TABLE CustomElementSet
(
xpath varchar(1000) not null
);
-- Fix languages table
ALTER TABLE Languages
ADD COLUMN isocode varchar(3),