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 / install-and-configure-mumble-server.zsh
Last active April 26, 2020 00:26
install and configure mumble server - set variables, run it, talk 👍
#!/bin/zsh
password=CHANGE1
serverpassword=CHANGE2
welcometext=CHANGE3
ssh my-server << EOF
# install
apt install -y mumble-server
@tcrowe
tcrowe / object-ification-of-promise.js
Created February 1, 2020 20:20
Turn async await promise into object result
/**
* 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 February 1, 2020 20:12
Turn async await into tuple output
/**
* 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 / npm-auth-token.js
Last active February 2, 2020 18:55
npm auth token with zsh or bash and curl or node
// 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 / 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'
@tcrowe
tcrowe / sapper-preload-example.svelte
Created September 25, 2019 21:17
Sapper preload instead of using stores for dynamic data
<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 / clickable-svg-path-note.md
Created September 24, 2019 20:39
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
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 / 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();