Skip to content

Instantly share code, notes, and snippets.

View dwurf's full-sized avatar

Darren Wurf dwurf

  • Australia
View GitHub Profile
@dwurf
dwurf / file.php
Created April 30, 2012 02:04
PHP code sample for autocomplete with jquery
<?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";
@dwurf
dwurf / dbscan.sql
Created May 2, 2012 15:08
MySQL hacks:
-- 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.
@dwurf
dwurf / bbc_q3a.sql
Created June 21, 2012 06:06
bbc example
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);
@dwurf
dwurf / leech.sh
Last active December 12, 2015 02:18 — forked from anonymous/leech.sh
#!/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:
@dwurf
dwurf / git-merges.md
Last active March 8, 2018 12:26
A short article on git branching for new git users.

Branching with git for safe merging

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.

The scenario

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

Changes not staged for commit:

@dwurf
dwurf / python-mutability.md
Last active December 17, 2015 13:38
A short article on mutability of data types in Python

Mutability of python data types

Most data types in python are immutable, including integers

a = 2
b = a # a and b refer to the same memory location, storing the value 2
b = 5 # b now points to a new memory location, storing the value 5

print a, b 

result: 2 5

@dwurf
dwurf / README.md
Last active August 29, 2015 13:56
Searching efficiently based on dates in various DBMS
@dwurf
dwurf / render_tiles_instructions.sh
Last active December 18, 2021 12:11
OSM Tile Renderer - setup instructions
# 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
#!/bin/bash
# Script to install kf2 server under wine on ubuntu 14.04 (AWS micro instance)
# This script makes a mess, run it in a subdirectory to keep it contained
# Also run it on a server you don't care about or be sure you don't mind when it
# installs a bunch of random crap
# Install wine
if dpkg -l wine > /dev/null 2>/dev/null; then
@dwurf
dwurf / setup.md
Last active October 26, 2015 11:42
Docker setup

These steps were run to set up the local network

Docker install

sudo apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sudo bash -c "echo deb https://apt.dockerproject.org/repo ubuntu-trusty main > /etc/apt/sources.list.d/docker.list"
sudo apt-get update
sudo apt-get -y install docker-engine
sudo docker run hello-world

sudo docker run -it ubuntu bash