Skip to content

Instantly share code, notes, and snippets.

@0
0 / arxiv.js
Last active August 4, 2022 02:09
Script to convert Zotero items from Journal Article to Preprint.
/*
* Previously, preprints were added to Zotero as items of the "Journal Article"
* type, but it now has a dedicated "Preprint" item type. This script finds all
* articles that look like arXiv preprints and converts them to the new type. If
* your items have categories in the publication name, you may need to remove
* them.
*
* Select all the articles you want to convert, go to Tools -> Developer -> Run
* JavaScript, check "Run as async function", paste this script on the left side,
* and press "Run". It may take a while, but eventually the right side should
@0
0 / misspell.py
Created October 8, 2017 08:38
Find misspelled words in text that contains many non-words.
#!/usr/bin/env python3
"""
A wrapper around difflib.get_close_matches to make it easy to find misspelled
words in text that contains many non-words.
For regular text, where every letter sequence must be a dictionary word,
checking spelling is straightforward. Technical text, such as documentation or
code comments, may contain many valid non-words (e.g. function names) and
deliberate nonsense example strings. As a consequence, there tend to be many

Keybase proof

I hereby claim:

  • I am 0 on github.
  • I am 0_0 (https://keybase.io/0_0) on keybase.
  • I have a public key ASDLXFbFtcCeD6vYtHwlR1M19TQhwTOOq93dfIqz9F6d3go

To claim this, I am signing this object:

@0
0 / bluetooth_serial.md
Last active May 15, 2024 07:01
Connecting a Bluetooth device for serial communication on Arch Linux.

The following are instructions for connecting a Bluetooth device for serial communication on Arch Linux using BlueZ 5.31.

Prerequisites

The following packages are required:

  • bluez: bluetoothd
  • bluez-utils: bluetoothctl, rfcomm
@0
0 / msp430-elf.md
Last active August 18, 2023 10:36
Building a GCC cross-compiler for the MSP430.

msp430-elf

The following are instructions for building a GCC cross-compiler for the MSP430. They are based in part on Peter Bigot's post to mspgcc-users.

Setup

export PREFIX=/usr/local/msp430
@0
0 / signed_sqrt.py
Created January 28, 2015 04:22
Calculate complex square roots with the correct sign for trajectories in the complex plane.
#!/usr/bin/env python3
"""
Calculate complex square roots with the correct sign for trajectories in the
complex plane.
Taking the square root of values along a continuous trajectory in the complex
plane is not as simple as calling a sqrt function, because the complex square
root is a multi-valued function whose Riemann surface is composed of two
sheets. If the trajectory crosses the branch cut (conventionally placed along
@0
0 / aif.jl
Last active November 27, 2019 17:24
Some toys in julialang
# Anaphoric if.
macro aif(ex)
@assert (ex.head == :if) "@aif must be applied to an if expression."
cond = ex.args[1]
ex.args[1] = :(convert(Bool, it))
quote
let it = $cond
$ex
@0
0 / README.md
Created July 20, 2014 05:12
x86 shellcode

x86 shellcode

Back in 2010, I needed some shellcode, so I wrote this. It spawns Vim rather than a shell, so I guess it's technically "vimcode".

It is, of course, null-free. There is a commented version in the test file, but here it is in its entirety:

\x31\xc0\x31\xc9\x99\x50\x68\x2f\x76\x69\x6d\x68\x2f\x62\x69\x6e\x68\x2f\x75\x73\x72\x89\xe3\xb0\x0b\xcd\x80
@0
0 / README.md
Last active August 29, 2015 14:03
Scheme RC4 implementation

arcfour.ss

For some reason, in January of 2009 I felt the need to implement RC4 in Scheme.

Usage

Known to work with Racket.

Specify the key and plaintext on the command-line as arguments, and it will output the ciphertext. For example,

@0
0 / arrays_pointers.c
Created December 20, 2013 20:50
Arrays aren't pointers!
/* gcc -std=c99 -pedantic -Wall -Wextra -Werror -o arrays_pointers arrays_pointers.c
*/
#include <stdio.h>
#include <string.h>
#define A_LEN 5
void foo(int a[], int *p);