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 / keymap.cson
Created Oct 25, 2019
atom editor, emmet, svelte language-specific tab trigger, keymap.cson
View keymap.cson
# svelte language-specific tab trigger
# NOT source.js scope -------------------------------v
'atom-text-editor[data-grammar="source svelte"]:not(.source.js)':
'tab': 'emmet:expand-abbreviation-with-tab'
tcrowe / sapper-preload-example.svelte
Created Sep 25, 2019
Sapper preload instead of using stores for dynamic data
View sapper-preload-example.svelte
<script context="module">
Preload runs on the client AND server
export async function preload({ path, query, params, session }) {
console.log('path', path)
console.log('query', query)
console.log('params', params)
tcrowe /
Created Sep 24, 2019
Reminer about clickable SVG path

A pal discovered a trick with SVG paths. It was not clickable by default!

He found that you must customize it with CSS:

figured it out, for future reference you need to set 
the "pointer-events" property on a path to make it
clickable. There are various options available.

Found a handy little reference here... 
tcrowe /
Created Sep 20, 2019
Testing IONOS cloud, parsing headers, cURL, node
# This approach works. ✅
# The idea is possibly cURL is tolerant to invalid headers.
# How to test:
# 1. Install cURL
# 2. In your terminal copy and paste:
curl -v -H 'X-TOKEN: 1234' ''
tcrowe / extending-svelte-store-writable.js
Created Sep 19, 2019
extending the svelte store writable with your own methods
View extending-svelte-store-writable.js
const { writable, get } = require("svelte/store");
const merge = require("lodash/merge");
* A svelte store writable with two extra methods
* Usage:
* const store = customStore({ name: "Erasmus" });
* store.merge({ name: "Billy" });
* store.reset();
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/
You can’t perform that action at this time.