Skip to content

Instantly share code, notes, and snippets.

View tcrowe's full-sized avatar
💭
Account archived | See link

Tony Crowe tcrowe

💭
Account archived | See link
View GitHub Profile
@tcrowe
tcrowe / osx-snippet-delete.js
Created March 14, 2019 17:25
Delete all the snippets in Sublimetext's packages and also the user's installed packages
/*
⚠️ 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
tcrowe / build-electron-exe.zsh
Created March 19, 2019 09:09
Build electron app for windows using osx
#!/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
@tcrowe
tcrowe / example.ejs
Created June 20, 2019 18:22
hexo ejs hierarchical categories display
<%
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>
@tcrowe
tcrowe / extending-svelte-store-writable.js
Created September 19, 2019 19:54
extending the svelte store writable with your own methods
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
tcrowe / express-cache-buster.js
Created September 18, 2019 19:15
express cache busting - disable the default caching
/*
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
tcrowe / nice-browser-sync.zsh
Last active December 11, 2019 00:20
a specific and quiet browser-sync
#!/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
@tcrowe
tcrowe / optimize-and-shut-up-npm.sh
Last active December 21, 2019 22:08
optimize and shut-up npm
npm config set -g send-metrics false
npm config set -g metrics-registry "http://127.0.0.1:11923"
npm config set -g ham-it-up false
npm config set -g optional false
npm config set -g loglevel error
npm config set -g init-version "0.1.0"
npm config set -g init-license "UNLICENSED"
npm config set -g init-author-url ""
npm config set -g init-author-email ""
npm config set -g init-author-name ""
@tcrowe
tcrowe / test-ionos-api-v1-curl.sh
Created September 20, 2019 21:11
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 https://curl.haxx.se/
# 2. In your terminal copy and paste:
curl -v -H 'X-TOKEN: 1234' 'https://cloudpanel-api.ionos.com/v1/servers'
@tcrowe
tcrowe / oblierate-service.zsh
Created January 29, 2020 23:53
Obliterate systemd service
#!/bin/zsh
#
# Obliterate systemd service
# https://superuser.com/questions/513159/how-to-remove-systemd-services#936976
#
systemctl stop $1 2>/dev/null || true
systemctl stop $1.service 2>/dev/null || true
systemctl disable $1 2>/dev/null || true
@tcrowe
tcrowe / keymap.cson
Created October 25, 2019 19:56
atom editor, emmet, svelte language-specific tab trigger, 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'