Skip to content

Instantly share code, notes, and snippets.

@vi
vi / git-extract-submodule
Created December 24, 2010 02:31
Script to extract submodules from git repositories. Depends on --split-submodule filter.
#!/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;
@vi
vi / 0001-Strace-based-speed-limiter.patch
Created November 29, 2011 16:33
Simple process IO read/write rate limiter based on strace
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`
---
@eddyb
eddyb / rustfilt.sh
Last active November 30, 2016 16:22
#!/usr/bin/env bash
SED_SCRIPT=`echo '{\
s/_\\$/$/g;\
s/\\$BP\\$/\&/g;\
s/\\$SP\\$/\@/g;\
s/\\$LT\\$/</g;\
s/\\$GT\\$/>/g;\
s/\\$LP\\$/(/g;\
s/\\$RP\\$/)/g;\
s/\\$RF\\$/\\&/g;\
@NickSto
NickSto / session-recover.py
Created November 28, 2017 05:28
Python 3 script to recover your tabs from a Session Manager .session file.
#!/usr/bin/env python3
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import
from __future__ import unicode_literals
import sys
import json
import errno
import argparse
@Centril
Centril / await.md
Last active April 30, 2019 13:52
Centril's views on the "Await Syntax Write Up"

Centril's views on the "Await Syntax Write Up"

in our opinion this — which we will call the "error handling problem” — remains the primary problem that we are trying to resolve.

I don't agree that this is the primary problem; it's one of many problems to resolve; Chaining (and thus not forcing temporaries), general composability, and working well with IDEs is among notable problems.

Syntactic Sugar Solution:

I think it is a stretch to call this syntactic sugar in the first place. The syntax await? is composing await + ?. In my view this is not enough semantic compression to be deserving of the description "syntactic sugar".

@ghedo
ghedo / Makefile
Last active January 13, 2022 13:22
Kernel module to disable the ptrace() system call (http://blog.ghedini.me/post/10240771002/kernel-module-to-disable-ptrace)
# Copyright (C) 2011 Alessandro Ghedini <alessandro@ghedini.me>
# Updated 2012 by Mike Perry to extract syscall table addresses
# Updated 2014 by Francis Brosnan Blázquez to check for ia32 support
obj-m += noptrace2.o
KERNEL_VER=$(shell uname -r)
SCT := $(shell grep " sys_call_table" /boot/System.map-$(KERNEL_VER) | awk '{ print $$1; }')
SCT32 := $(shell grep "ia32_sys_call_table" /boot/System.map-$(KERNEL_VER) | awk '{ print $$1; }')
@njonsson
njonsson / git-rebase-tags.rb
Created April 7, 2011 18:29
UPDATE: Use the `--tag-name-filter` option of `git-filter-branch`. http://blog.nilsjonsson.com/post/4421450571/rebasing-tags-in-git-repositories
#! /usr/bin/env ruby
def pluralize(word, count=2, plural_word=nil)
plural_word ||= "#{word}s"
"#{count} #{(count == 1) ? word : plural_word}"
end
unless (ARGV.length == 1) &&
(good_revision = system("git log -1 #{ARGV.first} 2>/dev/null"))
puts "Unknown revision '#{ARGV.first}'" unless good_revision
;annotation syntax
(import [java.lang.annotation Retention RetentionPolicy Target ElementType]
[javax.xml.ws WebServiceRef WebServiceRefs])
(definterface Foo (foo []))
;annotation on type
(deftype ^{Deprecated true
Retention RetentionPolicy/RUNTIME
javax.annotation.processing.SupportedOptions ["foo" "bar" "baz"]
@kazuho
kazuho / thundering-herd.pl
Last active February 8, 2023 03:46
thundering herd checker for select-accept pattern
#! /usr/bin/perl
#
# to test:
# 1) run this script with either "accept" or "select-accept" as the argument
# (the script listens to 127.0.0.1:12345)
# 2) telnet localhost 12345
# 3) if you see "accept failed", there is the thundering herd problem
#
#
use strict;
@vi
vi / hacky_streamer
Created September 5, 2011 07:00
Ad-hoc HTTP video streamer from webcam using socat and ffmpeg
#!/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'