Skip to content

Instantly share code, notes, and snippets.

View genregex.log
R! 16.0403 l=4 PPCG
R! 15.0236 l=2 ^P
R! 14.0646 l=6 ^[P^]P
R! 13.0919 l=9 [^?][PG]$
R! 12.1617 l=16 (?<!\\..)(?!]).$
R! 8.19108 l=19 ^[\w^]*$|!|]P|G]\$$
R! 8.17125 l=17 !|[^?]P(CG|G..)?$
R! 5.25195 l=25 !|((G.|P|\.)\$|[^?]P|CG)$
R! 4.2402 l=24 ^[(!P]|G..$|]..\||[^?]P$
R! 3.29278 l=29 ^.{3,23}[.-~]..\$$|[^P?][PG]$
@vi
vi / copy_with_links
Created Dec 18, 2014
Copy a file with accompanying symlinks
View copy_with_links
View hash_.cpp
#include <stdio.h>
void hash(const unsigned char* buf, size_t len, unsigned long long *hash1, unsigned long long *hash2)
{
unsigned long long &h=*hash1;
unsigned long long &j=*hash2;
size_t l = len;
const unsigned char* b = buf;
h=0xC0CC3051F486B191;
@vi
vi / selectfuzz.c
Created Jul 22, 2015
Intentionally cause select/poll spurious activations for testing, LD_PRELOAD-based
View selectfuzz.c
#define _GNU_SOURCE 1
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <dlfcn.h>
#include <sys/time.h>
#include <sys/select.h>
#include <time.h>
#include <sys/stat.h>
@vi
vi / inhibitseekfail.c
Created Jul 22, 2015
Inhibit seek failures to force programs to continue when writing to pipes/sockets, LD_PRELOAD-based
View inhibitseekfail.c
#define _GNU_SOURCE 1
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <dlfcn.h>
#include <errno.h>
static int (*orig_llseek)(
unsigned int fd, unsigned long offset_high,
@vi
vi / 0001-libbpg-Implement-noalpha-option-to-skip-PNG-s-alpha-.patch
Created Sep 3, 2015
Patch for libbpg's bpgenc v0.9.5 to add -noalpha option like in cwebp
View 0001-libbpg-Implement-noalpha-option-to-skip-PNG-s-alpha-.patch
From fd121ea3730530289422566bdae6e77a45402e34 Mon Sep 17 00:00:00 2001
From: Vitaly _Vi Shukela <vi0oss@gmail.com>
Date: Wed, 26 Aug 2015 02:22:50 +0300
Subject: [PATCH] libbpg: Implement -noalpha option to skip PNG's alpha channel
pngenc command line tool loves PNG.
Sometimes users need to convert the picture to png in order
to feed it to pngenc.
While converting to png, alpha channel may creep in.
This makes bpgenc to fail to work in x265 mode and also produce
@vi
vi / 1_git-http-push-bug.txt
Created Nov 8, 2010
The Git I built from source code fails while the git from binary distribution works.
View 1_git-http-push-bug.txt
vi@vi-notebook:/tmp/mod$ git config remote.origin.url
http://127.0.0.1/gitmod/
vi@vi-notebook:/tmp/mod$ ~/src/git/git/git push origin master:refs/heads/master
Counting objects: 5, done.
Writing objects: 100% (3/3), 288 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
# it freezes
^C
vi@vi-notebook:/tmp/mod$ /usr/bin/git push origin master:refs/heads/master
Counting objects: 5, done.
@vi
vi / gist:753796
Created Dec 24, 2010
Attempt to use --split-submodule
View gist:753796
vi@vi-notebook:~/_/gittest$ tar -czf /tmp/gittest.tar.gz .git
vi@vi-notebook:~/_/gittest$ git reset --hard
HEAD is now at 70cd7a6 fix assoc/auth event parsing
vi@vi-notebook:~/_/gittest$ git filter-branch --split-submodule headers
Rewrite a16340b152a6d3df3a3204adcbfb8d4c7670afa6 (1/261)cat: /home/vi/_/gittest/.git-rewrite/t/../map/: Is a directory
Rewrite cf98a6eae1681faa32d0da9fbabfc99707181a61 (6/261)fatal: 90272c0d8b3efd04a5e0666da6d8b8db1be16253 is not a valid 'commit' object
vi@vi-notebook:~/_/gittest$
@vi
vi / git-extract-submodule
Created Dec 24, 2010
Script to extract submodules from git repositories. Depends on --split-submodule filter.
View git-extract-submodule
#!/bin/bash
# Extract subdirectory into a submodule.
if [ -z "$1" ]; then
echo "Usage: extract-submodule subdirectory"
echo "No trailing slash"
echo "Should be run from the root directory of repository"
echo "Everything should be clean prior to running this script"
echo "You need to manually copy submodule somewhere and update .gitmodules file appropriately"
exit 1;
View gist:808077
vi@vi-notebook:~/_$ git clone -b valgrind-failure git://github.com/vi/tcplim.git
Cloning into tcplim...
...
vi@vi-notebook:~/_$ cd tcplim/
vi@vi-notebook:~/_/tcplim$ make
gcc -O2 tcplim.c -o tcplim
vi@vi-notebook:~/_/tcplim$ socat tcp-l:9998,reuseaddr,fork file:/dev/zero&
[1] 11525
vi@vi-notebook:~/_/tcplim$ valgrind ./tcplim 127.0.0.1 9999 127.0.0.1 9998 10000000 10000000 1000000000 1000000000 50 2> log&
[2] 11550
You can’t perform that action at this time.