Skip to content

Instantly share code, notes, and snippets.

View alexcu's full-sized avatar

Alex Cummaudo alexcu

View GitHub Profile
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//
// Arbitrary string encapsulator type
//
typedef struct string_t {
char *chars;
} string_t;
@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;
}
}
@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 / 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 / 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 / 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)()