<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>stick&#039;s corner &#187; tips+tricks</title>
	<atom:link href="http://stick.gk2.sk/blog/tag/tipstricks/feed/" rel="self" type="application/rss+xml" />
	<link>http://stick.gk2.sk</link>
	<description>All composite phenomena are impermanent. All contaminated things and events are unsatisfactory.</description>
	<lastBuildDate>Wed, 01 Feb 2012 17:58:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Bash PS1 tricks</title>
		<link>http://stick.gk2.sk/blog/2011/06/ps1-tricks/</link>
		<comments>http://stick.gk2.sk/blog/2011/06/ps1-tricks/#comments</comments>
		<pubDate>Wed, 08 Jun 2011 11:34:34 +0000</pubDate>
		<dc:creator>Pavol Rusnak</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[opensuse]]></category>
		<category><![CDATA[ps1]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[tips+tricks]]></category>

		<guid isPermaLink="false">http://stick.gk2.sk/?p=1893</guid>
		<description><![CDATA[Many of you know already about this feature, but some of you don&#8217;t so I wanted to share it with you. I just changed mine PS1 configuration in ~/.bashrc to look like this: export GIT_PS1_SHOWDIRTYSTATE=1 export GIT_PS1_SHOWSTASHSTATE=1 export GIT_PS1_SHOWUNTRACKEDFILES=1 export PS1='\[\033[1;37m\][\[\033[1;32m\]\u\[\033[0m\]@\h\[\033[0m\] $? \[\033[1;34m\]\w\[\033[0;35m\]$(__git_ps1 " %s")\[\033[1;37m\]]\[\033[0m\] ' Take a look at the following picture to see [...]]]></description>
			<content:encoded><![CDATA[<p>Many of you know already about this feature, but some of you don&#8217;t so I wanted to share it with you. I just changed mine PS1 configuration in <code>~/.bashrc</code> to look like this:</p>
<pre>export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWSTASHSTATE=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
export PS1='\[\033[1;37m\][\[\033[1;32m\]\u\[\033[0m\]@\h\[\033[0m\] $? \[\033[1;34m\]\w\[\033[0;35m\]$(__git_ps1 " %s")\[\033[1;37m\]]\[\033[0m\] '</pre>
<p>Take a look at the following picture to see how it works:</p>
<p><a href="http://stick.gk2.sk/blog/wp-content/uploads/2011/06/ps1tricks.png"  rel="lightbox[1893]"><img class="aligncenter size-medium wp-image-1895" title="PS1 tricks" src="http://stick.gk2.sk/blog/wp-content/uploads/2011/06/ps1tricks-300x125.png" alt="" width="300" height="125" /></a></p>
<p>or check the <a href="http://youtube.com/watch?v=AKNgtHnKgJc">video on youtube</a>.</p>
<p>The number between <code>user@host</code> and the current working directory is the exit status of the most recently executed command (or pipeline). This is great because you don&#8217;t have to type <code>echo $?</code> everytime you want to find it out. The <code>__git_ps1</code> magic will print git branch name if you are inside of the git repository. Furthermore it will add special characters indicating the state of the repo: <code>%</code> &#8211; untracked files present, <code>+</code> &#8211; new files added, <code>*</code> &#8211; some tracked files changed, <code>$</code> &#8211; there is something in the stash (see <code>git stash --help</code>). Pretty cool, right?</p>
]]></content:encoded>
			<wfw:commentRss>http://stick.gk2.sk/blog/2011/06/ps1-tricks/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Wrong usage of LD_LIBRARY_PATH</title>
		<link>http://stick.gk2.sk/blog/2009/10/wrong-usage-of-ld_library_path/</link>
		<comments>http://stick.gk2.sk/blog/2009/10/wrong-usage-of-ld_library_path/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 15:51:10 +0000</pubDate>
		<dc:creator>Pavol Rusnak</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[opensuse]]></category>
		<category><![CDATA[tips+tricks]]></category>

		<guid isPermaLink="false">http://stick.gk2.sk/?p=829</guid>
		<description><![CDATA[Lots of programs that bring their own libraries use the following snippet in their wrapper scripts: export LD_LIBRARY_PATH="/my/special/librarypath:$LD_LIBRARY_PATH" This allows linker to find the needed libraries, even if they are not located in the standard directories (which are defined by /etc/ld.so.conf). At first, this seems OK, but it creates one problem, though. When the $LD_LIBRARY_PATH [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Lots of programs that bring their own libraries use the following snippet in their wrapper scripts:</p>
<pre>export LD_LIBRARY_PATH="/my/special/librarypath:$LD_LIBRARY_PATH"</pre>
<p style="text-align: justify;">This allows linker to find the needed libraries, even if they are not located in the standard directories (which are defined by <code>/etc/ld.so.conf</code>). At first, this seems OK, but it creates one problem, though. When the <code>$LD_LIBRARY_PATH</code> was empty before the assignment, the new value ends with a colon. When we run the program wrapper, linker splits the variable into substrings and ends up with one empty path. This indicates to search for libraries in the CURRENT working directory, which can cause problems or even a security threat.</p>
<p style="text-align: justify;">So, what&#8217;s the correct way of defining the library path? Of course, we could check if the variable is empty before the assignment like this:</p>
<pre>if [ -n "$LD_LIBRARY_PATH" ]; then
    export LD_LIBRARY_PATH="/my/special/librarypath:$LD_LIBRARY_PATH"
else
    export LD_LIBRARY_PATH="/my/special/librarypath"
fi</pre>
<p>but there is one neat shell trick we can use (should work on all POSIX shells). The description says:</p>
<blockquote><p><code>${parameter:+word}</code><br />
Use Alternate Value.  If <code>parameter</code> is null or unset, nothing is substituted, otherwise the expansion of <code>word</code> is substituted.</p></blockquote>
<p>In the end we have:</p>
<pre>export LD_LIBRARY_PATH="/my/special/librarypath${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"</pre>
<p>which is not much longer than the line we started with, but does the assignment correctly. (The first colon belongs to shell syntax, the second one is a part of the value being appended).</p>
]]></content:encoded>
			<wfw:commentRss>http://stick.gk2.sk/blog/2009/10/wrong-usage-of-ld_library_path/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>The Ugly Duckling called $XDG_CONFIG_HOME</title>
		<link>http://stick.gk2.sk/blog/2009/03/the-ugly-duckling-called-xdg_config_home/</link>
		<comments>http://stick.gk2.sk/blog/2009/03/the-ugly-duckling-called-xdg_config_home/#comments</comments>
		<pubDate>Sun, 29 Mar 2009 12:09:02 +0000</pubDate>
		<dc:creator>Pavol Rusnak</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[appeal]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[tips+tricks]]></category>

		<guid isPermaLink="false">http://stick.gk2.sk/blog/?p=228</guid>
		<description><![CDATA[Let&#8217;s take a look into my home directory: [stick@spectra 0 ~] ls -F Applications/ Documents/ google.txt reverse-ssh* Desktop/ Downloads/ public_html/ work/ [stick@spectra 0 ~] ls -AF .0verkill google.txt public_html/ .adobe/ .grails/ .pulse/ .android/ .gstreamer-0.10/ .pulse-cookie Applications/ .gtk-bookmarks .pyhistory .AtomicWorm/ .gtkrc-2.0-kde4 .qt/ .bash_history .gvfs/ .rawstudio/ .bashrc .hplip/ .recently-used .bouml .htoprc .recently-used.xbel .boumlrc .hugin .repoconfig/ .bzr.log .icedteaplugin/ [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Let&#8217;s take a look into my home directory:</p>
<pre>[stick@spectra 0 ~] ls -F
Applications/  Documents/  google.txt    reverse-ssh*
Desktop/       Downloads/  public_html/  work/       

[stick@spectra 0 ~] ls -AF
.0verkill             google.txt              public_html/
.adobe/               .grails/                .pulse/
.android/             .gstreamer-0.10/        .pulse-cookie
Applications/         .gtk-bookmarks          .pyhistory
.AtomicWorm/          .gtkrc-2.0-kde4         .qt/
.bash_history         .gvfs/                  .rawstudio/
.bashrc               .hplip/                 .recently-used
.bouml                .htoprc                 .recently-used.xbel
.boumlrc              .hugin                  .repoconfig/
.bzr.log              .icedteaplugin/         reverse-ssh*
.cache/               .inkscape/              .rnd
.cddb/                .inputrc                .rpmpatch_macros
.cedega/              .IntelliJIdea80/        .rpmpatch_rpmrc
.civclientrc          .IntelliJIdea8x/        .scummvmrc
.civserver_history    .irssi/                 .signature-gk2
.config/              .java/                  .signature-gmail
.crack-attack/        .JxBrowser/             .signature-suse
.cxgames/             .kde/                   .skel/
.darkplaces/          .kde4/                  .Skype/
.dbus/                .kderc                  .smc/
.designer/            .kinorc                 .springrc
Desktop/              .ktorrent.lock          .sqlite_history
.directory            .lbrc.conf              .ssh/
.dmrc                 .lesshst                .strigi/
Documents/            .links/                 .subversion/
Downloads/            .liquidwarrc            .teeworlds/
.dvdcss/              .local/                 .thumbnails/
.eclipse/             .loki/                  .thunderbird/
.emacs                .macromedia/            .ufrawrc
.esd_auth             .mc/                    .ultramixer/
.fbhighlevelshistory  .mcop/                  .vendetta/
.fbhighscores         .miro/                  .viminfo
.fblevels/            .mixxxbpmscheme.xml     .vimrc
.fbrc                 .mixxx.cfg              .VirtualBox/
.fontconfig/          .mixxxmacros/           .vlc/
.fonts/               .MixxxMIDIBindings.xml  .vnc/
.fonts.conf           .mixxxtrack.xml         .w3m/
.gajim/               .mozilla/               .Wammu
.gconf/               .mplayer/               .wapi/
.gconfd/              .mysql_history          .windows-label
.gegl-0.0/            .mysticmine             .wine/
.gem/                 .netxrc                 .winetrickscache/
.gimp-2.6/            .nexuiz/                work/
.gitconfig            .ooo3/                  .Xauthority
.gnome/               .opera/                 .xim.template
.gnome2/              .osc_cookiejar          .xine/
.gnome2_private/      .oscrc                  .xsession-errors
.gnupg/               .profile                .y2usersettings
.google/              .psi/
.googleearth/         .psql_history</pre>
<p style="text-align: justify;">Out of 148 entries in my $HOME, there are only 12 of them I really want to see! How much nicer would it be, if it looked like this:</p>
<pre>[stick@spectra 0 ~] ls -AF
Applications/  Documents/  public_html/    .signature-gmail
.config/       Downloads/  reverse-ssh*    .signature-suse
Desktop/       google.txt  .signature-gk2  work/</pre>
<p style="text-align: justify;">This is very simple to achieve, if only applications followed the <a href="http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html">XDG Base Directory Specification</a>. Unfortunately, lots of them don&#8217;t. When you start using the following piece of code in your new awesome applications:</p>
<pre>config = getenv("XDG_CONFIG_HOME")
if (!config) config = getenv("HOME") + "/.config"
config = config + "/my_awesome_app"</pre>
<p style="text-align: justify;">instead of the old-school one:</p>
<pre>config = getenv("HOME") + "/.my_awesome_app"</pre>
<p style="text-align: justify;">users will gain two great advantages with nearly no extra effort:</p>
<ul>
<li>trying application without overwriting the existing configuration
<pre>XDG_CONFIG_HOME=/tmp/ my_awesome_app</pre>
</li>
<li>maintaining multiple configurations of the same application
<pre>XDG_CONFIG_HOME=~/.config/awesome3 my_awesome_app</pre>
</li>
</ul>
<p style="text-align: justify;">So, please, don&#8217;t ignore the ugly duckling called <code>$XDG_CONFIG_HOME</code>, I&#8217;m sure it will mature into a beautiful swan. <img src='http://stick.gk2.sk/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://stick.gk2.sk/blog/2009/03/the-ugly-duckling-called-xdg_config_home/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Image with rounded corners (using CSS3)</title>
		<link>http://stick.gk2.sk/blog/2009/03/image-with-rounded-corners-using-css3/</link>
		<comments>http://stick.gk2.sk/blog/2009/03/image-with-rounded-corners-using-css3/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 11:02:17 +0000</pubDate>
		<dc:creator>Pavol Rusnak</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[tips+tricks]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://stick.gk2.sk/blog/?p=204</guid>
		<description><![CDATA[W3C added nice new options for creating rounded corners of elements to their CSS3 working draft. Engines like Gecko, KHTML and WebKit already implemented these functions, but they use vendor prefixes in the keywords (-moz-border-radius, -khtml-border-radius and -webkit-border-radius respectively), because the feature is not yet fully standardized. That&#8217;s also the reason why Opera and Internet [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">W3C added nice <a href="http://www.css3.info/preview/rounded-border/">new options for creating rounded corners</a> of elements to their <a href="http://www.w3.org/TR/css3-background/">CSS3 working draft</a>. Engines like <a href="https://developer.mozilla.org/en/Gecko">Gecko</a>, <a href="http://en.wikipedia.org/wiki/KHTML">KHTML</a> and <a href="http://webkit.org/">WebKit</a> already implemented these functions, but they use vendor prefixes in the keywords (<code>-moz-border-radius</code>, <code>-khtml-border-radius</code> and <code>-webkit-border-radius</code> respectively), because the feature is not yet fully standardized. That&#8217;s also the reason why Opera and Internet Explorer decided not to implement this extension for now.</p>
<p style="text-align: justify;">I was playing with the rounded corners and I like this feature a lot, but I also hit one problem (in all 3 engines). When you use the <code>border-radius</code> with an <code>img</code> element, the image is drawn above the border, so it isn&#8217;t rounded (left example). Fortunately, the effect could be easily achieved by rounded <code>div</code>, setting its dimensions exactly to the image size and using the image as the <code>div</code>&#8216;s background (right example).</p>
<table style="width: 100%;" border="0">
<tbody>
<tr style="text-align: center">
<td><img class="size-full wp-image-205 aligncenter" title="rounded1" src="http://stick.gk2.sk/blog/wp-content/uploads/2009/03/rounded1.jpg" alt="rounded img" width="184" height="244" /></td>
<td><img class="size-full wp-image-205 aligncenter" title="rounded1" src="http://stick.gk2.sk/blog/wp-content/uploads/2009/03/rounded2.jpg" alt="rounded div" width="184" height="244" /></td>
</tr>
<tr style="vertical-align: top">
<td>
<pre>&lt;img style="border: 2px solid black;
            border-radius: 30px;
            -moz-border-radius: 30px;
            -khtml-border-radius: 30px;
            -webkit-border-radius: 30px;"
            src="presov.jpg" /&gt;</pre>
</td>
<td>
<pre>&lt;div style="border: 2px solid black;
            border-radius: 30px;
            -moz-border-radius: 30px;
            -khtml-border-radius: 30px;
            -webkit-border-radius: 30px;
            width: 180px;
            height: 240px;
            background: url('presov.jpg');" /&gt;</pre>
</td>
</tr>
</tbody>
</table>
<p style="text-align: justify;"><strong>Update#1:</strong> I reported the issue to <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=485501">Gecko</a>, <a href="https://bugs.kde.org/show_bug.cgi?id=188242">KHTML</a> and <a href="https://bugs.webkit.org/show_bug.cgi?id=24880">WebKit</a> bugzillas.</p>
<p style="text-align: justify;"><strong>Update#2:</strong> Dave Hyatt closed the WebKit bug with the comment: &#8220;This was fixed recently.&#8221; \o/</p>
]]></content:encoded>
			<wfw:commentRss>http://stick.gk2.sk/blog/2009/03/image-with-rounded-corners-using-css3/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>Parallel command execution with limits</title>
		<link>http://stick.gk2.sk/blog/2009/02/parallel-command-execution/</link>
		<comments>http://stick.gk2.sk/blog/2009/02/parallel-command-execution/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 16:32:18 +0000</pubDate>
		<dc:creator>Pavol Rusnak</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[tips+tricks]]></category>

		<guid isPermaLink="false">http://stick.gk2.sk/blog/?p=112</guid>
		<description><![CDATA[Randy_sk asked today on IRC if we had any idea how to run commands in parallel, but he also wanted to limit the number of the concurrent processes. I immediately responded: &#8220;use make&#8221;. I started to shape my idea further until I came to this Makefile: tasks := $(shell seq -s ' ' 1 `cat [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Randy_sk asked today on IRC if we had any idea how to run commands in parallel, but he also wanted to limit the number of the concurrent processes. I immediately responded: &#8220;use make&#8221;. I started to shape my idea further until I came to this Makefile:</p>
<pre>tasks := $(shell seq -s ' ' 1 `cat commands.txt | wc -l`)

all: $(tasks)
    @echo Done

%:
    @echo `sed '$@!d' commands.txt`
    @eval `sed '$@!d' commands.txt`</pre>
<p style="text-align: justify;">This expects you had the file commands.txt prepared, which contains one command per line. If you want to call the same command over and over again, just replace <code>commands.txt</code> with <code>values.txt</code> and <code>eval</code> with the command you want to run.</p>
<p style="text-align: justify;">Using this approach you can limit both the number of concurrent jobs: <code>make -j 5</code> and the maximum load: <code>make -l 2</code></p>
<p style="text-align: justify;">Others ideas were to use the shell with <code>&amp;</code> and <code>wait</code>, or to use the following one-liner:</p>
<pre>while sleep 1; do [ "`ps ax | grep your_cmd | wc -l`" -gt 6 ] || your_cmd &amp;; done</pre>
<p style="text-align: justify;">but I really like mine solution the most <img src='http://stick.gk2.sk/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://stick.gk2.sk/blog/2009/02/parallel-command-execution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

