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
# 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 |
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
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))) |
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
[ | |
{ | |
"id": "194463a7.c501ac", | |
"type": "subflow", | |
"name": "Who is home?", | |
"info": "", | |
"in": [ | |
{ | |
"x": 60, | |
"y": 60, |
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 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]); |
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 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--; |
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 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" | |
} |
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 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]) => { |
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 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; | |
}, {}); |
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 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; |
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
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) { |
NewerOlder