Skip to content

Instantly share code, notes, and snippets.

View fcicq's full-sized avatar

fcicq fcicq

View GitHub Profile
From: Tom Herbert <therbert@google.com>
Subject: net: backport SO_REUSEPORT patch to fix load imbalance among listen sockets
Patch-mainline: In house
References:
http://permalink.gmane.org/gmane.linux.network/158320
This patch implements so_reuseport (SO_REUSEPORT socket option) for
TCP and UDP. For TCP, so_reuseport allows multiple listener sockets
to be bound to the same port. In the case of UDP, so_reuseport allows
#!/usr/bin/env python
import random
class CurveFp( object ):
def __init__( self, p, a, b ):
self.__p = p
self.__a = a
self.__b = b
def p( self ):
@fcicq
fcicq / lub.sh
Created November 3, 2012 10:22
Live Ubuntu Backup (lub) V2.2 by billbear http://forum.ubuntu.org.cn/viewtopic.php?f=21&t=206287
#!/bin/bash
# Live Ubuntu Backup V2.2, Nov 4th,2009
# Copyright (C) 2009 billbear <billbear@gmail.com>
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License,
# or (at your option) any later version.
#
@fcicq
fcicq / amd-opencl-sdk.sh
Created November 7, 2012 11:46
install AMD OpenCL SDK
# use -b to put in background
wget http://download2-developer.amd.com/amd/Stream20GA/icd-registration.tgz
tar zxvf icd-registration.tgz
mkdir -p /etc/OpenCL/vendors/
cp etc/OpenCL/vendors/atiocl64.icd /etc/OpenCL/vendors/atiocl64.icd
wget http://download2-developer.amd.com/amd/APPSDK/AMD-APP-SDK-v2.4-lnx64.tgz
cd /opt
tar zxvf ~/AMD-APP-SDK-v2.4-lnx64.tgz # or path
@fcicq
fcicq / adler32.py
Created December 5, 2012 10:49
Rsync Rolling Hash (Adler-32)
# modified from pysync
_BASE=65521 # largest prime smaller than 65536
_NMAX=5552 # largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1
_OFFS=1 # default initial s1 offset
# fcicq: _NMAX is embedded in zlib's adler32 for one pass calculation,
# and we mainly do the rolling hash, so _NMAX is not used here.
import zlib
class adler32:
def __init__(self,data=''):
@fcicq
fcicq / qemu
Created December 8, 2012 13:13
/etc/libvirt/hooks/qemu backup, kvm+libvirt port range forwarding (iptables hooks)
#!/bin/sh
# this is /etc/libvirt/hooks/qemu
# see also http://wiki.libvirt.org/page/Networking#Forwarding_Incoming_Connections
HOST_PORT="17000:17030"
GUEST_IP="192.168.122.2"
COMMAND_1="iptables -t nat -D PREROUTING -p tcp --dport ${HOST_PORT} -j DNAT --to ${GUEST_IP}"
COMMAND_2="`echo \"${COMMAND_1}\" | sed -e \"s/tcp/udp/\"`"
COMMAND_3="iptables -D FORWARD -p tcp -d ${GUEST_IP}/32 -m state --state NEW -m tcp --dport ${HOST_PORT} -j ACCEPT"
COMMAND_4="iptables -D FORWARD -p udp -d ${GUEST_IP}/32 -m udp --dport ${HOST_PORT} -j ACCEPT"
[8755143.193404] BUG: soft lockup - CPU#1 stuck for 22s! [nginx:9811]
[8755143.194729] Process nginx (pid: 9811, ti=ec4ae000 task=eb64f230 task.ti=eac0c000)
[8755143.195964] Stack:
[8755143.197155] Call Trace:
[8755143.198350] <IRQ>
[8755143.199669] Code: cc cc cc cc b8 1c 00 00 00 cd 82 c3 cc cc cc cc cc cc cc cc cc cc
cc cc cc cc cc cc cc cc cc cc cc cc cc cc b8 1d 00 00 00 cd 82 <c3> cc cc cc cc cc cc cc
cc cc cc cc cc cc cc cc cc cc cc cc cc
@fcicq
fcicq / seaslic.sh
Created December 16, 2012 10:26
qemu + seaslic
# usage: qemu-kvm -acpitable file=FILE/TO/374/BYTES/SLIC/BIN
# You may wish to modify the path to your own
SLIC_PATH=""
if [ "${SLIC_PATH}" == "" ]; then
SLIC_PATH="/sys/firmware/acpi/tables/SLIC"
fi
git clone git://github.com/ghuntley/seaslic
cd seaslic
This patch adds configuration for DMI configuration data.
This is useful if you want to run SeaBIOS on real Hardware,
and the OS selects drivers based on hw manufacturer/model.
Signed-off-by: Sven Schnelle <svens at stackframe.org>
---
src/Kconfig | 26 ++++++++++++++++++++++++++
src/config.h | 1 -
src/smbios.c | 15 +++++++--------
3 files changed, 33 insertions(+), 9 deletions(-)
@fcicq
fcicq / gf.py
Last active December 10, 2015 00:29
GF(2^8)
# GF(2^8) by http://www.samiam.org/galois.html
def generate_table():
table = [0] * 256
ltable = [0] * 256
a = 1
for c in range(256):
table[c] = a
d = a & 0x80
a = (a << 1) & 0xff
if d == 0x80: a ^= 0x1b