• Build debian kernel

    Install required packages

    sudo apt-get install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc
    sudo apt-get --no-install-recommends install kernel-package
    Download kernel
    wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.4.tar.xz
    Unzip
    unxz linux-4.4.tar.xz
    tar xvf linux-4.4.tar
    Copy your config file and configure
    cd linux-4.4
    $ cp /boot/config-$(uname -r) .config

    make menuconfig
    Compile
    make-kpkg clean
    fakeroot make-kpkg --initrd --revision=1.0.myname kernel_image kernel_headers -j 4
    Install
    sudo dpkg -i ...


  • dmesg erroru meklēšana

    dmesg | more
    dmesg | egrep -i --color 'error|critical|failed'


  • opcache

    opcache.enable=1

    opcache.memory_consumption=128

    opcache.max_accelerated_files=4000

    opcache_revalidate_freq = 240

    sudo php5enmod opcache

    sudo service apache2 restart


  • WordPress behind nginx

    if ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] )
    && preg_match( '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/',
    $_SERVER['HTTP_X_FORWARDED_FOR'] ) )
    $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];


  • vlc as root

    sed -i 's/geteuid/getppid/' /usr/bin/vlc


  • HTML from capture mobile image

    <input type="file" id="mypic" accept="image/*">

    <form method="post" action="takephoto.php" enctype="multipart/form-data">
    <input type="file" accept="image/*" name="file">
    <input type="submit">
    </form>


  • process

    $ sudo update-rc.d myserver defaults

    To do this, you must create this file and save it in /etc/init.d/.

    #!/bin/sh

    DAEMON="/path/to/myserver.py"
    DAEMONUSER="myuser"
    DEAMON_NAME="myserver.py"

    PATH="/sbin:/bin:/usr/sbin:/usr/bin"

    test -x $DAEMON || exit 0

    . /lib/lsb/init-functions

    d_start () {
    log_daemon_msg "Starting system $DEAMON_NAME Daemon"
    start-stop-daemon --background --name $DEAMON_NAME --start --user $DAEMONUSER --exec $DAEMON
    log_end_msg $?
    }

    d_stop () {
    log_daemon_msg "Stopping system $DEAMON_NAME Daemon"
    start-stop-daemon --name $DEAMON_NAME --stop --retry 5 --name $DEAMON_NAME
    log_end_msg $?
    }

    case "$1" in

    start|stop)
    d_${1}
    ;;

    restart|reload|force-reload)
    d_stop
    d_start
    ;;

    force-stop)
    d_stop
    killall -q $DEAMON_NAME || true
    sleep 2
    killall -q -9 $DEAMON_NAME || true
    ;;

    status)
    status_of_proc "$DEAMON_NAME" "$DAEMON" "system-wide $DEAMON_NAME" && exit 0 || exit $?
    ;;
    *)
    echo "Usage: /etc/init.d/$DEAMON_NAME {start|stop|force-stop|restart|reload|force-reload|status}"
    exit 1
    ;;
    esac
    exit 0

    $ sudo chmod 755 /etc/init.d/myserver
    $ sudo chmod 755 /path/to/mserver.py

    http://stackoverflow.com/questions/13718821/run-python-script-as-daemon-at-boot-time-ubuntu


  • proftpd shut down issue

    /etc/init.d/proftpd
    Find this line:
    start-stop-daemon --stop --signal $SIGNAL --quiet --pidfile "$PIDFILE"
    Change to this:
    start-stop-daemon --stop --signal $SIGNAL --retry 1 --quiet --pidfile "$PIDFILE"


  • Fruitsnow

    <script src="fruitsnow.js" type="text/javascript"></script>
    <script type="text/javascript" src="http://beneposto.pl/jqueryrotate/js/jQueryRotateCompressed.js"></script>
    <script type="text/javascript">
    //<![CDATA[
    window.onload = function() {

    function timeouts() {
    setTimeout(function () {
    fruitfall();
    timeouts();
    }, 10000);
    }
    timeouts();
    fruitfall();

    var rotation = function (){
    jQuery(".auglis1").rotate({
    angle:0,
    animateTo:360,
    duration: 2000,
    callback: rotation,
    easing: function (x,t,b,c,d){
    return c*(t/d)+b;
    }
    });
    }
    rotation();

    var rotation2 = function (){
    jQuery(".auglis2").rotate({
    angle:360,
    animateTo:0,
    duration: 2000,
    callback: rotation2,
    easing: function (x,t,b,c,d){
    return c*(t/d)+b;
    }
    });
    }
    rotation2();

    };
    //]]>
    </script>

    fruitsnow.js

    for (i=1; i<9; i++){
    jQuery("#clickban").after("<img id='br"+i+"' class='auglis"+Math.floor((Math.random() * 2) + 1)+"' src='/augli/"+i+".png' style='width:100px;z-index:-1;position:absolute;right:30px;top:-200px;'>");
    }

    function rightfall(kurs){
    setTimeout(function(){
    var bar1 = jQuery('#br'+kurs);
    bar1.animate({top: jQuery(document).height()-200}, Math.floor((Math.random() * 10000) + (10000)), "linear", function() {
    //bar1.hide();
    bar1.css("top","-200px");
    });
    }, Math.floor((Math.random() * 8000) + ((kurs-1)*2000)));
    }

    for (i=1; i<9; i++){
    jQuery("#clickban").after("<img id='fr"+i+"' class='auglis"+Math.floor((Math.random() * 2) + 1)+"' src='/augli/"+i+".png' style='width:100px;z-index:-1;position:absolute;left:30px;top:-200px;'>");
    }

    function leftfall(kurs){
    setTimeout(function(){
    var bar1 = jQuery('#fr'+kurs);
    bar1.animate({top: jQuery(document).height()-200}, Math.floor((Math.random() * 10000) + (10000)), "linear", function() {
    //bar1.hide();
    bar1.css("top","-200px");
    });
    }, Math.floor((Math.random() * 8000) + ((kurs-1)*2000)));
    }

    function fruitfall(){
    for (i=1; i<9; i++){
    rightfall(i);
    leftfall(i);
    }
    }


  • WP category as class name

    <?php if (is_single()) {
    global $post;
    $cat='';
    $cats = get_the_category($post->ID);
    foreach ( $cats as $c ) {
    $cat .= $c->category_nicename.' ';
    }
    } ?>

    Add the code above to the header.php file before the tag
    <body <?php body_class($cat); ?>>