29. 8. 2012

GIT rebase a push/pull branch


GIT rebase a push/pull branch


http://www.lorrin.org/blog/2011/10/03/argumentless-git-pull-and-git-push/


GIT - Rebase pro kazdy novy upstream

Nastavte si rebase pro kazdy novy upstream, dela to historii srozumitelnejsi!

git config --global branch.autosetuprebase always

Dalsi vysvetleni rebase:
http://gitready.com/advanced/2009/02/11/pull-with-rebase.html


PHP 5.3.16 na Ubuntu, redis

Dnes jsem nainstaloval redis, zkousel jsem jak balicek z distra: 2.2, tak vlastni kompilaci 2.4, bohuzel to porad nejelo, php proste vytuhlo, resp. cekalo. Pripojeni probehlo OK, bohuzel query bezely nelidsky pomalu.

Po delsim hledani jsem zjistil, ze PHP 5.3.10 z distra nefunguje ani s jendou verzi jak by melo.
Pro instalaci PHP 5.3.16, ktera s Redis funguje nadherne:

  1. Do /etc/apt/sources.list pridejte:
    deb http://packages.dotdeb.org stable all
    deb-src packages.dotdeb.org stable all
  1. Import GPG klice aby nebyl APT ukecanej:
    wget -q -O- dotdeb.org/dotdeb.gpg | apt-key add -
  2. Update APT:
    sudo apt-get update
  3. (volitelne) upgrade co lze:
    sudo apt-get upgrade
  4. Install nove PHP:
    sudo apt-get install php5 
Test:
 $ php -v

18. 8. 2012

Logitech Unified Receiver, MX Performance mouse, (x)buntu 12.04

Tak jsem si poridil krasnou mys, kterou bohuzel nemohu pouzivat na linuxu, wokna ok, ale nekupuju si takovouhle mys kvuli herni konzoli, ze?! Obecne je to problem s tim Unified Receiver-em v tehle verzi. Ja jsem to pouzil na MX Performace Mouse.

Takze jsem zjistil, ze nejsem sam, kdo ma tento problem, zatim existuji dva workaroundy co jsem nasel.

1) pridejte do /etc/rc.local
modprobe -r hid_logitech_dj
modprobe hid_logitech_dj

2) otevrete /etc/modprobe.
d/blacklist.conf
odkomentujte "blacklist usbmouse" (zmen na "#blacklist usbmouse") nebo odstrante radku celou a restartujte system

Instatni reseni:  
sudo modprobe -r hid_logitech_dj && sudo modprobe hid_logitech_dj

15. 8. 2012

Netbeans 7 pekne na Linuxu (Ubuntu)

Pokud mate hnusne Netbeansy tak to obycejne byvaji fonty ve Vasem JRE, bud si nainstalujte jine JRE, jako Oracle Sun:
 
sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jdk sun-java6-plugin

nebo si jen aktivujte jiny styl pro netbeans. V adresari netbeans, /usr/local/netbeansX
najdete etc/netbeans.conf

do promenne netbeans_default_options pridejte nakonec pred posledni uvozovky:

 --laf Nimbus -J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd

Muj radek pak vypada takto:

netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.zip.disableMemoryMapping=true --laf Nimbus -J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd"


Dalsi odkaz na, ktery jsem dodatecne nalezl:
http://wiki.netbeans.org/NBLookAndFeels

6. 8. 2012

GIT web frontendy

GIT web frontend


Casto potrebujete nejaky pristup ke svemu GIT repu, idealne i k projektu, obcas je vyhodne pouzivat nejaky unifikovany, uz jenom kvuli odkazum na ruzne patche a diffy.

Par reseni jsem vyhledal, nesnazim se je hodnotit!

Zakladni:


  • gitweb, nativni (vyvijeny gitem) v PERL
  • cgit C
  • git-php PHP
  • ViewGit PHP

Komplikovanejsi (vice sluzeb):



  • gitorious RUBY
  • InDefero PHP, klon GoogleCode with git, Mercurial, SVN
  • GitLab

Nejvice je obecne doporucovany GitLab, tak prilozim screenshot a odkaz.

Howto Install: https://github.com/gitlabhq/gitlabhq/blob/stable/doc/installation.md

Screenshoty; http://blog.gitlabhq.com/screenshots/

29. 7. 2012

GREP search and replace

Nasel jsem krasnej post:

Use this command:
egrep -lRZ "\.jpg|\.png|\.gif" . \
    | xargs -0 -l sed -i -e 's/\.jpg\|\.gif\|\.png/.bmp/g'
  • egrep: find matching lines using extended regular expressions
  • -l: only list matching filenames
  • -R: search recursively through all given directories
  • -Z: use \0 as record separator
  • "\.jpg|\.png|\.gif": match one of the strings ".jpg", ".gif" or ".png"
  • .: start the search in the current directory
  • xargs: execute a command with the stdin as argument
  • -0: use \0 as record separator. This is important to match the -Z of egrep and to avoid being fooled by spaces and newlines in input filenames.
  • -l: use one line per command as parameter
  • sed: the stream editor
  • -i: replace the input file with the output without making a backup
  • -e: use the following argument as expression
  • 's/\.jpg\|\.gif\|\.png/.bmp/g': replace all occurrences of the strings ".jpg", ".gif" or ".png" with ".bmp"





Dropbox musite mit

juknete na dropbox!

Dropbox je cloud reseni, ktere funguje jak z webu tak z Windows, Linux, Mac, Android
nabizi zdarma dostatek storage a spoustu moznosti jak ziskat nejakou zdarma, sam jsem aktualne na 5GB zdarma. Pokud dropbox chcete tak kliknete na muj referal a dostanu za vas 250MB :-)

Dik

25. 7. 2012

How to create custom application launchers in Gnome 3

http://blog.randell.ph/2011/08/01/how-to-create-custom-application-launchers-in-gnome-3/

17. 7. 2012

Batch update URL aliases in Joomla 2.5

Jak nastavit spravne URL aliasy pro existujici zaznamy v databazi.

Zjistil jsem, ze Joomla neumi odstranit diakritiku z nazvu tak aby friendly URL bylo spravne a č nebylo smazano. Nenasel jsem zadny nastroj, ktery by to dokazal opravit nad existujicimi zaznamy, tak jsem si napsal malinkej PHP script.

Prepiste si ho tak aby jste mohli parametry zadavat treba v konzoli, tohle byla jednorazovka.


mb_internal_encoding('UTF-8');


$conn = mysql_connect('localhost','xxxxx','xxxxxxx');
mysql_select_db('xxxxxx');
mysql_query('set names utf8');


$result = mysql_query('select * from j25_content order by id desc');
while ( $record = mysql_fetch_assoc($result) ) {
    $found = mysql_query('select count(*) matched from j25_content where `alias`="'.addslashes(seoUrl($record['title'])).'" and id<>'.$record['id']);
    $foundM = mysql_fetch_assoc($found);
    $alias = seoUrl($record['title']);
    if ($foundM['matched']>1)
    {
        $duplicates++;
        $alias.="-".(intval($found['matched'])+1);
        echo ('[!!] ' . $record['alias']. 'would be duplicit, changed to: '.$alias."\n");
    }
    if ($record['alias']!=$alias) {
        echo ('[++] ' . $record['alias']. ' changed to '.$alias.' from title "'.$record['title'].'"'."\n");
        mysql_query('update j25_content set alias="'.$alias.'" where id='.$record['id']);
        $modified++;
    } else {
        $correct++;
    }
       
}
$result = mysql_query('select * from j25_menu order by id');
while ( $record = mysql_fetch_assoc($result) ) {
    $found = mysql_query('select count(*) matched from j25_menu where `link`="'.addslashes(seoUrl($record['title'])).'" and id<>'.$record['id']);
    $foundM = mysql_fetch_assoc($found);
    $alias = seoUrl($record['title']);
    if ($foundM['matched']>1)
    {
        $duplicates++;
        $alias.="-".(intval($foundM['matched'])+1);
        echo ('[!!] ' . $record['alias']. 'would be duplicit, changed to: '.$alias."\n");
    }
    if ($record['link']!=$alias) {
        echo ('[++] ' . $record['link']. ' changed to '.$alias.' from title "'.$record['title'].'"'."\n");
        mysql_query('update j25_menu set alias="'.$alias.'",  path="'.$alias.'" where id='.$record['id']);
        $modified++;
    } else {
        $correct++;
    }
       
}

echo mysql_num_rows($result)." analyzed, $correct was ok, $modified has been modified, $duplicates was duplicate...\n";


/**
  * Return URL-Friendly string slug
  * @param string $string
  * @return string
  */

function seoUrl($string) {
        //Unwanted:  {UPPERCASE} ; / ? : @ & = + $ , . ! ~ * ' ( )
        $string = mb_strtolower($string);
    $string = iconv('UTF-8','ASCII//TRANSLIT',$string);
        //Strip any unwanted characters
        $string = preg_replace("/[^a-z0-9_\s-]/", "", $string);
        //Clean multiple dashes or whitespaces
        $string = preg_replace("/[\s-]+/", " ", $string);
        //Convert whitespaces and underscore to dash
        $string = preg_replace("/[\s_]/", "-", $string);
        return $string;
}