Skip to content

Instantly share code, notes, and snippets.

View cemeyer's full-sized avatar

Conrad Meyer cemeyer

  • Seattle, Washington
View GitHub Profile
iterable $ make install
/home/konrad/rpmbuild/BUILD/go-src/bin/6g -o _go_.6 array.go iterable.go
iterable.go:12: can't find import: container/list
make: *** [_go_.6] Error 1
iterable $ ls $GOROOT/pkg/${GOOS}_${GOARCH}/container/list.a -lh
-rw-r--r-- 1 konrad konrad 51K 2010-05-14 19:08 /home/konrad/rpmbuild/BUILD/go-src/pkg/linux_amd64/container/list.a
# The libraries and binaries produced by this compiler are not compatible
# with coreutils strip (yet).
%global debug_package %{nil}
%global __spec_install_post /usr/lib/rpm/check-rpaths /usr/lib/rpm/check-buildroot \
/usr/lib/rpm/redhat/brp-compress
Name: go
Version: 0
Release: 0.__RELEASE__%{?dist}
#!/usr/bin/python3
import base64
import binascii
import curses
import random
import queue
import struct
import sys
import time
@cemeyer
cemeyer / 2013-09-15.md
Created September 15, 2013 16:02
Hack: Improving XML bad-character filtering performance by 10x (Qt4)

Backstory: Some [Unicode code points are invalid in XML][invalid]; specifically, we want to filter the code points (hex) 0-8, b-c, and e-1f. Qt4's QXmlStreamWriter() makes no attempt to filter these codepoints in the documents it writes.

So, here's our baseline, with the same benchmark we'll use later (big.gpx is a giant 142 MB file, and GPX is an XML-based format):

./gpsbabel -i gpx -f big.gpx [-o gpx -F /dev/null] (x5)

17.2 user, 4.8 system, 22.1 total

In [GPSBabel][], we already subclass QXmlStreamWriter to add other convenience methods. So our initial attempt to filter bad characters was simply to interpose on all methods that take potentially unfiltered inputs (writeAttribute(), writeTextElement(), ...) and apply a QString::replace() substitution with a QRegExp.

@cemeyer
cemeyer / fbrightcol.user.js
Created April 15, 2014 15:51
Facebook: nuke right column (crap and ads)
// ==UserScript==
// @name Facebook: Kill rightcol
// @namespace facebook.com
// @include https://www.facebook.com/*
// @include http://www.facebook.com/*
// @include https://facebook.com/*
// @include http://facebook.com/*
// @version 1
// @grant none
// ==/UserScript==
@cemeyer
cemeyer / Migrate VMware workstation to qemu+kvm
Last active June 27, 2019 23:18
Steps to migrate a VMware VM to KVM
1) Deleted all vmware snapshots for the VM. sync. sync.
2) Followed rwmj's guide to setting up a br0 device for libvirt in Fedora.[0]
3) Grabbed vmware2libvirt[1] from Ubuntu (it's just a standalone python script) and
used it with --bridge br0 -f foo.vmx > foo.xml.
4) Converted my vmdk to raw with qemu-img[2], moved it to /var/lib/libvirtd per
instructions[3]
5) Edited my xml to point to the right disk, use the qemu/raw driver, use the right
path for kvm (/usr/bin/qemu-kvm on Fedora).
5.a) Configure a unix socket serial device (like VMware's "pipe" mode):
#pragma warning(disable:4996)
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<time.h>
using namespace std;
int w[1001], // instance of vector for creating distribution
C[1001][1001], // histograms per output bucket
O[1001]; // an "output," used only for inputting lines
@cemeyer
cemeyer / a.c
Created June 12, 2014 22:26
basic mmap test
#include <sys/mman.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sysexits.h>
@cemeyer
cemeyer / mallctl_output.txt
Created November 23, 2014 01:00
Output from new `mallctl(1)` tool
version: 3.6.0-194-gd49cb68b9e8b57169240e16686f4f60d6b5a089f
epoch: 1
thread.arena: 0
thread.allocated: 0
thread.allocatedp: 140346141230912
thread.deallocated: 0
thread.deallocatedp: 140346141230920
thread.tcache.enabled: 1
thread.tcache.flush: <error(1): Operation not permitted>
thread.prof.name: <error(2): No such file or directory>
$ ./blah
*** Error in `./blah': free(): invalid next size (fast): 0x0000000001632010 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x75a4f)[0x7f803d638a4f]
/lib64/libc.so.6(+0x7cd78)[0x7f803d63fd78]
./blah[0x404830]
./blah[0x4047fe]
./blah[0x4044b2]
./blah[0x404131]
./blah[0x402720]