HNHacker News
TopNewBestAskShowJobs

asrp

426 karma · joined January 21, 2017

github.com/asrp

blog.asrpo.com

Contact: asrp email com

submissionscomments
asrp··on Show HN: Espeakui – a text-to-speech interface with mplayer-like bindings
This project is related to a "life hack" of sorts where you get to process more information by listening to it read aloud. In this case its by a computer using the espeak speech synthesizer. One way is to skim text by setting the speech rate rather high and pause/slowdown if anything catches your attention.

However, sending large amounts of text to espeak is too fragile. If you miss a bit you have to restart the entire thing. If some parts are uninteresting its not possible to skip through it. But large amounts of text is where espeak is really useful. An audio/video player's interface on the other hand is very good for playback. So I made this, a TTS with (some of) mplayer's playback interface.

So I made this. It has evolved quite a bit with my personal use and I now use this much more than anything else I've made. This also means there are some leftovers when I thought the interface would go in a different direction. There's surprisingly little information about designing audio interfaces that I could find (so that I'd have a better chance of getting it right on the first few tries).

asrp··on Show HN: Python C extension for the eSpeak speech synthesizer
espeak is a fast speech synthesizer and is the only open source synthesizer I know that's still understandable when played at high speed (300-400 words per minute).

And this is the only python library that wraps the C library `speak_lib` rather than calling the `espeak` binary. This wrapping is needed to get callbacks from espeak. The espeak C library `speak_lib` has even more features that I wanted so I added them to this wrapper.

What do I need these features for? That's being prepared for next week.

asrp··on Cheating on a string theory exam
I'm not sure if you're looking for an ELI5 of the question or the answer. I'll explain the answer since others already explained the question.

You'll only have the time at which your friend leaves (in seconds since the start of the exam). Knowing only this, whatever you two scheme, you'll have to write down your answers (from a scheme you both agreed on beforehand like "leaving after 324 seconds means answer true for the first 7 questions and false for the rest", "leaving after 325 seconds means answer false everywhere", ...) once your friend leaves. So really, you're just a transcriber. During the exam, its your friend who decide what you're going to write down by picking the right second to leave at.

Of course, they'll pick the second which makes you write as many correct answers as possible. (And of course, you'll want to pick the best scheme to help with that. But let's see what you can't do, no matter the scheme, first.)

Why can't you just always get all answers right? Because there are too many possible set of answers (2^23 for 23 questions) and your friend can only choose from the 90 * 60 = 5400 you two agreed on before the start of the exam.

In fact, you can't even be sure of getting 22 questions right. For each second (from 0 to 5399), there are only 23 set of true answers to the exam (among 2^23) for which leaving at that second gets you exactly one answer wrong (namely, one of getting each of the questions wrong). So 5400 + 5400 * 23 is an upper on the number of sets of true answers for which you'll get at most one answer wrong (using whatever scheme). Since 5400 + 5400 * 23 is still (much) less than 2^23, there will be many set of true answers to the exam where your friend doesn't have a choice but to make you write down many wrong answers.

The same goes for getting 21 answers right. For each second, there are 23 * 22 / 2 set of true answers for which leaving the exam at that time gets you exactly two questions wrong. (Pick the first question to get wrong, pick the second question to get wrong, divide by 2 because there are two ways to pick these two questions.)

    5400 + 5400 * 23 + (5400 * 23 * 22 / 2)
is still two small. So there are bound to be sets of true answers where you'll get more questions wrong.

It turns out that getting 20 answers right is possible. Now you have to actually pick a scheme. We can't just make the same calculation and add

    5400 * 23 * 22 * 21 / (2 * 3)
(which is now bigger than 2^23) because that's only an upper bound. Each second from 0 to 2399 "covers"

    1 + 23 + 23 * 22 / 2 + 23 * 22 * 21 / (2 * 3)
set of true answers (so if those are the true answers to the test, your scheme works). But if for some set of true answers is covered by more than one of the seconds (it happens when there are two different times at which your friend can leave and give you at most 3 answers wrong), it means that some other set of true answers might not be uncovered.

In your scheme, the only thing that matters is which 5400 set of answers your friend can make you write (swapping which answer goes with which second doesn't change anything).

As it happens, people have made tables of the minimum and maximum number of seconds needed to cover all 2^23 possibilities for getting at most 3 answers wrong. And its 4096 seconds which is less than 5400. In fact, the table contain ranges for different total number of questions and different number of questions that you can get wrong.

(I think there's something more interesting about this particular scheme that gets you 4096 but I haven't read all the other comments yet and haven't thought about this questions more since.)

asrp··on Cheating on a string theory exam
Sadly, I can only give the Google answer to this one:

> Working on a branch of physics called supersymmetry, Dr. James Gates Jr., discovered what he describes as the presence of what appear to resemble a form of computer code, called error correcting codes, embedded within, or resulting from, the equations of supersymmetry that describe fundamental particles.

asrp··on Cheating on a string theory exam
Pick 5400 23-bit vectors (the answers you will write) and your friend picks the one that minimizes its Hamming distance to the true answer.

    5400*23 + 5400*23*22/2 < 2**23
so answering 21 questions with certainty is impossible. (Pick the true answers so as to maximize the Hamming distance between it and whatever answer you decide to write, regardless of the scheme used.)

And there is a size 4096 < 5400 covering code [1] so answering 20 question is possible (by picking the 23-bit vectors in that code).

[1] see n = 23, R = 3 here http://www.sztaki.hu/~keri/codes/2_tables.pdf

Edit: formatting

asrp··on Show HN: Tkui – Python GUI maker that simulaneously edits the GUI and its editor
dragonwriter said it here but the actual reasoning went something like this:

1. I need to add some documentation and explanation.

2. I might as well document the different parts using screenshots since the elements are visual.

3. I might as well make videos (or gifs) to show what the actions do.

4. I might as well make the video interactive to drive home the points that the user can customize the interface to look like whatever they like. (This incidentally also perpetuate the joke about this program being meta.)

If this were Javascript, I think the guided tour wouldn't be an issue (but I understand that it isn't and the further step with virtualenv makes it even less approachable).

There's also the issue of time. That I'd probably only make one of these, at least at first. I chose 4. Maybe it was not the best choice.

I'm still trying to think of a good way to also add 2 or 3 but my gut feeling says that people are less likely to try the interactive version if I add that. I suppose this is the sort of thing that needs testing to find out.

Also, most visual tools have a clearly define "this is the toolbox" and "this is the stuff the tools apply to" so some though is needed to be able to show that there isn't even such a division. For example the default first screen is probably really confusing to look at on its own (so the natural next thing to ask for it an explanation of what the viewer is supposed to be looking at!).

asrp··on Show HN: Tkui – Python GUI maker that simulaneously edits the GUI and its editor
Interesting! I do the same with ipython. Now if only we could edit idle's own UI while its running.
asrp··on Show HN: Tkui – Python GUI maker that simulaneously edits the GUI and its editor
Maybe. What would you like to see in it? Sample use, detailed explanation, run through of the guided tour, ...?
asrp··on Show HN: Tkui – Python GUI maker that simulaneously edits the GUI and its editor
Thanks! From the first example, it looks more like a UI toolkit than a (visual) editor though. At least it seem the layout can only be created using code.

I remember Squeak having a tree (I forget the name) but don't remember if it was easy to edit with it directly.

asrp··on Show HN: Tkui – Python GUI maker that simulaneously edits the GUI and its editor
Indeed! Although I only recently learned of Squeak Smalltalk and variants like Pharo and Cuis (quite a bit after tkui was close to its current state). What GUI maker(s) do you recommend for Smalltalk?

Let me elaborate on your comment for other readers though. Smalltalk is a programming language in which an entire (graphical and audio) environment called Squeak was built. Smalltalk's dynamic nature and the nature of its global namespace (for classes and their methods) means that class and methods can be modified from within the environment at any time (and any future calls will use the new method). This is the part that make it similar to tkui (or perhaps rather tkui similar to Squeak).

asrp··on Show HN: Tkui – Python GUI maker that simulaneously edits the GUI and its editor
tkui is one of my joke side projects but it does run and serve a purpose. I was trying to make some quick GUIs in Python for my own use but always restarting the program when small details in the layout changes makes for a slow workflow (closing and reopening the program).

So I wanted to use a GUI editor. I don't remember exactly but I think I didn't find anything that suited (I know I at least looked online for a while). So I decided to make my own, which became tkui.

Now the editor is itself a GUI so it'd be awfully helpful to have a GUI editor to make it. Because time travel isn't an option, I started from scratch and tried to add useful elements for create tkui itself. Of course, those elements are also the elements of tkui. So now tkui is a tkui maker.

If anyone have suggestions for "build orders" for recreating similar programs from scratch, I'd be interested to know.

I tried to make it so I need to restart tkui/the current project as little as possible. I also tried to the keep the project small, although with both dependencies, its getting larger.

asrp··on Smallpt: Global Illumination in 99 lines of C++
Here are slides linked from that page with a reformatted version with 202 lines:

https://drive.google.com/file/d/0B8g97JkuSSBwUENiWTJXeGtTOHF...

Here's the source from those slides (I don't know who put it there).

http://codepad.org/ZWbF9yrY

I had to remove these two lines to make it compile.

    double M_PI = 3.14159265358979;
    double M_1_PI = 1.0/M_PI;
asrp··on Show HN: Pydb – a lightweight database with Python syntax queries, using ZeroMQ
I've just changed the project's name to pyzdb. Thanks again!
asrp··on Show HN: Pydb – a lightweight database with Python syntax queries, using ZeroMQ
Interesting! I will have to take a deeper look at BlitzDB. I don't know much about MongoDB (so probably wouldn't be a good maintainer) but the sample code looks good. I can't tell how it handles nesting though.
asrp··on Show HN: Pydb – a lightweight database with Python syntax queries, using ZeroMQ
Yes, indeed! Thanks for pointing that out. I actually saw that when I was cleaning this up a bit for release and couldn't make up my mind.

I mean I'm not modifying args or kwargs now but if I did later, I could shoot myself in the foot in a not so obvious way. But on the other hand, I don't know a succinct way to express these default values. I'd probably go with `args=None, kwargs=None` and then `args = args if args else ()`.

asrp··on Show HN: Pydb – a lightweight database with Python syntax queries, using ZeroMQ
I decided to push a quick patch to github so installation with just `pip install -r requirements.txt` is possible now. I'll look into proper packaging later on. Thanks again!
asrp··on Show HN: Pydb – a lightweight database with Python syntax queries, using ZeroMQ
Oh, thanks, I wasn't aware of that flag. Though for the moment

    pip install -e git://github.com/asrp/undoable#egg=undoable
tells me `setup.py` doesn't exist (because it doesn't). I haven't gotten around to packaging yet not knowing (before today) if anyone's interested.

I'll probably look into that soon.

asrp··on Show HN: Pydb – a lightweight database with Python syntax queries, using ZeroMQ
Thanks! I'm glad to see this looks potentially useful to someone other than myself.

If the client could start servers (other than by importing from server.py), what would be the intended outcome if two clients try to spin up servers at the same time? Otherwise would a file lock do? In that case, just file locking combined with pickle could possibly be enough for your needs.

asrp··on Show HN: Pydb – a lightweight database with Python syntax queries, using ZeroMQ
As you correctly observed, I mainly used ZeroMQ for the fan-in, so I need only consider one request at a time without worrying about chunking, disconnection or other lower (socket) level issues.

For speed, the idea is that you could potentially have multiple read-only servers answering queries simultaneous (all taking from the dealer). This isn't fleshed out yet. It possibly involves splitting requests into two queues for read and write requests (instead of only "run").

I'd be interested in hearing any info about potential slowdowns if you have them.

asrp··on Show HN: Pydb – a lightweight database with Python syntax queries, using ZeroMQ
Thank you! I looked up databases to see if there were obvious name clashes but never thought of debuggers despite using `pdb` a lot.

I'm open to suggestions for names if anyone has one. (Although I guess it'd be nice if the top discussion thread wasn't about naming.)

EDIT: I just saw you opened an issue on github so I'm happy to take name suggestions there.

asrp··on Problems I Have with Python
Oops, I didn't expect this to blow up, thanks for responding.

Here's a discussion about switch case (I was also looking for one the other day, but in my case, it was purely for optimization).

https://www.python.org/dev/peps/pep-3103/

And the wiki, for example, talks about the GIL

https://wiki.python.org/moin/GlobalInterpreterLock

I remember reading articles from here about that a few times, but can't find them now. If you are still interested, I can try to dig it up.

asrp··on Problems I Have with Python
A lot of the author's complaints, especially near the end, are personal preferences which explains by these "improvements" were never added. Not everyone would prefer a move to a significantly more functional style.

Arguably this difference is what caused Coconut to be made in the first place.

There's ample discussion on these topics to simply brush existing decisions off as "Incompetence? Politics? Both? Who knows."

For the fifth point, `list.index` works fine in Python 2 and 3 for me.

asrp··on Show HN: Mitt: The smallest event emitter in the world
This is a link to Litt while the HN title says "Mitt".
asrp··on 2D game art for programmers
Oh wow! Thanks for sharing this!

Is there a write up on how the accomplish the modularity side of things?

> Linux users: Kenney Studio works using Wine on Ubuntu and other Debian distros. We unfortunately can't give any support for this.

Oh well, this is a rather unfortunate. There doesn't seem to be a video preview either.

asrp··on Douane personal firewall for GNU/Linux
Nice project and makes you think why all programs are given all network access by default.

This page lists nothing under Packages but the author has actually made AUR packages for Archlinux:

https://github.com/Douane/Douane/wiki/Archlinux-Packaging

Here's a directly link to the installation instructions for anyone who'd want to try it out

https://github.com/Douane/Douane/wiki/Compilation

asrp··on 2D game art for programmers
> On the other hand, the nature of art and design is that it is a one-off and creating art for the game doesn't make creating art for another game easier for the artist, their friends or their business associates.

I have noticed this too. But why is it this way? Couldn't the process be made more modular?

The artist sometimes gets tool proficiency and workflow improvement out of it but the gain and reusability is not nearly as important as with programs.

asrp··on A very casual introduction to Fully Homomorphic Encryption (2012)
Can you tell us what do you mean by "encrypted program"?

Do you mean that if all operations of a universal Turing machine were homomorphic then you can encryt the code with a hard-coded input and get an encrypted output?

Can you also elaborate on your server example? I don't understand what you are trying to do. (Whats an "encrypted server"?

← PreviousPage 3 of 3