Skip to content

Instantly share code, notes, and snippets.

View cezary's full-sized avatar

cezary cezary

  • Chicago / Los Angeles
View GitHub Profile
# returns an elements unique css selector http://stackoverflow.com/questions/4588119/get-elements-css-selector-without-element-id
selector = (el, nodeChild = false)->
names = []
while el.parentNode
if el.id
names.unshift "##{ el.id }"
break
else
c = 1
// https://github.com/EyalAr/lwip/issues/100#issuecomment-71363633
var fs = require('fs');
var exif = require('exif-parser');
var lwip = require('lwip');
// path is the path to your image
fs.readFile(path, function (err, data) {
if (err) throw err;
var exifData = false;

Following is a translation of a post by Kenta Cho (@abagames) about what he learned making 50 minigames in 2014. The original post is here:

http://d.hatena.ne.jp/ABA/20141223#p1

This translation is by Paul McCann (@polm23); please feel free to contact me with any comments or corrections.

The Secret to Creating Fun Games I Learned By Making 50 Games in a Year

... is that there isn't one.

@cezary
cezary / statusapi.md
Created December 5, 2016 20:13 — forked from iansmith/statusapi.md
Explains the purpose of the YikYak status api and how to use it.

Purpose

The purpose of the Yik Yak status API is to allow a third-party application to set the status of a Yik Yak user programmatically. A secondary purpose is to allow a third-party application to set the location of the user (latitude, longitude), even though this is less likely to be less useful to most applications.

Mode Of Use

const animationFrame = () => new Promise(window.requestAnimationFrame);
const load = (el=window) => new Promise(resolve => el.onload = resolve);
const timeout = (time) => new Promise(resolve => setTimeout(resolve, time))
const letterMap = {
"A": 2,
"B": 3,
"C": 5,
"D": 7,
"E": 11,
"F": 13,
"G": 17,
"H": 19,
"I": 23,
const capitalize = word => word[0].toUpperCase() + word.slice(1).toLowerCase()
const abbreviate = (str, length=2) => {
str = str
.split(' ')
.map(word => word.toUpperCase() === word ? capitalize(word) : word)
.join(' ');
const ret = [];
str.replace(/([A-Z])/g, (match, p1) => {
// https://codepen.io/anon/pen/EpBJwR
const defaultOptions = { height: 100, width: 500 };
const generateSparkline = (data, options) => {
options = Object.assign({ defaultOptions, options });
const points = data.reduce((acc, [x, y], i) => {
x = (options.width / data.length) * i;
return acc + `${x},${options.height - y}\n`;
}, '');
@cezary
cezary / solve24.js
Last active September 17, 2018 18:23
// https://stackoverflow.com/a/20871714
const permutator = (inputArr) => {
let result = [];
const permute = (arr, m = []) => {
if (arr.length === 0) {
result.push(m)
} else {
for (let i = 0; i < arr.length; i++) {
let curr = arr.slice();