Skip to content

Instantly share code, notes, and snippets.

View sidouglas's full-sized avatar

sidouglas sidouglas

  • Sydney, Australia
View GitHub Profile
@sidouglas
sidouglas / instructions.txt
Created January 19, 2021 08:59
Connecting Barrier linux and machines
Refer: https://github.com/debauchee/barrier/issues/597
1. Start Barrier on Linux server - its IP is 192.168.1.135
2. Start Barrier on MacOS client, set it to connect to 192.168.1.135
Client shows "WARNING: failed to connect to sever: Timed out"
I verified Barrier was running and listening on the right port:
kit@wanderer:~$ sudo netstat -tupan | grep barrier
tcp6 0 0 :::24800 :::* LISTEN 31192/barriers
tcp6 0 0 :::35785 :::* LISTEN 31068/barrier
kit@wanderer:~$
@sidouglas
sidouglas / stringify.js
Created December 24, 2020 06:14
safe jsonStringify
/**
* jsonStringify
* Output any data structure to a string, without circular dep issues
* @param {*} data data to stringify
* @param {Number} space - indentation level
* @return {string}
*/
export function jsonStringify (data, space = 2) {
const getCircularReplacer = () => {
const seen = new WeakSet()
@sidouglas
sidouglas / jsdoc cheat sheet
Last active December 16, 2020 03:16
WIP jsdoc cheatsheet
/**
* @param {Object} model
* @param {boolean} [isOptional=false] // optional
* @param {{startDate:string, endDate: string}} [config={startDate:'startDate', endDate: 'endDate'}] //defaults set
* @param {object} defaults
* @param {number} defaults.nested // a nested object
* @return {{hasAnyDataSet: boolean, isValid: boolean, errorMessage: (string | null)}}
*/
@sidouglas
sidouglas / text
Created November 10, 2020 00:56
Add a new SSH Key to a server digital ocean
your machine: ssh-keygen in ~/.ssh -> all the defaults
your machine: pbcopy < thenewkey.pub
On server: append to ~/.ssh/authorized_keys the new public key - either via gui or another machine
your machine: ssh-add the thenewkey ( this is the private key )
// another thing to try
your machine: sudo nano /etc/ssh/sshd_config
alter -> PasswordAuthentication yes
sudo service sshd reload
@sidouglas
sidouglas / curl
Last active April 1, 2024 15:18
Slack API set status curl command
now=$(date +%s)
oneHour=$(($now + 3600))
curl 'https://slack.com/api/users.profile.set' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw "{
\"profile\": {
\"status_text\": \"On Lunch\",
\"status_emoji\": \":hamburger:\",
@sidouglas
sidouglas / git squash for git alias
Created July 2, 2020 06:43
Git squash command alias
[alias]
squash = "!f(){ git reset --soft HEAD~${1} && git commit --edit -m\"$(git log --format=%B --reverse HEAD..HEAD@{1})\"; };f"
@sidouglas
sidouglas / bitly.js
Created June 29, 2020 06:13
Node generate a bitly shortened url link
#!/usr/local/bin/node
const https = require("https");
const TOKEN = "YOUR_BITLY_TOKEN";
// get the script input variable from KBM otherwise use proces.argv.slice(2)[0] instead
const getStdIn = async () => {
let result = '';
process.stdin.setEncoding('utf8');
for await (const chunk of process.stdin) {
@sidouglas
sidouglas / eslintrc.json
Created June 22, 2020 10:23
Base eslint config file base
{
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": [
"eslint:recommended",
"prettier",
"prettier/react"
@sidouglas
sidouglas / Set Default Shell to (zsh nvm yarn)
Created February 5, 2020 23:17
Set default shell to zsh
# set default shell to zsh
set -g default-command /bin/zsh
set -g default-shell /bin/zsh
@sidouglas
sidouglas / throttle.sh
Created January 14, 2020 00:26
Mac Check if Processor is throttling shell script
pmset -g thermlog