Skip to content

Instantly share code, notes, and snippets.

@jethrogb
jethrogb / coordinate.rs
Last active August 17, 2021 10:08
Custom Diesel wrapper type example
/// This defines a custom Diesel type for storing a 6-bit integer and a 58-bit
/// integer in the same 64-bit SQL column
use std::error::Error;
use std::fmt;
use std::io::Write;
use diesel::backend::Backend;
use diesel::types::{FromSqlRow,FromSql,ToSql,HasSqlType,IsNull,BigInt,Nullable};
use diesel::expression::AsExpression;
use diesel::row::Row;
all: test-dl test-lrpath1 test-lrpath2 test-lsoname1 test-lsoname2 test-lsymver1 test-lsymver2
.SECONDARY:
clean:
rm -rf 1 2 libuse* libdef* test-* foo*.o
test-dl: test.c
gcc $< -ldl -o $@
@jethrogb
jethrogb / rust-libstd_build
Created June 19, 2015 08:40
Makefile for building Rust libstd
## DO NOT save as `Makefile', instead save this as Makefile.std or something
## You probably want to use the same source that your local rustc was built from.
## run `make info' before configuring manually
CFG_BUILD=x86_64-unknown-linux-gnu
HOST_LLVM_MC=`which llvm-mc-3.5`
HOST_LLC=`which llc-3.5`
## run `make prepare' before configuring by copy/pasting

Keybase proof

I hereby claim:

  • I am jethrogb on github.
  • I am jethrogb (https://keybase.io/jethrogb) on keybase.
  • I have a public key whose fingerprint is 1F9B 8F0D BFC9 4C2C 0762 26D7 E4F3 BEDE 5FD0 0974

To claim this, I am signing this object:

@jethrogb
jethrogb / nibblesort.c
Last active August 29, 2015 14:14
AVX2 nibble sort
/**
* Copyright (C) 2015 Jethro G. Beekman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@jethrogb
jethrogb / librustc_build
Created January 13, 2015 07:23
Script to build librustc only
#!/bin/bash
# Just rebuild librustc and friends from the rust source.
# This probably works as long as you use the same source tree your binaries
# were built from and you don't modify anything outside of src/librustc*
echo If rustc fails with '"multiple dylib candidates for `rustc_...` found"' you
echo should move away '"librustc_llvm-*.so"' from the '"candidate #1"' directory.
echo
# Grab these from `make -pn`
---
:symbols:
- [&c ! ':c', &d ! ':d', &l ! ':l', &m ! ':m', &p ! ':p', &r ! ':r', &s ! ':s', &t ! ':t', &v ! ':v']
- [&action ! ':action', &bonus ! ':bonus', &concentration ! ':concentration', &reaction ! ':reaction']
- [&brd ! ':brd', &clr ! ':clr', &drd ! ':drd', &pal ! ':pal', &rgr ! ':rgr', &sor ! ':sor', &wiz ! ':wiz', &wlk ! ':wlk']
- [&abjur ! ':abjur', &conj ! ':conj', &div ! ':div', &ench ! ':ench', &evoc ! ':evoc', &illus ! ':illus', &necro ! ':necro', &trans ! ':trans']
- [&phb ! ':phb']
# libYAML does not support symbols in a flow context, we use this kludge with
# aliases and tags instead. Syck and Spyc support it just fine, so feel free to
# s/*/:/ in that case and get rid of the lines above.