Skip to content

Instantly share code, notes, and snippets.

View adammiller's full-sized avatar

Adam Miller adammiller

View GitHub Profile
@adammiller
adammiller / douglasPeucker.js
Created February 14, 2011 16:54
Javascript implementation of the Douglas Peucker path simplification algorithm
var simplifyPath = function( points, tolerance ) {
// helper classes
var Vector = function( x, y ) {
this.x = x;
this.y = y;
};
var Line = function( p1, p2 ) {
this.p1 = p1;
(ffenv)Adam-Millers-iMac:webifyme adam$ python ff4/manage.py syncdb
Traceback (most recent call last):
File "ff4/manage.py", line 46, in <module>
execute_manager(settings)
File "/Users/adam/Sites/barbarian/webifyme/ffenv/src/django/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/Users/adam/Sites/barbarian/webifyme/ffenv/src/django/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/adam/Sites/barbarian/webifyme/ffenv/src/django/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
@adammiller
adammiller / js_fallback_example.html
Created May 19, 2011 02:18
A method for providing fallback content for JS-dependent sites using noscript and feature detection
<!DOCTYPE html>
<html>
<head>
<title>JS Fallback Example</title>
</head>
<body>
<noscript>
<div id="fallback" class="overlay-wrapper">
<div id="fallback-content">
<p>Your browser doesn't support the features used on this site. Please download a more modern browser.</p>
@adammiller
adammiller / healthy.js
Created April 23, 2012 20:09
FB init example
define( 'healthy',
['underscore', 'healthy/intro', 'healthy/quiz', 'healthy/results'],
function( _, intro, quiz, results ) {
var Healthy = {
'publicFn': {
'init': function( bodyClass ) {
Healthy.privateFn.setup( bodyClass );
Healthy.privateFn.onFacebookInit( function() {
$( window ).trigger( 'FBInit' );
template: {
b2b: {
src: SRC_TMP + 'b2b.dust',
dest: BUILD_TMP + 'b2b.html',
variables: _.extend( grunt.file.readJSON(SRC_TMP + '../data/common.json'), {preserveWhiteSpace: true})
}
}
less: {
src: [
SRC_CSS + 'vendor/elements.less',
SRC_CSS + 'ge.vars.less', // NEEDS REMOVED
SRC_CSS + 'ge.mixins.less', // NEEDS REMOVED
SRC_CSS + 'ge.b2b.less',
SRC_CSS + 'ge.footer.less',
SRC_CSS + 'ge.navigation.less'
],
dest: BUILD_CSS + 'ge.base.less'
var a = 1,
b = 2,
c = function() {
var d = 3,
e = function() {
var f = 4;
};
console.log('a = ', a);
console.log('b = ', a);
console.log('d = ', a);
// Build and update staging
grunt.registerTask("sprite", "Builds sprite sheets from the src imges", function() {
var task = this,
// tell grunt this task is async
done = this.async(),
commands = [
"montage img/_icons_blue/*.png -tile 1x -geometry '100x80>+0+0' -gravity NorthWest -background transparent img/icon_blue_sprite_2x.png",
"montage img/_icons_white/*.png -tile 1x -geometry '100x80>+0+0' -gravity NorthWest -background transparent img/icon_white_sprite_2x.png",
"convert img/icon_white_sprite_2x.png -negate img/icon_black_sprite_2x.png",
"convert img/icon_white_sprite_2x.png -resize 50% img/icon_white_sprite_1x.png",
@adammiller
adammiller / session_store.rb
Created December 12, 2013 01:16
If you're sharing sessions between a rails 3.x and 4.x application, this code can be dropped into the rails 4 app to work around the flash message incompatibility.
# We override some fo the Flash code here to ensure our flash messages from this app are written to a different
# session key than the default. This prevents conflicts with our older rails applications
require "rails"
ActionDispatch::Request.class_eval do
def flash
@env["#{Flash::KEY}_four"] ||= Flash::FlashHash.from_session_value(session['flash_4'])
end
end
define ["underscore", "backbone" ], (_, Backbone) ->
FilteredAttributes =
# Instruct toJSON to use a root node
rootNode: null
# Add attribute names to filteredAttributes to exclude them from JSON
filteredAttributes: []
# Process our JSON, excluding filteredAttributes, and using
# rootNode if present
toJSON: ->