Skip to content

Instantly share code, notes, and snippets.

@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
@vi
vi / gimp
Created Feb 18, 2011
memory allocation errors in gtk programs
View gimp
vi@vi-notebook:~/_$ gimp-2.7 2.jpg
This is a development version of GIMP. Debug messages may appear here.
GLib-ERROR **: /build/buildd-glib2.0_2.24.2-1-i386-AScyie/glib2.0-2.24.2/glib/gmem.c:137: failed to allocate 4096 bytes
aborting...
gimp-2.7: terminated: Aborted
(script-fu:5118): LibGimpBase-WARNING **: script-fu: gimp_wire_read(): error
@vi
vi / hacky_streamer
Created Sep 5, 2011
Ad-hoc HTTP video streamer from webcam using socat and ffmpeg
View hacky_streamer
#!/bin/sh
schedtool -R -p 2 -e /usr/bin/socat tcp-l:5555,fork,reuseaddr system:'printf "HTTP/1.0\\\\x20200\\\\x20OK\\\\r\\\\nContent-Type\:\\\\x20video/x-matroska\\\\r\\\\n\\\\r\\\\n" && ffmpeg -f video4linux2 -ss 2 -i /dev/video0 -ss 2 -f oss -ac 1 -i /dev/dsp -s 320x240 -vcodec libx264 -vpre ultrafast -b 300k -ar 22050 -acodec libmp3lame -ab 32k -f matroska pipe\:1 < /dev/null'
@vi
vi / 0001-Strace-based-speed-limiter.patch
Created Nov 29, 2011
Simple process IO read/write rate limiter based on strace
View 0001-Strace-based-speed-limiter.patch
From 7959a97980894e1a47361e566d234a5f341dd05d Mon Sep 17 00:00:00 2001
From: Vitaly _Vi Shukela <vi0oss@gmail.com>
Date: Tue, 29 Nov 2011 19:29:50 +0300
Subject: [PATCH] Strace-based speed limiter
Apply to strace-4.6
Set env SPEEDLIMIT_READ=1000 and slow down other process with strace
Example: SPEEDLIMIT_READ=$((200*1024)) ./strace -o /dev/null -p `pidof wget`
---
@vi
vi / cputime.patch
Created Feb 16, 2012
A patch for [Yappi](http://code.google.com/p/yappi/) to measure CPU time instead of wall time
View cputime.patch
From vi0oss@gmail.com Thu Feb 16 21:43:27 2012
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [PATCH] Switch between measuring wall-clock time and CPU time with
YAPPI_CPUTIME environment variable
X-Mercurial-Node: f73ffd1c1bed66f0a95b39460788cc411ddc1003
Message-Id: <f73ffd1c1bed66f0a95b.1329417806@localhost>
User-Agent: Mercurial-patchbomb/1.6.4
Date: Thu, 16 Feb 2012 21:43:26 +0300
@vi
vi / gist:1987652
Created Mar 6, 2012
Bug with git v1.8
View gist:1987652
v@l:20:30:10:/tmp/gittest$ git init
Initialized empty Git repository in /tmp/gittest/.git/
v@l:20:30:12:/tmp/gittest$ echo q > q && git add q && git commit -m q
[master (root-commit) 9d49ad5] q
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 q
v@l:20:30:16:/tmp/gittest$ echo q2 > q && git add q && git commit -m q2
[master 27cc7c1] q2
1 files changed, 1 insertions(+), 1 deletions(-)
v@l:20:30:23:/tmp/gittest$ git rebase -i HEAD^
@vi
vi / gist:1997196
Created Mar 7, 2012
"git diff --no-index" beheviour on special files
View gist:1997196
$ diff -ur <(printf 'a\nb\nc\n') <(printf 'a\nd\nc\n')
--- /dev/fd/63 2012-03-08 02:27:23.088325870 +0300
+++ /dev/fd/62 2012-03-08 02:27:23.088325870 +0300
@@ -1,3 +1,3 @@
a
-b
+d
c
$ git diff --no-index <(printf 'a\nb\nc\n') <(printf 'a\nd\nc\n')
diff --git a/dev/fd/63 b/dev/fd/62
You can’t perform that action at this time.