Skip to content

Instantly share code, notes, and snippets.

@garoevans
garoevans / gist:2011166
Created March 10, 2012 11:08
PHP: pre var dump
echo '<pre>',var_dump(),'</pre>';
@garoevans
garoevans / gist:2011169
Created March 10, 2012 11:10
CSS: Image Replacement
.ir {
border:0;
font: 0/0 a;
text-shadow: none;
color: transparent;
background-color: transparent;
}
@garoevans
garoevans / LINUX: automated mysql access
Created March 20, 2012 09:03
LINUX: automated mysql access
Sometimes you want automated access for root on your MySQL database. One way of accomplishing that is by doing this:
cd /root
touch .my.cnf
chmod 640 .my.cnf
And put in it:
[client]
user=root
@garoevans
garoevans / JavaScript: onmouseout stop child triggering
Created March 23, 2012 13:20
JavaScript: onmouseout stop child triggering
var e = event.toElement || event.relatedTarget;
if (e.parentNode == this || e == this) { return; };
@garoevans
garoevans / LINUX: create large random file
Created April 12, 2012 16:33
LINUX: create large random file
1MB
dd if=/dev/zero of=g_file.dat count=1024 bs=1024
500MB
dd if=/dev/zero of=g_file.dat count=1024 bs=51200
1GB
dd if=/dev/zero of=g_file.dat count=1024 bs=1048576
5GB
dd if=/dev/zero of=g_file.dat count=1024 bs=5242880
10GB
dd if=/dev/zero of=g_file.dat count=1024 bs=10485760
//"file_foo.php"
<?php
include "file_bar.php";
function foo1()
{
echo 'me';
}
function foo2()
{
bar();

Keybase proof

I hereby claim:

  • I am garoevans on github.
  • I am garoevans (https://keybase.io/garoevans) on keybase.
  • I have a public key whose fingerprint is B580 43E1 B507 99B8 AD9C BD98 C7AC B821 066E ABA7

To claim this, I am signing this object:

@garoevans
garoevans / curly_array.php
Created April 3, 2014 12:02
Curly braces for array acces?
<?php
$x = 10;
$foo = null;
$ref = &$foo;
do {
$ref = array('foo' => 'bar');
$ref = &$ref['foo'];
} while (--$x);
<?php
/**
* @author: gareth
*/
class Lock
{
/**
* @var string
*/
// 1) open the shared spreadsheed, make a copy of it, open tools|script editor, update the settings below, save
// https://docs.google.com/spreadsheets/d/15bTn9_Cv9IBVkvepINPlBRcK8oty74e6FlAieNbiQMg/edit?usp=sharing
// for script updates, simply copy this script into your spreadsheet using the script editor, i.e. select all, copy, paste, save
// 2) set the script's timezone (File|Project properties)
// 3) on the menu bar click Current Project's Triggers
// click add new trigger
// for Run select the function nestDataCollection, Events: time-driven, and select the rate per your preference (I do every 5 minutes)
// click add new trigger
// for Run select the function rollUpAllSheets, Events: time-driven, and select once a month
// 4) in the spreadsheet, set the spreadsheet's timezone to your timezone (File|Spreadsheet settings...)