Skip to content

Instantly share code, notes, and snippets.

View Quiark's full-sized avatar

Roman Plášil Quiark

View GitHub Profile
@Quiark
Quiark / sandbox.h
Created January 2, 2020 07:00
restricted version of sbtool that is compilable
// courtesy of clang
// https://github.com/applesrc/clang/blob/bb8f644/src/projects/compiler-rt/lib/sanitizer_common/sanitizer_mac_spi.cc
enum sandbox_filter_type {
SANDBOX_FILTER_NONE,
SANDBOX_FILTER_PATH,
SANDBOX_FILTER_GLOBAL_NAME,
SANDBOX_FILTER_LOCAL_NAME,
SANDBOX_FILTER_APPLEEVENT_DESTINATION,
mocha.setup({
ui: 'bdd',
timeout: 1000000
});
describe('key-recovery', function() {
describe('messaging', function() {
var allSessions, allMessengers, del;
beforeEach(function() {
private static final String CR_ALG_AES = "AES/CBC/PKCS5Padding";
private static final String CR_ALG_HMAC = "HmacSHA256";
private static final int CR_SALT_LENGTH = 16;
private CryptoHeader prepareHeader() {
CryptoHeader header = new CryptoHeader();
header.iv = new byte[16];
rnd.nextBytes(header.iv);
header.salt = new byte[CR_SALT_LENGTH];
rnd.nextBytes(header.salt);
@Quiark
Quiark / kdf.java
Last active February 28, 2016 07:55
Java Crypto Basics: generating key
import org.bouncycastle.crypto.PBEParametersGenerator;
import org.bouncycastle.crypto.digests.SHA256Digest;
import org.bouncycastle.crypto.generators.PKCS5S2ParametersGenerator;
import org.bouncycastle.crypto.params.KeyParameter;
private final int CR_ITERATIONS = 128 * 1000;
public byte[] kdfPassword(String pwd, byte[] salt, int outLength) {
PKCS5S2ParametersGenerator gen = new PKCS5S2ParametersGenerator(new SHA256Digest());
gen.init(PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(pwd.toCharArray()), salt, CR_ITERATIONS);
@Quiark
Quiark / compile.sh
Last active January 19, 2016 04:17
Emscripten exception bug
#!/bin/sh
FLAGS='-Wall -pedantic -std=c++11 -m32 -O0'
echo Compiling Emscripten...
mkdir -p emcc
/usr/local/opt/emscripten/libexec/em++ -o emcc/run.o $FLAGS -c -s DISABLE_EXCEPTION_CATCHING=0 -D_EXPORTING -D_REENTRANT -Isrc -Ithirdparty run.cpp
/usr/local/opt/emscripten/libexec/em++ -o emcc/tests_run.html $FLAGS -s DISABLE_EXCEPTION_CATCHING=0 emcc/run.o
echo Compiling native...
I0515 08:17:44.736468 97 handler.go:365] broadcast block to 3 peers. Total processing time: 10.052918ms
I0515 08:17:56.615301 97 chain_manager.go:628] imported 1 block(s) (0 queued 0 ignored) in 7.722167ms. #341261 [565afede / 565afede]
I0515 08:17:56.616387 97 handler.go:365] broadcast block to 3 peers. Total processing time: 9.309745ms
I0515 08:17:58.275281 97 chain_manager.go:628] imported 1 block(s) (0 queued 0 ignored) in 8.039771ms. #341262 [3c5b7245 / 3c5b7245]
I0515 08:17:58.276357 97 handler.go:365] broadcast block to 3 peers. Total processing time: 9.600445ms
I0515 08:18:18.752313 97 chain_manager.go:628] imported 1 block(s) (0 queued 0 ignored) in 7.66981ms. #341262 [4ab210d2 / 4ab210d2]
I0515 08:18:18.753286 97 handler.go:365] broadcast block to 3 peers. Total processing time: 9.118753ms
I0515 08:18:19.017984 97 chain_manager.go:580] Split detected. New head #341263 (7b8fd4a4) TD=50533362657080, was #341262 (3c5b7245) TD=50530696929510
I0515 08:18:19.019083
I0511 15:40:48.994113 33 backend.go:236] Protocol Version: 60, Network Id: 0
I0511 15:40:48.994285 33 backend.go:246] Blockchain DB Version: 2
I0511 15:40:48.999164 33 chain_manager.go:235] Last block (#303634) 61fda4d5349f75b781c5b3b997b89a86c4254987f401ffeaf2bfaf4a4017b926 TD=21511977842916
I0511 15:40:50.705388 33 cmd.go:107] Starting Geth/v0.9.18/linux/go1.4.2
I0511 15:40:50.705607 33 server.go:209] Starting Server
I0511 15:40:50.783944 33 udp.go:189] Listening, enode://bac7d8f39aacf6be0c6e14abbd01da2a156767f312d4d552c68f338512b0bf38f5985d68af27476faacf4f2e091d31c827319678421a6507194c1ef30f4286a4@61.238.66.141:30303
I0511 15:40:50.784130 33 backend.go:450] Server started
I0511 15:40:50.784127 33 server.go:349] Listening on [::]:30303
I0511 15:41:10.044957 33 server.go:487] Dialing enode://4beba5e2cfc63aa3bba90e84cd2c3690921b0ee4c72cecb96b6ce08b51d1614317dd86c167c957e7bf7c99c80ec7b6a948150bc29d1f76260b0e387e3acc1031@52.5.60.7:30303
I0511 15:41:10.045383 33
strokes = load_3d_csv(r'c:\Transfer\cmss\strokes.csv')
for ix, s in enumerate(strokes):
print ix, len(s['x']), len(s['y'])
assert len(s['x']) == len(s['y'])
assert len(s['x']) == len(s['t'])
assert len(s['x']) == (1 + len(s['v']))
@Quiark
Quiark / gist:7e7cf20e2749f52ef7ed
Created April 27, 2015 06:48
Loading the strokes.csv
def load_3d_csv(fname):
sta = []
with open(fname, 'rb') as inf:
rdr = csv.reader(inf, delimiter=';')
for ix, row in enumerate(rdr):
try:
if ix == 0: header = row
else: sta.append({header[y]: eval(row[y]) for y in range(len(row)) if row[y] != ''})
except SyntaxError as e:
The following email has not been delivered because the attachment does not
match recipient or there are multiple recipients for a statement.
================================
Recipient: {to}
Attachment: {filename}
Subject: {subject}
Date: {date}
================================