Skip to content

Instantly share code, notes, and snippets.

View agar3s's full-sized avatar

Gio agar3s

View GitHub Profile
@agar3s
agar3s / index.html
Created August 8, 2013 05:28
A CodePen by Giovanny.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>The Game</title>
</head>
<body>
<canvas id="board" width='700' height='600'></canvas>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
@agar3s
agar3s / index.html
Created July 29, 2013 21:37
A CodePen by Giovanny.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Canvas Background</title>
</head>
<body>
<header>
<h1>Hello canvas background</h1>
</header>
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;
@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;
@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 / 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>
function main(operation){
return (new Function('return ' + operation))();
}
@agar3s
agar3s / slugify
Last active August 29, 2015 14:10
var replaces = {
'á':'a',
'é':'e',
'í':'i',
'ó':'o',
'ú':'u',
'Á':'A',
'É':'E',
'Í':'I',
var memo = {
'0': 0,
'1': 1,
'2': 2,
'3': 6
};
function main(n){
if(n<=2){
return memo[n];
function main(word){
word = word.replace(/\s/g,'');
return word == word.split('').reverse().join('');
};