Skip to content

Instantly share code, notes, and snippets.

<?php
class DBObject {
public function getManyMany($class,$where = false,$options = array()){
$table = static::_table();
$join = $class::_table();
if (strnatcmp($table, $join))
$join_table = sprintf('%s_%s', $join, $table);
else
$join_table = sprintf('%s_%s', $table, $join);
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UILabel *label;
UITextField *textField;
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
@jacobch
jacobch / equi
Created February 21, 2011 03:50
function equi ( $A ) {
$count = count($A);
$total = array_sum($A);
$right = $total;
$left = 0;
for($i = 0; $i < $count; $i++) {
$right -= $A[$i];
if ($left == $right)
function ps ( $A ) {
$used = array();
$index = 0;
$count = count($A);
for($i = 0; $i < $count; $i++) {
if (!isset($used[$A[$i]])) {
$index = $i;
$used[$A[$i]] = true;
}
<?php
class Route {
private static $routes = array();
public static function set($regex, $defaults) {
self::$routes[] = new Route($regex, $defaults);
}
public static function match($uri) {
@jacobch
jacobch / phpComparitor.php
Created March 15, 2011 12:27
Comparing PHP Objects
<?php
class MyInt {
private $value = 0;
public function __construct($value) {
$this->value = $value;
}
}
$a = new MyInt(10);