Skip to content

Instantly share code, notes, and snippets.

View millermedeiros's full-sized avatar

Miller Medeiros millermedeiros

View GitHub Profile
@millermedeiros
millermedeiros / gist:2596657
Created May 4, 2012 18:05
"safe/strict" data store object
define(function(){
//just so we can check against undefined and set val as undefined
var UNDEF;
// here you create the "interface", trying to get/set any other property
// will throw errors before build (see pragmas on get).
var _data = {
foo : UNDEF,
bar : UNDEF,
@millermedeiros
millermedeiros / build.js
Created May 9, 2012 01:15
sample node.js build script including RequireJS optimizer (r.js) and copy/delete/filter files
// Combine JS and CSS files
// ---
//
// Make sure you install the npm dependencies
// > cd YOUR_PROJECT_FOLDER
// > npm install
//
// Than run:
// > node build
@millermedeiros
millermedeiros / gist:2690836
Created May 13, 2012 23:52 — forked from karlwestin/gist:2690501
Refactoring JS for testing part 5 – refactor
/*
* Karl Westin
* Part of the "refactoring javascript for unit testing" blog post
* ---
* Quick refactor by Miller Medeiros (http://blog.millermedeiros.com)
* Didn't tested the code during/after changes, might contain errors.
*/
function Lightbox(parent) {
@millermedeiros
millermedeiros / .htaccess
Created June 11, 2012 13:34
basic htaccess for perf
DirectoryIndex index.html index.htm index.php
ErrorDocument 404 /404
# Block directory listing
Options -Indexes
# === URL Rewrite === #
# Map all URIs except those corresponding to existing files/folders to the handler
RewriteEngine on
@millermedeiros
millermedeiros / gist:3057782
Created July 6, 2012 02:52
Links sobre otimização de performance (WPO)
@millermedeiros
millermedeiros / gist:3136745
Created July 18, 2012 15:06
find closest number in the sequence (1, 5, 10, 50, 100, 500, 1000, ...) that generates less than "n" steps
//
// find closest number in the sequence (1, 5, 10, 50, 100, 500, 1000, ...)
// that generates less than "n" steps
// ---
// useful for subdividing charts and any other things that requires a scale
// that follows reasonable numbers
//
function getStepSize(val, maxNSteps) {
var nSteps;
var stepSize = 1;
@millermedeiros
millermedeiros / example.html
Created August 28, 2012 13:52
node.js script to inline static includes
<!DOCTYPE html>
<!-- #include "inc_header.html" title="Example" header="Sample Title" -->
<html>
<head>
<meta charset="utf-8">
<title>Example</title>
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<h1>Sample Title</h1>
@millermedeiros
millermedeiros / Set.js
Created September 26, 2012 14:40
amd-utils array methods to mimic ES6 Set
// If OOP is "your thing" it can be easily abstracted into a constructor
define(
[
'amd-utils/array/insert',
'amd-utils/array/remove',
'amd-utils/array/contains',
'amd-utils/array/forEach'
],
function (insert, remove, contains, forEach) {
@millermedeiros
millermedeiros / updateLibs.sh
Last active October 11, 2015 12:37
Shell script to update 3rd party libs
#!/bin/sh
# This shell script is used to bootstrap the app and update external libraries
#
# ====== IMPORTANT ======
#
# it may break application if 3rd party libs aren't backwards compatible
# or if libs were edited locally, use with care !!!