Skip to content

Instantly share code, notes, and snippets.

View danielstocks's full-sized avatar
🏠
Working from home

Daniel Stocks danielstocks

🏠
Working from home
View GitHub Profile
@danielstocks
danielstocks / app.json
Created March 2, 2018 13:49
Expo Configuration FIle
{
"expo": {
"name": "Carvanro",
"description": "A simple, quick, cheap and fun way to commute together",
"slug": "Carvanro",
"privacy": "public",
"sdkVersion": "24.0.0",
"version": "1.1.0",
"platforms": ["android"],
"orientation": "portrait",
const testPageJSON = {
"children": [
{
"el": "div",
"props": {
"style": {
"background": "green"
}
},
"children": [
@danielstocks
danielstocks / arrayToOptionsObject.jsx
Last active September 4, 2017 13:05
arrayToOptionsObject.js
const HOURS = [
'05', '06', '07', '08', '09', '10', '11', '12',
'13', '14', '15', '16', '17', '18', '19', '20',
'21', '22', '23', '00', '01', '02', '03', '04',
]
/*
* Converts ['05'] to {'05': '05'}
*/
const arrayToOptionsObject = (array => (
// Paste and run in console!
alert(["0707", 92042, 697, 2746, 8646, 1792, 1].reduce(function(a, b) {
return a + b.toString()
}, "48617").split("").map(function(s, i, list) {
var x;
if (i % 2) x = list[i + 1] + (list[i + 2] ||  "");
if (i == 0) x = list[0] + list[1];
return x;
}).filter(function(item) {
return typeof item === 'string';
@danielstocks
danielstocks / gist:5da83982d3b4c7b503a0
Created October 17, 2014 11:38
Pretty print a JavaScript Tree Data Structure
// Example implementation: http://jsfiddle.net/2f7w2fpn/
var indent = 1;
function walk(tree) {
tree.forEach(function(node) {
console.log('--' + Array(indent).join('--'), node.key);
if(node.children) {
indent ++;
walk(node.children);
}
@danielstocks
danielstocks / gist:2490995
Created April 25, 2012 16:13
Testing multiple HTTP status codes
/*
* Disregard the fact that I'm using Array.forEach here
*/
TestCase("ReadyStateHandlerTest", {
"test should call failure handler for 404, 400, 500": function() {
var _this = this;
[400, 404, 500].forEach(function(status) {
var request = forceStatusAndReadyState(_this.xhr, status, 4)
assert(request.failure);
// dust.js template pre-compilation
var template = dust.compile("Hello {name}!");
// compiles to this string:
//
// '(function() {
// dust.register("demo", body_0);
//
// function body_0(chk, ctx) {
@danielstocks
danielstocks / gist:827322
Created February 15, 2011 09:46
css3 paper
<!doctype html>
<html>
<head>
<style>
.theme {
width:400px;
margin:0 2px;
padding: 10px;
find -name "*.py" | xargs perl -p -i -e 's/\s+\n/\n/g'
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>IE input value</title>
</head>
<body>
<form action="">
<input id="test" type="text" name="username">
</form>