Skip to content

Instantly share code, notes, and snippets.

View danieluhl's full-sized avatar

Typing Turtle danieluhl

View GitHub Profile
const endpoint = 'https://gist.githubusercontent.com/Miserlou/c5cd8364bf9b2420bb29/raw/2bf258763cdddd704f8ffd3ea9a3e81d25e2c6f6/cities.json';
const list = document.querySelector('.suggestions');
const input = document.querySelector('.search');
const populateList = data => {
const html = data.reduce((acc, item) => {
acc = `${acc}
<li>
<span class="name">${item.city}, ${item.state}</span>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JS + CSS Clock</title>
</head>
<body>
<div class="clock">
<div class="clock-face">
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JS + CSS Clock</title>
</head>
<body>
<div class="clock">
<div class="clock-face">
@danieluhl
danieluhl / es6-passing-params.js
Last active January 4, 2017 16:18
Ideal way to pass params to a function ES6
// functions take parameters in any order and set defaults
const greetPerson = ({first = 'Saw', last = 'Gerrera'}) => `Hello ${first}! Sorry, I meant Dr. ${last}`;
// objects or properties can be built however
const person = {
first: 'Cassian',
last: 'Andor',
birthday: '04/04',
age: '23',
position: 'Pilot'
const keyElements = document.querySelectorAll('.key');
const audioElements = document.querySelectorAll('audio');
const sounds = {};
const keys = {};
// got this from wes bos
function removeTransition (e) {
if (e.propertyName !== 'transform') return;
e.target.classList.remove('playing');
}
@danieluhl
danieluhl / luck_tester.html
Created January 13, 2016 23:10
HTML version of luck tester
<input id="button" type="button" value="WHAT'S MY LUCK!?!" onclick="return window.run()" />
<h1 id="results"></h1>
<script type="text/javascript">
var count = 0;
var result = '';
window.run = function() {
console.log('running');
var rand = Math.floor((Math.random() * 292000000)) + 1;
var check = 0;
while(true) {
@danieluhl
danieluhl / node_lottery_fast.js
Last active January 13, 2016 22:27
Quick and dirty odds based lotto game
var count = 0;
var run = function() {
var rand = Math.floor((Math.random() * 292000000)) + 1;
var check = 0;
while(true) {
check = Math.floor((Math.random() * 292000000)) + 1;
if(check === rand) {
break;
}
rand = Math.floor((Math.random() * 292000000)) + 1;
@danieluhl
danieluhl / node_lottery.js
Last active January 13, 2016 21:46
So you think you're gonna win the lottery? Run this node script to see how lucky you are!
// based on standard powerball lotto of 69 balls for the first 5 and 26 for the "power ball"
// note that this could potentially run forever, running in node should take ~30min but be warned, the browser is much slower!
var _ = require('underscore');
var balls = [];
var powerball = [];
for(var i = 1; i < 70; i++) {
balls.push(i);
}
for(i = 1; i < 27; i++) {
@danieluhl
danieluhl / node_lottery_1.js
Created January 13, 2016 21:23
not so random node lottery simulator distribution example
// somehow when running this in node I get strange numbers for the distribution of the final "random" number
// this assumes a lottery system of 6 balls, 5 picked randomly from a batch of 39 and the final one from 8
var fastLottery = function() {
var count = 0;
var running = true;
var distribution = [0, 0, 0, 0, 0, 0, 0, 0];
var finalCount = 0;
while (running) {
count++;
module.exports = function(grunt) {
grunt.registerTask('walk-ast', function() {
grunt.log.writeln('walking');
var file = require('file');
var uglify = require('uglify-js');
var result = [];
function walkAST(node) {
if (node instanceof uglify.AST_If) {
if (node.condition) {