Skip to content

Instantly share code, notes, and snippets.

View roden0's full-sized avatar
🎯
Focusing

Rodrigo Encinas roden0

🎯
Focusing
  • Barcelona
View GitHub Profile
@roden0
roden0 / rockpaperscissors.js
Last active August 29, 2015 14:18
rock paper scissors game
var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if(computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
} console.log("Computer: " + computerChoice);
function compare(choice1, choice2){
var FX = {
easing: {
linear: function(progress) {
return progress;
},
quadratic: function(progress) {
return Math.pow(progress, 2);
},
swing: function(progress) {
return 0.5 - Math.cos(progress * Math.PI) / 2;
@roden0
roden0 / trunner.js
Created July 10, 2014 14:31
Task Runner
/*
* Task runner
*/
var tRunner = (function() {
'use strict';
var _session = 1,
_index = 0,
_isPaused = true,
_backwards = true;
@roden0
roden0 / favicons.html
Created June 16, 2014 17:50
Favicons
<!-- Touch icon for iOS 2.0+ and Android 2.1+ -->
<link rel="apple-touch-icon-precomposed" href="path/to/favicon-152.png">
<!-- IE 10 Metro tile icon (Metro equivalent of apple-touch-icon) -->
<meta name="msapplication-TileColor" content="#FFFFFF">
<meta name="msapplication-TileImage" content="/path/to/favicon-144.png">
<!-- For iPad with high-resolution Retina display running iOS ≥ 7: -->
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="/path/to/favicon-152.png">
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(factory);
} else if (typeof exports === 'object') {
module.exports = factory;
} else {
root.MYMODULE = factory();
}
})(this, function () {
//
/*! ******************************
Handlebars helpers
*******************************/
// debug helper
// usage: {{debug}} or {{debug someValue}}
// from: @commondream (http://thinkvitamin.com/code/handlebars-js-part-3-tips-and-tricks/)
Handlebars.registerHelper("debug", function(optionalValue) {
console.log("Current Context");
console.log("====================");
@roden0
roden0 / node-generator.js
Created May 5, 2014 15:57
Node ES6. Promises & Generators.
var get = async(function *(){
var left = yield readJSON('left.json')
var right = yield readJSON('right.json')
return {left: left, right: right}
});
@roden0
roden0 / app.js
Created April 28, 2014 13:28
scalable javascript app
Core.register('module-name1', function(sandbox){/*...*/});
Core.register('module-name2', function(sandbox){/*...*/});
Core.register('module-name3', function(sandbox){/*...*/});
Core.startAll();
Core.addItem({item:'item number 1', price: 0.5});
Core.addItem({item:'item number 3', price: 0.8});
Core.getItemsCount();
@roden0
roden0 / singleton_gmap.js
Created March 24, 2014 11:48
GMaps Singleton object
var oldMap = {
map : null,
center : {lat:50, lng:20, zoom:3},
drawn : false,
data : {},
@roden0
roden0 / amd.define.js
Created February 26, 2014 17:27
JS Modular implementations
/*wrapper*/
define(
/*module ID*/
'myModule',
/*dependencies*/
['foo','bar','foobar'],
/*definition for module export*/
function(foo, bar, foobar){