Skip to content

Instantly share code, notes, and snippets.

View millermedeiros's full-sized avatar

Miller Medeiros millermedeiros

View GitHub Profile
@millermedeiros
millermedeiros / gist:837780
Created February 21, 2011 22:02
Simple Sorted Insertion
/**
* Add items to Array in a sorted order.
* @param {Array} arr
* @param {Number} item
* @author Miller Medeiros
* Released under the WTFPL (http://sam.zoy.org/wtfpl/)
*/
function sortedInsert(arr, item){
var n = arr.length;
do { n--; } while (item < arr[n]);
@millermedeiros
millermedeiros / gist:863421
Created March 10, 2011 01:41
JS-Signals 0.5.3
/*jslint onevar:true, undef:true, newcap:true, regexp:true, bitwise:true, maxerr:50, indent:4, white:false, nomen:false, plusplus:false */
/*!!
* JS Signals <http://millermedeiros.github.com/js-signals/>
* Released under the MIT license <http://www.opensource.org/licenses/mit-license.php>
* @author Miller Medeiros <http://millermedeiros.com/>
* @version 0.5.3
* @build 143 (02/21/2011 07:18 PM)
*/
var signals = (function(){
@millermedeiros
millermedeiros / gist:870867
Created March 15, 2011 15:18
JavaScript Chaining Example
//
// Orthodox Chaining
//
//basic Object that implements chaining
var myObj = {
_val : 'lorem',
val : function(val){
if(val === void(0)){
return this._val;
@millermedeiros
millermedeiros / gist:882682
Created March 23, 2011 05:47
RequireJS Async Load Plugin
/*!
* RequireJS plugin for async dependency load like JSONP and Google Maps
* @author Miller Medeiros
* @version 0.0.1 (2011/03/23)
* Released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
define(function(){
function injectScript(src){
var s, t;
@millermedeiros
millermedeiros / gist:891886
Created March 29, 2011 06:21
iPad HTML5 video quirks and hacks
/*
* Example how to preload HTML5 video on the iPad (iOS 3.2+)
* @author Miller Medeiros
* Released under WTFPL
*/
var vid = document.createElement('video');
vid.src = 'lol_catz.mp4';
document.getElementById('video-holder').appendChild(vid);
@millermedeiros
millermedeiros / LICENSE.txt
Created May 17, 2011 14:58 — forked from jed/LICENSE.txt
route client urls with 404s and pattern captures
Copyright (c) 2011 Jed Schmidt, http://jed.is
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@millermedeiros
millermedeiros / noext.js
Created July 1, 2011 05:17
RequireJS plugin for loading files without adding the JS extension
//set location of "noext!" plugin
//(this setting should be on the top-level of your app, inside your "main.js" or HTML file)
//you could also omit this setting and just place the "ext.js" file in the `baseUrl` folder.
require({
paths : {
noext : 'path_to_plugin/noext'
}
});
//load file without appending ".js" extension
@millermedeiros
millermedeiros / sample-hasher_crossroads.html
Created July 27, 2011 16:28
Using hasher together with crossroads.js
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>example crossroads + hasher</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div id="wrapper">
<ul>
@millermedeiros
millermedeiros / gist:1188835
Created September 2, 2011 14:58
reply to position-absolute.com post: Organizing events with jQuery
// -----------------------
// refactor by Miller Medeiros (http://blog.millermedeiros.com)
// of code samples present on position-absolute.com blog post:
// http://www.position-absolute.com/articles/organizing-events-with-jquery/
// -----------------------
//just so we make sure `myApp` does exist
window.myApp = window.myApp || {};
@millermedeiros
millermedeiros / gist:1189235
Created September 2, 2011 17:29
Explain difference between revealing module pattern and using a constructor as namespace
//create our "FOO" namespace
window.FOO = window.FOO || {};
FOO.app1 = {
bar : 'foo',
init : function(){
//this wont work as expected since timeout changes scope