Skip to content

Instantly share code, notes, and snippets.

@zackmdavis
zackmdavis / gist:bb4f1ea3b2b5ea11b31d
Created January 24, 2016 08:47
Less Wrong comments word vector exploration
in [200]: by_first_component[:100]
Out[200]:
[('u', -1.9398326),
('parameter', -1.8654854),
('1-p', -1.8631597),
('f', -1.8552135),
('T', -1.7352118),
('q', -1.6937695),
('F', -1.6872095),
('Pr', -1.6614704),
https://docs.google.com/forms/d/1fkTXWOjVLirPuX0VO8AhDLWRM-lbfGD0ERshGSuTQbI/viewform
Welcome to Mezzanine v. 0.2.0! Privately think of a criterion concerning
natural numbers not greater than 50. This program will attempt to efficiently
infer the nature of the criterion by asking you whether specific numbers do or
do not have the property of satisfying the criterion.
Size of hypothesis space: 21984
This program's belief distribution (over 21984 remaining hypotheses) has an
entropy of 14.424 bits. Learning whether 18 has the property is expected to
reduce the entropy by 1.000 bits.
Does 18 have the property? [Y/n] >> n
On the question of whether 18 has the property, you said false.
pub static CENTER_OF_THE_WORLD: u64 = 66229406269440;
pub static LOW_SEVENTH_HEAVEN: u64 = 65280;
pub static LOW_COLONELCY: u64 = 16711680;
pub static HIGH_SEVENTH_HEAVEN: u64 = 71776119061217280;
pub static HIGH_COLONELCY: u64 = 280375465082880;
@zackmdavis
zackmdavis / docstring.diff
Created November 24, 2015 21:21
demonstrative docstring
class MessageBox(object):
- """Puts a multi-line message in an ASCII-art box."""
+ """
+ +------------------------------------------------+
+ | Puts a multi-line message in an ASCII-art box. |
+ +------------------------------------------------+
+ """
This program's belief distribution has an entropy of 6.629 bits. Learning whether 60 has the property is expected to reduce the entropy by 0.533 bits.
Does 60 have the property? [Y/n] >> n
On the question of whether 60 has the property, you said false.
This program's belief distribution has an entropy of 6.443 bits. Learning whether 72 has the property is expected to reduce the entropy by 0.362 bits.
Does 72 have the property? [Y/n] >> n
On the question of whether 72 has the property, you said false.
This program's belief distribution has an entropy of 6.340 bits. Learning whether 84 has the property is expected to reduce the entropy by 0.381 bits.
Does 84 have the property? [Y/n] >> y
pzmd@SuddenHeap:~/Code/swift$ python3
Python 3.4.1 (default, May 25 2014, 22:33:14)
[GCC 4.6.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> def my_function(first, second, opt1=1, opt2=2, opt3=3):
... ... # do stuff
...
>>> my_function("first_value", opt1="a", opt2="b", opt3="c")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
@zackmdavis
zackmdavis / reed_solomon.py
Created April 17, 2015 18:56
extremely simplified Reed-Solomon coding in Python 3
from string import ascii_uppercase
ALPHABET = " "+ascii_uppercase
CHAR_TO_INT = dict(zip(ALPHABET, range(27)))
INT_TO_CHAR = dict(zip(range(27), ALPHABET))
def pad(message, chunk_size):
return message + ' '*(chunk_size - len(message) % chunk_size)
def unpad(message):
ack-grep
acpi-support
activity-log-manager-control-center
adduser
aisleriot
alarm-clock
alsa-base
anacron
ant
app-install-data-partner
# <timburke> acorwin: i don't think i like how your pre-incrementer handles things like `+i; +i`, but i can't think of a good way around it...
# [...]
# <acorwin> timburke: what don't you like about it?
# <acorwin> +i ; +i ; i.val yields 1
# <timburke> acorwin: yes! and they should have both yielded zero!
# <acorwin> timburke: well, they have to return i, but i.__str__() could just be str(i.val)
# <timburke> acorwin: well, yeah. the *state* after each should have been 0
# <acorwin> timburke: oh, well, without delving into the AST i can't actually verify that two +'s are together
# <timburke> acorwin: yeah. like i said, i can't think of a good way around it
# <acorwin> timburke: yeah. oh well.