воскресенье, 29 мая 2011 г.

simple token algorithm with PHP

function uid($n, $len1=5, $len2=15, $base=36)
  {
    $id_part = base_convert($n, 10, $base);
    $rand_part = str_shuffle('abcdefghijklmnopqrstuvwxyz0123456789');
    return sprintf("%0".$len1."s-%.".$len2."s", $id_part, $rand_part);
  }   

source: http://stackoverflow.com/questions/2377633/how-create-an-unique-20-single-byte-token-key-id-on-php

понедельник, 23 мая 2011 г.

Port forwarding on Linux without iptables?

socat TCP4-LISTEN:80,fork TCP4:www.yourdomain.org:8080

http://serverfault.com/questions/252150/port-forwarding-on-linux-without-iptables

четверг, 19 мая 2011 г.

Устраняем тормаза в ssh сессии debian

ServerAliveCountMax 3
ServerAliveInterval 10

понедельник, 16 мая 2011 г.

How to throttle bandwidth on a Linux network interface or app?

trickle should do what you want. If your running Ubuntu (or Debian, I think), you can install it with sudo apt-get install trickle, and then run it. trickle -s -d 10 -u 10 firefox (or so, I haven't used it in a while) would run firefox, limiting its download and upload speed to 10 kilobytes a second.

tc qdisc add dev tap0 root netem delay 50ms loss 50%
To add 20ms delay "tc qdisc add dev lo root handle 1:0 netem delay 20msec", and to remove it "tc qdisc del dev lo root"

wondershaper eth0 1000 200