Skip to content

Instantly share code, notes, and snippets.

View JamesMarino's full-sized avatar
🇦🇺
Working from Home

James Marino JamesMarino

🇦🇺
Working from Home
View GitHub Profile
@JamesMarino
JamesMarino / install-home-assistant-no-micro-sd-adapter.md
Last active July 23, 2021 15:30
Install Home Assistant on Raspberry Pi with No Micro SD Card

Install Home Assistant on Raspberry Pi with No Micro SD Card

Unfortunately I did not have a USB C to Micro SD adapter available so things had to be done the hard way.

  1. Live Boot from Thumbdrive using the Raspberry Pi Imager to load the OS on the thumbdrive
  2. Add an empty file named ssh in the root boot directory
  3. SSH into the machine, check device address on router and ssh pi@10.X.X.X with password raspberry

Run the following on the Raspberry Pi after SSH'ing into it.

  1. Phsyically insert the Micro SD card into the Pi Now
@JamesMarino
JamesMarino / useful_information_gathering.md
Last active July 31, 2020 13:11
Various useful commands

Useful Information Gathering

  1. List all DNS Records
dig any example.com @`dig +short  SOA example.com | cut -d' ' -f1`
  1. Get Nameservers
nslookup 1.2.3.4
@JamesMarino
JamesMarino / jetbrains_find_replace_regex_capture_groups.md
Created June 11, 2020 01:55
JetBrains Webstorm Find and Replace Capture Groups

To Find and Replace using Capture Groups

  1. Make sure the Regex Box is ticked
  2. Place your regex inside a capture group in your find box () e.g. \n(query \= \".+)\n - query = text_here will be stored in the first capture group
  3. Use $1 to use the captured group in the replace box

Example

Example using Webstorm Webstorm

@JamesMarino
JamesMarino / unlike_pages_facebook.js
Last active February 24, 2022 21:01
Unlike All Pages Facebook
// 1. Navigate to https://www.facebook.com/pages/?category=liked
// 2. Open up console and run the below, it will unlike all the current shown liked pages
const buttons = document.getElementsByTagName('button');
const likedText = 'Liked';
for (let button of buttons) {
if (button.innerHTML && button.innerHTML.includes()) {
button.click(likedText);
}
@JamesMarino
JamesMarino / google_photos_upload_prep.sh
Created April 29, 2018 07:09
Google Photos Upload Prep
# Change to directory with photos
cd /Users/me/photo/upload
# Flatten Current Directory (Forces overwrite)
find . -mindepth 2 -type f -exec mv -f '{}' . ';'
# Delete all folders (Assumes empty)
find . -type d -delete
# Split into 5000 files per folder
@JamesMarino
JamesMarino / arduino_nano_clone_setup.md
Last active November 10, 2017 16:09
Arduino Nano Clone - Setup - Mac OSX

Arduino Nano Clone - Setup - Mac OSX

Instructions

  1. Install Arduino Studio

  2. Install USB Microcontroller Driver for WCH CH340G

2.2 Go to WCH manufacturer site - http://www.wch.cn/

@JamesMarino
JamesMarino / api_gateway_custom_authoriser.js
Created October 29, 2017 00:12
Lambda Custom Authoriser API Gateway
exports.handler = (event, context, callback) => {
var token = event.authorizationToken;
switch (token.toLowerCase()) {
case 'allow':
callback(null, generatePolicy('user', 'Allow', event.methodArn));
break;
case 'deny':
callback(null, generatePolicy('user', 'Deny', event.methodArn));
break;
@JamesMarino
JamesMarino / useful_cognito.md
Created August 31, 2017 06:48
Useful Cognito
@JamesMarino
JamesMarino / TouchBar
Created May 15, 2017 01:53
Disable the TouchBar
#!/bin/bash
function enableTouchBar() {
local presentationModeProperties="<dict><key>app</key><string>fullControlStrip</string><key>appWithControlStrip</key><string>fullControlStrip</string><key>fullControlStrip</key><string>app</string></dict>"
defaults delete com.apple.touchbar.agent PresentationModeGlobal
defaults write com.apple.touchbar.agent PresentationModeFnModes $presentationModeProperties
launchctl load /System/Library/LaunchAgents/com.apple.controlstrip.plist
@JamesMarino
JamesMarino / VigenereBreaker.js
Created March 18, 2017 03:14
Vigenere Breaker
"use strict";
function getIncidenceOfCoincidence(sequence) {
// Get frequency
let frequencyTable = {};
for (let letter of sequence) {
if (!frequencyTable.hasOwnProperty(letter)) {
frequencyTable[letter] = 1;