Skip to content

Instantly share code, notes, and snippets.

View dandean's full-sized avatar
🌧️
It's raining.

Dan Dean dandean

🌧️
It's raining.
View GitHub Profile
@dandean
dandean / dillinger.css
Created November 10, 2011 00:37
Dillinger Styles
#preview {
padding: 20px;
width: 47%;
box-sizing: border-box;
}
.shadowbox {
-webkit-box-shadow: 0 0 80px rgba(0, 0, 0, 0.30), inset 0 0 5px rgba(0, 0, 0, 0.6);
} ^ ^
@dandean
dandean / backbone.model.es5properties.js
Created October 17, 2011 06:30
Monkey patch `Backbone.Model.extend()` with ES5 getters/setters for each attribute defined in the defaults.
/**
* Monkey patch `Backbone.Model.extend()` with ES5 getters/setters for each
* attribute defined in the defaults. Gives you the added bonus of being
* to pass your backbone models directly to your Mustache.js views.
*
* Example:
*
* var User = Backbone.Model.extend({
* defaults: {
* username: undefined,
@dandean
dandean / Object.defineProperty Shim.js
Created October 14, 2011 00:44
How many holes can you poke in this? And do they really matter?
if (!Object.defineProperty) {
if (Object.__defineGetter__) {
Object.defineProperty = function(obj, name, options) {
if (!options) throw new Error("`options` is a required argument.");
if ("get" in options || "set" in options) {
if ("get" in options) {
obj.__defineGetter__(name, options.get);
}
if ("set" in options) {
@dandean
dandean / gist:1235558
Created September 22, 2011 18:19
Copy all dlls from the the current directory's subfolders into a different sibling directory.
#!/bin/sh
#
# What this script should do:
#
# /repository <- source directory
# /foo/rad.dll
# /bar/cool.dll
#
# /other <- dlls get copied to here
# /rad.dll
@dandean
dandean / pre-commit.sh
Created September 21, 2011 22:42
Check for build failure before allowing a commit on a VisualStudio project
#!/bin/sh
#
# This script builds the project before a commit takes place. If the build
# fails, the commit is rejected and the build log is printed.
echo "Building solution..."
# Build the solution in Release mode...
LOG=`/c/Windows/Microsoft.NET/Framework/v3.5/MSBuild.exe "/property:Configuration=Release" "/verbosity:n" "/target:Clean;Rebuild"`
@dandean
dandean / tip.css
Created September 8, 2011 22:15
Super Tiny CSS ToolTips!
.tip {
position: absolute;
background: #FFF;
border: 4px solid #e9e6e1;
border-radius: 7px;
box-shadow: 0px 0px 4px rgba(0,0,0,0.7);
padding: 0;
margin: 0;
list-style: none;
font-size: 12px;
@dandean
dandean / transitions-supported.js
Created June 21, 2011 16:38
Detect feature support for CSS3 transitions.
// warning: pseudo-code
var TRANSITIONS_SUPPORTED = false;
(function() {
var div = document.createElement('div');
div.innerHTML = '<div style="transition:color 1s linear;-ms-transition:color 1s linear;-o-transition:color 1s linear;-webkit-transition:color 1s linear;-moz-transition:color 1s linear;"></div>';
var prefixes = ['', '-webkit-', '-moz-', '-o-', '-ms-'];
for (var i=0; i<prefixes.length; i++) {
if (prefixes[i] + 'transition' in div.firstChild.style) {
TRANSITIONS_SUPPORTED = true;
break;
@dandean
dandean / valueOf.js
Created June 17, 2011 00:18
Object#valueOf is fucking awesome
var thing = {
data: [1, 2, 3],
valueOf: function() {
var result = 0;
this.data.forEach(function(x) {
result += x;
});
return result;
}
};
@dandean
dandean / example-use.js
Created June 3, 2011 21:52
Model infrastructure for riak-js
var User = require("lib/models/user-model");
User.find("dandean", function(e, user) {
user.email = "[email protected]";
user.save();
});
@dandean
dandean / gist:956063
Created May 4, 2011 21:21 — forked from fling/gist:956023
Page Control CSS
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=724, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<title>Page Control</title>
<style>