Skip to content

Instantly share code, notes, and snippets.

@adatta02
adatta02 / recursive_underscore_template.html
Created August 1, 2012 04:42
UnderscoreJS recursive template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="underscore.js"></script>
<style>
.container {
position: relative;
var list = [];
$(".institution").each( function(){ list.push( $(this).text() ); } );
list = list.sort();
list.join("\n");
@adatta02
adatta02 / sfFastModelRebuild.class.php
Created September 27, 2012 02:06
Supports doing a partial Doctrine rebuild in Symfony 1.4
<?php
class FastModelRebuild {
// Just return some standard Symfony configs
private static function getConfig(){
return array(
"data_fixtures_path" => array( sfConfig::get("sf_data_dir") . "/fixtures" ),
"models_path" => sfConfig::get("sf_lib_dir") . "/model/doctrine",
"migrations_path" => sfConfig::get("sf_lib_dir") . "/migration/doctrine",
@adatta02
adatta02 / gist:3976807
Created October 29, 2012 21:56
Scroll an element with the page with a debounced event.
jQuery(document).ready( function(){
jQuery(window).scroll( function(){
if( jQuery(window).scrollTop() > 1940 ){
if( jQuery("#ss-ad").css("position") == "absolute" ){
if( window.criteoTimer ){
window.clearTimeout( window.criteoTimer );
jQuery("#answer26913X14194X74181").blur( function(){
var age = parseInt(jQuery("#answer26913X14194X74181").val());
age = 2012-age;
if( age == NaN ){
return;
}
if( age >= 55 ){
jQuery("#answer26913X14194X754604").click();
<?php
class MyTasks {
public static $HELP_TEXT = array(
"listAllFiles" => "List all the files in the current directory",
"clearOldRows" => "Clear out old rows from the DB. (Or something like that)"
);
public static function listAllFiles(){
foreach( $userIdProductIdTable as $userId => $productArray ){
foreach( $productArray as $productId => $tpIds ){
$total = 0;
foreach( $tpIds as $id ){ $total += $keyedResults[$id]["total"]; }
foreach( $tpIds as $id ){ $keyedResults[$id]["total"] = $total; }
}
}
<div id="hiddenDiv" style="display: none; padding-bottom: 10px">
<input type="range" min="1" max="100" step="1" value="5" />
</div>
<a href="#" id="toggle">Show the slider!</a>
@adatta02
adatta02 / backbone.delegateevents.js
Created December 30, 2012 00:01
Backbone.js delegateEvents
// Set callbacks, where `this.events` is a hash of
//
// *{"event selector": "callback"}*
//
// {
// 'mousedown .title': 'edit',
// 'click .button': 'save'
// 'click .open': function(e) { ... }
// }
//
var questionArray = { };
var questionLabels = [];
var tbl = $("<table class='js-format-table'><thead><tr></tr></thead><tbody></tbody></table>");
var boilerplate;
$('div[id^="question"]').each(function(i) {
if( $(this).hasClass("boilerplate") ){
boilerplate = $(this);
return true;