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 | |
// half-hearted CSS minification | |
$css = preg_replace( | |
array('/\s*(\w)\s*{\s*/','/\s*(\S*:)(\s*)([^;]*)(\s|\n)*;(\n|\s)*/','/\n/','/\s*}\s*/'), | |
array('$1{ ','$1$3;',"",'} '), | |
file_get_contents('linked.css') | |
); | |
// embed as a data: uri | |
$base64css = rtrim(strtr(base64_encode($css), '+/', '-_'), '='); |
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
#!/usr/bin/python3 | |
from sseclient import SSEClient | |
import json | |
from math import sqrt | |
import winsound # NOTE: Windows only | |
from datetime import datetime, timezone, timedelta | |
''' | |
Version 2.1 (2023-07-07): A small script that alerts the user of lightning if it strikes within 16 km (10 miles) of your home position in the Nordics. | |
Based on lightning observations broadcast as SSE from The Norwegian Meteorological Institute, https://www.met.no/. |
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
// Sublime Text - Build System for Javascript | |
{ | |
"cmd": ["node", "$file"], | |
"selector": "source.js" | |
} |
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 crypto = require('crypto'); | |
var secret = crypto.randomBytes(24); | |
function encrypt(plaintext) { | |
var cipher = crypto.createCipher('aes-256-cbc', secret); | |
cipher.setAutoPadding(false); | |
var ciphertext = ''; | |
for (var i=0; i < plaintext.length; i+=16) { | |
ciphertext += cipher.update(plaintext.substr(i, i+16), 'utf8', 'base64'); |
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
/** | |
* TaskRepository class deals with task persistence | |
*/ | |
function TaskRepository() { | |
this.tasks = []; | |
this.nextId = 1; | |
} | |
/** | |
* Find a task by id | |
* Param: id of the task to find |