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
type KeyGenerator<ItemProps> = (item: ItemProps) => string; | |
type Reducer<AggregatedProps, ItemProps> = ( | |
aggregation: AggregatedProps, | |
item: ItemProps, | |
idx: number, | |
) => AggregatedProps; | |
type Aggregation<AggregatedProps> = { | |
key: string; | |
items: ItemProps[]; | |
values: AggregatedProps; |
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 getRandomItem = list => list[Math.floor(Math.random() * list.length)]; | |
const components = [ | |
'matter/antimatter manifold', | |
'main deflector dish', | |
'kettle', | |
'Captain\'s copy of TMNT Issue #1 signed by Roger Moore', | |
'baffle plate', | |
'navigational laser', | |
'secondary plasma relay' |
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
var fs = require("fs"); //Load the filesystem module | |
const { join } = require('path'); | |
class FileNode { | |
constructor(path) { | |
const isDirectory = fs.lstatSync(path).isDirectory(); | |
this.path = path; | |
if (isDirectory) { |
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 stringifyExplicitObject(subject) { | |
return '{' + Object.entries(subject).map(function (entry) { | |
return entry[0] + ':' + stringify(entry[1]); | |
}).join(',') + '}'; | |
} | |
function stringifyArray(subject) { | |
return '[' + subject.map(function (element) { | |
return stringify(element); | |
}).join(',') + ']'; | |
} |
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
// Deliberately not using class because I want data to be private. | |
function MutableObject() { | |
const data = {}; | |
const get = name => (name === undefined) ? data : data[name]; | |
const setObject = value => Object.assign(data, value); | |
const setByFunction = fnc => fnc(this); | |
const setNameValue = (name, value) => data[name] = value; | |
const set = (a, b) => { | |
if (typeof a === 'object') { |
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 (document) { | |
var canvas = document.createElement('canvas'); | |
canvas.style.width='100%'; | |
canvas.style.height='100%'; | |
canvas.style.top=0; | |
canvas.style.left=0; | |
canvas.style.position='absolute'; | |
document.body.appendChild(canvas); | |
return canvas; | |
}(document)); |
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
// Takes a function with two parameters and allows them to be used in the format fnc(x)(y)(). | |
function functionalise(fnc) { | |
return function functionalised(x) { | |
return function (y) { | |
if (y === undefined) { | |
return x; | |
} else { | |
return functionalised(fnc(x, y)); | |
} | |
}; |
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 | |
// Usage example: pdftk stuff.pdf dump_data_fields | php pdf-fields.php | |
$stdin = file('php://stdin'); | |
// print_r($stdin); | |
$data = []; | |
$i = 0; | |
foreach($stdin as $idx => $line) { | |
$chunks = explode(': ', $line); |
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
#!/bin/bash | |
recent_restart=1 | |
while true; do | |
printf $(date +"%Y-%m-%d") | |
printf " " | |
printf $(date +"%H:%M:%S") | |
printf " " | |
if [[ $(ping -c 1 google.com) ]] > /dev/null 2>&1 ; then | |
if [ $recent_restart -eq 0 ] ; |
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
# Multi-window terminal | |
sudo apt-get install terminator | |
# Basic IDE | |
sudo apt-get install vim | |
# JRE | |
sudo apt-get install default-jre | |
# Clipboard, useful for copying rsa keys |
NewerOlder