Skip to content

Instantly share code, notes, and snippets.


Tony Crowe tcrowe

Block or report user

Report or block tcrowe

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
tcrowe / express-cache-buster.js
Created Sep 18, 2019
express cache busting - disable the default caching
View express-cache-buster.js
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");
tcrowe / src-middleware-authenticated.js
Created Sep 13, 2019
express, sapper, polka authentication idea
View src-middleware-authenticated.js
+ assuming you're using cookie-session or similar session
import authenticated from "./middleware/authenticated.js"
tcrowe / polka-express-http-proxy.js
Created Aug 23, 2019
polka sapper api proxy example
View polka-express-http-proxy.js
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");
tcrowe / example.ejs
Created Jun 20, 2019
hexo ejs hierarchical categories display
View example.ejs
function displayCategories(parent = undefined) { // start with no parent
.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();
tcrowe / binary-command-exists.zsh
Created Jun 2, 2019
Bash or ZSH: Check if a binary or command exists
View binary-command-exists.zsh
# 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/
tcrowe / build-electron-exe.zsh
Created Mar 19, 2019
Build electron app for windows using osx
View build-electron-exe.zsh
# tell electron packager's rcedit.exe to use wine64
export WINE=`which wine64`
export WINEARCH=win64
export WINE_ARCH=win64
# possibly interesting information
tcrowe / osx-snippet-delete.js
Created Mar 14, 2019
Delete all the snippets in Sublimetext's packages and also the user's installed packages
View osx-snippet-delete.js
⚠️ 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")
tcrowe / nice-browser-sync.zsh
Last active Feb 8, 2019
a specific and quiet browser-sync
View nice-browser-sync.zsh
browser-sync start -w --ss dist --port 9924 --host --logLevel error --no-notify --no-open --no-ui --no-online --no-ghost-mode
tcrowe /
Created Feb 6, 2019
new ssh host keys with "yes" confirmation
# 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? ---^
tcrowe / .eslintrc
Last active Nov 20, 2018
.eslintrc with prettier
View .eslintrc
"env": {
"es6": true,
"node": true
"plugins": ["prettier"],
"extends": [
You can’t perform that action at this time.