Skip to content

Instantly share code, notes, and snippets.

View chiefGui's full-sized avatar
:shipit:
Shipping stuff

Guilherme Oderdenge chiefGui

:shipit:
Shipping stuff
View GitHub Profile
function jj () {
var x = [0, 1, 2, 3, 4, 5];
while (true) {
yield x;
};
};
console.log(jj());
/**
* Em referência à https://gist.github.com/guisouza/8c592323f833d981cf1c
**/
/**
* No exemplo, o gato come Fish
* e depois come Food, mas pela lógica,
* Fish e Food já devem existir: ele não
* pode comer algo abstrato.
*
var koa = require('koa');
var app = koa();
// x-response-time
app.use(function *(next){
var start = new Date;
yield next;
var ms = new Date - start;
this.set('X-Response-Time', ms + 'ms');
var l = (function() {
return x;
x = function () {
console.log('hello?');
};
function x () {
console.log('is anybody there?');
};
var Backboneiros = Backbone.Collection.extend({
rearrange: function (atIndex, toIndex) {
var modelMemory = this.models[atIndex];
this.remove(modelMemory, { silent: true });
this.add(modelMemory, { at: toIndex });
}
});
module.exports = Backboneiros;
@chiefGui
chiefGui / CollectionDeepClone.js
Created June 2, 2015 19:44
Implementation of a deep cloning method into a Backbone.Collection
var Users = Backbone.Collection.extend({
clone: function (deep) {
if (deep) {
return new this.constructor(_.map(this.models, function (model) {
return model.clone();
}));
};
return Backbone.Collection.prototype.clone.apply(this);
}
/*! Stamplay v1.2.2 | (c) 2015 The Stamplay Dreamteam */// Underscore.js 1.8.3
// http://underscorejs.org
// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
// Underscore may be freely distributed under the MIT license.
(function(){function n(n){function t(t,r,e,u,i,o){for(;i>=0&&o>i;i+=n){var a=u?u[i]:i;e=r(e,t[a],a,t)}return e}return function(r,e,u,i){e=b(e,i,4);var o=!k(r)&&m.keys(r),a=(o||r).length,c=n>0?0:a-1;return arguments.length<3&&(u=r[o?o[c]:c],c+=n),t(r,e,u,o,c,a)}}function t(n){return function(t,r,e){r=x(r,e);for(var u=O(t),i=n>0?0:u-1;i>=0&&u>i;i+=n)if(r(t[i],i,t))return i;return-1}}function r(n,t,r){return function(e,u,i){var o=0,a=O(e);if("number"==typeof i)n>0?o=i>=0?i:Math.max(i+a,o):a=i>=0?Math.min(i+1,a):i+a+1;else if(r&&i&&a)return i=r(e,u),e[i]===u?i:-1;if(u!==u)return i=t(l.call(e,o,a),m.isNaN),i>=0?i+o:-1;for(i=n>0?o:a-1;i>=0&&a>i;i+=n)if(e[i]===u)return i;return-1}}function e(n,t){var r=I.length,e=n.constructor,u=m.isFunction(e)&&e.pr
@chiefGui
chiefGui / Home.jsx
Last active February 22, 2017 12:06
import React, {Component} from 'react'
class Home extends Component {
state = {isContactModalOpen: false}
renderContactModal () {
return (
<div id="modal">
<form>
<input type="text" placeholder="Your e-mail" />
@chiefGui
chiefGui / Modal.jsx
Last active February 22, 2017 12:14
import React, {Component, PropTypes} from 'react'
class Modal extends Component {
state = {isOpen: false}
static propTypes = {
isOpen: PropTypes.bool
}
componentWillMount() {
import React, {Component} from 'react'
import Modal from '../components/Modal'
class Home extends Component {
state = {isContactModalOpen: false}
render () {
const {isContactModalOpen} = this.state