Backup of SQL Fiddle code for this StackOverflow answer: http://stackoverflow.com/a/10395492/1349518
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Instructions to pre-render OSM tiles: | |
# Start with a clean Ubuntu Trusty 14.04 host | |
# Need postgis, importer and tools | |
sudo apt-get install postgresql-9.3 postgis osm2pgsql gdal-bin npm git curl xmlstarlet python-mapnik unzip | |
# Fonts | |
sudo apt-get install ttf-dejavu fonts-droid ttf-unifont fonts-sipa-arundina fonts-sil-padauk fonts-khmeros \ | |
ttf-indic-fonts-core ttf-tamil-fonts ttf-kannada-fonts | |
# nginx -- for leaflet UI |
Version Control is a critical tool in any software development project. Despite this, many of us suffer from a crippling fear of one terrifying event: The Dreaded Merge Conflict. Here I'll show you a risk-free way of merging with an easy way to back out if things go belly up.
You've been working for hours on a bug fix. Your changes were due an hour ago and you've just finished your unit tests. It's time to upload your changes...
c:\dev>git status
# On branch master
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script to leech videos from lca2013 | |
# Will not re-download stuff you already have | |
# | |
# Requires curl, sed and grep | |
# | |
# Yes, this parses HTML with regex. Deal with it. | |
# | |
# Known bugs: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table bbc ( | |
region varchar(50) not null, | |
name varchar(50) not null primary key, | |
population integer | |
); | |
insert into bbc values ('Oceania', 'Australia', 20); | |
insert into bbc values ('Oceania', 'New Zealand', 4); | |
insert into bbc values ('Oceania', 'Solomon Islands', NULL); | |
insert into bbc values ('Asia', 'Japan', 50); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Search all varchar columns in an entire database for a specific value | |
-- DANGER: do not use on large databases. 10k rows **should** be fine, larger than that requires caution. | |
-- Run this script in a temp database. It needs access to the target database and information_schema to run. | |
-- Results will go into a temporary table called rset. Everything will be cleaned up once you disconnect. | |
-- BEGIN SCRIPT -- | |
-- Variables. Modify these, the rest of the script will do the work for you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$connstring = "host=localhost dbname=test user=dwurf password=<secret>"; | |
$conn = pg_connect($connstring); | |
$search = ($_GET['term']); | |
if (!$conn) { die('Could not connect: ' . pg_last_error ());} | |
else | |
{ | |
$sql = "SELECT name FROM users_table WHERE name ILIKE '%$search%' ORDER BY name ASC"; |
NewerOlder