Skip to content

Instantly share code, notes, and snippets.

View fizyk20's full-sized avatar

Bartłomiej Kamiński fizyk20

View GitHub Profile
@fizyk20
fizyk20 / primes.rs
Created December 3, 2018 00:49
Find all primes between 0 and 2^32
use std::time::Instant;
fn number_to_index_mask(num: u32) -> (usize, u64) {
let num = (num - 1) / 2;
let index = (num / 64) as usize;
let bits = num % 64;
(index, 1 << bits)
}
fn unmark(mask: &mut [u64], num: u32) {
@fizyk20
fizyk20 / Texify-Mathjax.js
Last active July 4, 2018 12:42 — forked from goatandsheep/Texify-Mathjax.js
[Deprecated] A Tampermonkey / Greasemonkey script that turns LaTeX code on page into mathematical symbols using MathJax
// ==UserScript==
// @name TeXify the World MathJax
// @version 1.0
// @description Enables MathJax to process LaTeX on all websites. Based off SOUP (Stack Overflow Unofficial Patch) and http://www.math.ucla.edu/~robjohn/math/mathjax.html.
// @include *
// ==/UserScript==
var script = document.createElement("script");
script.type = "text/javascript";
/// Consumes a generic array, splitting it at a given position.
pub fn split<M: ArrayLength<T>>(self) -> (GenericArray<T, M>, GenericArray<T, Diff<N, M>>)
where
N: Sub<M>,
Diff<N, M>: ArrayLength<T>,
{
unsafe {
let array_ptr = &self as *const GenericArray<T, N>;
let ptr1 = mem::transmute::<_, *const GenericArray<T, M>>(array_ptr);
let tmp = mem::transmute::<_, *const T>(array_ptr);

Simple algorithm for encoding a set of prefixes

Motivation

There are situations in which it might be useful to send a set of prefixes to other nodes in order to verify that they have the same set as we do (inter-group synchronization). When there are large number of prefixes, it will be beneficial to encode them in some way instead of just putting them in full in the message.

The algorithm

@fizyk20
fizyk20 / keybase.md
Created February 5, 2016 10:38
Keybase proof

Keybase proof

I hereby claim:

  • I am fizyk20 on github.
  • I am ebvalaim (https://keybase.io/ebvalaim) on keybase.
  • I have a public key whose fingerprint is D7B6 BCC5 8A44 7959 3D23 B6AF 682F 8EEE E7E6 4B47

To claim this, I am signing this object:

@fizyk20
fizyk20 / google-calendar.py
Created January 11, 2016 23:02
WSGI script allowing substitution of the Google Calendar stylesheet in embedded calendars
from HTMLParser import HTMLParser
import requests
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
css_path = '/path/to/css'
class StyleReplacer(HTMLParser):