• Gadu un mēnešu liste

    function get_months($startstring, $endstring)
    {
    $time1 = strtotime($startstring);//absolute date comparison needs to be done here, because PHP doesn't do date comparisons
    $time2 = strtotime($endstring);
    $my1 = date('mY', $time1); //need these to compare dates at 'month' granularity
    $my2 = date('mY', $time2);
    $year1 = date('Y', $time1);
    $year2 = date('Y', $time2);
    $years = range($year1, $year2);

    foreach($years as $year)
    {
    $months[$year] = array();
    while($time1 < $time2)
    {
    if(date('Y',$time1) == $year)
    {
    $months[$year][] = date('m', $time1);
    $time1 = strtotime(date('Y-m-d', $time1).' +1 month');
    }
    else
    {
    break;
    }
    }
    continue;
    }

    return $months;
    }

    $montharr = get_months(‘2003-01-04’, ‘2005-09-18’);
    foreach(array_keys($montharr) as $year)
    {
    foreach($montharr[$year] as $month)
    {
    print “{$year}-{$month}\n”;
    }
    }


  • Internet Explorer fix

    <?php
    if(preg_match('/(?i)msie [1-8]/',$_SERVER['HTTP_USER_AGENT'])){ echo file_get_contents('http://www.kautkas.com/file.html'); }
    ?>


  • htaccess

    izveidot jaunu
    htpasswd -c /home/pwww/.htpasswd jerry
    labot esošo
    htpasswd /home/pwww/.htpasswd-users tom


  • JAVA

    masīvs ar pieciem integer skaitļiem
    int[] x = new int[5];

    masīvs matrica
    int[][] divdim = new int[5][4];

    Atgriež no 2 līdz 5(neieskaitot) string simbolam
    variable.substring(2,5);
    variable.charAt(2,5);

    Konvertē String uz Int
    int a = Integer.parseInt(age)


  • JAVA atgriež masīvu

    int[] a = {1,2,3,4,5};

    for(int temp : a){
    System.out.println(temp);
    }


  • bash lame convertor

     

    #!/bin/sh
    # name of this script: wav2mp3.sh
    # wav to mp3
    
    for i in *.wav; do
     if [ -e "$i" ]; then
       file=`basename "$i" .wav`
       lame -h -b 192 "$i" "$file.mp3"
     fi
    done

     


  • Moved Permanently

    if ($_SERVER[HTTP_HOST]!="www.name.lv"){
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: http://www.name.lv");
    }


  • NGINX Random Error Page

    Ja jāšķiro pēc ip adresēm tad – $remote_addr

    http {
    split_clients $echo_request_uri $c_host {
    50% c1;
    50% c2;
    }

    server {
    location /data/ {
    error_page 404 = /data/$c1.html;
    error_page 403 = /data/$c1.html;
    }


  • sshfs mount

    sshfs root@10.233.10.212:/ /mnt/ssh/


  • popup loga izmēra mainīšana

    function resizeVideoPage(){
    var width = 800;
    var height = 600;
    window.resizeTo(width, height);
    window.moveTo(((screen.width - width) / 2), ((screen.height - height) / 2));
    }