Skip to content

Instantly share code, notes, and snippets.

@yiqingj
yiqingj / populate_current_tables.sql
Last active May 30, 2017 16:57
repopulate current tables for osm apidb
TRUNCATE current_relation_members CASCADE;
TRUNCATE current_relation_tags CASCADE;
TRUNCATE current_relations CASCADE;
TRUNCATE current_way_nodes CASCADE;
TRUNCATE current_way_tags CASCADE;
TRUNCATE current_ways CASCADE;
TRUNCATE current_node_tags CASCADE;
TRUNCATE current_nodes CASCADE;
@yiqingj
yiqingj / create_osm_planet.sh
Last active September 29, 2016 23:59
create a new osm planet database instance
#!/bin/bash
###############################################################################
#
# This script will create an osmosis compatible database. The
# OSMOSIS_HOME environment variable must be set.
#
#
###############################################################################
@yiqingj
yiqingj / batch-db-del.sh
Created September 13, 2016 17:32
batch delete database
psql -U osm -d postgres -c "\l" | grep atlas-* | awk '{print $1}' | xargs -n 1 dropdb -U osm
@yiqingj
yiqingj / nuke-db.sql
Created September 13, 2016 17:30
delete all data in database
CREATE OR REPLACE FUNCTION truncate_tables(username IN VARCHAR) RETURNS void AS $$
DECLARE
statements CURSOR FOR
SELECT tablename FROM pg_tables
WHERE tableowner = username AND schemaname = 'public';
BEGIN
FOR stmt IN statements LOOP
EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.tablename) || ' CASCADE;';
END LOOP;
END;
@yiqingj
yiqingj / index.html
Created February 24, 2016 22:47 — forked from dnprock/index.html
World Map
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
width: 960px;
height: 500px;
position: relative;
}
@yiqingj
yiqingj / gist:46c4e2284e42384fac1b
Created January 27, 2016 00:24 — forked from joho/gist:3735740
PostgreSQL 9.2 upgrade steps
Steps to install and run PostgreSQL 9.2 using Homebrew (Mac OS X)
(if you aren't using version 9.1.5, change line 6 with the correct version)
1. launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
2. mv /usr/local/var/postgres /usr/local/var/postgres91
3. brew update
4. brew upgrade postgresql
5. initdb /usr/local/var/postgres -E utf8
6. pg_upgrade -b /usr/local/Cellar/postgresql/9.1.5/bin -B /usr/local/Cellar/postgresql/9.2.0/bin -d /usr/local/var/postgres91 -D /usr/local/var/postgres
7. cp /usr/local/Cellar/postgresql/9.2.0/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
@yiqingj
yiqingj / .vimrc
Created June 18, 2015 19:18
.vimrc file with vundle
" ============================================================================
" Vundle initialization
" Avoid modify this section, unless you are very sure of what you are doing
" no vi-compatible
set nocompatible
" Setting up Vundle - the vim plugin bundler
let iCanHazVundle=1
let vundle_readme=expand('~/.vim/bundle/vundle/README.md')
@yiqingj
yiqingj / .git-completion.sh
Last active August 29, 2015 14:02
git-auto-complete
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names
# *) local and remote tag names