Skip to content

Instantly share code, notes, and snippets.

View tutuca's full-sized avatar

Matías Iturburu tutuca

View GitHub Profile
@tutuca
tutuca / fabfile.py
Last active November 15, 2016 13:26
#!/usr/bin/env python
# -- coding: utf-8 --
"""Deployment script.
This script is coded so it can make the deployments automagically in the
designed servers, it also works as a documentation of where are the programs
installed.
USE: fab <hosts>:<username> <action>
EX: fab staging:admin release
# Copyright (C) 2005-2010 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@tutuca
tutuca / drty-lnk
Created February 4, 2011 22:08
Linking drty
npm ERR! error linking, rollback Error: No satisfying version found for 'request'@'>=1.2.0'
npm ERR! error linking, rollback Valid install targets for request: "latest", "0.10.0", "0.8.3", "0.9.0", "0.9.1", "0.9.5", "1.0.0"
npm ERR! error linking, rollback at /home/tutuca/lib/node/.npm/npm/0.2.16/package/lib/install.js:143:29
npm ERR! error linking, rollback at /home/tutuca/lib/node/.npm/npm/0.2.16/package/lib/install.js:178:5
npm ERR! error linking, rollback at /home/tutuca/lib/node/.npm/npm/0.2.16/package/lib/utils/registry/get.js:55:5
npm ERR! error linking, rollback at /home/tutuca/lib/node/.npm/npm/0.2.16/package/lib/utils/registry/request.js:37:10
npm ERR! error linking, rollback at IncomingMessage.<anonymous> (/home/tutuca/lib/node/.npm/npm/0.2.16/package/lib/utils/registry/request.js:174:14)
npm ERR! error linking, rollback at IncomingMessage.emit (events.js:59:20)
npm ERR! error linking, rollback at HTTPParser.onMessageComplete (http.js:111:23)
npm ERR! error linking, roll
@tutuca
tutuca / drty-startproject
Created February 4, 2011 22:17
Can't startproject
$ drty-admin startproject potaje
node.js:114
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'hashlib'
at Function._resolveFilename (module.js:198:11)
at Function._load (module.js:156:25)
at require (module.js:225:19)
at /home/tutuca/lib/node/.npm/drty/0.0.1/package/lib/contrib/facebook/index.js:4:12
@tutuca
tutuca / typor.js
Created September 5, 2011 05:54
Corrector de caracteres no deseados
(function($){
$.fn.corrector = function(options) {
var defaults = {
'withespace': ' ',
'doublespace': ' ',
};
var options = $.extend(defaults, options);
return this.each(function(){
@tutuca
tutuca / index.php
Created February 22, 2012 23:58
Serve any image directly.
<?php
$dir = glob("*.gif");
header('Content-Type: image/gif');
echo file_get_contents($dir[array_rand($dir)]); //file_get_contents streams the file directly as gd's Image
// does not support animated gifs
?>
@tutuca
tutuca / color_algo
Created February 27, 2015 14:38
Color harmony algorithm
public static List GenerateColors_Harmony(
int colorCount,
float offsetAngle1,
float offsetAngle2,
float rangeAngle0,
float rangeAngle1,
float rangeAngle2,
float saturation, float luminance)
{
List colors = new List();
@tutuca
tutuca / faketimer
Created March 3, 2015 17:45
Make fakeTimers work with an arbitrary date from moment.js
describe("Test sinon.fakeTimes with Moment.js", function() {
var today, tomorrow, ticks, clock;
beforeEach(function(){
// get milliseconds since UNIX epoch for this date.
ticks = parseInt(moment('01/15/2015').format('x'));
// set the timers to start at expected time.
clock = sinon.useFakeTimers(ticks);
});
afterEach(function(){
@tutuca
tutuca / Gruntfile.js
Created July 24, 2015 16:50
Toolchain
var webpack = require('webpack');
module.exports = function (grunt) {
'use strict';
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
lib: './node_modules',
src: './assets',
out: './app/static/coso',
@tutuca
tutuca / BackboneMixin.js
Last active August 29, 2015 14:27
A mixin for ReactJS that looks for `this.props.collection` or `this.props.model` listens for all Backbone events to update the React Component.
define([
], function() {
return {
componentDidMount: function() {
this._boundForceUpdate = this.forceUpdate.bind(this, null);
this.getBackboneObject().on("all", this._boundForceUpdate, this);
},
componentWillUnmount: function() {
this.getBackboneObject().off("all", this._boundForceUpdate);
},