Skip to content

Instantly share code, notes, and snippets.

View vstarck's full-sized avatar

Valentin Starck vstarck

  • Argentina
View GitHub Profile
@vstarck
vstarck / fizzbuzz.js
Created September 14, 2012 19:26
FizzBuzz
function fb(i) {
i > 0 && (
console.log(
(!(i%3) && 'Fizz' || '') +
(!(i%5) && 'Buzz' || '') ||
i
), fb(i - 1)
);
}
@vstarck
vstarck / Company.php
Created September 8, 2012 20:45
Ejercicio en PHP
<?php
namespace exercise;
class Company {
use Xetter;
private $name;
private $employees = array();
public function __construct() {
@vstarck
vstarck / codeigniter.validations.php
Created August 24, 2012 14:50
codeigniter.validations.php
$originalPOST = $_POST;
$_POST = $data;
$this->set_rules($rules);
$result = $this->run();
$_POST = $originalPOST;
@vstarck
vstarck / exercise.js
Created August 10, 2012 15:58
exercise.js
var app = {
uid: (function() {
var seed = 0;
return function() {
return seed++;
};
})(),
create: function(model, opts) {
var instance = new app.model[model](opts);
@vstarck
vstarck / base64.proxy.js
Created July 11, 2012 18:57
base64.proxy.js
var express = require("express");
var request = require("request");
var app = express.createServer(express.logger(), express.bodyParser());
app.get("/batch", function(req, res) {
if(!req.param("data")) return;
var data = req.param("data");
var callback = req.param("callback") || 'callback';
@vstarck
vstarck / broken.lambdas2.php
Created June 14, 2012 00:03
broken.lambdas2.php
<?php
class Foo {
public function __construct() {
$this->bar = function() {
echo 'Hello World!';
};
}
}
@vstarck
vstarck / list.php
Created June 13, 2012 23:33
list.php
<?php
class MyList {
private $list = array();
public function __construct() {
$this->list = func_get_args();
}
public function add($value) {
@vstarck
vstarck / broken.lambdas.php
Created June 13, 2012 21:16
broken.lambdas.php
<?php
// Constants may only evaluate to scalar values
define('MY_CONSTANT', function() {});
class Foo {
// Parse error: syntax error, unexpected T_FUNCTION
const IS_GET = function() {};
// Parse error: syntax error, unexpected T_FUNCTION
private $foo = function() {};
@vstarck
vstarck / maestros.demo_video.html
Created May 28, 2012 23:19
maestros.demo_video.html
<!DOCTYPE html>
<html>
<head>
<title>Animaciones en Canvas - Utilizando videos</title>
</head>
<body>
<video loop controls id="video">
<source src="cat.webm" type='video/webm; codecs="vp8, vorbis"' />
<source src="cat.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
@vstarck
vstarck / hug.color.js
Created May 28, 2012 20:39
hug.color.js
var Color = hug()
Color('#set')('init', function($self, r, g, b) {
$self
('#set')('r', r)
('#set')('g', g)
('#set')('b', b)
})
Color('#set')('+', function($self, another) {