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
/* | |
1. by default express is using etags caching which may not be preferable | |
2. add nocache middleware | |
3. disable etags for server | |
4. disable etags and last modified for static files middleware | |
*/ | |
const express = require("express"); |
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
/* | |
+ assuming you're using cookie-session or similar session | |
usage: | |
import authenticated from "./middleware/authenticated.js" | |
server.use(authenticated) | |
*/ |
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
/* | |
they usually use ES Modules but i used CommonJS here | |
you can port it to suite your need | |
*/ | |
const sirv = require("sirv"); | |
const polka = require("polka"); | |
const compression = require("compression"); |
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
<% | |
function displayCategories(parent = undefined) { // start with no parent | |
site.categories | |
.find({ parent }) // warehouse allows for complex queries | |
.sort("name") // sorting .sort("fieldName", 1) ascending or .sort("fieldName", -1) descending | |
.each(function(category) { | |
// count the child categories | |
const childCount = site.categories.find({ parent: category._id }).count(); | |
%> | |
<li> |
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
# which goes into dev null | |
# $? is the magic that tells us if it worked 0 = exists | |
if [[ `which nvm &>/dev/null && $?` != 0 ]]; then | |
source ~/.nvm/nvm.sh | |
fi |
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
#!/bin/zsh | |
# tell electron packager's rcedit.exe to use wine64 | |
export WINE=`which wine64` | |
export WINEARCH=win64 | |
export WINE_ARCH=win64 | |
# possibly interesting information | |
# https://wiki.winehq.org/Debug_Channels | |
# unset WINEDEBUG |
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
/* | |
⚠️ It does not prompt or ask permission. It just deletes all the snippets! | |
usage: node osx-snippet-delete.js | |
*/ | |
const path = require("path"); | |
const {exec} =require("child_process") |
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
# v--automatic yes | |
yes | ssh-keygen -q -t ed25519 -N '' -f /etc/ssh/ssh_host_ed25519_key | |
yes | ssh-keygen -q -t rsa -b 2048 -N '' -f /etc/ssh/ssh_host_rsa_key | |
# what bits do you want? ---^ |
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
#!/bin/zsh | |
browser-sync start -w --ss dist --port 9924 --host 127.0.0.1 --logLevel error --no-notify --no-open --no-ui --no-online --no-ghost-mode |
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
/* | |
# the basic echo bot | |
Instructions: | |
+ Pops up the docs in the browser | |
+ npm docs node-telegram-bot-api | |
+ Install the bot module | |
+ npm install node-telegram-bot-api | |
+ Dump in this code into a JS file like ./index.js |