Skip to content

Instantly share code, notes, and snippets.

@Ortham
Ortham / releasesDownloadCount.js
Created February 3, 2015 22:21
Get total downloads from releases in a repository
/* A short script to get the total number of downloads of files in a
repository's releases. I just discovered that GitHub provides this info
through its API! I thought I'd traded the loss of such metrics for the
goodness of GitHub... */
// Use LOOT as an example.
var owner = 'loot';
var repo = 'loot';
var xhr = new XMLHttpRequest();
@Ortham
Ortham / releaseDownloadCount.js
Last active June 16, 2022 18:37
Get the total number of downloads for a single release, using its tag name.
//Get the total number of downloads for a single release, using its tag name.
function releaseDownloadCount(owner, repo, tag) {
const url = `https://api.github.com/repos/${owner}/${repo}/releases`;
fetch(url)
.then(response => response.json())
.then(releases => releases.find(release => release.tag_name == tag))
.then(release => release
.assets
.reduce((previous, next) => previous + next.download_count, 0))
@Ortham
Ortham / BSA_process_directory.m
Created September 10, 2015 17:19
Beam spot analysis Matlab script
function BSA_process_directory(path)
path = strcat(path, '\');
% Filter only camera PNGs.
files = dir(strcat(path, 'Frame_*.png'));
% Create a Gaussian filter. This will be used
% to blur the image slightly so that spots
% form contiguous regions which can be
% analysed.
@Ortham
Ortham / primitive_laser.sh
Created January 14, 2017 10:48
Image reproduction using Primitive
#!/bin/bash
# Generate a single image using Primitive.
# https://github.com/fogleman/primitive
INPUT_FILE=$(ls $1/*.jpg | head -1)
OUTPUT_FILE=$1/$1.png
SHAPES_NUMBER=$2
if [ "$3" == "combo" ]
then
@Ortham
Ortham / mount_windows.sh
Last active July 4, 2017 20:09
A script to simplify mounting a Bitlocker-encrypted Windows partition using Dislocker
#!/bin/bash
# Run with 'sudo'
set -e
BITLOCKER_PARTITION=/dev/sda3
BITLOCKER_MOUNT=/mnt/bitlocker
DECRYPTED_MOUNT=/mnt/windows
echo "Please enter your Bitlocker password: "
read -s BITLOCKER_PASSWORD
@Ortham
Ortham / slim_pdfs.sh
Created August 6, 2017 12:50
A script for slimming PDFs (eg. of scanned documents)
ls -1 *.pdf | (IFS=: ; while read FILENAME; do s=${FILENAME##*/} ; gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=${s%.pdf}.2.pdf ${FILENAME} && mv ${s%.pdf}.2.pdf ${FILENAME} ; done)
@Ortham
Ortham / clang-format.ps1
Last active February 18, 2018 09:42
clang-format everything in Git source control
clang-format -style=file -i $(git ls-files *.cpp *.h)
@Ortham
Ortham / win7_winhttp_tls1.2.reg
Created February 23, 2018 14:45
Enable TLS 1.2 support on Windows 7
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client]
"DisableByDefault"=dword:00000000
"Enabled"=dword:00000001
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"DisableByDefault"=dword:00000000
"Enabled"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp]
"DefaultSecureProtocols"=dword:00000a00
@Ortham
Ortham / keybase.md
Last active October 21, 2018 10:10
My keybase proof of identity

Keybase proof

I hereby claim:

  • I am ortham on github.
  • I am wrinklyninja (https://keybase.io/wrinklyninja) on keybase.
  • I have a public key ASC3MC3YuhcXoG2t5fNglFuRGXPwOoDl4yQDiOrwi_a6kQo

To claim this, I am signing this object:

@Ortham
Ortham / intro.rs
Last active March 3, 2022 13:28
An intro to basic Rust syntax and features
// Adjust linter settings to make output less noisy.
#![allow(unused_variables, dead_code)]
/*
The Rust programming language
=============================
Website: https://www.rust-lang.org/
## Learning