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 / foo.txt
Created January 19, 2012 19:35
compile php 5.3.x on OS X
./configure --with-curl --with-config-file-path=/private/etc --with-mysqli --with-mysql --with-apxs2 --with-mcrypt --enable-soap --with-openssl --enable-zip --enable-bcmath --enable-mbstring --enable-sockets
@zacharydanger
zacharydanger / god
Created October 10, 2011 13:29
/etc/init.d/god
#!/bin/sh
### BEGIN INIT INFO
# Provides: god
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: God
### END INIT INFO
#! /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
@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>
@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 / 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 == ''));
<?php
require_once 'PHPUnit/Framework.php';
class TimeLoggerListener implements PHPUnit_Framework_TestListener {
private $_filename;
private $_handle;
public function __construct($filename) {
$this->_filename = $filename;
}
<?php
require_once 'PHPUnit/Framework.php';
function foobar(Array $array) {
}
class FoobarTest extends PHPUnit_Framework_TestCase {
/**
* @expectedException PHPUnit_Framework_Error
<pre>
<?php
echo shell_exec('whoami && ps');
echo shell_exec('ps');
?>
</pre>
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: