Skip to content

Instantly share code, notes, and snippets.

View millermedeiros's full-sized avatar

Miller Medeiros millermedeiros

View GitHub Profile
@millermedeiros
millermedeiros / .vimrc
Last active December 11, 2023 14:44
My VIM settings (.vimrc)
" =============================================================================
" Miller Medeiros .vimrc file
" -----------------------------------------------------------------------------
" heavily inspired by: @factorylabs, @scrooloose, @nvie, @gf3, @bit-theory, ...
" =============================================================================
" -----------------------------------------------------------------------------
" BEHAVIOR
@millermedeiros
millermedeiros / json.js
Created September 30, 2011 21:25
RequireJS plugin to load JSON files
/*!
* RequireJS plugin for loading JSON files
* - depends on Text plugin and it was HEAVILY "inspired" by it as well.
*
* IMPORTANT: it only works on r.js optimizer after version 0.26+ 20011/09/27
*
* @author Miller Medeiros
* @version 0.0.1 (2011/06/10)
* Released under the WTFPL <http://sam.zoy.org/wtfpl/>
*/
@millermedeiros
millermedeiros / universal-module.js
Created September 29, 2011 19:21 — forked from ryanflorence/universal-module.js
Universal JavaScript Module, supports AMD (RequireJS), Node.js, and the browser.
(function(def){
def('myModule', ['someDependency', 'somethingElse'], function(someDependency, somethingElse){
//return the module's API
return {};
});
}(
// wrapper to run code everywhere
typeof define === 'function' && define.amd?
@millermedeiros
millermedeiros / build-main_settings.js
Created September 23, 2011 14:33
Another example of single entry point with RequireJS + individual section/module versioning
({
//settings for the r.js optimizer
baseUrl : '../js',
name : 'main',
out : '../deploy/js/main-v2.js', //here you can set the versioning
excludes : [
//so we can load those modules only when needed, also to make sure
//individual versioning of sections also work as expected.
'sections/search/main',
'sections/news/main',
@millermedeiros
millermedeiros / AbstractModel.js
Created September 20, 2011 20:39
AbstractModel.js
define(['jquery'], function($){
var DEFAULT_DATA_TYPE = 'json';
/**
* Abstract REST service model.
* @author Miller Medeiros
* @version 0.3.1 (2011/09/21)
* @param {object} [services] Services
* @see AbstractModel.services
@millermedeiros
millermedeiros / index.html
Created September 3, 2011 16:20
Example of how to use a single JS file for multiple pages of an application
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example</title>
<meta name="description" content="This is just an example">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/main.css">
</head>
<body data-modules="foobar, lorem/ipsum">
@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
@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 / 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 / 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