Skip to content

Instantly share code, notes, and snippets.

View ericlifka's full-sized avatar

Eric Lifka ericlifka

View GitHub Profile
String.prototype.encodeAsPeriods = function () {
var characterArray = this.split('');
var charCodeArray = characterArray.map(function (char) {
return char.charCodeAt();
});
var periodEncodedCharArray = charCodeArray.map(function (charCode) {
var charCodeString = "" + charCode;
var digitArray = charCodeString.split('');
var periodStringArray = digitArray.map(function (digitString) {
var digit = parseInt(digitString, 10);
var transitions = [ "#slider_1", /* ... */ ];
var transitionNext = function () {
var next = transitions.shift();
if (!next) {
return;
}
$(next).transition({
function requestWithTimeout() {
return new Promise((resolve, reject) => {
window.setTimeout(() => reject('timeout - request took more than 30 seconds'), THIRTY_SECONDS);
makeRequest((err, res) => {
if (err) {
reject(err);
}
else {
resolve(res);
}
@ericlifka
ericlifka / class_example.js
Created November 4, 2015 04:02
javascript class example
function Character(x, y) {
this.movingDirection = 0;
this.movesLeft = 0;
this.x = x;
this.y = y;
}
Character.prototype = {
getX: function() {
return this.x_position;
},
@ericlifka
ericlifka / test-game.py
Created January 30, 2017 03:46
test-game.py
from scene import *
import sound
import random
import math
class MyScene (Scene):
def setup(self):
self.background_color = 'midnightblue'
self.ship = SpriteNode('spc:PlayerShip1Orange')
self.ship.position = self.size / 2
@ericlifka
ericlifka / day1.js
Last active December 10, 2017 00:45
advent of code
let numbers =
`... snip ...`
.split('')
.map(n => parseInt(n, 10))
let sum = 0
for (let index = 0; index < numbers.length; index++)
if (numbers[index] === numbers[(index + 1) % numbers.length])
sum += numbers[index]