• CSS objekta 360 grādu pargriezšana

    .rotate{
    -webkit-transition-duration: 0.8s;
    -moz-transition-duration: 0.8s;
    -o-transition-duration: 0.8s;
    transition-duration: 0.8s;
    -webkit-transition-property: -webkit-transform;
    -moz-transition-property: -moz-transform;
    -o-transition-property: -o-transform;
    transition-property: transform;
    overflow:hidden;
    }
    .rotate:hover
    {
    -webkit-transform:rotate(360deg);
    -moz-transform:rotate(360deg);
    -o-transform:rotate(360deg);
    }


  • jQuery ajax pieprasījums

    GET
    $.ajax({
    type:'GET',
    url: 'http://www.kautkas.lv/kautkas.php',
    data: "action=something&id="+id,
    success:function(data){
    $('#lauks').html(data);
    }
    });

    POST
    $.ajax({
    type: "POST",
    url: "ajax.php?",
    data: { idnumurs: "id" },
    success:function(data){
    $("#lauks").val(data);
    }
    });


  • png uz jpg ar izgriezšanas funkciju

    function png2jpg($originalFile, $outputFile, $quality, $crop, $crop2, $cirpt) {
    $image = imagecreatefrompng($originalFile);
    if ($crop>0){
    $size = getimagesize($originalFile);
    $width = $size[0];
    $height = $size[1];
    $ww=$crop;
    $hh=$crop2;
    if ($cirpt==1){
    if($width> $height) {
    $x=$width/$ww;
    } else {
    $x=$height/$hh;
    }
    $thumb_size1=ceil($width/$x);
    $thumb_size2=ceil($height/$x);
    } else if ($cirpt==2){
    $thumb_width = $crop;
    $thumb_height = $crop2;
    $width = $size[0];
    $height = $size[1];
    $original_aspect = $width / $height;
    $thumb_aspect = $thumb_width / $thumb_height;
    if ( $original_aspect >= $thumb_aspect )
    {
    // If image is wider than thumbnail (in aspect ratio sense)
    $new_height = $thumb_height;
    $new_width = $width / ($height / $thumb_height);
    }
    else
    {
    // If the thumbnail is wider than the image
    $new_width = $thumb_width;
    $new_height = $height / ($width / $thumb_width);
    }
    $thumb_size1=$crop;
    $thumb_size2=$crop2;
    $x1 = 0 - ($new_width - $thumb_width) / 2;
    $y1 = 0 - ($new_height - $thumb_height) / 8;
    $x=0;
    $y=0;
    } else {
    $new_width = $size[0];
    $new_height = $size[1];
    $width = $size[0];
    $height = $size[1];
    }
    $new_im = ImageCreatetruecolor(($thumb_size1),$thumb_size2);
    imagecopyresampled($new_im,$image,$x1,$y1,$x,$y,$new_width,$new_height,$width,$height);
    imagejpeg($new_im, $outputFile, $quality);
    imagedestroy($new_im);
    } else {
    imagejpeg($image, $outputFile, $quality);
    imagedestroy($image);
    }
    }


  • curl post pieprasījums

    curl_setopt($handle, CURLOPT_URL,"http://www.example.lv/kautkas.php");
    curl_setopt($handle, CURLOPT_POST, true);
    curl_setopt($handle, CURLOPT_POSTFIELDS, array("var1" => $var1 ));
    curl_exec($handle);


  • json no php masīva

    $json[]=array('artist'=>'var1','title'=>$var2));
    echo json_encode($json);


  • nginx modificē hederi

    location ~* \.(txt|xml)${
    add_header Access-Control-Allow-Origin *;
    }


  • Nginx noklusētā error page

    Ievieto iekš konkrētā server{}
    location /home/domain1/ {
    error_page 404 = /home/domain/error1.html;
    error_page 403 = /home/picture.jpg;
    }


  • Youtube ID no dziesmas nosaukuma

    $homepage = file_get_contents('https://gdata.youtube.com/feeds/api/videos?q='.urlencode($dz_izpilditajs).'%20-%20'.urlencode($dz_nosaukums).'&orderby=relevance&start-index=1&max-results=1&v=2&alt=json');
    $ytraw=json_decode($homepage, true);
    $here = explode(":", $ytraw['feed']['entry'][0]['id']['$t']);
    $num = (count($here) - 1);
    $yt = $here[$num];

    Vairāk info šeit:
    https://developers.google.com/youtube/2.0/developers_guide_protocol_api_query_parameters?hl=cs


  • Seko mums draugiem.lv

    <script type="text/javascript" src="//sekomums.lv/cb.lv.js"></script>
    <script type="text/javascript" src="//draugiem.lv/api/api.js"></script>
    <script type="text/javascript">function r(f){/in/.test(document.readyState)?setTimeout('r('+f+')',9):f()}; r(function(){new ConversionsBox("Pat%C4%ABk%20radio%20SPIN%20FM%3F%20Seko%20mums%20ar%C4%AB%20Draugiem.lv!%20","mans-nosaukums");});</script>


  • nginx status page

    nginx -V | grep --color -o http_stub_status

    location /nginx_status {
    # Turn on nginx stats
    stub_status on;
    # I do not need logs for stats
    access_log off;
    # Security: Only allow access from 192.168.1.100 IP #
    allow 192.168.1.100;
    # Send rest of the world to /dev/null #
    deny all;
    }