Skip to content

Instantly share code, notes, and snippets.

@mattisfrommars
mattisfrommars / gist:0036138d379b56d87db1
Created November 12, 2014 17:20
Tech Test for loop
'use strict';
/**
* @returns {Promise} that will be resolved
*/
function doSomething () {
return new Promise(function( resolve, reject ){
setTimeout(function(){
resolve();
}, Math.random() * 1000 );
@mattisfrommars
mattisfrommars / pre-commit
Last active August 29, 2015 14:14
Run gulp before commit
######################################################################
# Unit Tests: Run unit tests/specs before committing
######################################################################
./node_modules/.bin/gulp
EXIT_CODE=$?
if [[ ${EXIT_CODE} -ne 0 ]]; then
echo "[ERRROR] code = " ${EXIT_CODE}
echo "Tests failed."
echo "Commit aborted."
exit 1
@mattisfrommars
mattisfrommars / gist:baefcea88abb2f4dcec5
Last active August 29, 2015 14:18
Things Valentin Hates
[
"Patent Trolls",
"David Cameron",
"Xenophobia",
"Everything",
"Irresponsible Drug Policy",
"Money",
"Jay Walking",
"Spicy Food",
"Caffeine",
@mattisfrommars
mattisfrommars / Ugh.js
Created March 8, 2017 14:31
Either I'm having a brain fart, or there's no nice way of doing this. I have 3 independent boolean variables and need to render a view based on those states
const a = Math.random() >= 0.5;
const b = Math.random() >= 0.5;
const c = Math.random() >= 0.5;
if (a) {
if (b) {
if (c) {
return '111';
} else {
return '110';
@mattisfrommars
mattisfrommars / index.d.ts
Last active October 24, 2017 15:14 — forked from pierre-H/index.d.ts
Expo TypeScript Definitions
declare module 'expo' {
import {EventSubscription} from 'fbemitter';
import {ViewProperties, ViewStyle} from 'react-native';
/**
* Expo Accelerometer
*/
export namespace Accelerometer {
// TODO: good export type of x, y and z
export interface AccelerometerObject {
function createCombinations(input, result = []) {
return multiply(input)
}
function multiply(inputArrays, result = []) {
const [input, ...rest] = inputArrays
if (!input) return result
@mattisfrommars
mattisfrommars / Cell.js
Created June 5, 2020 17:45
Recursive maze drawing algorithm
function Cell(i, j, w, rows, cols) {
let x, y;
this.i = i;
this.j = j;
this.w = w;
this.x = x = i * w;
this.y = y = j * w;
this.walls = [
[x, y, x + w, y], // TOP
[x + w, y, x + w, y + w], // RIGHT