Skip to content

Instantly share code, notes, and snippets.

define(['m2m-modal-form'], function(M2mForm){
return function(params) {
M2mForm(_.extend(params, {
endereco: {
url: '/admin/artista/_tr-endereco/',
$el: $('.enderecos tbody')
}
}));
define(['m2m-modal-form'], function(M2mForm) {
return function(params) {
var m2m = M2mForm(params);
m2m.addRelation('endereco', {
url: '/admin/artista/_tr-endereco/',
$el: $('.enderecos tbody')
});
define(['modal', 'hijack', 'belongs', 'operation'],
function(Modal, Hijack, Belongs, Operation) {
return function(parent) {
var relations = {};
Operation('js_operation',
_.extend(
Belongs({
<?php
$related_query = \Question::order_by('created_at','DESC');
$related_count = $related_query->take(2)->count();
$result = $related_query->take(2);
@Sigmus
Sigmus / server
Last active December 12, 2015 06:48
Open browser and serve current dir.
function server() {
if [ $1 ]
then
open "http://localhost:$1"
python -m SimpleHTTPServer $1
else
open "http://localhost:8000"
python -m SimpleHTTPServer 8000
fi
}
@Sigmus
Sigmus / optional.js
Created February 12, 2013 20:41
Optional parameters pattern
function sum(a, b, c, d) {
a = a || 1;
b = b || 2;
c = c || 3;
d = d || 4;
return a + b + c + d;
}
@Sigmus
Sigmus / gist:4981079
Created February 18, 2013 21:50
pseudo-controler
$(function() {
var action = $('[data-script]').data();
if (_.isNull(action)) { return; }
resolve(action);
function resolve() {
_.each(action.script.split(','), function(name) {
define [
'backbone',
'models/recording'
'config'
],
(Backbone, RecordingModel, Config) ->
status = 'stopped'
#
@Sigmus
Sigmus / gist:5068300
Last active December 14, 2015 09:58
Sublime user preferences.
{
"caret_style": "phase",
"color_scheme": "Packages/Theme - Cobalt2/cobalt2.tmTheme",
"font_face": "Monaco",
"font_size": 12.0,
"highlight_line": true,
"highlight_modified_tabs": true,
"ignored_packages":
[
"Vintage"
@Sigmus
Sigmus / cpf.js
Created March 11, 2013 18:12
Validador CPF.
var validate_cpf = function(value) {
var cpf = value;
while(cpf.length < 11) cpf = "0"+ cpf;
var expReg = /^0+$|^1+$|^2+$|^3+$|^4+$|^5+$|^6+$|^7+$|^8+$|^9+$/,
a = [], b = new Number, c = 11;
for (i=0; i<11; i++) {
a[i] = cpf.charAt(i);