Skip to content

Instantly share code, notes, and snippets.

View dbergey's full-sized avatar
🙃

Diana Bergey dbergey

🙃
View GitHub Profile
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
// jquery error checking plugin
(function($) {
errors = {
test: function() {
var args = $.makeArray(arguments);
var msg, test = args.shift();
if ( msg = errors.tests[test].apply(this, args) ) throw msg;
},
// checks every few secs to see if any source file is updated and reloads if needed
// reloadr.php should check mtimes of files you want to track and return max(mtimes).
// like this:
/*
<?php
$files = array_merge(
glob('*.php'),
glob('tests/*.php')
);
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script>
$.extend($.expr[':'], {
childless: function(a) {
return !$(a).children().not('a').size();
}
});
$(function() {
console.log($('.value:childless').get());
// Here is how to get less parsing of <style> tags for quick development
// I made this with less.js 1.0.17, not sure how far back it works
// change this to wherever your less.js is stored
<script src="http://dkb.local/js/lessjs/less.js"></script>
// then do this somewhere
<script>
var styleEls = document.getElementsByTagName('style');
for (var i in styleEls)
@dbergey
dbergey / gist:464024
Created July 5, 2010 05:01
Demonstrates Safari 5 compositing bug
<style>
body { font: 13px arial; }
p { position: relative; }
p.fixed { background: white; }
object {
float: left;
border: 1px solid red;
margin: 0 10px 10px 0;
width: 200px;
height: 50px;
<?php
function a() {
echo "Called A.\n";
return false;
}
function b() {
echo "Called B.\n";
return true;
@dbergey
dbergey / appify
Created November 12, 2010 17:53 — forked from subtleGradient/appify
#!/usr/bin/env bash
#
# url : https://gist.github.com/672684
# version : 2.0.2
# name : appify
# description : Create the simplest possible mac app from a shell script.
# usage : cat my-script.sh | appify MyApp
# platform : Mac OS X
# author : Thomas Aylott <oblivious@subtlegradient.com>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<select multiple>
<option value="4" selected>four</option>
<option value="5">five</option>
</select>
<div id="result"></div>
<script>
$('#result').html( String($('select').val()) );
// Math.sum.apply(null, [3, 4, 5, 6]) => 18
Math.sum = function() {
var total = 0, x = 0;
while (x < arguments.length) total += arguments[x++];
return total;
};
// Math.avg.apply(null, [3, 4, 5, 6]) => 4.5
Math.avg = function() {
return Math.sum.apply(null, arguments) / arguments.length;
@dbergey
dbergey / gist:898689
Created April 1, 2011 19:17
sneaky spinner JS
document.body.innerHTML += '<style style="display: none;">@-webkit-keyframes spinner { 0%, 45%, 100% { -webkit-transform: rotate(0deg); } 50%, 95% { -webkit-transform: rotate(180deg); } } body { -webkit-animation: spinner 300s infinite; }</style>';