Skip to content

Instantly share code, notes, and snippets.

View willeccles's full-sized avatar
🖤
probably out driving

Will Eccles willeccles

🖤
probably out driving
View GitHub Profile
@willeccles
willeccles / english wordlist.txt
Created September 27, 2017 18:32
a list of english words, can be used for spellcheck or whatever you want :)
This file has been truncated, but you can view the full file.
aa
aah
aahed
aahing
aahs
aal
aalii
aaliis
aals
aardvark
@willeccles
willeccles / coinflip.cpp
Created November 14, 2017 03:45
WAY overcomplicated coinflip program which I used to decide which new phone to buy.
#include <iostream>
#include <ctime>
#include <random>
#include <ctime>
#include <string>
#include <cstdio>
enum coinFace {
HEADS = 0,
TAILS = 1
@willeccles
willeccles / doubles.cpp
Last active October 16, 2018 14:53
A simple program to print out the base 2 (binary) representation of a 64-bit double (including sample output).
#include <iostream>
#include <cmath>
/* Double Basics:
* The basic format of a IEEE 754 64-bit double is the following:
* 1 00000000000 0000000000000000000000000000000000000000000000000000
* b63 is the sign bit, 1 = negative, 0 = positive
* b52-b62 are the 11 exponent bits
* b0-b51 are the 52 fraction/significand bits
*
@willeccles
willeccles / Fitts Test Hack.js
Created November 6, 2018 18:56
A quick hack for http://fww.few.vu.nl/hci/interactive/fitts/ that lets you get any time you want.
// use with this site http://fww.few.vu.nl/hci/interactive/fitts/
var cheat = (atime) => {
var doc = document.getElementsByTagName("iframe")[0].contentDocument.getElementsByTagName("iframe")[0].contentWindow;
var nextbutton = document.getElementsByTagName("iframe")[0].contentDocument.getElementById("clicknext");
var avgtime = 0; // what the average time should be in ms
if (atime && atime > 0)
avgtime = atime;
if (atime && atime < 10 && atime > 0) {
@willeccles
willeccles / inplaceswap.cpp
Created November 13, 2018 16:16
Swap two integer values without using a temporary value, using no extra memory.
#include <cstdio>
int main(void) {
int a = 5; // 0b0101
int b = 11; //0b1011
std::printf("Before swap:\na: %d\nb: %d\n", a, b);
// perform the swap
a ^= b; // a now = 0b1110
@willeccles
willeccles / alfred-kitty.scpt
Last active February 26, 2024 11:47
AppleScript for using Kitty in Alfred. This was made for bash, but can easily be made to work with any shell.
(* 2019-06-07: Added nohup and output redirection to fix a bug with "Open Terminal here" feature.
Thanks to @fools-mate for bringing the issue to my attention. *)
on alfred_script(q)
do shell script "cd ~; nohup /Applications/kitty.app/Contents/MacOS/kitty /bin/bash -c \"source ~/.bashrc && " & q & ";/bin/bash\" > /dev/null 2>&1 &"
end alfred_script
@willeccles
willeccles / Binary File Structs.md
Last active January 25, 2019 16:57
Writing structs to a binary file in C++

Why?

Why not? There are many times when saving a section of memory into a binary file (and being able to read it back) would be incredibly useful.

How?

You can do this using std::ofstream::write and std::ifstream::read, and you can open their files with the std::ifstream::binary flag.

Can you test it?

@willeccles
willeccles / robots parser.cpp
Last active March 26, 2019 20:31
A simple parser for robots.txt files.
/* Tested with https://www.google.com/robots.txt */
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <utility> // for std::pair
#include <cstdio> // for std::printf
@willeccles
willeccles / fget.go
Created April 9, 2019 00:40
A simple Go program to download a file and save it to the disk.
package main
import (
"fmt"
"io/ioutil"
"os"
"net/http"
"net/url"
)
@willeccles
willeccles / bftranspiler.cpp
Last active May 17, 2019 19:08
A C++ program that transpiles brainfuck code into usable C code.
#include <fstream>
#include <iostream>
#include <string>
#include <map>
#include <regex>
const std::map<char, std::string> bfinstructions{
{'>', "++ptr;"},
{'<', "--ptr;"},
{'+', "++*ptr;"},