Skip to content

Instantly share code, notes, and snippets.

@t-mat
t-mat / building-busybox-w32-on-ubuntu.md
Created April 3, 2014 23:00
Building busybox-w32 on Ubuntu
sudo apt-get install -y git gcc-mingw32 libncurses5-dev
cd
git clone https://github.com/rmyorston/busybox-w32.git
cd ~/busybox-w32
find . -name "*" -exec sed -i "s/i686-pc-mingw32-/i686-w64-mingw32-/g" '{}' \;
make mingw32_defconfig
make menuconfig
# Exit menuconfig.
busybox sed -i '417 s/# undef HAVE_VASPRINTF$//g' include/platform.h
@t-mat
t-mat / lz4-streaming-api-example.c
Last active August 29, 2015 14:02
LZ4 streaming API example (double buffer)
// LZ4 streaming API example
#define _CRT_SECURE_NO_WARNINGS // for MSVC
#include "lz4.h"
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
enum {
@t-mat
t-mat / range-based-for-null-terminated-string.cpp
Created July 9, 2014 17:26
Range based for null terminated string
#include <iostream>
#include <string>
template<class Char>
class ForEachNullTreminatedStringIterator {
using ThisClass = ForEachNullTreminatedStringIterator;
public:
ForEachNullTreminatedStringIterator() : p{} {}
ForEachNullTreminatedStringIterator(Char* p) : p{p} {}
@t-mat
t-mat / 00_results.md
Last active August 29, 2015 14:04
LZ4 streaming API example 3 (pseudo logger application of the ring buffer method)

Results

Note : -my-streaming method is line-by-line LZ4 streaming compression.

Bytes Ratio File
205242368 1.0 access_log_Jul95
51008234 4.02 access_log_Jul95.lz4 -my-streaming
39127074 5.25 access_log_Jul95.lz4 -1
24648061 8.33 access_log_Jul95.lz4 -9
@t-mat
t-mat / Makefile-version
Created July 29, 2014 17:40
LZ4 Makefile test
## Old
##
## LIBVER_MAJOR=`sed -n '/LZ4_VERSION_MAJOR/s/.*\s\+\([0-9]\+\).*/\1/p' < lz4.h`
## LIBVER_MINOR=`sed -n '/LZ4_VERSION_MINOR/s/.*\s\+\([0-9]\+\).*/\1/p' < lz4.h`
## LIBVER_PATCH=`sed -n '/LZ4_VERSION_RELEASE/s/.*\s\+\([0-9]\+\).*/\1/p' < lz4.h`
## New
##
## (1) Need 'define ' to match only one line.
## (2) Use ' ' instead of '\s' for the compatibility. (Perhaps '[:blank:]' is better)
@t-mat
t-mat / svn-diff.bat
Created August 11, 2014 05:24
svn diff
set LANG=C
set LC_MESSAGES=C
svn diff > diff.txt
@t-mat
t-mat / using-latest-qemu-and-raspbian-on-windows.md
Last active August 29, 2015 14:05
Using lastest QEMU and Raspbian on Windows

Using lastest QEMU and Raspbian on Windows (x64)

Prerequisite

  • Put curl and 7z on your %PATH%

Downloading

@t-mat
t-mat / lz4-framing-api-example1.c
Last active August 29, 2015 14:05
lz4-framing-api-example1.c
#include <stdio.h>
#include "lz4Frame.h"
size_t LZ4F_getSrcSize(const LZ4F_preferences_t* preferences); // still missing function ?
int main() {
int result = EXIT_FAILURE;
FILE* inpFp = fopen("src.bin", "rb");
FILE* outFp = fopen("dst.lz4", "wb");
@t-mat
t-mat / lz4-framing-api-decoupled.c
Last active August 29, 2015 14:05
lz4-framing-api-decoupled.c
#include <stdio.h>
#include "lz4frame.h"
size_t compress(LZ4F_compressionContext_t* ctx, FILE* outFp, FILE* inpFp,
void* dstBuffer, size_t dstMaxSize, void* srcBuffer, size_t srcSize,
const LZ4F_compressOptions_t* options)
{
// Maybe LZ4F_compressBegin()'s compressOptions seems to have overlooked.
const size_t headerSize = LZ4F_compressBegin(
ctx, dstBuffer, dstMaxSize, options);
@t-mat
t-mat / lz4-framing-api-memory-to-memory-compression.c
Last active August 29, 2015 14:05
lz4-framing-api-memory-to-memory-compression.c
#include <stdio.h>
#include "lz4frame.h"
// Upper bound of total output frame size
size_t LZ4F_compressFrameBound(size_t srcSize, const LZ4F_preferences_t* preferences);
size_t compress(
LZ4F_compressionContext_t* ctx,
char* outPtr, size_t outSizeMax, const char* inpPtr, size_t inpSize,
const LZ4F_compressOptions_t* options, const LZ4F_preferences_t* preferences