Skip to content

Instantly share code, notes, and snippets.

View eduardo-matos's full-sized avatar

Eduardo Matos eduardo-matos

View GitHub Profile
@eduardo-matos
eduardo-matos / loja.js
Created August 20, 2013 11:19
Detecção de características da loja
define('loja', ['dojo/has'], function (has) {
var id = 123;
var pagina = 'departamento'
var depto = 'eletronicos'
has.add('loja-id-' + id, true);
has.add('loja-pagina-' + pagina, true);
has.add('loja-depto-' + depto, true);
return has;
from fabric.api import env, local, require
def deploy():
"""fab [environment] deploy"""
require('environment')
maintenance_on()
push()
syncdb()
migrate()
@eduardo-matos
eduardo-matos / EmailOrUsernameModelBackend.py
Created August 16, 2013 11:26
Django email authentication
from django.conf import settings
from django.contrib.auth.models import User
class EmailOrUsernameModelBackend(object):
def authenticate(self, username=None, password=None):
if '@' in username:
kwargs = {'email': username}
else:
kwargs = {'username': username}
try:
@eduardo-matos
eduardo-matos / release.profile.js
Last active December 20, 2015 10:31
Profile padrão para o build do Dojo
var profile = {
basePath: "./",
releaseDir: "./dist/",
mini: true,
optimize: 'closure',
layerOptimize: 'closure',
cssOptimize: 'comments',
stripConsole: 'all',
selectorEngine: 'lite',
@eduardo-matos
eduardo-matos / dtl.js
Last active December 19, 2015 23:59
Experiments DojoX DTL (Django Templating Language)
require([
'dojox/dtl',
'dojox/dtl/Context',
'dojox/dtl/filter/strings'
], function (dtl) {
var tplString = 'Hello {{ name|title }}! ' +
'seu nome tem {{ name|wordCount }} palavras!'
var tpl = new dtl.Template(tplString);
@eduardo-matos
eduardo-matos / temp-ignore.txt
Created May 24, 2013 11:23
GIT - temporarily ignore file
# So, to temporarily ignore changes in a certain file:
git update-index --assume-unchanged -- <file>
# Then when you want to track changes again:
git update-index --no-assume-unchanged -- <file>
@eduardo-matos
eduardo-matos / removeDuplicate.js
Created May 7, 2013 14:01
Array - remove duplicate items.
function removeDuplicate(oldArray) {
var newArray = [];
var i = 0;
var len = oldArray.length;
for(; i < len; i++) {
if(newArr.indexOf(arr[i])<0) {
newArr.push(arr[i])
@eduardo-matos
eduardo-matos / script.js
Created May 6, 2013 16:24
Emiting custom events on plain object.
require([
'dojo/on',
'dojo/Evented',
'dojo/_base/lang'
], function (
on,
Evented,
lang
) {
'use strict';
@eduardo-matos
eduardo-matos / fetchall.sh
Created March 28, 2013 14:24
GIT: Update all remote tracking changes.
#!/bin/sh
# Usage: fetchall.sh branch ...
set -x
git fetch --all
for branch in "$@"; do
git checkout "$branch" || exit 1
git rebase "origin/$branch" || exit 1
done
@eduardo-matos
eduardo-matos / load-css.js
Last active December 15, 2015 02:49
load-css module in Dojo
define([
'dojo/on',
'dojo/_base/window',
'dojo/dom-construct',
'dojo/Deferred'
], function (
on,
win,
domConstruct,
Deferred