Skip to content

Instantly share code, notes, and snippets.

@vi
vi / CLBlast_M_GT2.txt
Created Dec 21, 2017
Testing CLBlast
View CLBlast_M_GT2.txt
clblast_test_diagnostics
* Options given/available:
-platform 0 [=default]
-device 0 [=default]
--- OpenCL device naming:
* Device type GPU
* Device name Intel(R) HD Graphics IvyBridge M GT2
@vi
vi / tokiostdin.rs
Created Oct 9, 2017
Simple copy stdin to stdout example using Rust tokio
View tokiostdin.rs
extern crate futures;
extern crate tokio_core;
extern crate tokio_io;
extern crate tokio_file_unix;
use futures::{Future};
use tokio_io::io::copy;
use tokio_core::reactor::Core;
use std::io::{Result};
@vi
vi / miostdin.rs
Created Oct 9, 2017
Simple copy stdin to stdout example using Rust mio
View miostdin.rs
extern crate mio;
use mio::unix::EventedFd;
use std::fs::File;
use mio::{Token, PollOpt, Ready, Poll, Events};
//use mio_uds::UnixStream;
use std::os::unix::io::{FromRawFd};
use std::io::{Read, Write};
@vi
vi / hextobin.c
Created Aug 25, 2017
Hex string to byte buffer in C
View hextobin.c
// Based on https://stackoverflow.com/a/23898449/266720
void tallymarker_hextobin(const char * str, uint8_t * bytes, size_t blen)
{
uint8_t pos;
uint8_t idx0;
uint8_t idx1;
// mapping of ASCII characters to hex values
const uint8_t hashmap[] =
{
@vi
vi / _example.c
Last active Oct 27, 2017
Simple Robin Hood hash table implemented using C macros. See also: https://github.com/vi/macro_robinhood_hash
View _example.c
#include <stdio.h>
#include <stddef.h>
#include <assert.h>
#include "robinhoodhash.h"
struct entry {
int key;
char value;
};
@vi
vi / zlibdict.c
Last active May 4, 2017
Compress short files with a pre-defined zlib dictionary from command line
View zlibdict.c
#include <stdio.h>
#include <string.h>
#include <zlib.h>
#include <inttypes.h>
#include <assert.h>
uint8_t dict[4096];
size_t dict_size;
@vi
vi / mkv.csv
Last active Feb 1, 2017
Matroska element types from official spec page
View mkv.csv
We can make this file beautiful and searchable if this error is corrected: It looks like row 10 should actually have 14 columns, instead of 11. in line 9.
AlphaMode,4,[53][C0],-,-,-,0,u,,,*,*,*,Alpha Video Mode. Presence of this Element indicates that the BlockAdditional Element could contain Alpha data.
AspectRatioType,4,[54][B3],-,-,-,0,u,*,*,*,*,*,"Specify the possible modifications to the aspect ratio (0: free resizing, 1: keep aspect ratio, 2: fixed)."
AttachedFile,2,[61][A7],mand.,mult.,-,-,m,*,*,*,*,,An attached file.
AttachmentLink,3,[74][46],-,-,not 0,-,u,*,*,*,*,,The UID of an attachment that is used by this codec.
Attachments,1,[19][41][A4][69],-,-,-,-,m,*,*,*,*,,Contain attached files.
Audio,3,[E1],-,-,-,-,m,*,*,*,*,*,Audio settings.
BitDepth,4,[62][64],-,-,not 0,-,u,*,*,*,*,*,"Bits per sample, mostly used for PCM."
BitsPerChannel,5,[55][B2],-,-,-,0,u,,,,*,,Number of decoded bits per channel. A value of 0 indicates that the BitsPerChannel is unspecified.
Block,3,[A1],mand.,-,-,-,b,*,*,*,*,*,Block containing the actual data to be rendered and a timestamp relative to the Cluster Timecode. (see Block Structure)
BlockAddID,5,[EE],mand.,-,not 0,1,u,*,*,*
View memdump.c
// Source: http://unix.stackexchange.com/a/251769/17594
// Modifications: long long, exit codes, diagnostics
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <sys/ptrace.h>
#include <sys/socket.h>
#include <arpa/inet.h>
@vi
vi / formatunicode.pl
Last active Jun 24, 2016
Simple converter from markdown-style _annotations_ to Unicode combining characters.
View formatunicode.pl
#!/usr/bin/perl -C63
# Converts
# The -quick- _brown_ =fox= ^jumps^ +over+ ~the~ @lazy@ dog.
# into
# The q̶u̶i̶c̶k̶ b̲r̲o̲w̲n̲ f̳o̳x̳ j̅u̅m̅p̅s̅ o̱v̱e̱ṟ t̴h̴e̴ l̿a̿z̿y̿ dog.
#
# Implemented by Vitaly "_Vi" Shukela in 2016. Public domain / CC-0.
use strict;
@vi
vi / 000.txt
Last active May 24, 2016
Testing of bup hashsplit
View 000.txt
Aggregated data and plots: https://docs.google.com/spreadsheets/d/1lZ0D9ximUQuBydBsv-ASZ7L4NLMqipeg1o34z3LGbxY/edit#gid=0
System:
Linux vi-notebook 4.4.8-grsec-64+ #78 SMP PREEMPT Fri May 6 01:12:25 FET 2016 x86_64 GNU/Linux
Userland is 32-bit Linux Debian jessie/wheezy (bup is running in 32-bit mode)
Python 2.7.9
12 Gigabytes of RAM installed
There is considerable background activity.
You can’t perform that action at this time.