Skip to content

Instantly share code, notes, and snippets.

View dwurf's full-sized avatar

Darren Wurf dwurf

  • Australia
View GitHub Profile
@dwurf
dwurf / tcp_client.py
Created March 20, 2017 23:38
TCP client/server code in Python (asyncore library)
#!/usr/bin/env python
# This script opens CONNECTIONS simultaneous connections to a remote socket,
# and sends a fixed string before closing the connection. The process is then
# repeated indefinitely
# Intended to unit test the tcp_server.py script
import asyncore
import socket
@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
@dwurf
dwurf / hello.svg
Created September 6, 2020 05:45
Half a submission for the pycon 2020 Rube Codeberg challenge - unfinished
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dwurf
dwurf / sendfile.py
Created December 15, 2019 22:44
Using Python's built-in smtplib to send files
#!/usr/bin/env python
"""Script for sending an email (with an optional file attachment)."""
# Modified from the documentation at
# https://docs.python.org/2/library/email-examples.html
#
# Tested against python 2.6, 2.7 and 3.6
#
# For help, run this script!
@dwurf
dwurf / Makefile
Last active September 13, 2019 13:10
Query Valve servers
.PHONY: run
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
pth := $(notdir $(patsubst %/,%,$(dir $(mkfile_path))))
run: $(pth)/venv
$(pth)/venv/bin/python3 $(pth)/query.py
$(pth)/venv:
@dwurf
dwurf / go.mod
Last active September 1, 2019 02:28
Go web server - hello world!
module https://gist.github.com/dwurf/25d26181b407a58ab8a67e824675e487
@dwurf
dwurf / keybase.md
Created April 24, 2018 10:30
keybase.md

Keybase proof

I hereby claim:

  • I am dwurf on github.
  • I am dwurf (https://keybase.io/dwurf) on keybase.
  • I have a public key ASDQJHM8GNRuzcosO3uRNIX6hvy5qDyjKLpms2GMATU8vAo

To claim this, I am signing this object:

@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 / 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 / slides.md
Last active February 28, 2016 09:30
Practical Use of Docker
## Docker

Docker is a useful abstraction for processes

  • Web application server (django/rails/tomcat/...)
  • Database
  • Reverse HTTP proxy (nginx/apache)

... each in their own Docker container