Skip to content

Instantly share code, notes, and snippets.

View jbgutierrez's full-sized avatar

Javier Blanco Gutiérrez jbgutierrez

View GitHub Profile
@jbgutierrez
jbgutierrez / app.coffee
Last active December 14, 2015 04:29
Laboratorio de yeoman y angular (http://yoplay.jbgutierrez.info)
String::pad = (l, s) ->
if (l -= @length) > 0
(s = new Array(Math.ceil(l / s.length) + 1).join(s)).substr(0, s.length) + this + s.substr(0, l - s.length)
else
@
app = angular.module "yoplayApp", ["ngResource"]
app.factory "myHttpInterceptor", ["$q", "$window", "$rootScope", ($q, $window, $rootScope) ->
(promise) ->
@jbgutierrez
jbgutierrez / main.es6
Created December 11, 2015 00:28
ES6 Express Server
import express from "express"
var app = express();
app.get("/", (req, res) => {
res.json({hello: 'world'});
});
var port = process.env.PORT || 3000;
@jbgutierrez
jbgutierrez / lazy-logger.rb
Last active October 29, 2015 21:10
Lazy logging errors to bost performace
# Meassure the difference:
# $ ab -r -n 10 http://127.0.0.1:4567/ | grep "Requests per second"
require 'sinatra'
require 'logger'
ERRLOG = Logger.new "#{__FILE__}.err"
ERRQ = Queue.new
Thread.new do
loop do
@jbgutierrez
jbgutierrez / .htdigest
Last active October 29, 2015 21:08
Invoke shell scripts via web
user:realm:fb6cb9e166c6c764ff2bdea12175a8aa
@jbgutierrez
jbgutierrez / life.rb
Last active October 29, 2015 20:59
Conway's Game of Life in Ruby
board = """
........................o...........
......................o.o...........
............oo......oo............oo
...........o...o....oo............oo
oo........o.....o...oo..............
oo........o...o.oo....o.o...........
..........o.....o.......o...........
...........o...o....................
............oo......................
@jbgutierrez
jbgutierrez / index.html
Created September 19, 2012 11:00
HTMLElement.click behaviour
<a id='clickMe' href='#'>Click me</a>​
@jbgutierrez
jbgutierrez / metaprograming_example.coffee
Created July 3, 2012 09:17
Metaprogramación con Coffescript
Function::hasProperties = (properties) ->
self = @
self.prototype.properties = {}
definePropertie = (key, value) ->
self.prototype.properties[key] = value
self.prototype[key] = (newValue) ->
@properties[key] = newValue
@
for key, value of properties
definePropertie key, value
@jbgutierrez
jbgutierrez / AClass.js
Created April 3, 2012 08:20
Idea para contextualizar las llamadas a console.log
var AClass = new Class({
Implements: [ExtendedLogger],
initialize: function() {
this.initLogger('AClass', {
skip: ['silentMethod'],
debug: true
});
this.silentMethod();
this.otherMethod();
},
<!DOCTYPE HTML>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Events Flow</title>
<style type="text/css" media="screen">
div {
background-color: #ddd;
padding: 40px;
border: 1px solid white;
}
@jbgutierrez
jbgutierrez / media-query-ie-fallback.html
Created January 25, 2012 10:39
Media querys IE fallback
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Media querys IE fallback</title>
<style>
p {
color: blue;
}