Skip to content

Instantly share code, notes, and snippets.

View mrpapercut's full-sized avatar

Mischa Rodermond mrpapercut

View GitHub Profile
@mrpapercut
mrpapercut / bitstringToBigInt.js
Created March 30, 2023 08:22
Javascript bitstring to BigInt
const bitstringToBigInt = bstr => {
let counter = 0n;
let byteindex = 0n;
for (let i = bstr.length - 1; i >= 0; i--) {
if (bstr[i] === '1') {
counter += 2n**byteindex;
}
byteindex++;
@mrpapercut
mrpapercut / 01. T5KParser.php
Last active April 6, 2023 08:33
T5K primelist parser
<?php
class T5KParser {
private $primelistURL = 'https://t5k.org/primes/lists/all.txt';
private $primelistRaw;
public $primes = [];
public $proofcodes = [];
public function parse() {
This file has been truncated, but you can view the full file.
6564953747038235790955217330623214601774215358095936006017110214784860168687227631027635937839153757268380642974079467157334809566999540962148704233794850102097231093372707426616562692617106981691872758671712110601540505296280467223417393799786109394608287675526571645626442023311821444974297444491272713503050842692707454144812229426034131743996661007715345018917604748834080149496485127824272414386407155506056534722573065665058662947434721059145788344714873337189186944176649103698979268480570375719992781428767497822025468002474658914212189996461627669962337714237025844747155610322336476635982392947311400713905569889295619682873789914852700713265655533621966991091545559256866123490950539453524126917512556053020524791870367438813728085218574561793464589185584667137527301268689841454825589001774026515152992307669651794159610073155993294468509578431647455474435187659015344735661080488116422219151150513430742172406608569003085896799891013375757397457153381693475634334147234494649818673347328769575430106983888770141
@mrpapercut
mrpapercut / 0-truncatable-primes.jl
Last active November 25, 2022 12:34
Truncatable primes
using Primes
function appendLeft(num, base, prims = [])
for n in 1:(base-1)
leftAppended = parse(BigInt, "$n$num", base = base)
if isprime(leftAppended)
appendLeft("$n$num", base, prims)
else
if ("$num" in prims) == false
push!(prims, "$num")
@mrpapercut
mrpapercut / UnicodeBlocks.json
Created May 16, 2021 16:26
JSON object of all Unicode blocks
/* "<name of block>": [<start of block>, <end of block>] */
{
"Basic Latin": [0x0000, 0x007F],
"Latin-1 Supplement": [0x0080, 0x00FF],
"Latin Extended-A": [0x0100, 0x017F],
"Latin Extended-B": [0x0180, 0x024F],
"IPA Extensions": [0x0250, 0x02AF],
"Spacing Modifier Letters": [0x02B0, 0x02FF],
"Combining Diacritical Marks": [0x0300, 0x036F],
"Greek and Coptic": [0x0370, 0x03FF],
@mrpapercut
mrpapercut / LICENSE
Last active April 21, 2021 11:17
WTF Public License 2.0 for all code-snippets at gist.github.com/mrpapercut/
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@mrpapercut
mrpapercut / raw-dns-req.py
Last active February 20, 2024 10:08
Raw DNS requests with python
#!/usr/bin/env python3
import binascii
import socket
import sys
from collections import OrderedDict
# See https://web.archive.org/web/20180919041301/https://routley.io/tech/2017/12/28/hand-writing-dns-messages.html
# See https://tools.ietf.org/html/rfc1035
@mrpapercut
mrpapercut / forceLatestTweets.js
Created July 23, 2019 11:51
Force Latest Tweets settings for Twitter
// Force latest tweets
let twid_cookie = document.cookie.split(/;\s?/).filter(c => /^twid=/.test(c))[0];
if (twid_cookie) {
let twid = twid_cookie.replace('twid=u%3D', '');
let forceRefresh = false;
// Get DB
let req = window.indexedDB.open('localforage', 2);
req.onerror = ev => {
@mrpapercut
mrpapercut / createElement.js
Last active September 30, 2023 00:52
ES6-only createElement function
const createElement = (tagname = '') => {
return (...content) => {
const el = document.createElement(tagname);
if (content[0] instanceof Object && !(content[0] instanceof HTMLElement)) {
let attributes = content.shift();
for (let attr in attributes) {
switch (attr) {
case 'events':