Skip to content

Instantly share code, notes, and snippets.

Joshua Landau Veedrac

Block or report user

Report or block Veedrac

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Veedrac
Veedrac / print_buf64.cpp
Last active Aug 2, 2019
Prints integers really fast. Pads output with null bytes to length-20 for speed reasons. The code is released under CC0. The length calculation (neg_log2 * 1233 >> 12) is from Bit Twiddling Hacks, and also public domain.
View print_buf64.cpp
const char DIGIT_PAIRS[] =
"00" "01" "02" "03" "04" "05" "06" "07" "08" "09"
"10" "11" "12" "13" "14" "15" "16" "17" "18" "19"
"20" "21" "22" "23" "24" "25" "26" "27" "28" "29"
"30" "31" "32" "33" "34" "35" "36" "37" "38" "39"
"40" "41" "42" "43" "44" "45" "46" "47" "48" "49"
"50" "51" "52" "53" "54" "55" "56" "57" "58" "59"
"60" "61" "62" "63" "64" "65" "66" "67" "68" "69"
"70" "71" "72" "73" "74" "75" "76" "77" "78" "79"
"80" "81" "82" "83" "84" "85" "86" "87" "88" "89"
View times_genPrimes.py
def genPrimes(n):
found = []
found_lo = []
for x in range(2,n+1):
yas = True
for y in found_lo:
if x%y == 0:
yas = False
break
if yas:
View sufficient_velocity_user_filter.user.js
// ==UserScript==
// @name Sufficient Velocity User Filter
// @version 1.0
// @description Restyle the page and allow selective ignore of specific threads
// @author Veedrac
// @match https://forums.sufficientvelocity.com/*
// @exclude https://forums.sufficientvelocity.com/watched/threads
// @run-at document-start
// @grant none
// ==/UserScript==
View binarytrees.cpp
#include <stdlib.h>
#include <iostream>
#include <memory>
class Tree {
std::unique_ptr<Tree> left;
std::unique_ptr<Tree> right;
public:
Tree(int depth) {
View search_deep_expanded.rs
use std::thread;
static NEED: [u8; 21] = [43, 25, 20, 16, 15, 13, 12, 12, 11, 10, 10, 8, 8, 4, 4, 3, 3, 1, 1, 1, 1];
fn is_ok<F>(pred: F) -> bool
where F: Fn(u8) -> u8
{
let mut counts = [0; 256];
for tok in 0..256 {
counts[pred(tok as u8) as usize] += 1;
View search_deep.py
from itertools import combinations, combinations_with_replacement, product
need = 43, 25, 20, 16, 15, 13, 12, 12, 11, 10, 10, 8, 8, 4, 4, 3, 3, 1, 1, 1, 1
def is_ok(pred):
# This is equivalent to the naïve Counter-based method, but
# optimized to be fast on PyPy.
counts = [0] * 256
for tok in range(256):
View diagram.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View generate.py
import random
# Make this higher when you want better graphs
iters = 100
def trunc(x):
return x % (2**64)
def test_row(f, swaps):
seen = set()
View internal_iter.rs
pub trait InternalIterator {
type Item;
fn each<F>(&mut self, mut f: F) -> bool
where F: FnMut(Self::Item) -> bool;
}
impl<I> InternalIterator for I
where I: Iterator,
{
type Item = I::Item;
View gist:d53a6c2795890f94fa66e0bafb0bf73b
time: 0.594; rss: 322MB parsing
time: 0.000; rss: 322MB recursion limit
time: 0.000; rss: 322MB crate injection
time: 0.000; rss: 322MB plugin loading
time: 0.000; rss: 322MB plugin registration
time: 0.295; rss: 349MB expansion
time: 0.000; rss: 349MB maybe building test harness
time: 0.012; rss: 349MB maybe creating a macro crate
time: 0.000; rss: 349MB checking for inline asm in case the target doesn't support it
time: 0.023; rss: 349MB complete gated feature checking
You can’t perform that action at this time.