Skip to content

Instantly share code, notes, and snippets.

View joshwnj's full-sized avatar

Josh Johnston joshwnj

View GitHub Profile
<?php
function create_full_view() {
global $fbc;
echo '
<ul>';
for($a=0;$a<count($this->xmlobj->entry);$a++) {
$attr = $this->xmlobj->entry[$a]->attributes();
$class = '';
if("{$attr['link']}" == "{$fbc['item_a']}") {
$class = 'selected ';
@joshwnj
joshwnj / current.php
Created July 21, 2010 00:39
Loading recaps data
<?php
/************************************
begin recaps logic
************************************/
// default xml file
$fbc['xmldir'] = "{$fbc['showfullpath']}/_ugc/xml/recaps/";
$fbc['defaultxmlfile'] = "season-1_episode-1.xml";
if(!isset($fbc['item_a'])) {
$nav = simplexml_load_file("{$fbc['xmldir']}manifest.xml");
$attr = $nav->entry[0]->attributes();
<?php
echo '
<ul>';
for($a=0;$a<count($this->xmlobj->entry);$a++) {
$attr = $this->xmlobj->entry[$a]->attributes();
$class = '';
if("{$attr['link']}" == "{$fbc['item_a']}") {
$class = 'selected ';
}
if($a == 0 && $fbc['item_a'] == '') {
<?php
/**
* Instead of adding each js file one by one to a page,
* we define a chain of dependencies and then just include the top-level components.
*
* This makes it easier to see what components are being used on a page,
* and easier to add/remove/replace components.
*/
@joshwnj
joshwnj / hijack.js
Created October 14, 2010 01:19
hijack a js function
/**
* Hijack a function with custom behaviour
* @param {object} Context object
* @param {string} Name of the context object's function
* @param {function} Override function
* @return {function} Original function
*/
function hijack(object, funcName, override) {
var original = object[funcName];
object[funcName] = override(original);
@joshwnj
joshwnj / text_overflow.js
Created October 18, 2010 23:18
detect text overflow and crop, inserting an ellipsis
var TextOverflow = {
crop: function(elm) {
var w = elm.width(),
t = elm.text(),
child;
elm.html('<span style="overflow: hidden; white-space: nowrap">'+t+'</span>');
child = elm.children(":first-child");
while (t.length > 0 && child.width() > w) {
t = t.substr(0, t.length - 1);
<?php
chdir(dirname(__FILE__));
require_once '../app/setup.php';
$username = $argv[1];
if (!$username) {
echo "usage {$argv[0]} {username} {new_email}\n";
exit;
}
@joshwnj
joshwnj / test
Created February 10, 2011 22:46
#content {
background: blue;
}
#!/bin/sh
PWD=`dirname $0`
cd $PWD
## memcached
~/src/term.sh -t memcached
## couchdb
~/src/term.sh -t sudo -i -u couchdb couchdb
/**
* Generic behaviour for an object which can observe objects
* @param {array | object} items
*/
Xteam.Observer = function(items) {
items = items || [];
// wrap items in an array
if (typeof items.length == "undefined") {
items = [items];