This file contains hidden or 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
# usage: | |
# $ = "1+2" | |
# 3 | |
# quotes are necessary only for some expressions like *, but better to use them all the time just to be safe | |
function = { | |
echo "$1" | bc -l | |
} |
This file contains hidden or 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
# usage | |
# $ deg 10c # Celsius to Fahrenheit | |
# 50.0 | |
# | |
# $ deg 115f # Fahrenheit to Celsius | |
# 46 | |
deg() { | |
unit=${1:(-1)} | |
d=${1:0:(-1)} | |
if [ $unit = c ] |
This file contains hidden or 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/env zx | |
$.verbose = false; | |
console.log('Retrieving granted API permissions...'); | |
const apiPermissions = JSON.parse(await $`m365 spo sp grant list -o json`); | |
for (let i = 0; i < apiPermissions.length; i++) { | |
const permission = apiPermissions[i]; | |
console.log(`Removing permission ${permission.Resource}/${permission.Scope} (${permission.ObjectId})...`); | |
try { |
This file contains hidden or 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/env zx | |
$.verbose = false; | |
console.log('Retrieving permission requests...'); | |
const permissionRequests = JSON.parse(await $`m365 spo sp permissionrequest list -o json`); | |
for (let i = 0; i < permissionRequests.length; i++) { | |
const request = permissionRequests[i]; | |
console.log(`Removing request ${request.Resource}/${request.Scope} (${request.Id})...`); | |
try { |
This file contains hidden or 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/env zx | |
const fs = require('fs'), | |
path = require('path'); | |
const nonWebPFiles = fs | |
.readdirSync(process.cwd()) | |
.filter(file => !file.endsWith('.webp')); | |
const lastHour = new Date(); | |
lastHour.setHours(lastHour.getHours() - 1); |
This file contains hidden or 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
export function CacheMiddleware(expirationConfig) { | |
this.nextMiddleware = undefined; | |
this.expirationConfig = expirationConfig; | |
const getHeaders = (headers) => { | |
const h = {}; | |
for (var header of headers.entries()) { | |
h[header[0]] = header[1]; | |
} | |
return h; |
This file contains hidden or 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
# https://nodejs.org/en/docs/guides/simple-profiling/ | |
NODE_ENV=production node --prof app.js | |
node --prof-process isolate-0xnnnnnnnnnnnn-v8.log > processed.txt |
This file contains hidden or 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
$now = Get-Date | |
Get-ChildItem | ? { | |
($now - $_.LastWriteTime).totalhours -le 1 | |
} | % { | |
cwebp $_.Name -o $($_.BaseName+".webp") | |
} |
This file contains hidden or 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 fs = require('fs'); | |
const os = require('os'); | |
const path = require('path'); | |
function readdirR(dir) { | |
return fs.statSync(dir).isDirectory() | |
? Array.prototype.concat(...fs.readdirSync(dir).map(f => readdirR(path.join(dir, f)))) | |
: dir; | |
}; |
This file contains hidden or 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 ts = require('typescript'); | |
const path = require('path'); | |
const fs = require('fs'); | |
function getAsEnumerable(file, node) { | |
const nodes = [node]; | |
node.getChildren(file).forEach(n => { | |
nodes.push(...getAsEnumerable(file, n)); | |
}); |