Skip to content

Instantly share code, notes, and snippets.

View alexcu's full-sized avatar

Alex Cummaudo alexcu

View GitHub Profile
@alexcu
alexcu / bookmarklet
Last active September 22, 2021 06:03
Extract my Locke ID from realestate.com.au's cookies
javascript:(function()%7Balert(JSON.parse(atob(document.cookie.split(%22%3B%22).map(c%20%3D%3E%20c.trim()).filter(c%20%3D%3E%20c.startsWith(%22reauinf%22))%5B0%5D.split(%22%3D%22)%5B1%5D)).lid)%7D)()
@alexcu
alexcu / code-from-demo.py
Last active June 22, 2020 02:44
Small python script to extract timestamps from VHS tapes.
import cv2
import pytesseract
import re
cap = cv2.VideoCapture("/Users/Alex/Desktop/untitled folder/Home Movie No 2.m4v")
fps = round(cap.get(cv2.CAP_PROP_FPS))
frame_num = 0
NTH_SECONDS = 5
@alexcu
alexcu / bitly.sh
Last active March 27, 2019 04:31
Bitly link generator for macOS
#/usr/bin/env bash
# Refer to http://bit.ly/2TF7FU8 on how to find your Bearer and Group GUID
link=$(curl -s -X POST \
https://api-ssl.bitly.com/v4/bitlinks \
-H 'Authorization: Bearer XXXXXXXX' \
-H 'Content-Type: application/json' \
-d "{
\"group_guid\": \"XXXXXXXX\",
@alexcu
alexcu / Export Papers Library to BibTeX.scpt
Created August 6, 2018 05:34
Exports Papers Library to a BibTeX file
activate application "Papers"
tell application "System Events"
tell process "Papers"
keystroke "1" using command down
set allPapers to text field 1 of row 2 of outline 1 of scroll area 1 of scroll area 1 of group 1 of group 1 of splitter group 1 of group 1 of group 1 of splitter group 1 of group 1 of group 1 of window 1
click allPapers
tell table 1 of scroll area 1 of group 1 of group 1 of splitter group 1 of group 1 of splitter group 1 of group 2 of splitter group 1 of group 1 of group 1 of window 1
keystroke "a" using command down
keystroke "c" using {command down, control down}
end tell
@alexcu
alexcu / comp2005_sample_exam_answers.c
Created May 29, 2018 05:58
COMP2005 Sample Exam Answers
/********* Q1 **********/
int amicable_pair(int n1, int n2) {
int sum_factors_n1 = 0, sum_factors_n2 = 0;
int i;
for (i = 1; i < n1; i++) {
if (n1 % i == 0) {
sum_factors_n1 += i;
}
}
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//
// Arbitrary string encapsulator type
//
typedef struct string_t {
char *chars;
} string_t;
#include <stdio.h>
#include <stdlib.h>
typedef enum supermarket_t {
COLES, WOOLIES, ALDI
} supermarket_t;
typedef struct product_t {
char *name;
float price;
@alexcu
alexcu / myio.h
Last active April 30, 2018 08:05
// ============================
// = User Input Function in C =
// ============================
#include <stdio.h>
//
// The my_string type can be used to represent a "string" in C.
// This needs to be a struct so that it can be returned from
@alexcu
alexcu / home.sh
Last active February 18, 2018 05:23
sed -i -e 's/home:/home:windows /g' /etc/nsswitch.conf
@alexcu
alexcu / macos_version.sh
Last active October 30, 2017 03:46
Get the major and minor versions of macOS from the command line
# Gets the macOS major/minor versions
mac_os_major_version=$(sw_vers | grep "ProductVersion:" | sed -e 's/.*10\.\([0-9][0-9]\).*/\1/')
mac_os_minor_version=$(sw_vers | grep "ProductVersion:" | sed -e 's/.*10\.[0-9][0-9]\(.*\)/\1/')
# macOS Sierra 10.12.2 requires extra config in .ssh/config
# See https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
if [ $((mac_os_major_version)) -gt 12 ] ||
([ $((mac_os_major_version)) -eq 12 ] && [ $((mac_os_minor_version)) -ge 0.2 ]); then
cat << EOF >> ~/.ssh/config
Host *