This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function given (_val) { | |
console.assert(typeof _val === 'number') | |
var val = _val | |
// look out it's the comma operator! | |
const multiply = (num) => (val *= num, methods) | |
const add = (num) => (val += num, methods) | |
const divide = (num) => (val /= num, methods) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Game { | |
function __construct () { | |
$this->players = array(); | |
} | |
/* deal 2 cards to each player in the game */ | |
public function deal () { | |
foreach($this->players as $player_name => $player) { | |
$card_values = rand(2, 21); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$data = json_decode(file_get_contents('php://input'), TRUE); | |
$space_id = $data['id']; | |
$car_size = $data['size']; | |
$reg_space_count = array( | |
"type" => "reg", | |
"available" => 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const n = (fn, count) => count === 0 ? fn(count) : (fn(count), n(fn, count - 1)) | |
const show = (x) => { console.log(`showing ${x}`) } | |
n(show, 4) | |
/** | |
* showing 4 | |
* showing 3 | |
* ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="base"> | |
<div class="completed"></div> | |
<div class="circle bg-blue"> | |
<div class="circle fg-white"> | |
<p class="percentage">50%</p> | |
</div> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get elements by id: | |
document.getElementById('logout-button'); | |
// returns single element | |
// => <button id='logout-button'>Logout!</button> | |
// get elements by class name: | |
document.getElementsByClassName('order-items'); | |
// returns HTML collection of elements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head> | |
<title>adding multiple event listeners</title> | |
<style> | |
.square { | |
height: 200px; | |
width: 200px; | |
border: 2px solid green; | |
display: inline-block; | |
transition: width 1.5s, height 1.5s, background-color 1.5s, transform 1.5s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('lookup-multicast-dns/global') | |
const net = require('net') | |
const jsonStream = require('duplex-json-stream') | |
const host = process.argv[3] | |
const nick = process.argv[2] || 'guest' | |
var socket = net.connect(9494, `${host}.local`) | |
socket = jsonStream(socket) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function rockPaperScissors(num) { | |
var res = [] | |
var t = ['rock', 'paper', 'scissors'] | |
if (num < 1) return [] | |
function rps (part, n) { | |
part = part || [] | |
if (part.length === n) return res.push(part) | |
for (let i = 0, len = t.length; i < len; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Write a function mergeRanges that takes an array of meeting time ranges and# | |
* | |
* Example: | |
* var times = [[0, 1], [3, 5], [4, 8], [10, 12], [9, 10] | |
* | |
* mergeRanges(times); -> [[0, 1], [3, 8], [9, 12]] | |
* | |
* Do not assume the ranges are in order | |
*/ |