Skip to content

Instantly share code, notes, and snippets.

Single-threaded
┌───────┬─────────────────────┬──────────┬────────────────────────────────────────────┬────────┬───────────┬─────────┬───────────┬──────────┬──────┬───────────────┐
│ Index │ Implementation │ Solution │ Label │ Passes │ Duration │ Threads │ Algorithm │ Faithful │ Bits │ Passes/Second │
├───────┼─────────────────────┼──────────┼────────────────────────────────────────────┼────────┼───────────┼─────────┼───────────┼──────────┼──────┼───────────────┤
│ 1 │ PrimeCPP │ 3 │ flo80_constexpr │ 37737 │ 5.00010 │ 1 │ base │ no │ 1 │ 7547.25207 │
│ 2 │ PrimeCython │ 1 │ ssovest-cy │ 20838 │ 5.00015 │ 1 │ other │ yes │ 1 │ 4167.47164 │
│ 3 │ PrimeC │ 2 │ danielspaangberg_5760of30030_owrb │ 20255 │ 5.00021 │
@camertron
camertron / enumerable.py
Created July 21, 2020 17:09
Python implementation of Ruby's enumerable module
import unittest
def enum(obj):
if type(obj) == list:
return EnumList(obj)
elif type(obj) == dict:
return EnumDict(obj)
class Enumerable(object):
def each(self, cb):
@camertron
camertron / git-extract.py
Last active July 10, 2020 22:49
Quick-and-dirty script to move lines from one source file to a new source file, preserving git authorship along the way. The new file will be made up of a number of commits, each one attributed to the original author and at the original date and time.
import argparse
from datetime import (datetime, timedelta)
import os
import re
import subprocess
class Commit(object):
def __init__(self, commit_id, fields):
self.commit_id = commit_id
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.
Don't forget to include the above Crash Report log file in bug reports.
-- Control frame information -----------------------------------------------
c:0001 p:0000 s:0003 E:001120 (none) [FINISH]
@camertron
camertron / NullObjectListTerminator.java
Last active September 2, 2019 22:17
Using a null object as a list terminator
interface INode<T> {
boolean hasNext();
Node<T> getNext();
T getValue();
}
class Node<T> implements INode<T> {
private T value;
private INode<T> next;
@camertron
camertron / BitInputStream.java
Last active August 6, 2017 17:15
Java classes for reading and writing streams of bits.
import java.io.IOException;
import java.io.InputStream;
/**
* An input stream capable of reading individual bits from an underlying input stream.
*
* EN 605.421 Foundations of Algorithms
* Johns Hopkins Engineering for Professionals
* Summer 2017
*
@camertron
camertron / asset_preloader.rb
Created June 10, 2017 04:46
Preload assets to make rails dev faster
require 'parallel'
require 'thread'
# The asset preloader is designed to precompute and cache all precompilable
# assets in parallel to avoid doing it in serial on the first request. As of
# Sprockets 3, all assets on the precompile list (i.e. config.assets.precompile)
# are compiled on the first request whether the current page has asked for them
# or not. Obviously such behavior can mean a very slow initial request (we were
# seeing load times on the order of 10-11 minutes). By preloading, or warming the
# sprockets cache, initial page load times can be reduced to ~15 seconds (with
@camertron
camertron / upload_master_resources.rb
Created February 23, 2017 18:49
Txgh upload script
#! /usr/bin/env ruby
ENV['TXGH_CONFIG'] = "file://#{File.expand_path('../../config/txgh-config.yml', __FILE__)}"
require 'bundler'
Bundler.setup
require 'txgh'
config = begin
@camertron
camertron / validate.rb
Created February 23, 2017 18:48
Txgh validation script
#! /usr/bin/env ruby
ENV['TXGH_CONFIG'] = "file://#{File.expand_path('../../config/txgh-config.yml', __FILE__)}"
require 'bundler'
Bundler.setup
require 'txgh'
config = begin