Skip to content

Instantly share code, notes, and snippets.

View agar3s's full-sized avatar

Gio agar3s

View GitHub Profile
@agar3s
agar3s / Pixel-art-Experiments.markdown
Created August 19, 2014 22:54
A Pen by Giovanny.
Estado del Arte desarrollo de videojuegos en HTML5
-- Capacidades en el browser
- canvas
- webgl
- dispositivos de entrada
- key events
- mouse events
- usermedia: http://www.html5rocks.com/es/tutorials/getusermedia/intro/
- mic
function main(word){
word = word.replace(/\s/g,'');
return word == word.split('').reverse().join('');
};
var memo = {
'0': 0,
'1': 1,
'2': 2,
'3': 6
};
function main(n){
if(n<=2){
return memo[n];
@agar3s
agar3s / slugify
Last active August 29, 2015 14:10
var replaces = {
'á':'a',
'é':'e',
'í':'i',
'ó':'o',
'ú':'u',
'Á':'A',
'É':'E',
'Í':'I',
function main(operation){
return (new Function('return ' + operation))();
}
@agar3s
agar3s / index.html
Created December 31, 2014 20:49
Aplicando físicas básicas para videojuegos en JavaScript
<html>
<head>
<meta charset="utf-8">
<title>Fundamentos de física</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1>Aplicando físicas a videojuegos</h1>
<canvas id="scene" width="600" height="400"></canvas>
<script type="text/javascript" src="main.js"></script>
@agar3s
agar3s / SyncMapIterator.js
Created July 29, 2015 21:03
This is a snippet for a pattern I used to use when I iterate over an Array of objects applying a map async function but the process needs to be sync.
/**
* Creates a new Sync MapIterator over objects with an asyncrhonus mapFunction
* @param {[array]} objects [object array to iterate over]
* @param {[Function]} mapFunction [function to apply over each object sync mode]
* @param {Function} done [function to call when it's done]
*/
var SyncMapIterator = function(objects, mapFunction, done){
this.objects = objects;
this.i = 0;
this.retries = 0;
@agar3s
agar3s / syncMapIterator.js
Last active August 29, 2015 14:26
This is a snippet for a pattern I used to use when I iterate over an Array of objects applying a map async function but the process needs to be sync.
/**
* Creates a new Sync MapIterator over objects with an asyncrhonus mapFunction
* @param {[array]} objects [object array to iterate over]
* @param {[Function]} mapFunction [function to apply over each object sync mode]
* @param {Function} done [function to call when it's done]
*/
var SyncMapIterator = function(objects, mapFunction, done){
this.objects = objects;
this.i = 0;
this.retries = 0;
fun naranjas(n:int) =
let fun funcion_auxiliar(numero, acumulador) =
if numero = 0 then
acumulador
else
funcion_auxiliar(numero - 1, acumulador * numero)
in
funcion_auxiliar(n, 1)
end;