Skip to content

Instantly share code, notes, and snippets.

View randomecho's full-sized avatar
🚽
Developer

Soon Van randomecho

🚽
Developer
View GitHub Profile
@randomecho
randomecho / phpinfo-dump.php
Created June 27, 2014 03:23
Grab, strip and dump out phpinfo() into part of a page, neutering some of its overriding HTML and styles.
ob_start();
phpinfo();
$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
@randomecho
randomecho / keybase.md
Created October 3, 2014 03:33
Keybase.io proof

Keybase proof

I hereby claim:

  • I am randomecho on github.
  • I am randomecho (https://keybase.io/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:

@randomecho
randomecho / bash_profile
Last active August 29, 2015 14:11
Custom Git settings on a Mac OS bash prompt
# ~/.bash_profile
export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"
# Auto-completion helper when you hit tab
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
@randomecho
randomecho / dump.php
Last active October 3, 2015 07:58
Ugly dump of the variable used, needing something that was easily seen on the page
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";
print_r($thevar);
if (is_object($thevar))
{
echo "\n\nmethods on this object";
print_r(get_class_methods($thevar));
}
@randomecho
randomecho / git-it-good.md
Last active October 13, 2015 18:58
bagged dipping dots of git commands and config settings

[alias].gitconfig

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
randomecho / core.html
Last active December 10, 2015 18:58
Plain HTML5 template based off of H5BP and other sites
<!DOCTYPE html><html><head><meta charset="utf-8">
<title></title>
<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
randomecho / base64-image-saver.php
Created February 20, 2013 20:50
Create and save image from Base 64 string
/**
* 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
randomecho / snipper.php
Last active December 16, 2015 00:52
Strip down a chunk of formatted text to use for META description tag.
/**
* 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
@randomecho
randomecho / ruby-on-windows.md
Last active December 17, 2015 14:29
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
randomecho / db.php
Last active December 18, 2015 09:38
Database hookup for wrapping around PDO
<?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 {