Skip to content

Instantly share code, notes, and snippets.


Soon Van randomecho

View GitHub Profile
randomecho / dump.php
Last active Oct 3, 2015
Ugly dump of the variable used, needing something that was easily seen on the page
View dump.php
function dump($thevar, $killme = false)
echo "\n\n".'<pre style="text-align:left;color:#000;background:#fff;padding:1em;border:1px dotted #ccc;margin:1em 0;clear:both;">'."\n\n";
if (is_object($thevar))
echo "\n\nmethods on this object";
randomecho /
Last active Oct 13, 2015
bagged dipping dots of git commands and config settings


quick search of commit messages (and showing hash) with certain word

search = !sh -c 'git log --grep=$1 --pretty=format:\"%h%C(bold yellow) %s%C(reset)\"' -
$ git search wax // e.g. list out all commits that contain "wax" in message

export last X commits showing just commit message and files touched

whatup = !sh -c 'git whatchanged --pretty=format:%n%s --name-only -$1 > /w/logs/git.log' -
randomecho / core.html
Last active Dec 10, 2015
Plain HTML5 template based off of H5BP and other sites
View core.html
<!DOCTYPE html><html><head><meta charset="utf-8">
<link rel="stylesheet" href="" />
<link rel="author" href="" />
<link rel="alternate" type="application/rss+xml" title="" href="" />
<link rel="canonical" href="" />
<meta name="description" content="" />
<meta name="author" content="" />
<meta name="generator" content="" />
<meta name="dcterms.rightsHolder" content="" />
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 -
* @copyright 2013 Soon Van
* @license
* @param string raw text with possible formatting
randomecho / base64-image-saver.php
Created Feb 20, 2013
Create and save image from Base 64 string
View base64-image-saver.php
* Create and save image from Base 64 string
public function generate_image($base64_string, $save_location)
$gen_image = imagecreatefromstring(base64_decode($base64_string));
if ($gen_image !== false)
imagejpeg($gen_image, $save_location);
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
May contain errors where latitude and longitude are off. Use at own non-validated risk.
DROP TABLE IF EXISTS postcodes_geo;
randomecho /
Last active Dec 17, 2015
Workarounds and reminders for Ruby development on Windows (Vista at least)

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 / db.php
Last active Dec 18, 2015
Database hookup for wrapping around PDO
View db.php
* Database hookup for wrapping around PDO
* @author Soon Van -
* @copyright 2013 Soon Van
* @license
class DB {
randomecho / phpinfo-dump.php
Created Jun 27, 2014
Grab, strip and dump out phpinfo() into part of a page, neutering some of its overriding HTML and styles.
View phpinfo-dump.php
$phpInfo = ob_get_clean();
$phpInfo = preg_replace('/600(px)?/', '100%', $phpInfo); // table and hr width
$phpInfo = str_replace('75%', '95%', $phpInfo); // font-size
$phpInfo = preg_replace('/<?([\w]|<|\/|>)*(a:|!DOCTYPE|<html|title|body)(.+)?\\n?/', '', $phpInfo); // main html doc tags

Keybase proof

I hereby claim:

  • I am randomecho on github.
  • I am randomecho ( on keybase.
  • I have a public key whose fingerprint is 119D F84C 21E4 E785 9C66 6D17 F21A BCE5 326C 3BC0

To claim this, I am signing this object: