Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
(っ◕‿◕)っ

Tony Crowe tcrowe

💭
(っ◕‿◕)っ
View GitHub Profile
@tcrowe
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
tcrowe / install-and-configure-mumble-server.zsh
Last active Apr 26, 2020
install and configure mumble server - set variables, run it, talk 👍
View install-and-configure-mumble-server.zsh
#!/bin/zsh
password=CHANGE1
serverpassword=CHANGE2
welcometext=CHANGE3
ssh my-server << EOF
# install
apt install -y mumble-server
@tcrowe
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/nvm.sh
fi
@tcrowe
tcrowe / npm-auth-token.js
Last active Feb 2, 2020
npm auth token with zsh or bash and curl or node
View npm-auth-token.js
// npm install superagent
const superagent = require("superagent");
// this is verdaccio's url ↓ but you could use like registry.npmjs.com if that is allowed in their TOS
const registryUrl = "http://127.0.0.1:4873";
const username = "myusername2";
const password = "mypassword2";
const frm ={
name: username,
@tcrowe
tcrowe / object-ification-of-promise.js
Created Feb 1, 2020
Turn async await promise into object result
View object-ification-of-promise.js
/**
* Object-ification of a promise result
* @method to
* @param {promise} p
* @returns {array}
*/
const to = p =>
p.then(res => ({ err: null, res }))
.catch(err => ({ err }));
@tcrowe
tcrowe / tuple-ification-of-promise.js
Created Feb 1, 2020
Turn async await into tuple output
View tuple-ification-of-promise.js
/**
* Tuple-ification of a promise result
* @method to
* @param {promise} p
* @returns {array}
*/
const to = p => p.then(res => [null, res]).catch(err => [err]);
/**
@tcrowe
tcrowe / clickable-svg-path-note.md
Created Sep 24, 2019
Reminer about clickable SVG path
View clickable-svg-path-note.md

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
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
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
tcrowe / oblierate-service.zsh
Created Jan 29, 2020
Obliterate systemd service
View oblierate-service.zsh
#!/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
You can’t perform that action at this time.