Skip to content

Instantly share code, notes, and snippets.

View erochest's full-sized avatar

Eric Rochester erochest

View GitHub Profile
@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 / 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 / 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 / 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 / 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(%';
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 / exitscript.bash
Created September 5, 2012 13:59
Combined exit codes
#!/bin/bash
./sub_exit.bash
ec1=$?
./sub_exit.bash
ec2=$?
[[ "$ec1" -eq "0" && "$ec2" -eq "0" ]]
@erochest
erochest / fix.js
Created August 28, 2012 15:17
Wandering OL points
var _this = this;
var Map = OpenLayers.Map;
if (jQuery.browser.webkit) {
Map = OpenLayers.Class(OpenLayers.Map, {
updateSize: function() {
OpenLayers.Map.prototype.updateSize.apply(this, arguments);
var mapHeight = _this.element.height(),
mapWidth = _this.element.width();
_this.element.find('svg').each(function (i, el) {
jQuery(el).height(mapHeight).width(mapWidth);
@erochest
erochest / gist:3491062
Created August 27, 2012 18:21
The unnatural thing I did to get homebrew to compile MacVim (& vim) against Python 2.7 on Mac 10.6
cd /System/Library/Frameworks/Python.frameworks/Versions
sudo mv Current Current26
sudo ln -s /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7 Current
#!/usr/bin/env python
import re
import sys
def fix_pre(match):
buffer = ['\n[sourcecode']
if match.group(1) and match.group(2):
buffer.append('{0}"{1}"'.format(match.group(1), match.group(2)))