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
| import express from 'express'; | |
| import serveIndex from 'serve-index'; | |
| const PUBLIC_DIR = '/public'; | |
| const PORT = 3000; | |
| const app = express(); | |
| app.use(express.static(PUBLIC_DIR), serveIndex(PUBLIC_DIR, { 'icons': true })); |
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
| ;=To activate this file execute: reg add "HKCU\Software\Microsoft\Command Processor" /v Autorun /d "doskey /macrofile=\"%homedrive%%homepath%/aliases.doskey\"" /f | |
| ;=If you don't want to restart the terminal execute: doskey /macrofile="%homedrive%%homepath%/aliases.doskey" | |
| code=code-insiders $* | |
| gb= git branch $* | |
| gcam=git commit -am $* | |
| gco=git checkout $* | |
| gcod= git checkout develop | |
| gl=git log --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" --abbrev-commit $* | |
| gm=git merge --no-edit $* | |
| gpr=git pull --rebase --autostash $* |
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 useAbortableAsyncResult<T extends any = any>( | |
| fn: (signal: AbortSignal, clearData: () => void) => Promise<T>, | |
| dependencies: DependencyList = [] | |
| ) { | |
| const isMounted = React.useRef(false); | |
| const abortController = React.useRef<AbortController>(); | |
| const [isInitialized, setIsInitialized] = React.useState(false); | |
| const [data, setData] = React.useState<T>(); | |
| const [error, setError] = React.useState<Error>(); | |
| const [isLoading, setIsLoading] = React.useState(false); |
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 qrcode = require('qrcode-terminal'); | |
| const open = require('open'); | |
| // setup your httpServer as you like (express.js) | |
| // ... | |
| // The '0.0.0.0' binding is important here, otherwise the addresses will not work | |
| httpsServer.listen(1337, '0.0.0.0', () => { | |
| for (const [_, addresses] of Object.entries(os.networkInterfaces())) { | |
| const relevantAddresses = addresses.filter((a) => !a.internal && a.family === 'IPv4').map((a) => a.address); |
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
| @import './variables'; | |
| // @import "~bootstrap/scss/bootstrap"; | |
| @import '~bootstrap/scss/_functions'; | |
| @import '~bootstrap/scss/_variables'; | |
| @import '~bootstrap/scss/_mixins'; | |
| @import '~bootstrap/scss/_root'; | |
| @import '~bootstrap/scss/_reboot'; | |
| @import '~bootstrap/scss/_type'; |
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
| alias yo=yarn outdated $* | |
| alias yup=yarn upgrade-interactive --latest $* | |
| alias yes=yarn start $* | |
| alias yb=yarn build $* | |
| alias y=yarn $* | |
| alias gco=git checkout $* | |
| alias gm=git merge $* | |
| alias gcam=git commit -am $* | |
| alias gs=git status $* | |
| alias gps=git push $* |
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 cluster = require('cluster'); | |
| const numCPUs = require('os').cpus().length - 1; | |
| const {promisify} = require('util'); | |
| const pbkdf2 = promisify(require('crypto').pbkdf2); | |
| if (cluster.isMaster) { | |
| const workers = []; | |
| console.log(`Starting ${numCPUs} workers…`) | |
| for (let i = 0; i < numCPUs; i += 1) { | |
| workers.push(cluster.fork()); |
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 http = require('http'); | |
| const {promisify} = require('util'); | |
| http.get[promisify.custom] = function getAsync(options) { | |
| return new Promise((resolve, reject) => { | |
| http.get(options, (response) => { | |
| response.end = new Promise((resolve) => response.on('end', resolve)); | |
| resolve(response); | |
| }).on('error', reject); | |
| }); |
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
| "use strict"; | |
| import fs from 'fs'; | |
| import express from 'express'; | |
| import bodyParser from 'body-parser'; | |
| import Handlebars from 'handlebars'; | |
| import wkhtmltopdf from 'wkhtmltopdf'; | |
| const app = express(); | |
| app.use(bodyParser.json()); |