Skip to content

Instantly share code, notes, and snippets.

View MiguelCastillo's full-sized avatar

Miguel Castillo MiguelCastillo

View GitHub Profile
@MiguelCastillo
MiguelCastillo / gist:9873073
Created March 30, 2014 13:51
Loading Tern module
define(["require", "exports", "module"], function (require, exports, module) {
"use strict";
/*
* requirejs support in tern
*/
var ternRequire = window.require.config({
"baseUrl": require.toUrl("./tern/"),
"paths": {
"acorn": "node_modules/acorn"
@MiguelCastillo
MiguelCastillo / gist:9973772
Created April 4, 2014 12:34
Brackets loading CodeMirror addon
/**
* Brackets Themse Copyright (c) 2014 Miguel Castillo.
*
* Licensed under MIT
*/
define(function (require, exports, module) {
"use strict";
@MiguelCastillo
MiguelCastillo / gist:10595457
Created April 13, 2014 18:14
HTML + Inline Script
<html>
<head>
<script>
document.title = "From the 90s";
document.writeln("It has been a long time");
</script>
</head>
<body>
Welcome back Netscape!
@MiguelCastillo
MiguelCastillo / gist:10595702
Created April 13, 2014 18:20
contacts.html + inline script
<html>
<head>
<script>
document.title = "From the 90s - Contact";
document.writeln("It has been a long time");
document.writeln("Contacts");
document.writeln("Terminator");
document.writeln("Predator");
document.writeln("Robocop");
</script>
@MiguelCastillo
MiguelCastillo / gist:10596040
Last active August 29, 2015 13:59
First html with early encarnations of a module
<html>
<head>
<script src="app.js"></script>
<script src="common.js"></script>
<script src="utils.js"></script>
<script src="contacts.js"></script>
<script src="hiring.js"></script>
</head>
<body>
@MiguelCastillo
MiguelCastillo / gist:10608600
Last active August 29, 2015 13:59
requirejs define
define(function() {
return {
"hello": "world";
};
});
@MiguelCastillo
MiguelCastillo / gist:10608677
Last active August 29, 2015 13:59
define with depedency
define([
"simple"
], function( simple ){
console.log( simple.hello );
})
@MiguelCastillo
MiguelCastillo / gist:10654916
Last active August 29, 2015 13:59
Modular design pattern
var Module = (function() {
var message = "Hello World"
function greetings() {
return console.log(message);
}
return {
greetings: greetings
};
@MiguelCastillo
MiguelCastillo / greetings.js
Last active August 29, 2015 13:59
RequireJS module
define(function() {
var message = "Hello World"
function greetings() {
return console.log(message);
}
return {
greetings: greetings
};
@MiguelCastillo
MiguelCastillo / main.js
Last active August 29, 2015 13:59
Require dependency
define( ["greetings"], function( greetings ) {
greetings.greetings();
});