This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find(fn): | |
words = open(fn, encoding='utf8').read().split() | |
template = input('word (_ for unknown): ') | |
missing = input('more letter: ') | |
unwanted = input('other letters: ') | |
for word in words: | |
if len(word) == len(template): | |
for t,l in zip(template, word): | |
if t!='_' and t!=l: | |
break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import struct | |
import sys | |
for i in sys.argv[1:]: | |
i = int(i[2:], 16) if i.lower().startswith('0x') else int(i) | |
d = struct.unpack('!d', struct.pack('!Q', i))[0] | |
print(d) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
</head> | |
<body> | |
<canvas style="width:100%; height:100%;"></canvas> | |
<script src="https://twgljs.org/dist/4.x/twgl-full.min.js"></script> | |
<script type="text/javascript"> | |
const o = { | |
sectionVerts: 30, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from datetime import datetime | |
import pandas as pd | |
def prt(*args): | |
print('\t'.join(args), file=wf) | |
global line_no | |
line_no += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
'''Start of a trivial Python-to-Nim transpiler. So far, only a few | |
basic syntax matters are settled. Curious to see if it's hard to | |
get anything useful done with AST as input while hard-coding | |
output formatting.''' | |
from ast import * | |
from functools import reduce | |
ast_parse = parse |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ported from https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/mandelbrot-java-2.html | |
# Nim is about 29% faster than the Java 11 version. | |
# | |
# Build: nim c --threads:on -d:release --passC:-march=native mandelbrot2.nim && time ./mandelbrot2 16000 > m.pbm | |
# real 0m1.096s | |
# user 0m11.859s | |
# sys 0m0.141s | |
{.experimental, checks:off, optimization: speed.} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Taken from https://github.com/def-/nim-benchmarksgame/blob/master/mandelbrot8.nim and made | |
# compile with v1.4.8. | |
# | |
# Build: nim c --threads:on -d:release mandelbrot.nim | |
# Run: time ./mandelbrot 16000 >image.pbm | |
# real 0m1.649s | |
# user 0m17.969s | |
# sys 0m0.172s | |
{.experimental.} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dateutil.parser | |
from datetime import datetime | |
import pytz | |
def local2timestamp(s): | |
return int(dateutil.parser.parse(s).timestamp() * 1000) | |
def timestamp2local(t): | |
return datetime.fromtimestamp(t/1000).isoformat().replace('T',' ') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import socket | |
import sys | |
host,port = sys.argv[1].split(':') | |
port = int(port) | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.bind((host,port)) | |
s.listen(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import rand | |
const ( | |
nan = math.nan() | |
) | |
union Data { | |
data_int []int | |
data_f64 []f64 |