Skip to content

Instantly share code, notes, and snippets.

from math import floor, sqrt
from typing import List
def sieve(n: int) -> List[int]:
A: List[bool] = [True] * n
for i in range(2, floor(sqrt(n) + 1), 1):
if A[i]:
for j in range(i ** 2, n, i):
@bvanrijn
bvanrijn / README.md
Last active April 5, 2020 22:21
This is the wordlist from http://codekata.com/data/wordlist.txt with fixed accents.

wordlist.txt

This is the wordlist from codekata.com/data/wordlist.txt with fixed accents. The original uses Windows-1252, which leads to some accents being replaced with the [Unicode replacement character][2]. Once I remembered how to, it was easily fixed using [Visual Studio Code][3], and I thought I'd upload the word list here for anyone else who might need it.

(🤓🎉: [git.io/wordlist.txt][4] [links here][5])

@bvanrijn
bvanrijn / build.md
Last active February 26, 2020 20:30
How to build Ruby from source on Ubuntu 18.04

⚠️ Warning: This will install an unstable version of Ruby with the latest changes.

apt update
apt install autoconf bison build-essential gcc git libedit-dev libffi-dev libgdbm-dev libqdbm-dev libreadline-dev libssl-dev make ruby zlib1g-dev
git clone --depth 1 https://github.com/ruby/ruby
cd ruby
autoconf
./configure
make
@bvanrijn
bvanrijn / bench.txt
Created May 27, 2018 00:03 — forked from gabrielhpugliese/bench.txt
Python 3.4 asyncio + aiohttp parallel vs sequential requests
$python parallel.py
[13:48:59:130701] Doing GET request to http://google.com
[13:48:59:134958] Doing GET request to http://facebook.com
[13:48:59:135498] Doing GET request to http://twitter.com
[13:48:59:136174] Doing GET request to http://slack.com
****** STATUSES: [{'status': 200, 'url': 'http://google.com'}, {'status': 200, 'url': 'http://twitter.com'}, {'status': 200, 'url': 'http://slack.com'}, {'status': 200, 'url': 'http://facebook.com'}]
$python sequential.py
[13:49:04:078752] Doing GET request to http://google.com
[13:49:04:232725] Doing GET request to http://facebook.com
import hashlib as hasher
import datetime as date
# Define what a Snakecoin block is
class Block:
def __init__(self, index, timestamp, data, previous_hash):
self.index = index
self.timestamp = timestamp
self.data = data
self.previous_hash = previous_hash
@bvanrijn
bvanrijn / talkingbots.py
Last active December 14, 2016 12:39
Talking bots. Oh, my!
from urllib.parse import quote_plus
import requests
import time
class bot():
def __init__(self, name):
self.name = name
self.text = ''
self.said = []
@bvanrijn
bvanrijn / bot.py
Last active December 6, 2016 12:01
blink(1) telegram bot
import time
import tempfile
import logging
import requests
from colorthief import ColorThief
from blink1.blink1 import Blink1
from telegram.ext import Updater, MessageHandler, Filters
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
@bvanrijn
bvanrijn / recursive-fibonacci.go
Created July 7, 2016 10:26
Recursive Fibonacci
package main
import "fmt"
func F(n int) int {
if n == 0 { return 0 }
if n == 1 { return 1 }
return F(n-2) + F(n-1)
}
# -*- coding: utf-8 -*-
'''
usage: python xh-system-convert.py FILE
Converts X or H system to Esperanto alphabet characters in FILE
Written by @grooveplex, released into the public domain under the terms of the
CC0 license.
'''
body{
font-family: Roboto, sans-serif;
background: #2196f3;
}
.top{
background: #1976d2;
height: 150px;
-webkit-box-shadow: 0px 1px 8px #2c2c2c;
-moz-box-shadow: 0px 1px 8px #2c2c2c;
-ms-box-shadow: 0px 1px 8px #2c2c2c;