Skip to content

Instantly share code, notes, and snippets.

View kragen's full-sized avatar

Kragen Javier Sitaker kragen

View GitHub Profile
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Try out my Python implementation of the relational algebra on a real query.
I wrote it a few years back, and then I realized that the SQL version
of this query was much worse than the relational algebra version, so I
thought I would see if the query in my Python implementation of part
of the relational algebra was also better than the SQL version.
Here’s the original relational algebra source code:

Fuck. Firefox's history UI is so fucking bad that this is actually fucking better:

: user@debian:~; sqlite3 places.sqlite 
SQLite version 3.7.13 2012-06-11 02:05:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .mode column
sqlite> select title, url, visit_count, datetime(last_visit_date/1000000, 'unixepoch') from moz_places order by last_visit_date desc limit 100;

Disable or remove Add-ons | Firefox Help  https://support.mozilla.org/en-US/kb/disable-or-remove-add-ons  1            2015-04-27 22:27:25                           
### Basic Sierpinski harmony bytebeat t & t >> 8 in as few bytes as possible:
.globl _start
_start: inc %ebx # output fd 1 in %ebx for write()
inc %edx # byte count of 1 in %edx for write()
loop: inc %eax # increment t each time through the loop
push %eax # save it on the stack
and %ah, %al # compute t & t >> 8, our output sample
push %eax # store it on the stack for write()
lea 3(%ebx), %eax # a three-byte way to set %eax to 4 (__NR_write)
mov %esp, %ecx # pass sample pointer to write() (little-endian!)
@kragen
kragen / README.md
Created October 12, 2011 20:04
hello, world in C++ produces 2000+ lines of crap!

In response to this silly complaint. Have these people never before seen a compiler and linker?

-- more notes on this issue at http://gist.github.com/106582 and http://gist.github.com/109036
-- Here are the table definitions I’m using.
create table visits (plano text,
"column" text,
"row" text,
route text);
create table square (plano text,
"column" text,
"row" text,
@kragen
kragen / ideas.md
Last active January 23, 2019 02:03

What I have most of are ideas, that and paranoia about evildoers imperiling their realization with patents, or using patents to force them to be realized in ways that strengthen the existing structures of oppression. So here are a few ideas, in case anyone else is interested.

  • Programmable self-reproducing robots from inorganic raw materials, of course, are the absolute most important thing that anyone could be working on right now. This is the crucial missing piece that keeps us constrained to a political structure where the owners of

Some people have serious difficulty with some naturally occurring levels of heat. The CEO of Singapore, Lee Kuan Yew, has credited air conditioning with allowing his (tropical) country to develop economically; and in recent years, as I age, I find myself suffering increasing levels of impairment and ill-being from the Buenos Aires summer. But air conditioning has some disadvantages. It requires large, capital-intensive machinery; it consumes a lot of energy to cool large spaces, and a lot of power to cool spaces with a lot of surface area to a hot outdoors; and it isn’t portable to many places people would like to go.

@kragen
kragen / gist:4b8644be70871c829448676900507c7d
Created November 30, 2017 20:35
how Hypothesis found a bug in my Adler-32 implementation
user@debian ~/dumpulse $ make test
cc -fPIC -g -Os -Wall -Wpedantic -std=c89 -o dumpulse.o -c dumpulse.c
cc -shared dumpulse_so.o dumpulse.o -o dumpulse.so
py.test-3 test.py
===================================== test session starts =====================================
platform linux -- Python 3.5.2, pytest-2.8.7, py-1.4.31, pluggy-0.3.1
rootdir: /home/user/dumpulse, inifile:
plugins: hypothesis-3.0.1
collected 1 items

(Forked from an earlier version.)

Suppose you're at an internet café machine and you want to create something, but you don't trust the machine with access to your credentials and identity. What can you do?

It turns out there are a variety of services on the web that allow you to publish things anonymously, with a greater or lesser degree of permanency, and with a public URL.

Pastebins

  • gist provides Markdown, editability (with a cookie I guess), versioning (and thus editing), and SSL encryption in transit.

Henry Farrell said, of Aaron Swartz:

Maybe better way to put it was that he was intensely focused on his (and only his) understanding of right thing to do.

Now, of course a person could be less focused on the right thing to do. Many people, for example, are focused on what they want to do, or what others want them to do, without regard to whether or not it's right. Clearly this is a way Aaron was very different from the mainstream.

And if you're considering understandings of right and wrong in the abstract — perhaps because you're teaching a class in ethics — perhaps you could focus on other people's understandings of right and wrong. Perhaps you're strongly consequentialist (as Aaron was) but today you're leading your students through Kant. You'd better focus on deontological understandings of the right thing to do, or your students are going to be in trouble.

But if we're talking about focusing on understandings of the right thing to do