Skip to content

Instantly share code, notes, and snippets.

@tsnoad
tsnoad / gist:2642087
Created May 9, 2012 05:25
SSHA password hashing. this format is used by OpenLDAP to store passwords
<?
function make_salt($salt_size=32) {
//list of possible characters from which to cerate the salt
$sea = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
//how many possible characters are there
$sea_size = strlen($sea);
$salt = "";
@tsnoad
tsnoad / gist:614667
Created October 7, 2010 06:44
insert days into a psql database
#!/bin/bash
#As reconcile.php runs, it adds entries to invoice, receipt, etc. tables.
#The timestamp fields in these tables reference the dw_timestamp table
#So, we need to add every conceivable date to dw_timestamp
#back to 1900 should be enough ^_^
#set a variable to use as an iteration counter
export i=0;
<?
//tabular.php line 2856
case "editsquidconstraint":
$output->title = "Edit Constraint";
$output->title_desc = "";
$output->data .= Tabular_view::view_editconstraint($blah);
break;
@tsnoad
tsnoad / MADNESS!.php
Created July 9, 2010 06:30
php's __get __set crazyness
<?php
//Define a simple class
class Foo {
//run this whenever a variable of this class is set
function __set($name, $value) {
//store the value we're setting in a completely arbitrary place
$this->morp = $value;
}
@tsnoad
tsnoad / gist:466365
Created July 7, 2010 06:02
questions for evan
<?
//just say i have an object without __set() defined...
//will this work?
$foo->squiggle = "zebra";
//now just say the set function is defined like this:
function __set($name, $value) {
var_dump($name, $value);
@tsnoad
tsnoad / gist:460942
Created July 2, 2010 04:46
soap interface to sugarcrm
<?php
// set up options array
$options = array(
"location" => 'http://192.168.25.28/soap.php',
"uri" => 'http://192.168.25.28',
"trace" => 2
);
// connect to soap server