Skip to content

Instantly share code, notes, and snippets.

@sibbl
sibbl / Microsoft.PowerShell_profile.ps1
Last active March 17, 2021 10:43
Windows Terminal / PowerShell Core setup
# Setup as shown in https://docs.microsoft.com/en-us/windows/terminal/tutorials/powerline-setup
Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt -Theme paradox
function Alias_Repos { Set-Location ~/source/repos/$args }
Set-Alias repos Alias_Repos
function Clean-Git-Branches {
git fetch -p
SELECT CUMULATIVE_SUM(difference) FROM (SELECT DIFFERENCE(mean) FROM (SELECT MEAN(value) FROM "kWh" WHERE ("domain" = 'sensor' AND "entity_id" = 'power_washing_machine_energy') AND $timeFilter GROUP BY time($__interval) fill(null)))
[
{
"id": "194463a7.c501ac",
"type": "subflow",
"name": "Who is home?",
"info": "",
"in": [
{
"x": 60,
"y": 60,
const input = document.querySelector("body").textContent.split("\n").filter(x => x);
const points = input.map(str => str.split(",").map(part => parseInt(part)));
const distance = ([x1, y1], [x2, y2]) => Math.abs(x1 - x2) + Math.abs(y1 - y2);
const [maxX, maxY] = points.reduce(([maxX, maxY], [x, y]) => {
return [x > maxX ? x : maxX, y > maxY ? y : maxY];
}, [0,0]);
const input = document.querySelector("body").textContent.trim();
const removePairs = (str) => {
let removedSomething = false;
for(let i = 0; i < str.length - 1; i++) {
const firstChar = str[i];
const secondChar = str[i+1];
if(firstChar !== secondChar && firstChar.toLowerCase() == secondChar.toLowerCase()) {
str = str.substr(0, i) + str.substr(i+2, str.length - i - 2);
i--;
const input = document.querySelector("body").textContent.split("\n").filter(x => x);
const regexp = /^\[(.*)\]\s*(Guard #(\d+) begins shift|.*)$/;
const MessageTypes = {
FALLS_ASLEEP: "falls asleep",
WAKES_UP: "wakes up",
SHIFT_BEGIN: "guard begins shift",
UNKNOWN: "unknown"
}
const input = document.querySelector("body").textContent.split("\n").filter(x => x);
const regexp = /^#(\d+)\s*@\s*(\d+)\s*,\s*(\d+):\s*(\d+)x(\d+)$/;
const allIds = new Set();
const matrix = input
.map(line => {
let [, id, x, y, width, height] = line.match(regexp);
const rect = { id, width, height, x, y };
return Object.entries(rect).reduce((acc, [key, value]) => {
const input = document.querySelector("body").textContent.split("\n").filter(x => x);
const countChars = str => str.split("").reduce((a,b) => {
if(a[b] === undefined) {
a[b] = 0;
}
a[b]++;
return a;
}, {});
const input = document.querySelector("body").textContent.split("\n").filter(x => x);
const numbers = input.map(i => Number(i));
const frequencies = new Set([0]);
let firstSum, sum = 0, firstFrequencyDuplicate;
do {
sum = numbers.filter(x => x).reduce((a,b) => {
const currentFrequency = a + b;
if(firstFrequencyDuplicate === undefined && frequencies.has(currentFrequency)) {
firstFrequencyDuplicate = currentFrequency;
async void Signup(User user) {
await user.validate();
var salt = await Bcrypt.genSalt(10);
var saltedHashedPassword = await Bcrypt.hash(user?.Password, salt, null);
return await User.insertIntoDatabase(user, saltedHashedPassword);
}
/* or even */
async void Signup(User user) {