Skip to content

Instantly share code, notes, and snippets.

View jakemcgraw's full-sized avatar
📈
start up cash in sell out bro down

Jake McGraw jakemcgraw

📈
start up cash in sell out bro down
View GitHub Profile
@jakemcgraw
jakemcgraw / hurdur.php
Created April 19, 2011 20:10
The hurdur templating engine for PHP
# hurdur.php
<?php
function hurdur_render($_template, array $params=array()) {
if (isset($params['_template'])) {
trigger_error('_template is reserved');
}
extract($params);
include $_template;
@jakemcgraw
jakemcgraw / truph_photo.js
Created November 1, 2010 20:13
Do like Facebook/Twitter
TRUPH = jQuery.extend(true, TRUPH||{}, {
domain: "http://tru.ph",
basePath: "/photo",
getBaseUrl: function(){
return TRUPH.domain+TRUPH.basePath;
},
shebang: "#!"
});
jQuery(function($){
window.PHONO = null;
$.phono({
apiKey: "XXXXX",
onReady: function(){
PHONO = this;
}
});
$(function(){
<?php
$xml = <<<EOD
<?xml version="1.0" encoding="UTF-8"?>
<cmrl xmlns:dotgo="http://dotgo.com/cmrl/1.0" account="jddbb-ztc2l-f1tb7-2c8st">
<match pattern="">
<message><content>DOTGO.COM<br />
Welcome to DOTGO!<br />
<br />
Reply:<br />
//...
$("a.edit").live("click", function(){
$(this).prev(".cmrl").msgeditor({showPreview:true, buttons:{
Accept: function(hash) {
// Update preview, show
$(hash.textarea).next(".preview").html(hash.preview).show();
// Update CMRL, close editor
<?php
// More info at http://framework.zend.com/manual/en/zend.db.adapter.html
// Assumes Zend dir is in your include path
require_once 'Zend/Db.php';
$db = Zend_Db::factory('Pdo_Mysql', array(
'host' => '127.0.0.1',
'username' => 'webuser',
var pollInterval = 1000;
var someFunc = function(){
/* do some shit */
window.setTimeout(someFunc, pollInterval);
};
someFunc();
// In global scope
ANDREW = $.extend(window.ANDREW||{}, {
someVar : 1,
someOtherVar : false,
someFunc : function(params) {},
someOtherFunc : function(params) {},
});
// ... Later
<?php
// For the following sequence, the correct answer is set '79778' produces product '24696'
$numbers = <<<EOD
73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557668966489504452445231617318564030987111217223831136222989342338030813533627661428280644448664523874930358907296290491560440772390713810515859307960866701724271218839987979087922749219016997208880937766572733300105336788122023542180975125454059475224352584907711670556013604839586446706324415722155397536978179778461740649551492908625693219784686224828397224137565705605749026140797296865241453510047482166370484403199890008895243450658541227588666881164271714799244429282308634656748139191231628245861786645835912456652947654568284891288314260769004224219022671055626321111109370544217506941658960408071984038509624554443629812309878799272442849091888458015616609791913387549920052406368991256071760605886116
<?php
$str;
while(true) {
if (preg_match('/^(.{1,60})( |$)/', $str, $match)) {
print $match[1];
$str = substr($str, strlen($match[1]));
}
else {