Skip to content

Instantly share code, notes, and snippets.

Nico Weber nico

Block or report user

Report or block nico

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
import Adafruit_SSD1306
import struct
import sys
import termios
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
# 128x64 display with hardware I2C:
disp = Adafruit_SSD1306.SSD1306_128_64(rst=24)
View gist:0ca75f5e0afd898ef78ef8d078ead7bb
C:\src\hack>type xmltest_in.xml
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="common.css"?>
<hi xmlns="" xmlns:x="urn:example-com:bar-ns">
<?foobar version="1.0"?>
/>text&amp;more@<x:ho x:attr="adsf"/>
<!-- adsf -->
View gist:97bd26b5f287808ecf2edf8e1c4eb55d
Nicos-MacBook-Pro:hack thakis$ clang -o xmltest -I$(xcrun -show-sdk-path)/usr/include/libxml2 -lxml2 && ./xmltest xmltest_in.xml
xmltest_in.xml:3: namespace warning : xmlns: URI foo is not absolute
<hi xmlns="foo" xmlns:x="bar">
1/XML_ELEMENT_NODE hi (null)
def ns: ((null):foo XML_NAMESPACE_DECL) (x:bar XML_NAMESPACE_DECL) 3/XML_TEXT_NODE text
nico / foo.diff
Created Apr 17, 2017
tim.exe memory tracking
View foo.diff
diff --git a/ b/
index 4d8200e..f6cfc19 100644
--- a/
+++ b/
@@ -16,7 +16,11 @@
#include <stdlib.h>
#include <windows.h>
+#include <psapi.h> // Must be after windows.h

Keybase proof

I hereby claim:

  • I am nico on github.
  • I am thakis ( on keybase.
  • I have a public key whose fingerprint is 6CB0 90B6 D027 3BCF FD99 475D E98E DBFB D44D EE5C

To claim this, I am signing this object:

nico / gist:b0cca071e5b1fd71f929
Last active Jun 3, 2019
benchmarking different file stat()ing techniques on windows (parts based on
View gist:b0cca071e5b1fd71f929
// cl /Ox /GL /GR-
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
#include <direct.h>
View gist:511d9c0522c1c7c4f7e9
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
#include <direct.h>
#include <stdint.h>
nico / gist:5779489
Created Jun 14, 2013
repro for ninja issue #595
View gist:5779489
Nicos-MacBook-Pro:repro thakis$ cat
#!/usr/bin/env python
import ninja_syntax
n = ninja_syntax.Writer(open('', 'w'))
command='clang++ -c $in -o $out -MF $out.d -MMD',
nico / gist:5398098
Created Apr 16, 2013
ninja perf data for empty chromium builds over time.
View gist:5398098
Data was collected with:
time caffeinate ./ 4d9bf949e0fd6976725dea12bcc254fd39da6490 master ./ | tee time.csv
$ cat
# This script runs a given command over a range of Git revisions. Note that it
# will check past revisions out! Exercise caution if there are important
nico / gist:3890115
Created Oct 14, 2012
saving images
View gist:3890115
// uncompressed png, no dependencies
// from
void wpng(int w, int h, const uint8_t* pix, FILE* f) { // pix: rgba in memory
uint32_t crc_table[256];
for (uint32_t n = 0, c = 0; n < 256; n++, c = n) {
for (int k = 0; k < 8; k++) c = (c & 1) ? 0xedb88320L ^ (c >> 1) : c >> 1;
crc_table[n] = c;
#define CRCWRITE(d, len) fwrite(d, 1, len, f); for (int n = 0; n < len; n++) \
crc = crc_table[(crc ^ (d)[n]) & 0xff] ^ (crc >> 8)
You can’t perform that action at this time.