<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Soultrav&#039;s Weblog</title>
	<atom:link href="http://soultrav.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://soultrav.wordpress.com</link>
	<description>I&#039;m not antisocial; I&#039;m just not user-friendly</description>
	<lastBuildDate>Mon, 09 Jan 2012 10:10:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='soultrav.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/ff24aa8e7eb59b1f73d7982c3235e15b?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Soultrav&#039;s Weblog</title>
		<link>http://soultrav.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://soultrav.wordpress.com/osd.xml" title="Soultrav&#039;s Weblog" />
	<atom:link rel='hub' href='http://soultrav.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Tmux &#8211; a good alternative to GNU screen</title>
		<link>http://soultrav.wordpress.com/2011/12/23/tmux-a-good-alternative-to-gnu-screen/</link>
		<comments>http://soultrav.wordpress.com/2011/12/23/tmux-a-good-alternative-to-gnu-screen/#comments</comments>
		<pubDate>Fri, 23 Dec 2011 13:01:14 +0000</pubDate>
		<dc:creator>Soultrav</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[tmux]]></category>

		<guid isPermaLink="false">http://soultrav.wordpress.com/?p=466</guid>
		<description><![CDATA[What is it and what do you need it for? If you are working with Linux remote machines on a daily basis, or simply are the kind of person who wants to work with his terminals in the most efficient way possible, you probably already heard of GNU screen. It is a terminal multiplexer, meaning [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=soultrav.wordpress.com&amp;blog=3794532&amp;post=466&amp;subd=soultrav&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>What is it and what do you need it for?</h3>
<p>If you are working with Linux remote machines on a daily basis, or simply are the kind of person who wants to work with his terminals in the most efficient way possible, you probably already heard of <a href="http://www.gnu.org/software/screen/">GNU screen</a>. It is a terminal multiplexer, meaning that it allows you to access multiple virtual terminal sessions from inside a single physical terminal. How can this help you? Well, most commonly, it can help you in two situations:</p>
<ul>
<li>you want to work with six terminals on a remote machine;<br />
How do you do it?<br />
The classic way: you open up six terminals (or Putty sessions) and ssh to the remote machine on each one of them. Even if you have ssh keys configured and don&#8217;t have to introduce a password, it&#8217;s still a bummer. You still have to alt+tab or alt+# through six terminals and managing them can become a headache.<br />
The terminal multiplexer way: you open up a terminal/putty session and ssh to the remote machine. There, you run screen, and open new virtual terminals (called <em>windows</em>) without having to ssh to the remote machine again. You manage you windows with simple shortcuts, and instead of six open applications, you have just one.</li>
<li>you want to have more terminals open on your screen at the same time, so you don&#8217;t have to switch through them to read each of their output;<br />
Newly created windows can be arranged like multiple tabs in your terminal, but in addition, each window can be split into regions, such that you can see and access multiple terminals at once, having all of them in front of you. For example, one way I am using this is for logically separating my areas of work: I keep one window with multiple regions for writing code in different files, one window with multiple regions for testing my code (each executable will have its own region) and one window for reading log files.</li>
</ul>
<p>Like screen, tmux is also a terminal multiplexer; I&#8217;ve never been a screen power user, so I won&#8217;t go ranting on why one of them is better than the other. If you&#8217;re interested, from what I&#8217;ve read the main things that differentiate tmux from screen are:</p>
<ul>
<li> it&#8217;s a server-client system &#8211; meaning that there is a server instance (started when tmux is first run) and the sessions you open are the clients; this allows you to even move windows from one session to another, or view a window from multiple sessions at the same time</li>
<li> it can split panes vertically, not just horizontally</li>
<li> it has a pane-synchronizing option, such that when you write something in a pane, it simultaneously writes the same thing in all the panes from the current window</li>
<li> multiple paste buffers</li>
<li> the option of choosing either vim or emacs key bindings</li>
<li> some say it&#8217;s less resource hungry than screen (but I don&#8217;t think any real benchmarks have been run yet in this regard)</li>
</ul>
<h3>How to use tmux</h3>
<p>Tmux probably isn&#8217;t going to be installed by default on your system, so you will first have to install it either using your favorite package manager (aptitude, yum, &#8230;) or by compiling the sources. These can be found on <a href="http://tmux.sourceforge.net/">the tmux website</a>. If you decide to compile from source, be aware that you will also need to have installed the development files for libevent (on RHEL, these are libevent-devel.i686 or libevent-devel.x86_64, depending on your platform).</p>
<p>After you installed it, you can simply run &#8216;tmux&#8217; to start a new session:<br />
<pre class="brush: bash;">$ tmux</pre><br />
To list all your running sessions:<br />
<pre class="brush: bash;">
$ tmux ls
0: 2 windows (created Thu Dec 22 15:07:17 2011) [237x54] (attached)
</pre><br />
To attach from a detached session (we will see later how you can detach a session):<br />
<pre class="brush: bash;">$ tmux attach [-d] [-t session_index]</pre><br />
If you specify the &#8216;-d&#8217; option, it will detach the specified session and attach it to your current terminal. The session index is the identifier of the session you wish to attach to (you can find it with &#8216;tmux ls&#8217;).</p>
<p>As you can see, tmux now looks just like your basic terminal, with the exception of the green status bar on the bottom. To give commands to tmux, you can either enter the tmux command prompt (by pressing C-b : ) and issue the command or you can use a key binding associated with a command. Below are the <strong>most common key bindings</strong> I use (PS: you can reassign key bindings if they&#8217;re not good for you, see the next section):</p>
<ul>
<li>C-b c -&gt; create a new window</li>
<li>C-b 0 to 9 -&gt; go to a window number</li>
<li>C-b n -&gt; go to the next window</li>
<li>C-b p -&gt; go to the previous window</li>
<li>C-b &#8221; -&gt; split the current pane in two: top and bottom</li>
<li>C-b % -&gt; split the current pane in two: left and right</li>
<li>C-b ←/→/↑/↓ -&gt; move focus to other panes; if you want to move through multiple panes, you don&#8217;t have to press C-b and a directional key every time, just press C-b once and then quickly press multiple directional keys</li>
<li>C-b C-o -&gt; swap panes in counter-clockwise order</li>
<li>C-d -&gt; exit the current shell</li>
<li>C-b, and while holding Ctrl, press ←/→/↑/↓ -&gt; resize a pane</li>
<li>C-b ! -&gt; make the current pane a new window</li>
<li>C-b d -&gt; detach from the current session</li>
<li>C-b Alt-1 to Alt-5 -&gt; arrange panes in one of the five preset layouts: even-horizontal, even-vertical, main-horizontal, main-vertical, or tiled</li>
<li>C-b ? -&gt; see all key bindings</li>
</ul>
<p>There are a few more bindings it&#8217;s very useful that you know. A tmux window may operate in two ways: the default mode, which gives you access to the terminal attached to the window, and the copy mode. The last one lets you select and copy some text from your window into a paste buffer, so that you can later paste the selection into another window/pane.</p>
<ul>
<li>C-b [ -&gt; enter copy mode; press Space to start selection, Enter to copy the selection into a paste buffer and q to go back to the default mode</li>
<li>C-b ] -&gt; paste the contents of the last paste buffer</li>
<li>C-b = -&gt; interactively choose a paste buffer from which to paste the contents into the current terminal</li>
</ul>
<p>However, there are some interesting commands that don&#8217;t have key bindings by default. To issue them, press &#8216;C-b :&#8217;, write the command and press Enter. Some useful commands are:</p>
<ul>
<li><em>set-option -g mouse-resize-pane on</em> -&gt; lets you rearrange the panes&#8217; width and height using the mouse</li>
<li><em>set-option -g mouse-select-pane on</em> -&gt; lets you select panes by left-clicking on them</li>
<li><em>set-window-option -g mode-mouse on</em> -&gt; lets you use the mouse to enter copy mode, copy a selection by dragging and scroll with the mouse wheel</li>
<li><em>set-window-option -g monitor-activity on</em> -&gt; tells tmux that it should monitor the activity on all windows</li>
<li><em>set-window-option -g visual-activity on</em> -&gt; display a status line message when activity occurs in a window that has the monitor-activity option enabled</li>
<li><em>set-window-option monitor-content match-string</em> -&gt; tells tmux to monitor the content in the window, looking to match the match-string pattern</li>
<li><em>set-window-option visual-content on</em> -&gt; display a status line message when content is present in a window for which the monitor-content option is enabled</li>
<li><em>set-window-option synchronize-panes on</em> -&gt; synchronizes what you write in a pane with the rest of the panes in a window</li>
</ul>
<p>You can see all the available commands in tmux&#8217;s man page. </p>
<h3>The configuration file</h3>
<p>If you want some options to be persistent over multiple runs of tmux, you must write them in the tmux configuration file: either /etc/tmux.conf, which is the global configuration file (it applies to all users), or ~/.tmux.conf, which only applies to the current user. Here is the configuration file I use:<br />
<pre class="brush: bash;">
# use this if you want to set the prefix to C-a, like screen does
# unbind C-b
# set -g prefix C-a

set -g history-limit 16384  # the number of lines you can search through in copy mode
set -g buffer-limit 50      # number of paste buffers
set -g base-index 1         # the window numbering will start from 1 instead of 0

# create a window with 4 panes by default
# Be careful! if you do this you must start tmux with 'tmux attach'
# if you start it with 'tmux' it will take you to a newly created session,
# and you will have 2 sessions, as 'tmux' is equivalent to 'tmux new-session'
new
splitw -v -t 0
splitw -h -t 1
splitw -h -t 0
selectp -t 0

# when splitting a window, make sure the new terminal keeps the same
# directory, just like gnome-terminal does when opening a new tab
bind h send-keys &quot; ~/.scripts/tmux-split -h&quot; \; send-keys &quot;Enter&quot;
bind v send-keys &quot; ~/.scripts/tmux-split -v&quot; \; send-keys &quot;Enter&quot;

# bind keys for pane synchronizing
bind y set-window-option synchronize on
bind t set-window-option synchronize off
</pre><br />
Normally, when you split the screen, the new created pane takes you to the directory of the tmux server, not the one of the pane you&#8217;re currently in. The last two commands fix this by binding two keys to the execution of a script, which I&#8217;ve taken from <a href="https://wiki.archlinux.org/index.php/Tmux#Split_window_and_retain_current_directory">here</a>. The script receives an argument (-h or -v) which tells it what kind of split to do. Then it changes the path of the new pane to your current working directory:<br />
<pre class="brush: bash;">
$ cat ~/.scripts/tmux-split
#!/usr/bin/env bash
PWD=`pwd`
tmux split-window $1
tmux send-keys &quot; cd $PWD;clear&quot;
tmux send-keys &quot;Enter&quot;
</pre></p>
<h3>In conclusion&#8230;</h3>
<p>Tmux is one of those tools which, if configured and used right, can raise your productivity substantially. Even if it&#8217;s hard to get used to at first, it&#8217;s worth it in the long run.</p>
<p>PS: Even if it hasn&#8217;t any practical value, it&#8217;s damn cool to have 152 terminals into one single screen :)<br />
<a href="http://soultrav.files.wordpress.com/2011/12/screenshot-1.png"><img src="http://soultrav.files.wordpress.com/2011/12/screenshot-1.png?w=500&#038;h=248" alt="" title="Screenshot-1" width="500" height="248" class="alignnone size-full wp-image-485" /></a></p>
<br />Filed under: <a href='http://soultrav.wordpress.com/category/it/'>IT</a> Tagged: <a href='http://soultrav.wordpress.com/tag/screen/'>screen</a>, <a href='http://soultrav.wordpress.com/tag/tmux/'>tmux</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/soultrav.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/soultrav.wordpress.com/466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/soultrav.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/soultrav.wordpress.com/466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/soultrav.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/soultrav.wordpress.com/466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/soultrav.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/soultrav.wordpress.com/466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/soultrav.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/soultrav.wordpress.com/466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/soultrav.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/soultrav.wordpress.com/466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/soultrav.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/soultrav.wordpress.com/466/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=soultrav.wordpress.com&amp;blog=3794532&amp;post=466&amp;subd=soultrav&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://soultrav.wordpress.com/2011/12/23/tmux-a-good-alternative-to-gnu-screen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>44.444059 26.054458</georss:point>
		<geo:lat>44.444059</geo:lat>
		<geo:long>26.054458</geo:long>
		<media:content url="http://0.gravatar.com/avatar/044a270a95836821f6bfd2b5c0561f96?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">Soultrav</media:title>
		</media:content>

		<media:content url="http://soultrav.files.wordpress.com/2011/12/screenshot-1.png" medium="image">
			<media:title type="html">Screenshot-1</media:title>
		</media:content>
	</item>
		<item>
		<title>Beating the Bulls and Cows game</title>
		<link>http://soultrav.wordpress.com/2011/05/26/beating-the-bulls-and-cows-game/</link>
		<comments>http://soultrav.wordpress.com/2011/05/26/beating-the-bulls-and-cows-game/#comments</comments>
		<pubDate>Thu, 26 May 2011 13:31:05 +0000</pubDate>
		<dc:creator>Soultrav</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[average]]></category>
		<category><![CDATA[bulls and cows]]></category>
		<category><![CDATA[expect]]></category>
		<category><![CDATA[tcl]]></category>

		<guid isPermaLink="false">http://soultrav.wordpress.com/?p=442</guid>
		<description><![CDATA[After beating GNUChess :P, I feel I&#8217;m on a stroke on challenging hard games, so I&#8217;m going to tackle the Bulls and Cows game this time. The basics Bulls and Cows (a version of Mastermind) is a 2-player game where your opponent (the computer) randomly chooses a 4-digit number for you to guess. All digits [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=soultrav.wordpress.com&amp;blog=3794532&amp;post=442&amp;subd=soultrav&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After beating GNUChess <a href="https://soultrav.wordpress.com/2011/05/24/do-you-hate-gnuchess/" target="_blank">:P</a>, I feel I&#8217;m on a stroke on challenging hard games, so I&#8217;m going to tackle the Bulls and Cows game this time.</p>
<h2>The basics</h2>
<p><a href="http://en.wikipedia.org/wiki/Bulls_and_cows" target="_blank">Bulls and Cows</a> (a version of Mastermind) is a 2-player game where your opponent (the computer) randomly chooses a 4-digit number for you to guess. All digits in the number must be distinct and you are allowed a maximum of 8 tries. After every try, it gives you feedback: how many digits you got in the correct position, and how many digits you got in the wrong position.<br />
An open-source version of this game is available <a href="http://downloads.sourceforge.net/fourdigits/4digits_0.9.tar.bz2" target="_blank">here</a>.</p>
<h2>The game solver</h2>
<p>For solving the game, I decided to start from <a href="http://rosettacode.org/wiki/Bulls_and_cows" target="_blank">this page</a> and for the language I chose Tcl.<br />
First, I compiled the text version of 4 digits:<br />
<pre class="brush: bash;">
[claudiu@localhost Desktop]$ tar -xjvf 4digits_0.9.tar.bz2
...
[claudiu@localhost Desktop]$ cd 4digits-0.9/
[claudiu@localhost 4digits-0.9]$ make 
gcc -Wall -std=c99 -pedantic -g 4digits-text.c -o 4digits-text
</pre><br />
, after which I modified the script to work with 4digits.<br />
I then changed it a little more because it was written for a general Bulls and Cows game, which is any number of digits, up to 10 I think. So it was generating all the 10 digits numbers and then just taking the first 4 digits out of each number; you can realize that was a huge amount of work, which wasn&#8217;t necessary.<br />
Here is the revised code:<br />
<pre class="brush: plain;">
#!/usr/bin/tclsh

package require struct::list
package require struct::set

# some procedures

proc in {str list} {
        foreach elem $list {
                if {$elem eq $str} {
                        return 1
                }
        }              
        return 0
}
 
proc has_diff_digits {x} {
        set i1 [lindex $x 0]
        set i2 [lindex $x 1]
        set i3 [lindex $x 2]
        set i4 [lindex $x 3]
        if {$i1 != $i2 &amp;&amp; $i1 != $i3 &amp;&amp; $i1 != $i4 &amp;&amp; 
             $i2 != $i3 &amp;&amp; $i2 != $i4 &amp;&amp; $i3 != $i4} {
                return 1
        }
        return 0
}

proc scorecalc {guess chosen} {
    set bulls 0
    set cows 0
    foreach g $guess c $chosen {
	if {$g eq $c} {
	    incr bulls
	} elseif {[in $g $chosen]} {
	    incr cows
	}
    }
    return [list $bulls $cows]
}
 
# settings

set size 4
set choices {}

for {set i 1234} {$i &lt; 10000} {incr i} {
        set l [split $i &quot;&quot;]
        if {[has_diff_digits $l]} {
		struct::set include choices $l
        }
}

set answers {}
set scores {}
 
# starting

puts &quot;Playing Bulls &amp; Cows with $size unique digits\n&quot;
fconfigure stdout -buffering none
while 1 {
    set ans [lindex $choices [expr {int(rand()*[llength $choices])}]]
    lappend answers $ans
    puts -nonewline \
	&quot;Guess [llength $answers] is [join $ans {}]. Answer (Bulls, cows)? &quot;
    set score [scan [gets stdin] %d,%d]
    lappend scores $score
    if {[lindex $score 0] == 4} {
	puts &quot;Ye-haw!&quot;
	break
    }
    foreach c $choices[set choices {}] {
	if {[scorecalc $c $ans] eq $score} {
	    lappend choices $c
	}
    }
    if {![llength $choices]} {
	puts &quot;Bad scoring? nothing fits those scores you gave:&quot;
	foreach a $answers s $scores {
	    puts &quot;  [join $a {}] -&gt; ([lindex $s 0], [lindex $s 1])&quot;
	}
	break
    }
}
</pre></p>
<p>A print screen of the execution of 4digits in parallel with the solver:<br />
<a target='_blank' href='http://img594.imageshack.us/i/bullsandcows.png/'><img src='http://img594.imageshack.us/img594/2888/bullsandcows.png' border='0' /></a></p>
<h2>Automating with Expect</h2>
<p>Of course, it&#8217;s better if we put a small script to do the work for us:<br />
<pre class="brush: plain;">
#!/usr/bin/expect -f

log_user 0

spawn -noecho /localhome/claudiu/workspace/expect/4digits-0.9/4digits-text
set 4digits $spawn_id

spawn -noecho ./bulls_cows.tcl
set bc $spawn_id

set tries 0
while 1 {
    incr tries
    expect -re &quot;is (.+)\\.&quot;
    puts &quot;TCL tries......$expect_out(1,string)&quot;
    set spawn_id $4digits
    send &quot;$expect_out(1,string)\r&quot;
    expect -re &quot;(\[0-9])A(\[0-9])B&quot;
    if {$expect_out(1,string) == 4} {
        puts &quot;4digits says...That's it!&quot;
        puts &quot;\nNr. of tries: $tries&quot;
        exit 0
    }
    puts &quot;4digits says...$expect_out(0,string)\n&quot;
    set spawn_id $bc
    send &quot;$expect_out(1,string),$expect_out(2,string)\r&quot;
}
</pre></p>
<p>A run of the script:<br />
<a href="http://soultrav.files.wordpress.com/2011/05/bulls_cows_exp.jpg"><img src="http://soultrav.files.wordpress.com/2011/05/bulls_cows_exp.jpg?w=500" alt="" title="bulls_cows_exp"   class="alignnone size-full wp-image-464" /></a></p>
<h2>Some statistics</h2>
<p>Although the solution isn&#8217;t the optimum one, because we are only playing the 4-digit game, it runs pretty fast.<br />
To measure an average of tries per game, I wrote another small Expect script that calls the initial script a number of times:<br />
<pre class="brush: plain;">
#!/usr/bin/expect -f

log_user 0

set runs 1000

set min 100
set max 0
set sum 0

for {set i 0} {$i &lt; $runs} {incr i} {
    spawn -noecho ./bulls_cows.exp
    expect -re &quot;tries: (\[0-9])&quot;
    puts &quot;$expect_out(0,string)&quot;
    set tries $expect_out(1,string)
    if {$tries &lt; $min} {
        set min $tries
    }
    if {$tries &gt; $max} {
        set max $tries
    }
    set sum [expr $sum + $tries]
}

puts &quot;Minimum number of tries: $min&quot;
puts &quot;Maximum number of tries: $max&quot;
puts &quot;Average tries for $runs runs: [expr double($sum)/$runs]&quot;
</pre> </p>
<p>The result for this code with 1000 runs is an average of 5.402 tries per game. Also, the minimum number of tries is 2 (how lucky can you get?!) and the maximum number of tries was 8.</p>
<br />Filed under: <a href='http://soultrav.wordpress.com/category/it/'>IT</a> Tagged: <a href='http://soultrav.wordpress.com/tag/average/'>average</a>, <a href='http://soultrav.wordpress.com/tag/bulls-and-cows/'>bulls and cows</a>, <a href='http://soultrav.wordpress.com/tag/expect/'>expect</a>, <a href='http://soultrav.wordpress.com/tag/tcl/'>tcl</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/soultrav.wordpress.com/442/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/soultrav.wordpress.com/442/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/soultrav.wordpress.com/442/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/soultrav.wordpress.com/442/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/soultrav.wordpress.com/442/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/soultrav.wordpress.com/442/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/soultrav.wordpress.com/442/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/soultrav.wordpress.com/442/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/soultrav.wordpress.com/442/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/soultrav.wordpress.com/442/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/soultrav.wordpress.com/442/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/soultrav.wordpress.com/442/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/soultrav.wordpress.com/442/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/soultrav.wordpress.com/442/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=soultrav.wordpress.com&amp;blog=3794532&amp;post=442&amp;subd=soultrav&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://soultrav.wordpress.com/2011/05/26/beating-the-bulls-and-cows-game/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>44.444059 26.054458</georss:point>
		<geo:lat>44.444059</geo:lat>
		<geo:long>26.054458</geo:long>
		<media:content url="http://0.gravatar.com/avatar/044a270a95836821f6bfd2b5c0561f96?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">Soultrav</media:title>
		</media:content>

		<media:content url="http://img594.imageshack.us/img594/2888/bullsandcows.png" medium="image" />

		<media:content url="http://soultrav.files.wordpress.com/2011/05/bulls_cows_exp.jpg" medium="image">
			<media:title type="html">bulls_cows_exp</media:title>
		</media:content>
	</item>
		<item>
		<title>Do you hate GNUChess?</title>
		<link>http://soultrav.wordpress.com/2011/05/24/do-you-hate-gnuchess/</link>
		<comments>http://soultrav.wordpress.com/2011/05/24/do-you-hate-gnuchess/#comments</comments>
		<pubDate>Tue, 24 May 2011 07:11:21 +0000</pubDate>
		<dc:creator>Soultrav</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[expect]]></category>
		<category><![CDATA[gnuchess]]></category>

		<guid isPermaLink="false">http://soultrav.wordpress.com/?p=411</guid>
		<description><![CDATA[If you have tried to play chess against GNUChess, you know what I mean. Unless you are a more experienced player, you have no chance to win against it (I&#8217;ve heard even experienced players have problems beating it). But you can have the pleasure of seeing it defeated. How? By making a Gnuchess vs Gnuchess [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=soultrav.wordpress.com&amp;blog=3794532&amp;post=411&amp;subd=soultrav&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you have tried to play chess against GNUChess, you know what I mean. Unless you are a more experienced player, you have no chance to win against it (I&#8217;ve heard even experienced players have problems beating it).<br />
But you can have the pleasure of seeing it defeated. How? By making a Gnuchess vs Gnuchess match.</p>
<p>For doing this, you can of course run 2 instances of GNUChess , take the output from the first instance, put it into the input of the second instance and vice-versa. But it would be easier to make a script that does this, and you can just lay back and watch the computer lose (er&#8230;unless it&#8217;s a draw).</p>
<p>Expect is a tool I recently discovered, which helps you automate interactive applications, so it&#8217;s suited perfectly for our goal. I&#8217;m actually amazed I didn&#8217;t discover it earlier, it&#8217;s such a great tool, and also works great with Tcl and Tk.</p>
<h2>The code</h2>
<p>You can look at the code below (I made printscreens because wordpress doesn&#8217;t have TCL syntax) or at this <a href="http://pastebin.com/qfVTkVhD" target="_blank">pastebin</a>:<br />
<a target='_blank' href='http://img821.imageshack.us/i/chess1.png/'><img src='http://img821.imageshack.us/img821/7324/chess1.png' border='0' /></a><br />
<a target='_blank' href='http://img683.imageshack.us/i/chess2.png/'><img src='http://img683.imageshack.us/img683/6954/chess2.png' border='0' /></a><br />
<a target='_blank' href='http://img703.imageshack.us/i/chess3.png/'><img src='http://img703.imageshack.us/img703/6859/chess3.png' border='0' /></a></p>
<h2>Some details</h2>
<ul>
<li><strong>set</strong> &#8211; defines a variable</li>
<li><strong>spawn</strong> &#8211; spawns a new process (in out case gnuchess, with it&#8217;s argument -x so it could play in engine mode) and holds a process identifier in $spawn_id. This variable helps us when we want to do switching between multiple processes. In out script, we constantly have to switch between the two instances of gnuchess, so we memorize the spawned id&#8217;s in variables $player1 and $player2</li>
<li><strong>proc</strong> &#8211; defines a procedure, which can be then called by writing &#8220;proc_name argument1 argument 2 &#8230;&#8221;. In our example, the &#8220;turn&#8221; procedure is called with one argument, a string representing the player&#8217;s name.</li>
<li><strong>send</strong> &#8211; sends input to the current proces; for example, when we say <em>send &#8220;go\r&#8221;</em>, we tell gnuchess to start playing</li>
<li><strong>expect</strong> &#8211; waits for output from the currently spawned process. We can tell it to wait for some output that we define, and on its arrival to do certain actions. The &#8220;-re&#8221; flag tells the command that the output we&#8217;re expecting is a regular expression.<br />
For example, on lines 20 through 25 we tell expect that we want to wait for some output from gnuchess that looks like &#8220;move&#8221;, then an undefined number of characters, and finally a newline. If output in this format arrives, expect will print on the screen the move of the current player, then change to the other player and send it the current player&#8217;s move.</li>
</ul>
<h2>Results</h2>
<p>The test machine has an AMD Athlon(tm) 64 X2 Dual Core Processor 4400+, 2 GB of RAM, and runs on CentOS 5.5. GNUChess version is 5.08 and you can get it from <a href="ftp://ftp.gnu.org/gnu/chess/" target="_blank">here</a></p>
<ul>
<li><a href="http://pastebin.com/KcYDQGvV" target="_blank">Depth 1, game ends in ~ 6 seconds</a></li>
<li><a href="http://pastebin.com/fcZZzh2K" target="_blank">Depth 2, game ends in ~ 5 seconds</a></li>
<li><a href="http://pastebin.com/nU5GjwnT" target="_blank">Depth 3, game ends in ~ 7 seconds</a></li>
<li><a href="http://pastebin.com/UNPLmEGJ" target="_blank">Depth 4, game ends in ~ 6 seconds</a></li>
<li><a href="http://pastebin.com/BkvkmEHy" target="_blank">Depth 5, game ends in ~ 11 seconds</a></li>
<li><a href="http://pastebin.com/BR2Bj9CS" target="_blank">Depth 6, game ends in ~ 22 seconds</a></li>
<li><a href="http://pastebin.com/nEhvW96b" target="_blank">Depth 7, game ends in ~ 1m, 17seconds</a></li>
<li><a href="http://pastebin.com/E85YahdE" target="_blank">Depth 8, game ends in 2.5h</a></li>
<li><a href="http://pastebin.com/MQVNsiLe" target="_blank">Default depth, GNUChess beats GNUChess!</a></li>
<li><a href="http://pastebin.com/M2PsfSKg" target="_blank">Default depth, it&#8217;s a draw</a></li>
<li><a href="http://pastebin.com/AEu79KRx" target="_blank">Player 1 at depth 1, Player 2 at depth 3 &#8211; player 1 wins!</a></li>
</ul>
<p>Expect can be easily used on any interactive program, and can help automate some like ftp, ssh, etc.<br />
So I strongly recommend giving it a look, and also getting your hands on the <a href="http://oreilly.com/catalog/9781565920903" target="_blank">Exploring Expect</a> book if possible, it&#8217;s well written and fun to read.</p>
<br />Filed under: <a href='http://soultrav.wordpress.com/category/it/'>IT</a> Tagged: <a href='http://soultrav.wordpress.com/tag/expect/'>expect</a>, <a href='http://soultrav.wordpress.com/tag/gnuchess/'>gnuchess</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/soultrav.wordpress.com/411/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/soultrav.wordpress.com/411/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/soultrav.wordpress.com/411/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/soultrav.wordpress.com/411/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/soultrav.wordpress.com/411/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/soultrav.wordpress.com/411/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/soultrav.wordpress.com/411/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/soultrav.wordpress.com/411/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/soultrav.wordpress.com/411/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/soultrav.wordpress.com/411/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/soultrav.wordpress.com/411/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/soultrav.wordpress.com/411/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/soultrav.wordpress.com/411/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/soultrav.wordpress.com/411/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=soultrav.wordpress.com&amp;blog=3794532&amp;post=411&amp;subd=soultrav&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://soultrav.wordpress.com/2011/05/24/do-you-hate-gnuchess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>44.444059 26.054458</georss:point>
		<geo:lat>44.444059</geo:lat>
		<geo:long>26.054458</geo:long>
		<media:content url="http://0.gravatar.com/avatar/044a270a95836821f6bfd2b5c0561f96?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">Soultrav</media:title>
		</media:content>

		<media:content url="http://img821.imageshack.us/img821/7324/chess1.png" medium="image" />

		<media:content url="http://img683.imageshack.us/img683/6954/chess2.png" medium="image" />

		<media:content url="http://img703.imageshack.us/img703/6859/chess3.png" medium="image" />
	</item>
		<item>
		<title>Wget &gt; Chrome</title>
		<link>http://soultrav.wordpress.com/2011/03/20/wget-chrome/</link>
		<comments>http://soultrav.wordpress.com/2011/03/20/wget-chrome/#comments</comments>
		<pubDate>Sun, 20 Mar 2011 17:34:32 +0000</pubDate>
		<dc:creator>Soultrav</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[wget]]></category>
		<category><![CDATA[resume]]></category>
		<category><![CDATA[download]]></category>

		<guid isPermaLink="false">http://soultrav.wordpress.com/?p=397</guid>
		<description><![CDATA[So, I&#8217;m downloading a relatively large package (considering my 3G connection in the train) with Chrome and suddenly there&#8217;s no signal, and the download is left hanging&#8230;when the signal comes back, I tried resuming the download (repeatedly pause and resume the download) but nothing seems to happen. The solution? wget :D Go to the directory [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=soultrav.wordpress.com&amp;blog=3794532&amp;post=397&amp;subd=soultrav&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So, I&#8217;m downloading a relatively large package (considering my 3G connection in the train) with Chrome and suddenly there&#8217;s no signal, and the download is left hanging&#8230;when the signal comes back, I tried resuming the download (repeatedly pause and resume the download) but nothing seems to happen. The solution? wget :D</p>
<p>Go to the directory where Chrome is currently downloading the file (the file will look something like &#8220;filename.crdownload&#8221;) and make a copy of your file<br />
<pre class="brush: bash;">
cp your_filename.crdownload your_filename
</pre></p>
<p>Then, issue the command:<br />
<pre class="brush: bash;">
wget -c http://link_to_your_file
</pre><br />
The &#8220;-c&#8221; parameter tells wget to continue to get a partially-downloaded file, and the copy command is necessary because wget will look in your current directory for a file named the same as the one in the link you provided.</p>
<p>So, when you connection is not so steady, wget may save from lots of trouble :)</p>
<br />Filed under: <a href='http://soultrav.wordpress.com/category/it/'>IT</a> Tagged: <a href='http://soultrav.wordpress.com/tag/chrome/'>chrome</a>, <a href='http://soultrav.wordpress.com/tag/download/'>download</a>, <a href='http://soultrav.wordpress.com/tag/resume/'>resume</a>, <a href='http://soultrav.wordpress.com/tag/wget/'>wget</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/soultrav.wordpress.com/397/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/soultrav.wordpress.com/397/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/soultrav.wordpress.com/397/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/soultrav.wordpress.com/397/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/soultrav.wordpress.com/397/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/soultrav.wordpress.com/397/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/soultrav.wordpress.com/397/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/soultrav.wordpress.com/397/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/soultrav.wordpress.com/397/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/soultrav.wordpress.com/397/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/soultrav.wordpress.com/397/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/soultrav.wordpress.com/397/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/soultrav.wordpress.com/397/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/soultrav.wordpress.com/397/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=soultrav.wordpress.com&amp;blog=3794532&amp;post=397&amp;subd=soultrav&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://soultrav.wordpress.com/2011/03/20/wget-chrome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>44.444059 26.054458</georss:point>
		<geo:lat>44.444059</geo:lat>
		<geo:long>26.054458</geo:long>
		<media:content url="http://0.gravatar.com/avatar/044a270a95836821f6bfd2b5c0561f96?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">Soultrav</media:title>
		</media:content>
	</item>
		<item>
		<title>Solving Pidgin&#8217;s message character limit</title>
		<link>http://soultrav.wordpress.com/2010/12/28/solving-pidgins-message-character-limit/</link>
		<comments>http://soultrav.wordpress.com/2010/12/28/solving-pidgins-message-character-limit/#comments</comments>
		<pubDate>Tue, 28 Dec 2010 13:33:14 +0000</pubDate>
		<dc:creator>Soultrav</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[message limit]]></category>
		<category><![CDATA[message splitter]]></category>
		<category><![CDATA[pidgin]]></category>
		<category><![CDATA[yahoo]]></category>

		<guid isPermaLink="false">http://soultrav.wordpress.com/?p=383</guid>
		<description><![CDATA[When using Pidgin in Linux for my Yahoo! account, I was often annoyed by the &#8220;Unable to send message: The message is too large.&#8221; error that appeared when trying to send out a too large message. I would have to cut the text manually into smaller pieces by copying it into gedit and dividing it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=soultrav.wordpress.com&amp;blog=3794532&amp;post=383&amp;subd=soultrav&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When using Pidgin in Linux for my Yahoo! account, I was often annoyed by the &#8220;Unable to send message: The message is too large.&#8221; error that appeared when trying to send out a too large message. I would have to cut the text manually into smaller pieces by copying it into gedit and dividing it there or by using CTRL + UP to bring up in the textbox the last message I wrote and split it up. And of course, that&#8217;s not a great solution to the problem&#8230;</p>
<h3>Some details</h3>
<p>So I searched a bit and found <a href="http://pidgin.im/pipermail/support/2009-August/004917.html">here</a> that some constants that control the maximum message length are defined in libpurple/protocols/yahoo/yahoo.h. However, this post was from 2009, and yahoo.h didn&#8217;t exist in version 2.7.9 of pidgin. So I downloaded the source code from <a href="http://sourceforge.net/projects/pidgin/files/Pidgin/2.7.9/pidgin-2.7.9.tar.bz2">here</a> and did a bit of searching myself:<br />
<pre class="brush: bash;">
claudiu@elmer:~/Downloads/pidgin-2.7.9/libpurple/protocols/yahoo$ grep YAHOO_MAX_MESSAGE_LENGTH *
libymsg.c:		if(lenb &gt; YAHOO_MAX_MESSAGE_LENGTH_BYTES || lenc &gt; YAHOO_MAX_MESSAGE_LENGTH_CHARS) {
libymsg.c:					&quot;  Message is '%s'.\n&quot;, lenb, lenc, YAHOO_MAX_MESSAGE_LENGTH_BYTES,
libymsg.c:					YAHOO_MAX_MESSAGE_LENGTH_CHARS, msg2);
libymsg.h:#define YAHOO_MAX_MESSAGE_LENGTH_BYTES 984
libymsg.h:#define YAHOO_MAX_MESSAGE_LENGTH_CHARS 800
</pre><br />
, and the explanation found in libymsg.h was:<br />
<pre class="brush: cpp;">
/*
 * Current Maximum Length for Instant Messages
 *
 * This was found by experiment.
 *
 * The YMSG protocol allows a message of up to 948 bytes, but the official client
 * limits to 800 characters.  According to experiments I conducted, it seems that
 * the discrepancy is to allow some leeway for messages with mixed single- and
 * multi-byte characters, as I was able to send messages of 840 and 932 bytes
 * by using some multibyte characters (some random Chinese or Japanese characters,
 * to be precise). - rekkanoryo
 */
#define YAHOO_MAX_MESSAGE_LENGTH_BYTES 984
#define YAHOO_MAX_MESSAGE_LENGTH_CHARS 800
</pre><br />
As you can see, the size of the message you send is limited to 800 characters. This may seem enough, but when sending more than 2 or 3 large sentences, I assure you it isn&#8217;t.<br />
Unfortunately, this is a limitation of the protocol, not the client, so modifying those constants in order to be able to send more than 800 characters would not be a valid solution.<br />
PS: in some cases, the maximum length of a message was limited drastically to just one medium-sized sentence &#8211; in these cases, the most common problem was the Colorize plugin. So if you find yourself in this situation, just go to Tools-&gt;Plugins in a pidgin window and uncheck the Colorize plugin.</p>
<h3>The solution</h3>
<p>&#8230;is a Pidgin plugin called Message Splitter, you just send the message as it is, and the plugin splits it up into more messages if it exceeds a certain character limit. You can even set this limit by yourself (remember, this limit can not be more than 800!). In addition, you can also specify the amount of delay in ms two messages will have between them.<br />
To activate the plugin, you must install the pidgin-plugin-pack packet, but first you have to add the Pidgin Developers PPA to the repository. To do this, add the following two lines to your /etc/apt/sources.list file:<br />
<pre class="brush: bash;">
$ sudo vim /etc/apt/sources.list
deb http://ppa.launchpad.net/pidgin-developers/ppa/ubuntu maverick main
deb-src http://ppa.launchpad.net/pidgin-developers/ppa/ubuntu maverick main
</pre><br />
, and don&#8217;t forget to replace &#8220;maverick&#8221; with your current version of Linux.<br />
Then, you must update the repository. If it tells you it didn&#8217;t find a certain public key, you must download that key first, and then update your repository.<br />
<pre class="brush: bash;">
$ sudo apt-get update
[...]
W: GPG error: http://ppa.launchpad.net maverick Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7FB8BEE0A1F196A8
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7FB8BEE0A1F196A8
$ sudo apt-get update
</pre><br />
Next, you install the plugin pack:<br />
<pre class="brush: bash;">
$ sudo apt-get install pidgin-plugin-pack
</pre><br />
, and then simply open the Pidgin main window, go to Tools-&gt;Plugins, search for the plugin named &#8220;Message Splitter&#8221; and check it&#8217;s box. Further, you can adjust the maximum length of a message and the delay between messages by clicking on &#8216;Configure&#8217; and modifying the parameters:<br />
<a href="http://soultrav.files.wordpress.com/2010/12/untitled.jpg"><img src="http://soultrav.files.wordpress.com/2010/12/untitled.jpg?w=500" alt="" title="Untitled"   class="aligncenter size-full wp-image-388" /></a><br />
For testing, you can copy-paste <a href="http://pastebin.com/Fmf9zU9a">this text</a>, which is 1114 characters long, and it should be divided in two messages with the standard settings.</p>
<br />Filed under: <a href='http://soultrav.wordpress.com/category/it/'>IT</a> Tagged: <a href='http://soultrav.wordpress.com/tag/message-limit/'>message limit</a>, <a href='http://soultrav.wordpress.com/tag/message-splitter/'>message splitter</a>, <a href='http://soultrav.wordpress.com/tag/pidgin/'>pidgin</a>, <a href='http://soultrav.wordpress.com/tag/yahoo/'>yahoo</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/soultrav.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/soultrav.wordpress.com/383/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/soultrav.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/soultrav.wordpress.com/383/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/soultrav.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/soultrav.wordpress.com/383/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/soultrav.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/soultrav.wordpress.com/383/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/soultrav.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/soultrav.wordpress.com/383/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/soultrav.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/soultrav.wordpress.com/383/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/soultrav.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/soultrav.wordpress.com/383/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=soultrav.wordpress.com&amp;blog=3794532&amp;post=383&amp;subd=soultrav&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://soultrav.wordpress.com/2010/12/28/solving-pidgins-message-character-limit/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<georss:point>44.444059 26.054458</georss:point>
		<geo:lat>44.444059</geo:lat>
		<geo:long>26.054458</geo:long>
		<media:content url="http://0.gravatar.com/avatar/044a270a95836821f6bfd2b5c0561f96?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">Soultrav</media:title>
		</media:content>

		<media:content url="http://soultrav.files.wordpress.com/2010/12/untitled.jpg" medium="image">
			<media:title type="html">Untitled</media:title>
		</media:content>
	</item>
		<item>
		<title>Excel 97 flight simulator</title>
		<link>http://soultrav.wordpress.com/2010/12/25/excel-97-flight-simulator/</link>
		<comments>http://soultrav.wordpress.com/2010/12/25/excel-97-flight-simulator/#comments</comments>
		<pubDate>Sat, 25 Dec 2010 20:56:55 +0000</pubDate>
		<dc:creator>Soultrav</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[excel 97]]></category>
		<category><![CDATA[flight]]></category>
		<category><![CDATA[simulator]]></category>
		<category><![CDATA[windows 98]]></category>

		<guid isPermaLink="false">http://soultrav.wordpress.com/?p=342</guid>
		<description><![CDATA[If you are wondering what does a flight simulator has to do with Excel, you should know that version 97 (and 2000 I think) of Microsoft Excel has a hidden flight simulator launched if you follow some steps. I heard about this myth many years ago, but never managed to get my hands on an [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=soultrav.wordpress.com&amp;blog=3794532&amp;post=342&amp;subd=soultrav&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you are wondering what does a flight simulator has to do with Excel, you should know that version 97 (and 2000 I think) of Microsoft Excel has a hidden flight simulator launched if you follow some steps.<br />
I heard about this myth many years ago, but never managed to get my hands on an Office 97 pack and test it (don&#8217;t ask me where I got it from now).<br />
So I installed Office 97 on my Windows 7 OS, launched Excel and followed the next steps:</p>
<ol>
<li>Push F5</li>
<li>In the reference tab, type x97:L97 and push the Enter key</li>
<li>Push Tab</li>
<li>Hold Ctrl+Shift and click on the chart wizard (The icon with the coloured bars)</li>
</ol>
<p>And indeed, the myth was true!<br />
<a href="http://soultrav.files.wordpress.com/2010/12/photo0094.jpg"><img src="http://soultrav.files.wordpress.com/2010/12/photo0094.jpg?w=300&#038;h=225" alt="" title="Photo0094" width="300" height="225" class="aligncenter size-medium wp-image-365" /></a><br />
<a href="http://soultrav.files.wordpress.com/2010/12/photo0095.jpg"><img src="http://soultrav.files.wordpress.com/2010/12/photo0095.jpg?w=300&#038;h=225" alt="" title="Photo0095" width="300" height="225" class="aligncenter size-medium wp-image-367" /></a><br />
You can control it easily with the mouse, or with the keyboard arrows. You can also see credits for the programmers (on the first photo) but what are supposed to be mountains (I think) appear a bit&#8230;colourful.<br />
I modified the options for excel to run in compatibility with Windows 98, but same result unfortunately. So I thought maybe it&#8217;s because I&#8217;m running Win7 and not an older OS&#8230;so I wiped the dust off a Windows 98 CD, installed it on a virtual machine in VMWare and tried to run the simulator there. Then I realized, there&#8217;s no way I could install my video driver in Windows 98! (and I thing there&#8217;s issues with the virtual machine trying to access the video card too).<br />
But anyway, if you missed Windows 98 (riiight&#8230;) here&#8217;s some screenshots:<br />
<a href="http://soultrav.files.wordpress.com/2010/12/win98sestup.png"><img src="http://soultrav.files.wordpress.com/2010/12/win98sestup.png?w=300&#038;h=170" alt="" title="win98sestup" width="300" height="170" class="aligncenter size-medium wp-image-368" /></a><br />
<a href="http://soultrav.files.wordpress.com/2010/12/win98startup.png"><img src="http://soultrav.files.wordpress.com/2010/12/win98startup.png?w=300&#038;h=186" alt="" title="win98startup" width="300" height="186" class="aligncenter size-medium wp-image-371" /></a><br />
<a href="http://soultrav.files.wordpress.com/2010/12/win98desktop.png"><img src="http://soultrav.files.wordpress.com/2010/12/win98desktop.png?w=300&#038;h=225" alt="" title="win98desktop" width="300" height="225" class="aligncenter size-medium wp-image-372" /></a><br />
<a href="http://soultrav.files.wordpress.com/2010/12/win98google.png"><img src="http://soultrav.files.wordpress.com/2010/12/win98google.png?w=300&#038;h=225" alt="" title="win98google" width="300" height="225" class="aligncenter size-medium wp-image-369" /></a><br />
(a dozen of these last errors appeared when I tried to access Google)</p>
<br />Filed under: <a href='http://soultrav.wordpress.com/category/it/'>IT</a> Tagged: <a href='http://soultrav.wordpress.com/tag/excel-97/'>excel 97</a>, <a href='http://soultrav.wordpress.com/tag/flight/'>flight</a>, <a href='http://soultrav.wordpress.com/tag/simulator/'>simulator</a>, <a href='http://soultrav.wordpress.com/tag/windows-98/'>windows 98</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/soultrav.wordpress.com/342/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/soultrav.wordpress.com/342/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/soultrav.wordpress.com/342/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/soultrav.wordpress.com/342/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/soultrav.wordpress.com/342/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/soultrav.wordpress.com/342/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/soultrav.wordpress.com/342/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/soultrav.wordpress.com/342/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/soultrav.wordpress.com/342/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/soultrav.wordpress.com/342/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/soultrav.wordpress.com/342/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/soultrav.wordpress.com/342/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/soultrav.wordpress.com/342/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/soultrav.wordpress.com/342/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=soultrav.wordpress.com&amp;blog=3794532&amp;post=342&amp;subd=soultrav&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://soultrav.wordpress.com/2010/12/25/excel-97-flight-simulator/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<georss:point>44.444059 26.054458</georss:point>
		<geo:lat>44.444059</geo:lat>
		<geo:long>26.054458</geo:long>
		<media:content url="http://0.gravatar.com/avatar/044a270a95836821f6bfd2b5c0561f96?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">Soultrav</media:title>
		</media:content>

		<media:content url="http://soultrav.files.wordpress.com/2010/12/photo0094.jpg?w=300" medium="image">
			<media:title type="html">Photo0094</media:title>
		</media:content>

		<media:content url="http://soultrav.files.wordpress.com/2010/12/photo0095.jpg?w=300" medium="image">
			<media:title type="html">Photo0095</media:title>
		</media:content>

		<media:content url="http://soultrav.files.wordpress.com/2010/12/win98sestup.png?w=300" medium="image">
			<media:title type="html">win98sestup</media:title>
		</media:content>

		<media:content url="http://soultrav.files.wordpress.com/2010/12/win98startup.png?w=300" medium="image">
			<media:title type="html">win98startup</media:title>
		</media:content>

		<media:content url="http://soultrav.files.wordpress.com/2010/12/win98desktop.png?w=300" medium="image">
			<media:title type="html">win98desktop</media:title>
		</media:content>

		<media:content url="http://soultrav.files.wordpress.com/2010/12/win98google.png?w=300" medium="image">
			<media:title type="html">win98google</media:title>
		</media:content>
	</item>
		<item>
		<title>45 minutes of audio pleasure :)</title>
		<link>http://soultrav.wordpress.com/2010/12/13/45-minutes-of-audio-pleasure/</link>
		<comments>http://soultrav.wordpress.com/2010/12/13/45-minutes-of-audio-pleasure/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 03:08:09 +0000</pubDate>
		<dc:creator>Soultrav</dc:creator>
				<category><![CDATA[Music]]></category>
		<category><![CDATA[dark]]></category>
		<category><![CDATA[electro]]></category>
		<category><![CDATA[minimal]]></category>

		<guid isPermaLink="false">http://soultrav.wordpress.com/?p=352</guid>
		<description><![CDATA[I finally decided to upload an audio set on SoundCloud, hoping this will motivate me to finish some tracks I started making aeons ago :-) It&#8217;s some dark minimal stuff, including pretty well-known tracks by artists like John Dahlback and Heartthrob, but also a more underground-ish track by Radu Adrian. Last few minutes end with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=soultrav.wordpress.com&amp;blog=3794532&amp;post=352&amp;subd=soultrav&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I finally decided to upload an audio set on <a href="http://soundcloud.com/soultrav/soultrav-dark-minimal-mix-08-12-2010">SoundCloud</a>, hoping this will motivate me to finish some tracks I started making aeons ago :-)<br />
It&#8217;s some dark minimal stuff, including pretty well-known tracks by artists like John Dahlback and Heartthrob, but also a more underground-ish track by Radu Adrian. Last few minutes end with an electro antithesis by Anthony Rother: &#8220;Gott&#8221; and &#8220;Luzifer&#8221;.</p>
<object height="81" width="100%"><param name="wmode" value="transparent"><param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F7992478&amp;g=1&amp;"></param><embed height="81" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F7992478&amp;g=1&amp;" type="application/x-shockwave-flash" width="100%"> </embed> </object>
<p>(click <a href="http://soundcloud.com/soultrav/soultrav-dark-minimal-mix-08-12-2010">here</a> if the SoundCloud widget doesn&#8217;t load)</p>
<br />Filed under: <a href='http://soultrav.wordpress.com/category/music/'>Music</a> Tagged: <a href='http://soultrav.wordpress.com/tag/dark/'>dark</a>, <a href='http://soultrav.wordpress.com/tag/electro/'>electro</a>, <a href='http://soultrav.wordpress.com/tag/minimal/'>minimal</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/soultrav.wordpress.com/352/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/soultrav.wordpress.com/352/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/soultrav.wordpress.com/352/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/soultrav.wordpress.com/352/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/soultrav.wordpress.com/352/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/soultrav.wordpress.com/352/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/soultrav.wordpress.com/352/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/soultrav.wordpress.com/352/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/soultrav.wordpress.com/352/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/soultrav.wordpress.com/352/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/soultrav.wordpress.com/352/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/soultrav.wordpress.com/352/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/soultrav.wordpress.com/352/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/soultrav.wordpress.com/352/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=soultrav.wordpress.com&amp;blog=3794532&amp;post=352&amp;subd=soultrav&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://soultrav.wordpress.com/2010/12/13/45-minutes-of-audio-pleasure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/044a270a95836821f6bfd2b5c0561f96?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">Soultrav</media:title>
		</media:content>
	</item>
		<item>
		<title>l -sl</title>
		<link>http://soultrav.wordpress.com/2010/12/02/l-sl/</link>
		<comments>http://soultrav.wordpress.com/2010/12/02/l-sl/#comments</comments>
		<pubDate>Thu, 02 Dec 2010 07:18:34 +0000</pubDate>
		<dc:creator>Soultrav</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[ls]]></category>

		<guid isPermaLink="false">http://soultrav.wordpress.com/?p=334</guid>
		<description><![CDATA[If the title seems odd, I&#8217;ll give you a hint&#8230;it&#8217;s a bash command. Seems familiar? Yeah, it&#8217;s a speed misspelling of &#8220;ls -l&#8221;&#8230;and to my surprise it worked! Turns out &#8220;l&#8221; is an alias for &#8220;ls -CF&#8221; :) (for a moment I thought the terminal was reading my mind) Filed under: IT Tagged: bash, ls<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=soultrav.wordpress.com&amp;blog=3794532&amp;post=334&amp;subd=soultrav&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If the title seems odd, I&#8217;ll give you a hint&#8230;it&#8217;s a bash command. Seems familiar?</p>
<p>Yeah, it&#8217;s a speed misspelling of &#8220;ls -l&#8221;&#8230;and to my surprise it worked!<br />
Turns out &#8220;l&#8221; is an alias for &#8220;ls -CF&#8221; :) </p>
<p><pre class="brush: bash;">
claudiu@elmer:~$ alias
alias alert='notify-send --urgency=low -i &quot;$([ $? = 0 ] &amp;&amp; echo terminal || echo error)&quot; &quot;$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&amp;|]\s*alert$//'\'')&quot;'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'
</pre></p>
<p>(for a moment I thought the terminal was reading my mind)</p>
<br />Filed under: <a href='http://soultrav.wordpress.com/category/it/'>IT</a> Tagged: <a href='http://soultrav.wordpress.com/tag/bash/'>bash</a>, <a href='http://soultrav.wordpress.com/tag/ls/'>ls</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/soultrav.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/soultrav.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/soultrav.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/soultrav.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/soultrav.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/soultrav.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/soultrav.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/soultrav.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/soultrav.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/soultrav.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/soultrav.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/soultrav.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/soultrav.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/soultrav.wordpress.com/334/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=soultrav.wordpress.com&amp;blog=3794532&amp;post=334&amp;subd=soultrav&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://soultrav.wordpress.com/2010/12/02/l-sl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>44.444059 26.054458</georss:point>
		<geo:lat>44.444059</geo:lat>
		<geo:long>26.054458</geo:long>
		<media:content url="http://0.gravatar.com/avatar/044a270a95836821f6bfd2b5c0561f96?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">Soultrav</media:title>
		</media:content>
	</item>
		<item>
		<title>CSMA/CD after&#8230;a social approach</title>
		<link>http://soultrav.wordpress.com/2010/12/02/csmacd-after-a-social-approach/</link>
		<comments>http://soultrav.wordpress.com/2010/12/02/csmacd-after-a-social-approach/#comments</comments>
		<pubDate>Thu, 02 Dec 2010 02:56:53 +0000</pubDate>
		<dc:creator>Soultrav</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[collision]]></category>
		<category><![CDATA[csma/cd]]></category>
		<category><![CDATA[duplex]]></category>
		<category><![CDATA[half]]></category>
		<category><![CDATA[social]]></category>

		<guid isPermaLink="false">http://soultrav.wordpress.com/?p=321</guid>
		<description><![CDATA[Today, while drinking some beer with my friends and after a night with a couple of hours of sleep, I suddenly realized (!) we were all talking at the same time and no one could understand what the others were saying. It was clear this was a collision system which needed some algorithm to stop [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=soultrav.wordpress.com&amp;blog=3794532&amp;post=321&amp;subd=soultrav&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today, while drinking some beer with my friends and after a night with a couple of hours of sleep, I suddenly realized (!) we were all talking at the same time and no one could understand what the others were saying. It was clear this was a collision system which needed some algorithm to stop the collisions!</p>
<p>While thinking what are the social rules that apply when people need to understand each other in these situations, two solutions rapidly came to mind:</p>
<ol>
<li>one of us could yell really loud and stop the others from talking &#8211; then express his/her point of view &#8211; but that&#8217;s not very polite is it?</li>
<li>most often, people will wait an amount of time for the other person to finish what they had to say, then take their turn to speak.</li>
</ol>
<p>The second solution immediately made me think of CSMA/CD. Then I thought &#8220;hey, but why not choose the first solution for collision detection on computer networks?&#8221;, but rapidly realized it was a bad idea. Network cards would need personality, then other network cards would probably be mad at the loud ones, and then refuse to communicate, etc etc<br />
Anyhow, thinking how many factors influence humans in the process of shutting up and letting others speak (character,eye contact, relationship with the other individual)&#8230; I realized I don&#8217;t REALLY understand the collision detection method at the physical level.</p>
<h2>Some background on CSMA/CD</h2>
<p>CSMA/CD is Carrier Sense Multiple Access / Collision Detection :<br />
- Carrier Sense &#8211; the ability of a network card to <i>sense</i> or detect communication on the network<br />
- Multiple Access &#8211; states that in that network there are multiple stations that could access the network at the same time<br />
- Collision Detection &#8211; the method we need for detecting a collision</p>
<p><a href="http://soultrav.files.wordpress.com/2010/11/csma-cd.jpg"><img src="http://soultrav.files.wordpress.com/2010/11/csma-cd.jpg?w=247&#038;h=300" alt="csma/cd" title="csma-cd" width="247" height="300" class="aligncenter size-medium wp-image-323" /></a></p>
<p>When a collision is detected, the devices involved in the collision send a <i>jam signal</i> to be sure the other devices detect the collision. After that, they initiate the <i>back-off algorithm</i>, which practically means they wait for a random amount of time before rescanning the medium for any frames and then retransmitting.<br />
Ethernet devices will wait for a minimum amount of time before retransmitting, named interframe gap. This time is the time necessary to transmit 96 bits of data on the medium, so it has several values depending on the cable type. </p>
<p>Important to keep in mind is that collision detection is needed only on wired networks where stations in the network communicate in <strong>half-duplex</strong> mode. A half-duplex transmission allows both ends of the channel to be transceiver and receiver, but since they use the same wire they cannot transmit at the same time!<br />
<a href="http://soultrav.files.wordpress.com/2010/11/comunicaciones-half-duplex-y-full-duplex_7898_6_1.jpg"><img src="http://soultrav.files.wordpress.com/2010/11/comunicaciones-half-duplex-y-full-duplex_7898_6_1.jpg?w=500" alt="half-duplex" title="comunicaciones-half-duplex-y-full-duplex_7898_6_1"   class="aligncenter size-full wp-image-326" /></a><br />
So, two widely spread computer network types today that <i>don&#8217;t use</i> CSMA/CD are:</p>
<ul>
<li>local area networks connected with UTP cables &#8211; the Ethernet technology, when using UTP cables, allows full-duplex transmission, which means two stations will transmit and receive at the same time but on different wires, so without any interference<br />
PS: you can still get collisions on copper and fiber (different channels); you can also still get collisions on full-duplex if you use hubs instead of switches!</li>
<li>wireless networks &#8211; because a wireless device cannot detect a receiving signal while transmitting, it uses the CSMA/<strong>C</strong>ollision <strong>A</strong>voidance scheme.</li>
</ul>
<h2>On the physical level&#8230;</h2>
<p>So, the thing is: how does a NIC (network interface card) detect a collision?<br />
Well, it appears that NICs detect collisions because they appear to be higher in signal amplitude than normal signals.<br />
Thus, the current level when leaving the transmitter might be between 16 and 20 milliamperes, but the receiver will get back a stronger signal. But why is the receiver getting a stronger signal, aren&#8217;t the currents opposed one to each other?</p>
<p>In addition, what is the jam signal made up of? Does it&#8217;s amplitude need to be between some fixed values so the other stations know it&#8217;s a signal of a collision happening? If that&#8217;s so, can the emitting NIC know for sure the signal won&#8217;t attenuate too much as it propagates along the lines?</p>
<p>Hope I&#8217;ll get the answer to these questions soon and update this post&#8230;until then, mystery unsolved :)  </p>
<p>Edit: well, it seems I was looking at the problem the wrong way&#8230;there are actually voltages on the wire, so when packets are put on the wire by the NIC, they have certain voltage levels, which obviously add up (0 and 1 bits are sent through the wire using different encodings, for example <a href="http://en.wikipedia.org/wiki/NRZI#Non-Return-to-Zero_Inverted_.28NRZI.29">NRZI</a> in the case of Ethernet).</p>
<p>My physics knowledge suck.</p>
<br />Filed under: <a href='http://soultrav.wordpress.com/category/it/'>IT</a> Tagged: <a href='http://soultrav.wordpress.com/tag/collision/'>collision</a>, <a href='http://soultrav.wordpress.com/tag/csmacd/'>csma/cd</a>, <a href='http://soultrav.wordpress.com/tag/duplex/'>duplex</a>, <a href='http://soultrav.wordpress.com/tag/half/'>half</a>, <a href='http://soultrav.wordpress.com/tag/social/'>social</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/soultrav.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/soultrav.wordpress.com/321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/soultrav.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/soultrav.wordpress.com/321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/soultrav.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/soultrav.wordpress.com/321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/soultrav.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/soultrav.wordpress.com/321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/soultrav.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/soultrav.wordpress.com/321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/soultrav.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/soultrav.wordpress.com/321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/soultrav.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/soultrav.wordpress.com/321/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=soultrav.wordpress.com&amp;blog=3794532&amp;post=321&amp;subd=soultrav&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://soultrav.wordpress.com/2010/12/02/csmacd-after-a-social-approach/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/044a270a95836821f6bfd2b5c0561f96?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">Soultrav</media:title>
		</media:content>

		<media:content url="http://soultrav.files.wordpress.com/2010/11/csma-cd.jpg?w=247" medium="image">
			<media:title type="html">csma-cd</media:title>
		</media:content>

		<media:content url="http://soultrav.files.wordpress.com/2010/11/comunicaciones-half-duplex-y-full-duplex_7898_6_1.jpg" medium="image">
			<media:title type="html">comunicaciones-half-duplex-y-full-duplex_7898_6_1</media:title>
		</media:content>
	</item>
		<item>
		<title>File uploads with AJAX</title>
		<link>http://soultrav.wordpress.com/2010/09/02/file-uploads-with-ajax/</link>
		<comments>http://soultrav.wordpress.com/2010/09/02/file-uploads-with-ajax/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 01:21:54 +0000</pubDate>
		<dc:creator>Soultrav</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[iframes]]></category>
		<category><![CDATA[swfupload]]></category>
		<category><![CDATA[upload]]></category>

		<guid isPermaLink="false">http://soultrav.wordpress.com/?p=260</guid>
		<description><![CDATA[Unfortunately, you can&#8217;t do real AJAX file uploads (without some exceptions) but there are ways you can give it the AJAX feel. Here are some of them: iframes This is a good method to use, taking in account that most browsers will support it and it&#8217;s not too complicated&#8230; So let&#8217;s say your page contains [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=soultrav.wordpress.com&amp;blog=3794532&amp;post=260&amp;subd=soultrav&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Unfortunately, you can&#8217;t do <em>real</em> AJAX file uploads (without some exceptions) but there are ways you can give it the AJAX feel. Here are some of them:</p>
<h2><strong>iframes</strong></h2>
<p>This is a good method to use, taking in account that most browsers will support it and it&#8217;s not too complicated&#8230;<br />
So let&#8217;s say your page contains a basic form, like this one:<br />
<pre class="brush: xml;">
&lt;form name=&quot;upload_form&quot; target=&quot;hidden_frame&quot; action=&quot;upload.php&quot; enctype=&quot;multipart/form-data&quot; method=&quot;post&quot;&gt;
Attach a file:
&lt;input id=&quot;file_upload&quot; name=&quot;file_upload&quot; type=&quot;file&quot; onchange=&quot;document.uploadform.submit()&quot; /&gt;
&lt;/form&gt;
</pre></p>
<p>Now, when you will choose a file to upload, it will trigger the submit() function and it will run the script <em>upload.php</em>, targeted into the hidden iframe. So, the script will run without anybody seeing it.<br />
Additionally, you can add an (initially) empty paragraph where the name of the file will appear after the upload has been completed, so the user will know it has been uploaded.<br />
<pre class="brush: xml;">
&lt;iframe name=&quot;hidden_frame&quot; style=&quot;display: none&quot;&gt;&lt;/iframe&gt;
&lt;p id=&quot;filename&quot;&gt;&lt;/p&gt;
</pre><br />
Next, let&#8217;s see the <em>upload.php</em> page. At the end the file will contain some javascript that puts HTML code (the name of the uploaded file) into the paragraph &#8220;filename&#8221; so the user will know the file was uploaded.<br />
<pre class="brush: xml;">
// UPLOAD_DIR is a constant holding the path to the upload folder
$path = UPLOAD_DIR.basename($_FILES['file_upload']['name']);

if (!move_uploaded_file($_FILES['file_upload']['tmp_name'], $path)) {
    echo &quot;There was an error uploading the file!&quot;;
}
?&gt;
&lt;script language=&quot;javascript&quot;&gt;
parent.document.getElementById('file_upload').innerHTML += 
  '&lt;br/&gt;
   &lt;a href=&quot;&lt;?php echo UPLOAD_DIR.$_FILES['file_upload']['name'] ?&gt;&quot;&gt;
   &lt;?php echo $_FILES['filefieldname']['name'] ?&gt;
   &lt;/a&gt;';
&lt;/script&gt;
</pre><br />
If you want to upload a single file, change the $path variable to a fixed file name and it will always overwrite the file&#8217;s contents every time a new file is chosen. You could make that file a temporary one, and play with it in any way you wish to.<br />
Also, to upload a single file, do not forget to change the <strong>+=</strong> to <strong>=</strong> in the javascript portion of the code where HTML code is attributed to the paragraph, like this:<br />
<pre class="brush: jscript;">
parent.document.getElementById('file_upload').innerHTML = ...
</pre><br />
And that&#8217;s about it. For an example, click <a href="http://www.sajithmr.com/wp-content/uploads/2007/11/file-upload-like-gmail.rar">here</a>. The related website is <a href="http://www.sajithmr.me/upload-files-like-gmail/">here</a>.</p>
<h2><strong>The AJAX File Upload plugin</strong></h2>
<p>This is easier to implement than the previous one, but it involves using jQuery. So, for this one, you must download a version of <a href="http://docs.jquery.com/Downloading_jQuery">jQuery</a> and the <a href="http://valums.com/ajax-upload/">AJAX File Upload plugin</a> and include them in your index.html file.<br />
<pre class="brush: xml;">
&lt;script type=&quot;text/javascript&quot; src=&quot;../js/jquery1.2.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;../js/ajaxupload.3.5.js&quot;&gt;&lt;/script&gt;
</pre><br />
Next, you must write the upload form (although, with this plugin you don&#8217;t really need a form!). So let&#8217;s introduce a button (it can be any element you want), a paragraph where the status will be displayed and a div where the names of the uploaded files will appear.<br />
<pre class="brush: xml;">
&lt;div id=&quot;files&quot;&gt;&lt;/div&gt;
&lt;input name=&quot;btnFile&quot; id=&quot;btnFile&quot; type=&quot;button&quot; value=&quot;Upload file&quot; /&gt;
&lt;p id=&quot;status_file&quot; &gt;&lt;/p&gt;
</pre><br />
Now let&#8217;s start doing the magic. For the plugin to work, you must instantiate an AjaxUpload object and define a few parameters. You can do this inside a  tab in the index.htm file or you can write a separate javascript file and include it.<br />
On <em>submission</em> the text &#8220;Uploading&#8230;&#8221; will be introduced inside the paragraph <em>status_file</em>. After the file has been uploaded (on <em>completion</em>), that text will disappear and a link to the uploaded file will be available.<br />
Here&#8217;s a simple example that you can include in the index.htm file:<br />
<pre class="brush: xml;">
$(function(){
  var fileUpload = $('#btnFile');
  var status = $('#status_file');
  new AjaxUpload(fileUpload, {
    action: 'upload.php',
    name: 'file',
    onSubmit: function(file, ext){
        status.html('&lt;br/&gt;Uploading...');
    },
    onComplete: function(file, response){
       status.text('');
       //Add uploaded file to list
       $('&lt;p&gt;&lt;/p&gt;').appendTo('#files').html('&lt;img src=&quot;./uploads/'+file+'&quot; alt=&quot;&quot; /&gt;&lt;br /&gt;'+file).addClass('success');
    }
  });
});
</pre><br />
And here is the upload.php script:<br />
<pre class="brush: php;">
&lt;?php
  $uploaddir = './uploads/'; 
  $file = $uploaddir.basename($_FILES['file']['name']); 
  move_uploaded_file($_FILES['file']['tmp_name'], $file);
?&gt;
</pre><br />
If you want a single-file upload, you have to change the line where you add the uploaded file to the list to:<br />
<pre class="brush: xml;">
$('#files').html('&lt;p class=&quot;success&quot;&gt;
                    &lt;a href=&quot;./uploads/'+file+'&quot;&gt;'+file+'&lt;/a&gt;
                    &lt;br/&gt;
                    &lt;br/&gt;
                  &lt;/p&gt;');
</pre><br />
You can find a working example <a href="http://demo.webdeveloperplus.com/source-code/ajax-file-upload.zip">here</a>.</p>
<h2><strong>SWFUpload</strong></h2>
<p>SWFUpload is a cute flash/javascript library that can handle multiple file uploads, allow you to choose what filetypes you want uploaded, shows upload progress and has client-side file size checking. Another cool thing is that it will degrade to a normal file input-field if flash/javascript isn&#8217;t allowed.<br />
First, you have to download the library, from <a href="http://code.google.com/p/swfupload/downloads/list">here</a>.<br />
Now let&#8217;s begin writing the code. So, for starters, you will have to create a SWFUpload object and set some of its parameters.<br />
<pre class="brush: jscript;">
&lt;script type=&quot;text/javascript&quot;&gt;
		var swfu;

		window.onload = function() {
			var settings = {
				flash_url : &quot;../swfupload/swfupload.swf&quot;,
				upload_url: &quot;upload.php&quot;,
				post_params: {&quot;PHPSESSID&quot; : &quot;&quot;},
				file_size_limit : &quot;100 MB&quot;,
				file_types : &quot;*.*&quot;,
				file_types_description : &quot;All Files&quot;,
				file_upload_limit : 100,
				file_queue_limit : 0,
				custom_settings : {
					progressTarget : &quot;fsUploadProgress&quot;,
					cancelButtonId : &quot;btnCancel&quot;
				},
				debug: false,

				// Button settings
				button_image_url: &quot;images/TestImageNoText_65x29.png&quot;,
				button_width: &quot;65&quot;,
				button_height: &quot;29&quot;,
				button_placeholder_id: &quot;spanButtonPlaceHolder&quot;,
				button_text: '&lt;span class=&quot;theFont&quot;&gt;Upload&lt;/span&gt;',
				button_text_style: &quot;.theFont { font-size: 16; }&quot;,
				button_text_left_padding: 12,
				button_text_top_padding: 3,
				
				// event handler functions should be defined elsewhere
				file_queued_handler : fileQueued,
				file_queue_error_handler : fileQueueError,
				file_dialog_complete_handler : fileDialogComplete,
				upload_start_handler : uploadStart,
				upload_progress_handler : uploadProgress,
				upload_error_handler : uploadError,
				upload_success_handler : uploadSuccess,
				upload_complete_handler : uploadComplete,
				queue_complete_handler : queueComplete
			};

			swfu = new SWFUpload(settings);
	     };
&lt;/script&gt;
</pre><br />
, and the HTML:<br />
<pre class="brush: xml;">
&lt;form id=&quot;form1&quot; action=&quot;index.php&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;&gt;
  &lt;div class=&quot;fieldset flash&quot; id=&quot;fsUploadProgress&quot;&gt;
    &lt;span class=&quot;legend&quot;&gt;Upload Queue&lt;/span&gt;
  &lt;/div&gt;
  &lt;div id=&quot;divStatus&quot;&gt;0 Files Uploaded&lt;/div&gt;
  &lt;div&gt;
    &lt;span id=&quot;spanButtonPlaceHolder&quot;&gt;&lt;/span&gt;
    &lt;input id=&quot;btnCancel&quot; type=&quot;button&quot; value=&quot;Cancel All Uploads&quot; onclick=&quot;swfu.cancelQueue();&quot; disabled=&quot;disabled&quot;     style=&quot;margin-left: 2px; font-size: 8pt; height: 29px;&quot; /&gt;
  &lt;/div&gt;
&lt;/form&gt;
</pre><br />
For an easier configuration of the plugin, you could use the <a href="http://github.com/ifunk/swfupload-jquery-plugin/blob/master/src/jquery.swfupload.js">swfupload jquery plugin</a>. You can find more information at <a href="http://blogs.bigfish.tv/adam/2009/06/14/swfupload-jquery-plugin/">Adam Royle&#8217;s blog</a>.</p>
<p>Also, you can find some useful demos of SWFUpload <a href="http://demo.swfupload.org/v220/index.htm">here</a>.</p>
<p><strong>Note:</strong> Unfortunately, the plugin doesn&#8217;t work on Linux operating systems, and Adobe&#8217;s workaround is <em>&#8220;Use Mac OS or Windows OS to perform uploads, where the exact same SWF works fine&#8221;.</em> I know, that&#8217;s nice. <a href="http://bugs.adobe.com/jira/browse/FP-377">Check it out.</a></p>
<h2><strong>Other stuff</strong></h2>
<p>If you&#8217;re using ASP.NET, you could try this -&gt; <a href="http://ajaxuploader.com/">Ajax Uploader</a><br />
If you&#8217;re using Java, you could try this -&gt; <a href="http://directwebremoting.org/blog/joe/2008/12/16/dwr_version_3_0_release_candidate_1.html">DWR version 3.0</a><br />
Haven&#8217;t tried them out, but looks promising.</p>
<p>On a future post, I&#8217;ll look more into those exceptions I was talking about: the real AJAX file uploads :)</p>
<br />Filed under: <a href='http://soultrav.wordpress.com/category/it/'>IT</a> Tagged: <a href='http://soultrav.wordpress.com/tag/ajax/'>ajax</a>, <a href='http://soultrav.wordpress.com/tag/file/'>file</a>, <a href='http://soultrav.wordpress.com/tag/iframes/'>iframes</a>, <a href='http://soultrav.wordpress.com/tag/swfupload/'>swfupload</a>, <a href='http://soultrav.wordpress.com/tag/upload/'>upload</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/soultrav.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/soultrav.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/soultrav.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/soultrav.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/soultrav.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/soultrav.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/soultrav.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/soultrav.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/soultrav.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/soultrav.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/soultrav.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/soultrav.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/soultrav.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/soultrav.wordpress.com/260/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=soultrav.wordpress.com&amp;blog=3794532&amp;post=260&amp;subd=soultrav&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://soultrav.wordpress.com/2010/09/02/file-uploads-with-ajax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/044a270a95836821f6bfd2b5c0561f96?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">Soultrav</media:title>
		</media:content>
	</item>
	</channel>
</rss>
