Skip to content

Instantly share code, notes, and snippets.

💭
(っ◕‿◕)っ

Tony Crowe tcrowe

💭
(っ◕‿◕)っ
View GitHub Profile
@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 / 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 / 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 / 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
@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 / 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 / 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 / test-ionos-api-v1-curl.sh
Created Sep 20, 2019
Testing IONOS cloud, parsing headers, cURL, node
View test-ionos-api-v1-curl.sh
# 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 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();
You can’t perform that action at this time.