Skip to content

Instantly share code, notes, and snippets.

View maxp's full-sized avatar

Maxim Penzin maxp

View GitHub Profile
gpsbabel -w -t -i garmin -f /dev/ttyS0 -o kml -F output.kml
String json_q( String s ) {
return s.replaceAll( "\\\\", "\\\\\\\\" ).replaceAll( "\"", "\\\\\"" );
}
@maxp
maxp / linux-tcp.txt
Created December 2, 2010 09:56
Tuning the Linux Kernel for many tcp connections
Put these in /etc/sysctl.conf then run sysctl -p to apply them.
# General gigabit tuning:
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_syncookies = 1
# this gives the kernel more memory for tcp
@maxp
maxp / load-css.js
Created December 3, 2010 17:25
how to load css using jquery
$("head").append("<link>");
css = $("head").children(":last");
css.attr({
rel: "stylesheet",
type: "text/css",
href: "/javascripts/jwysiwyg/jquery.wysiwyg.css"
});
@maxp
maxp / deferred-gmap.js
Created December 4, 2010 04:41
deferred GoogleMap loading
(function(window,undefined){
var document = window.document;
var self = {
map: undefined,
elem: undefined,
load: function( elem ) {
self.elem = elem;
if( self.is_loaded ) { return; }
var callback = "window.gmap.load_cb"
var s = document.createElement("script");
@maxp
maxp / ebs-fabric.py
Created December 11, 2010 12:17
A Fabric script for striping EBS volumes
import commands
from fabric.api import *
# Globals
env.project='EBSSTRIPING'
env.user = 'myuser'
DEVICES = [
@maxp
maxp / tcp-tune.sh
Created December 11, 2010 15:59
tcp high load
echo “10152 65535″ > /proc/sys/net/ipv4/ip_local_port_range
sysctl -w fs.file-max=128000
sysctl -w net.ipv4.tcp_keepalive_time=300
sysctl -w net.core.somaxconn=250000
sysctl -w net.ipv4.tcp_max_syn_backlog=2500
sysctl -w net.core.netdev_max_backlog=2500
ulimit -n 10240
class AttrDict(dict):
def __getattr__(self, key):
return self[key]
def __setattr__(self, key, value)
self[key] = value
@maxp
maxp / vim-russian.vim
Created March 26, 2011 14:37
vim russian
set keymap=russian-jcukenwin
set iminsert=0
set imsearch=0
highlight lCursor guifg=NONE guibg=Cyan
:setlocal spell spelllang=ru_yo,en_us
:setlocal spell spelllang=ru_ru,en_us
# use Ctrl-^ to switch
@maxp
maxp / pi.c
Created April 7, 2011 15:09
Program to compute an approximation of pi by Brian Westley, 1988
// required: gcc -traditional-cpp pi.c
#define _ -F<00||--F-OO--;
int F=00,OO=00;
main(){F_OO();printf("%1.3f\n",4.*-F/OO/OO);}F_OO()
{
_-_-_-_
_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_