Skip to content

Instantly share code, notes, and snippets.

Avatar
🚽
Developer

Soon Van randomecho

🚽
Developer
View GitHub Profile
@randomecho
randomecho / australian-postcodes.sql
Last active Jul 22, 2021
Australian postcodes (with states and suburb names) geocoded with latitude and longitude.
View australian-postcodes.sql
/*
Taken and cribbed from blog.datalicious.com/free-download-all-australian-postcodes-geocod
May contain errors where latitude and longitude are off. Use at own non-validated risk.
*/
SET NAMES utf8;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
DROP TABLE IF EXISTS postcodes_geo;
View .gitconfig
[alias]
soonvan = commit -m \"Created by Soon Van - randomecho.com\"
purple = commit -am \"purple monkey dishwasher\"
hist = log --pretty=format:\"%h %ad | %s%d\" --graph --date=short
histo = log --max-count=12 --pretty=format:\"%h %ad %s%d\" --graph --date=short
search = !sh -c 'git log --max-count=12 --grep=$1 --pretty=format:\"%h%C(bold yellow) %s%C(reset)\"' -
undo = reset --soft HEAD~
edit = commit --amend
twt = !git add twitter.txt
waxy = !git add wax* && git s
@randomecho
randomecho / melt.sh
Last active Dec 1, 2017
Merge and then delete traces of feature branch
View melt.sh
#!/bin/sh
feature_branch=$(git branch | grep \* | sed 's/\* //')
all_branches=$(git branch | tr '\n' ' ')
main_branch=$1
if [[ $all_branches != *$main_branch* ]]; then
echo "$main_branch is not a valid branch to merge back into"
exit 1
fi
View patterns.erl
-module(patterns).
-export([exxor/2,exxot/2,exxon/2,efix/2,maxThree/3,howManyEqual/3]).
exxor(X,Y) ->
X =/= Y.
exxot(X,Y) ->
X == Y.
exxon(X,Y) ->
@randomecho
randomecho / .bashrc
Last active Jan 24, 2016
Save in ~/.bashrc and reload with `source ~/.bashrc`
View .bashrc
# .bashrc
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias elog='tail -f /var/log/httpd/error_log'
alias loga='tail -f /var/log/httpd/access_log'
alias sugar='tail -f sugarcrm.log'
alias web='cd /srv/httpd/'
alias phpunit='custom/vendor/bin/phpunit --color'
@randomecho
randomecho / purge_empties.rb
Last active Jan 18, 2016
Delete empty directories recursively
View purge_empties.rb
#!/usr/bin/env ruby
#
# Delete empty directories recursively
#
# Author:: Soon Van - randomecho.com
# Copyright:: Copyright 2016 Soon Van
# License:: http://opensource.org/licenses/BSD-3-Clause
require 'FileUtils'
@randomecho
randomecho / underscored.rb
Last active Jan 18, 2016
mv folders to have underscore prefix
View underscored.rb
#!/usr/bin/env ruby
#
# mv folders to have underscore prefix
#
# Author:: Soon Van - randomecho.com
# Copyright:: Copyright 2016 Soon Van
# License:: http://opensource.org/licenses/BSD-3-Clause
require 'FileUtils'
@randomecho
randomecho / db.php
Last active Dec 18, 2015
Database hookup for wrapping around PDO
View db.php
<?php
/**
* Database hookup for wrapping around PDO
*
* @author Soon Van - randomecho.com
* @copyright 2013 Soon Van
* @license http://www.opensource.org/licenses/BSD-3-Clause
*/
class DB {
@randomecho
randomecho / ruby-on-windows.md
Last active Dec 17, 2015
Workarounds and reminders for Ruby development on Windows (Vista at least)
View ruby-on-windows.md

Bloody hell is Ruby on Rails development on Windows an exercise in chasing through search engines.

database configuration does not specify adapter

"database configuration does not specify adapter" error with PG gem in Rails 3.2

@randomecho
randomecho / snipper.php
Last active Dec 16, 2015
Strip down a chunk of formatted text to use for META description tag.
View snipper.php
/**
* Render text with possible markup into snippet of plain text chunk
* suitable for meta description tag or other display area that
* may not like HTML tags or Markdown formatting.
*
* @author Soon Van - randomecho.com
* @copyright 2013 Soon Van
* @license http://www.opensource.org/licenses/BSD-3-Clause
*
* @param string raw text with possible formatting