2015 m. rugpjūčio 28 d., penktadienis

php image classes

https://github.com/claviska/SimpleImage     php 5.3 + GD
http://imagine.readthedocs.org/en/latest/index.html php 5.3 GD/imagick
http://phpthumb.sourceforge.net/ php 4+/5 GD/imagick

imagick pamokos: http://www.phpro.org/tutorials/Imagick.html

PHP URL shortening functions

Integer konvertavimas.

Jigu tinka - ir _ simboliai

function encode($number) {
    return strtr(rtrim(base64_encode(pack('i', $number)), '='), '+/', '-_');
}
function decode($base64) {
    $number = unpack('i', base64_decode(str_pad(strtr($base64, '-_', '+/'), strlen($base64) % 4, '=')));
    return $number[1];
}

jeigu norima tik raidyno ir skaiciu

  1. function encode($val, $base=62, $chars='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') {
  2. // can't handle numbers larger than 2^31-1 = 2147483647
  3. $str = '';
  4. do {
  5. $i = $val % $base;
  6. $str = $chars[$i] . $str;
  7. $val = ($val - $i) / $base;
  8. } while($val > 0);
  9. return $str;
  10. } 
  11. function decode($str, $base=62, $chars='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') {
  12. $len = strlen($str);
  13. $val = 0;
  14. $arr = array_flip(str_split($chars));
  15. for($i = 0; $i < $len; ++$i) {
  16. $val += $arr[$str[$i]] * pow($base, $len-$i-1);
  17. }
  18. return $val;
  19. }


paprastam url konvertavimui

function base64url_encode($data) {
  return 
rtrim(strtr(base64_encode($data), '+/''-_'), '=');
}

function 
base64url_decode($data) {
  return 
base64_decode(str_pad(strtr($data'-_''+/'), strlen($data) % 4'='STR_PAD_RIGHT));

2015 m. rugpjūčio 24 d., pirmadienis

2015 m. rugpjūčio 19 d., trečiadienis

2015 m. rugpjūčio 11 d., antradienis

Word macro - visu paveikslu dydzio nuresetinimas i 100%

word uzseiviname naujausiu formatu kad nebutu vompability mode. Einame i view -> macro  ir sukuriame funkcija

  Sub AllGraphicsTo100()

      Dim ILS As Word.InlineShape
      Dim SHP As Word.shape

      For Each ILS In ActiveDocument.InlineShapes
        If ILS.Type = wdInlineShapePicture Or ILS.Type = wdInlineShapeLinkedPicture Then
            ILS.ScaleHeight = 100
            ILS.ScaleWidth = 100
        End If
      Next ILS

      For Each SHP In ActiveDocument.Shapes
        If SHP.Type = msoPicture Or SHP.Type = msoLinkedPicture Then
            SHP.ScaleHeight 1#, True
            SHP.ScaleWidth 1, True
        End If
      Next SHP

    End Sub