Skip to content

Instantly share code, notes, and snippets.

View Hillsie's full-sized avatar
👋

Hillsie Hillsie

👋
  • Sydney, Australia
  • 15:07 (UTC +10:00)
View GitHub Profile
@Hillsie
Hillsie / gist:127110790882bef277cf113e38acd28b
Last active October 18, 2018 02:45
Uncomplicated Firewall Rules - ufw
# smtp.office365.com. There are a whole lot more ip's to white list including IPv6
### All the smtp.office365.com rules
sudo ufw reject in 587
sudo ufw allow from 127.0.0.1 port 587 to 13.107.9.152/31 port 587
sudo ufw allow from 127.0.0.1 port 587 to 13.107.18.10/31 port 587
sudo ufw allow from 127.0.0.1 port 587 to 13.107.19.10/31 port 587
sudo ufw allow from 127.0.0.1 port 587 to 13.107.128.0/22 port 587
sudo ufw allow from 127.0.0.1 port 587 to 23.103.160.0/20 port 587
sudo ufw allow from 127.0.0.1 port 587 to 23.103.224.0/19 port 587
sudo ufw allow from 127.0.0.1 port 587 to 40.96.0.0/13 port 587
@Hillsie
Hillsie / get-tweet-collection-by-id.js
Created December 23, 2018 13:32
Twitter API call with native https NodeJS
const http = require("https");
// prettier-ignore
const options = {
"method": "GET",
"hostname": "api.twitter.com",
"port": 443,
"path": "/1.1/collections/entries.json?id=custom-90708098097098-fake",
"headers": {
"authorization":`OAuth oauth_consumer_key="yourtwitterconsumerkey",oauth_token="yourregisteredtwittertoken", oauth_signature_method="HMAC-SHA1",oauth_timestamp="atimestame",oauth_nonce="anonceofyourchoic",oauth_version="1.0",oauth_signature="anoauthtweet"`,
"cache-control": "no-cache"
@Hillsie
Hillsie / SignInWithTwitter.js
Created December 31, 2018 08:33 — forked from rhussmann/SignInWithTwitter.js
Simple 'sign in with Twitter' implementation in node.js
var http = require('http'),
sys = require('sys'),
URL = require('url'),
querystring = require('querystring'),
OAuth = require('oauth').OAuth;
var oa = new OAuth('https://api.twitter.com/oauth/request_token',
'https://api.twitter.com/oauth/access_token',
'YOUR APP CONSUMER KEY HERE',
'YOUR APP CONSUMER SECRET HERE',
@Hillsie
Hillsie / OAuthSignInToTwitterGetTweetCollection.js
Created December 31, 2018 08:55
Basic OAuth sign in to Twitter and get tweet collection defined in tweetdeck
// OAuth handles the nounce and tokens for you under the hood, but seems like OAuth is nolonger being maintained.
// Works as of 31 Dec 2018, unless I added a typo while obfusicating secrets... think not.
const OAuth = require('oauth').OAuth;
const oauth = new OAuth(
'https://api.twitter.com/oauth/request_token',
'https://api.twitter.com/oauth/access_token',
'your application consumer key',
'your application secret',
'1.0A',
@Hillsie
Hillsie / preventCollectingOwnGA.js
Last active March 15, 2020 22:23
Prevent Collection of Your Own Google Analytics Results
(function analyticsIFFE(){
const googleTagObj = { hostname :'yourDomainName', gtag: 'UA-XXXXXX-2'};
if (document.location.hostname === googleTagObj.hostname){
const documentHead = document.head;
const scriptTag = document.createElement("script");
scriptTag.async = 1;
scriptTag.src = `https://www.googletagmanager.com/gtag/js?id=${googleTagObj.gtag}`
documentHead.appendChild(scriptTag);
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
function getTranslationMap(rhyme) {
const rhymes = {
"apples and pears": "Stairs",
"hampstead heath": "Teeth",
"loaf of bread": "Head",
"pork pies": "Lies",
"whistle and flute": "Suit",
};
return rhymes[rhyme.toLowerCase()] ?? "Rhyme not found";
@Hillsie
Hillsie / Emotion_and_material-ui5.md
Last active October 16, 2021 06:06
Notes Styling with material-ui v5 and Emotion

Styling with Material-ui V5.0 and Emotion as primary

Material UI

  1. Follow material-ui migration v4 to v5. May require manual upgrade with legacy refactor in future.
  2. As part of the package:
"@emotion/react": "^11.xxx",
"@emotion/styled": "^11.xxx",
"@mui/icons-material": "^5.0.1",
"@mui/lab": "^5.0.0-alpha.49",
@Hillsie
Hillsie / docker-help.md
Created December 30, 2021 04:08 — forked from bradtraversy/docker-help.md
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

@Hillsie
Hillsie / TypeScriptCallBackPromise.md
Last active July 29, 2022 09:09
typing a typescript callback that resolves a promise

Typing a callback that resoles a promise

cb:()=> Promise<void> = () => Promise.resolve();
@Hillsie
Hillsie / validate_abn.ts
Created February 6, 2023 02:31
Validate ABN - (Australian Business Number)
function validateABN(abn: string): boolean {
/*
@name: validateABN
@param {string} abn
@returns {boolean}
@link https://abr.business.gov.au/Help/AbnFormat
*/
const weightingFactors = [10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
const cleanedABN = abn.replace(/\s/g, '')