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 el<K extends keyof HTMLElementTagNameMap>( | |
tagName: K, | |
props?: Partial<HTMLElementTagNameMap[K]> & { | |
ref?: (r: HTMLElementTagNameMap[K]) => void; | |
}, | |
...children: Array<HTMLElement | string | null | undefined> | |
): HTMLElementTagNameMap[K] { | |
const element = document.createElement(tagName); | |
Object.assign(element, props); |
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
/** | |
* @param {Array[Number]} cell Coordinates of the cell to return a value for | |
* @param {Number} xMax The number of cells across the x axis | |
* @param {Number} yMax The number of cells across the y axis | |
* @param {Array[Array[Number]} snake Coordinates of the position of the snake from head to tail. E.g. [[4, 1], [3, 1]] | |
* @param {Array[Number]} point Coorodinates of the point. | |
*/ | |
function heuristic(cell, xMax, yMax, snake, point) { | |
let snakeHead = snake[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
text content: | |
'AF' => 'Afghanistan' | |
'AX' => 'Aland Islands' | |
'AL' => 'Albania' | |
'DZ' => 'Algeria' | |
... | |
(regex mode on) | |
find: ('\w\w') => ('.*') | |
replace: $2 => $1 |
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
for i in {1..30};do curl -s -w "%{time_total}\n" -o /dev/null http://example.com; done |
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 | |
until [ $STATUS = "200" ]; do | |
STATUS=`curl -sL -w "%{http_code}\\n" "https://www.example.com/" -o /dev/null` | |
echo $STATUS | |
sleep 5 | |
done | |
echo "Website back up" | |
osascript -e 'display notification "Website back up" with title "isup"' |
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
Show hidden characters
{ | |
"ensure_newline_at_eof_on_save": true, | |
"font_size": 12, | |
"ignored_packages": | |
[ | |
"Vintage" | |
], | |
"tab_size": 2, | |
"translate_tabs_to_spaces": true, | |
"trim_trailing_white_space_on_save": true, |
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 distances = `London to Dublin = 464 | |
London to Belfast = 518 | |
Dublin to Belfast = 141`.split("\n"); | |
var cities = {}; | |
var shortest = {distance:null, route:null}; | |
//Turn the inputs into objects | |
for (var i=0; i<distances.length; i++) { | |
var distance = distances[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
var lines = `123 -> x | |
456 -> y | |
x AND y -> d | |
x OR y -> e | |
x LSHIFT 2 -> f | |
y RSHIFT 2 -> g | |
NOT x -> h | |
NOT y -> i`.split('\n'); |
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 scroll_to(element, duration = 500, easing = 'easeInOutQuart') { | |
var start_pos = document.body.scrollTop, | |
end_pos = element.offsetTop, | |
distance = end_pos - start_pos, | |
start_time = Date.now(), | |
end_time = start_time + duration; | |
var easingFunctions = { |
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
<style> | |
#images * { | |
width: 140px; | |
} | |
</style> | |
<p id='status'></p> | |
<div id='images'></div> | |
<button onclick='fusker.start()'>--go--</button> |
NewerOlder