Skip to content

Instantly share code, notes, and snippets.

@thanatos
thanatos / minimal-xhtml.rst
Last active August 29, 2015 14:01
Minimal XHTML document

Gathering info from here_ and `The WHATWG Blog`_, the minimal XHTML 5 document.

(This is served with Content-Type: application/xhtml+xml.)

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title></title>
@thanatos
thanatos / py-unittest-locations.rst
Last active August 29, 2015 14:04
Python: Where do unittests go?

Considerations

The filename

It's basically between test_foo.py and foo_test.py, though one might argue that if tests are in a tests/ directory, you shouldn't need to prefix/suffix each file with test because the path already has it. However, it seems like many testing frameworks — such as nose — really want that.

@thanatos
thanatos / tmobile.txt
Last active August 29, 2015 14:05
T-Mobile, what *is* this?
Captured in the heart of silicon valley…
--- 8.8.8.8 ping statistics ---
1590 packets transmitted, 1513 packets received, 4.8% packet loss
round-trip min/avg/max/stddev = 36.482/2250.401/69421.562/8192.683 ms
Request timeout for icmp_seq 65
Request timeout for icmp_seq 66
Request timeout for icmp_seq 67
@thanatos
thanatos / utf8-template1.sql
Created October 2, 2014 19:00
Make PosgreSQL's "template1" database UTF-8
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
DROP DATABASE template1;
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UTF-8';
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
GRANT CONNECT ON DATABASE template1 TO PUBLIC;
REVOKE TEMPORARY ON DATABASE template1 FROM PUBLIC;
\c template1
VACUUM FREEZE;
@thanatos
thanatos / test.md
Last active August 29, 2015 14:11
markdown test
this is a test qqq
a b c r
@thanatos
thanatos / context_switch_speed.py
Created February 3, 2015 16:12
Context Switches Speeds: OS threads vs. gevent greenlets
from __future__ import print_function
import datetime
import threading
import gevent
# Greenlets:
@thanatos
thanatos / Cargo.toml
Last active August 29, 2015 14:17
Rust regex! requires `extern crate regex` in `src/lib.rs`?
[package]
name = "regextest"
version = "0.0.1"
[dependencies]
regex = "*"
regex_macros = "*"
@thanatos
thanatos / printf.py
Created May 1, 2015 04:21
printf() in Python
# Bring together the wonderful .format() function, and print():
def printf(pformat, *args, **kwargs):
print_kwargs = {}
for arg in ('sep', 'end', 'file', 'flush'):
if arg in kwargs:
print_kwargs[arg] = kwargs.pop(arg)
print(pformat.format(*args, **kwargs), **print_kwargs)
@thanatos
thanatos / about.rst
Last active August 29, 2015 14:21
Why do these ping packets not get dropped?

Why do these ping packets not get dropped?

See the attached ping outputs, where I get hilariously bad ping times, including this beauty:

64 bytes from 8.8.8.8: icmp_seq=425 ttl=55 time=92255.756 ms

This is on mobile.

There's a corresponding ping to the phone, but it tends to be at about ~2ms. The phone reports terrible signal ("-107 dBm * 3 ASU") for about the first half (up to the part where I'm getting 90 second pings) at which point I move to a window, and my signal improves drastically to "-85 dBm * 14 ASU" (full bars); regardless, the entire time the phone reports that it has "(DC)HSDPA+ * 42.2 Mbps", which I understand to be the best my phone can do (Samsung Galaxy Nexus). Even after moving to the high signal location, the high ping times continue. It's not until I bounce (I go into airplane mode briefly) the antennas on my phone that things improve.

foo(N) :- write('Roy'), write('sits'), bar(N), write('bored'), write(N).
bar(N) :- write('here').