Skip to content

Instantly share code, notes, and snippets.

View zacharydanger's full-sized avatar
🥔
POTATO!

Zachary Danger zacharydanger

🥔
POTATO!
View GitHub Profile
@zacharydanger
zacharydanger / git-submodule-recurse
Created July 17, 2009 01:17
Simple bash script for recursive submodule init/update
#!/bin/bash
#save this file somewhere in your path and make it executable
#then you can just run git-submodule-recurse to recursively init / update your git submodules
git submodule init
git submodule update
git submodule foreach git-submodule-recurse
<?php
class Foobar {
static $global_value;
private $_local_value;
public function __construct($local_val = null) {
if(false == is_null($local_val)) {
$this->_local_value = $local_val;
}
product_list = list of selected products and quantities;
global_dunnage = percentage defined by admin;
fudge_factor = percentage defined by admin;
if ( total_cost meets freight override conditions ):
return freight calculation;
exit;
else:
<pre>
<?php
echo shell_exec('whoami && ps');
echo shell_exec('ps');
?>
</pre>
<?php
require_once 'PHPUnit/Framework.php';
function foobar(Array $array) {
}
class FoobarTest extends PHPUnit_Framework_TestCase {
/**
* @expectedException PHPUnit_Framework_Error
<?php
require_once 'PHPUnit/Framework.php';
class TimeLoggerListener implements PHPUnit_Framework_TestListener {
private $_filename;
private $_handle;
public function __construct($filename) {
$this->_filename = $filename;
}
@zacharydanger
zacharydanger / MyTestCase.php
Created January 17, 2011 22:33
Why our config is jacked.
<?php
class MyTestCase extends PHPUnit_Framework_TestCase {
public function testBoolEquality() {
$this->assertTrue((true == 'true'));
$this->assertTrue((true == (bool)'true'));
$this->assertTrue((true == 'false'));
$this->assertTrue((true == (bool)'false'));
$this->assertTrue((true == (bool)'1'));
$this->assertTrue((false == (bool)'0'));
$this->assertFalse((true == ''));
@zacharydanger
zacharydanger / super_round.php
Created April 8, 2011 19:29
How to properly round numbers in PHP
<?php
/**
* works around PHP's shitty floating point math to properly round numbers
*
* USE THIS EVERYWHERE BECAUSE FLOATS FUCKING SUCK
*/
function super_round($number, $precision = 0) {
$power = bcpow(10, $precision);
$rounded = round(bcmul($number, $power, 1), 0);
return bcdiv($rounded, $power, $precision);
@zacharydanger
zacharydanger / gatebot-9000.xml
Created June 3, 2011 13:04
Gatebot-9000 Twilio Script
<Response>
<Say>I will eat your children.</Say>
<Play>http://dl.dropbox.com/u/392166/callboxen/9.wav</Play>
<Sms to="555-555-5555">Gatebot-9000: I probably just let a murderer into the apartment complex. So be ready for that.</Sms>
</Response>
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db