Skip to content

Instantly share code, notes, and snippets.

View ghe's full-sized avatar

Gerard Ens ghe

View GitHub Profile
@ghe
ghe / primebits.py
Last active August 5, 2019 16:06
graph the number of '1' bits in use for each prime number
import matplotlib.pyplot as plt
import numpy
def primesfrom2to(n):
""" Input n>=6, Returns a array of primes, 2 <= p < n """
sieve = numpy.ones(n//3 + (n%6==2), dtype=numpy.bool)
for i in range(1,int(n**0.5)//3+1):
if sieve[i]:
k=3*i+1|1
sieve[ k*k//3 ::2*k] = False

Keybase proof

I hereby claim:

  • I am ghe on github.
  • I am gens (https://keybase.io/gens) on keybase.
  • I have a public key whose fingerprint is 56D3 2036 D7B2 9434 8744 CCCE E4C4 C989 F15B 3F9F

To claim this, I am signing this object:

@ghe
ghe / git-alt-ssh
Last active August 29, 2015 14:14
run git with an alternate ssh key file
#!/bin/bash
KEYFILE=$1
CMDS=${@:2}
if [ -e ${KEYFILE} ]; then
chmod 600 ${KEYFILE}
TMP_GIT_SSH=$(mktemp /tmp/git_ssh.XXXXXXXXXX)
echo "#!/bin/sh" > ${TMP_GIT_SSH}
echo "exec /usr/bin/ssh -o StrictHostKeyChecking=no -i ${KEYFILE}" '"$@"' >> ${TMP_GIT_SSH}
chmod +x ${TMP_GIT_SSH}

Keybase proof

I hereby claim:

  • I am ghe on github.
  • I am gens (https://keybase.io/gens) on keybase.
  • I have a public key whose fingerprint is 9CC7 B320 F161 0CBD 209F 8881 96BF 6E53 87CE C70A

To claim this, I am signing this object: