Skip to content

Instantly share code, notes, and snippets.

/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2016 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
@pragtich
pragtich / Euler37Alg.py
Last active August 29, 2015 14:13
Actual algorithm for Euler problem 37
from itertools import chain
def rtrunc_primes():
"""Generate a set of all right-truncatable primes"""
rprimes = [[2, 3, 5, 7]] # Seed with 1-digit primes
rdigits = [1, 3, 7, 9] # Only possible digits after first digit
n = 2
while rprimes[n-2]: # Continue as long as we have found a prime in the previous n
nprimes = [p for base in rprimes[n-2] for p in [10*base+d for d in rdigits ] if is_prime (p)]
@pragtich
pragtich / PrimalityMR.py
Last active August 29, 2015 14:13
Primality test for Euler problem 37
# Primality testing as taken from http://rosettacode.org/wiki/Miller-Rabin_primality_test#Python
# Not proven for very large primes, but probably (?) right?
# TODO: try better set from http://miller-rabin.appspot.com/
def _try_composite(a, d, n, s):
if pow(a, d, n) == 1:
return False
for i in range(s):
if pow(a, 2**i * d, n) == n-1:
return False
@pragtich
pragtich / TruncPrimes.py
Last active August 29, 2015 14:13
Generating truncatable primes in Python: Project Euler problem 37 solution
# Primality testing as taken from http://rosettacode.org/wiki/Miller-Rabin_primality_test#Python
# Not proven for very large primes, but probably (?) right?
# TODO: try better set from http://miller-rabin.appspot.com/
from itertools import chain
def _try_composite(a, d, n, s):
if pow(a, d, n) == 1:
return False
for i in range(s):
if pow(a, 2**i * d, n) == n-1:
diff --git a/_plugins/postfiles.rb b/_plugins/postfiles.rb
index 08c60bf..ce79b55 100644
--- a/_plugins/postfiles.rb
+++ b/_plugins/postfiles.rb
@@ -20,13 +20,13 @@ def generate(site)
site.posts.each do |post|
# Go back to the single-file post name
- postfile_id = post.id.gsub(/[\s\w\/]*(\d{4})\/(\d\d)\/(\d\d)\/(.*)/, '\1-\2-\3-\4')
+ postfile_id = post.id.gsub(/[\s\w\/%]*(\d{4})\/(\d\d)\/(\d\d)\/(.*)/, '\1-\2-\3-\4')