<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-17318314</id><updated>2011-10-19T21:10:55.729-07:00</updated><category term='linux'/><category term='parser'/><category term='javascript'/><category term='latex'/><category term='exceptions php output buffer unwinding'/><title type='text'>HERHANGİ BİRİ</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://herhangibiri.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://herhangibiri.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>herhangibiri</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>17</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-17318314.post-1067530527249515059</id><published>2008-05-04T08:05:00.000-07:00</published><updated>2008-05-04T08:40:50.989-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='parser'/><title type='text'>Javascript recursive descent parser generator</title><content type='html'>&lt;p&gt;&lt;a href="http://users.fulladsl.be/spb1622/js_parser_generator/"&gt;Here&lt;/a&gt; is a recursive descent parser generator for javascript. As always, I'm too lazy to document how it works. I did not test it much. Just play with it if you like.

&lt;p&gt;In the first section, you define the tokens. There is a special token called SKIP, which is ignored.

&lt;p&gt;In the second section, you define the grammar of your language. Some examples:

&lt;pre&gt;
C = { 
  A A;
  B;
};
&lt;/pre&gt;
means C is A followed by A, or C is B.

&lt;p&gt;You can add types to your productions:
&lt;pre&gt;
C = { 
  [A_PAIR] A A;
  [JUST_B] B;
};
&lt;/pre&gt;

&lt;p&gt;You can name the symbols in the productions:
&lt;pre&gt;
C = { 
  [A_PAIR] first:A second:A;
  [JUST_B] value:B;
};
&lt;/pre&gt;
Say that A denotes the token /[a-z]/, than the parse result of "x y" is an object like this:&lt;br&gt;

{ Type: "A_PAIR", first:"x", second:"y" }

&lt;p&gt;You can omit braces if there is only one production for a rule:
&lt;pre&gt;
C = A A;
&lt;/pre&gt;

&lt;p&gt;You can also inherit the parse result of a sub-rule. So instead of:
&lt;pre&gt;
C = A A;
X = lbrace value:C rbrace;
&lt;/pre&gt;
then using x.value.first, you can do:
&lt;pre&gt;
C = A A;
X = lbrace #C rbrace;
&lt;/pre&gt;
then use x.first.

&lt;p&gt;You can also use wildcards in restricted cases:
&lt;pre&gt;
Alist = A+;
Blist = B*;
&lt;/pre&gt;
in which case the result object will be an array.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17318314-1067530527249515059?l=herhangibiri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://herhangibiri.blogspot.com/feeds/1067530527249515059/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17318314&amp;postID=1067530527249515059' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/1067530527249515059'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/1067530527249515059'/><link rel='alternate' type='text/html' href='http://herhangibiri.blogspot.com/2008/05/javascript-recursive-descent-parser.html' title='Javascript recursive descent parser generator'/><author><name>herhangibiri</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17318314.post-1812521648816153379</id><published>2007-12-22T18:55:00.000-08:00</published><updated>2011-01-17T12:40:26.372-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><title type='text'>Serializing JavaScript objects</title><content type='html'>&lt;p&gt;I once have &lt;a href="http://users.fulladsl.be/spb1622/dump.html"&gt;written&lt;/a&gt; a JavaScript function that dumps a JavaScript object in a human readable format. It was something like JSON, but it also handled objects containing &lt;del&gt;circular references&lt;/del&gt; &lt;ins&gt;shared object references&lt;/ins&gt;. I must admit that it was written badly.&lt;/p&gt;&lt;p&gt;After reading &lt;a href="http://blog.notdot.net/archives/29-Serializing-JavaScript-objects-with-circular-references.html"&gt;this&lt;/a&gt;, I thought that maybe it's a good idea to change the previous code for serializing JavaScript objects. I also refactored the code. You can find it below. I didn't test it thoroughly, so be careful.&lt;/p&gt;An example of what it can do:
&lt;pre&gt;
var x = {};

x.foo  = new Object();
x.self = x;
x.arr  = [x.self];
x.bar  = x.foo;

var s = serialize(x);
var y = deserialize(s);
alert(y == y.self);    // true
alert(y == y.arr[0]);  // true
alert(y.foo == y.bar); // true

alert(s);
// {
//     'foo': {},
//     'self': { _root_: [  ] },
//     'arr': [
//         { _root_: [  ] }
//     ],
//     'bar': { _root_: [ "foo" ] }
// }
&lt;/pre&gt;

&lt;i&gt;&lt;b&gt;Addition:&lt;/b&gt; I think that I have to express that better:
don't expect it to serialize functions, regular expressions, images (or any other browser object), etc. It's just something like JSON, but it also handles shared object references.&lt;/i&gt;

Code: &lt;code&gt;&lt;pre&gt;
//============================================================================//
//  JavaScript object de/serialization with circular references.              //
//                                                                            //
//  author: Mehmet Yavuz Selim Soyturk                                        //
//  e-mail: Mehmet dot Yavuz dot Selim at gmail dot com                       //
//============================================================================//

Array.prototype.findIf = function(predicate) {
    for(var i in this) {
        if (predicate(this[i]))
            return i;
    }
    return -1;
};
Array.prototype.map = function(func) {
    var len = this.length;
    var result = [];
    for (var i=0; i&amp;lt;len; i++) {
        result[i] = func(this[i]);
    }
    return result;
};
Array.prototype.appended = function(value) {
    var copy = this.slice(0);
    copy[copy.length] = value;
    return copy;
};

//============================================================================//
//  SERIALIZATION                                                             //
//============================================================================//

function indented(n) {
    var s = '';
    for(var i=0; i&amp;lt;n; i++) s += '    ';
    return s;
}

function serializePrimitive(value) {
    if (typeof value == 'string')
        return '&amp;quot;' + value + '&amp;quot;';
    else
        return '' + value;
}

function serializePrimitiveArray(arr) {
    var s = &amp;quot;[ &amp;quot;;
    s += arr.map(serializePrimitive).join(', ');
    s += &amp;quot; ]&amp;quot;;
    return s;
}

function serializeArray(arr, seen, indices, depth) {
    if (arr.length == 0)
        return '[]';

    seen[seen.length] = {obj: arr, indices: indices};
    
    var result = '[\n';
    for (var i=0; i&amp;lt;arr.length; i++) {
        result += indented(depth + 1);
        result += serializeAny(arr[i], seen, indices.appended(i), depth + 1);
        result += (i == arr.length - 1) ? '' : ', ';
        result += '\n';
    }
    result += indented(depth) + ']';

    return result;
}

function serializeObject(obj, seen, indices, depth) {
    seen[seen.length] = {obj: obj, indices: indices};
    
    var result = '{\n';
    var count = 0;
    for (var i in obj) {
        if (typeof obj[i] != 'function') {
            count++;
            result += indented(depth+1);
            result += &amp;quot;'&amp;quot; + i + &amp;quot;': &amp;quot;;
            result += serializeAny(obj[i], seen, indices.appended(i), depth + 1);
            result += &amp;quot;, \n&amp;quot;; // bad hack, see next
        }
    }
    if (count &amp;gt; 0) {
        result = result.substring(0, result.length-3) + '\n'; // bad hack
        return result + indented(depth) + '}';
    }
    else {
        return '{}';
    }
}


function serializeAny(value, seen, indices, depth) {
    var t = typeof(value);
    var prevIndex;
    
    if (t == 'function') {
        throw new Error(&amp;quot;Cannot serialize function. Keys from root: &amp;quot; + 
            serializePrimitiveArray(indices));
    }
    else if (t != 'object') {
        return serializePrimitive(value);
    }
    else if ( (prevIndex = seen.findIf
                    ( function(obj) { return obj.obj == value } )
              ) &amp;gt;= 0) {
        return '{ _root_: ' + serializePrimitiveArray(seen[prevIndex].indices) + ' }';
    }
    else if (value.constructor == Array) {
        return serializeArray(value, seen, indices, depth);
    }
    else {
        return serializeObject(value, seen, indices, depth);
    }
};

function serialize(obj) {
   return serializeAny(obj, [], [], 0);
}


//============================================================================//
//  DESERIALIZATION                                                           //
//============================================================================//

function followIndices(obj, indices) {
    for (var i=0; i&amp;lt;indices.length; i++)
        obj = obj[indices[i]];
        
    return obj;
}

function replaceRootRefs(obj, root) {
    if (typeof obj != 'object' || obj == null)
        return;
    
    for (var i in obj) {
        var prop = obj[i];
        if (typeof prop == 'object' &amp;&amp; prop != null) {
            if ('_root_' in prop)
                obj[i] = followIndices(root, prop._root_);
            replaceRootRefs(prop, root);
        }
    }
}

function deserialize(str) {
    var obj = eval( '(' + str + ')' );
    if (str.indexOf('_root_') &amp;lt; 0)
        return obj;
    
    replaceRootRefs(obj, obj);
    return obj;
}&lt;/pre&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17318314-1812521648816153379?l=herhangibiri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://herhangibiri.blogspot.com/feeds/1812521648816153379/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17318314&amp;postID=1812521648816153379' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/1812521648816153379'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/1812521648816153379'/><link rel='alternate' type='text/html' href='http://herhangibiri.blogspot.com/2007/12/serializing-javascript-objects.html' title='Serializing JavaScript objects'/><author><name>herhangibiri</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17318314.post-291658613392226778</id><published>2007-12-15T14:52:00.000-08:00</published><updated>2007-12-15T16:08:11.780-08:00</updated><title type='text'>Kablosuz aglari dinlemek icin</title><content type='html'>Interface'i monitor moda getir:
&lt;pre&gt;$ sudo iwconfig eth1 mode monitor&lt;/pre&gt;
Wireshark'i calistir:
&lt;pre&gt;$ sudo wireshark&lt;/pre&gt;
Dinle ve interface'i eski haline getir:
&lt;pre&gt;$ sudo iwconfig eth1 mode managed&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17318314-291658613392226778?l=herhangibiri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://herhangibiri.blogspot.com/feeds/291658613392226778/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17318314&amp;postID=291658613392226778' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/291658613392226778'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/291658613392226778'/><link rel='alternate' type='text/html' href='http://herhangibiri.blogspot.com/2007/12/wireless-aglari-sniff-etmek-icin.html' title='Kablosuz aglari dinlemek icin'/><author><name>herhangibiri</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17318314.post-6207152553890566718</id><published>2007-12-13T04:11:00.000-08:00</published><updated>2007-12-13T04:18:10.371-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><title type='text'>latex, html, plain text</title><content type='html'>Converting latex to html, if the tex file has utf8 encoding:

&lt;pre&gt;latex2html -html_version 4,unicode document.tex&lt;/pre&gt;

If you want only one page:

&lt;pre&gt;latex2html -split 0 -html_version 4,unicode document.tex&lt;/pre&gt;

Converting html to plain tex:

&lt;pre&gt;elinks -dump document.html&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17318314-6207152553890566718?l=herhangibiri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://herhangibiri.blogspot.com/feeds/6207152553890566718/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17318314&amp;postID=6207152553890566718' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/6207152553890566718'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/6207152553890566718'/><link rel='alternate' type='text/html' href='http://herhangibiri.blogspot.com/2007/12/latex-html-plain-text.html' title='latex, html, plain text'/><author><name>herhangibiri</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17318314.post-7659660766196780475</id><published>2007-11-16T12:51:00.000-08:00</published><updated>2007-11-16T13:18:38.670-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='exceptions php output buffer unwinding'/><title type='text'>Output buffer unwinding for PHP?</title><content type='html'>PHP 5 supports exception handling. When an exception occurs, PHP does stack unwinding so that it restores the state of the script... does it? No. An important state of the script does not get restored: the output. Would it not be a good idea if PHP also did some sort of output buffer unwinding?

That is the idea:
&lt;pre&gt;&amp;lt;?php

exceptional_ob_start();

echo "Begin\n";
try {
    echo "Exception\n";
    throw new Exception();
} catch (Exception $e) {}
echo "End\n";

exceptional_ob_end_flush();
    
?&amp;gt;&lt;/pre&gt;

And that is the only output:
&lt;pre&gt;Begin
End&lt;/pre&gt;

I am not a PHP (nor webscripting) guy so I may be wrong, but I think that something like that would be very useful. It is maybe even needed for making PHP exceptions useful.&lt;br&gt;&amp;nbsp;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17318314-7659660766196780475?l=herhangibiri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://herhangibiri.blogspot.com/feeds/7659660766196780475/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17318314&amp;postID=7659660766196780475' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/7659660766196780475'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/7659660766196780475'/><link rel='alternate' type='text/html' href='http://herhangibiri.blogspot.com/2007/11/output-buffer-unwinding-for-php.html' title='Output buffer unwinding for PHP?'/><author><name>herhangibiri</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17318314.post-7237657699235319204</id><published>2007-08-18T10:24:00.000-07:00</published><updated>2007-12-15T16:15:54.366-08:00</updated><title type='text'>Currying in JavaScript</title><content type='html'>We can make our functions curried in JavaScript:

&lt;pre&gt;
function curry(f, needed_len) {
    if (needed_len == undefined)
        needed_len = f.length;
        
    var curried = function() {
        var curried_args = arguments;
        if (curried_args.length &amp;gt;= needed_len) {
            return f.apply(this, arguments);
        }
        else {
            var curry_result_function = function() {
                var args = [];
                for(var i=0; i&amp;lt;curried_args.length; i++)
                    args[args.length] = curried_args[i];
                
                for(var i=0; i&amp;lt;arguments.length; i++)
                    args[args.length] = arguments[i];

                return f.apply(this, args);
            };
            return curry(curry_result_function, needed_len-curried_args.length);
        }
    };
    return curried;
}
&lt;/pre&gt;

And usage:
&lt;pre&gt;var curried_add = curry(function (a, b, c) {
    return a + b + c;
});

print(curried_add(1)(2)(3));
print(curried_add(1)()(2)()(3));
print(curried_add(1,2,3));
print(curried_add(1)(2,3));
print(curried_add(1,2)(3));
&lt;/pre&gt;

See also next pages for other implementations:
&lt;a href="http://www.dustindiaz.com/javascript-curry"&gt;http://www.dustindiaz.com/javascript-curry&lt;/a&gt;
&lt;a href="http://www.svendtofte.com/code/curried_javascript/"&gt;http://www.svendtofte.com/code/curried_javascript/&lt;/a&gt;
&lt;br&gt;&amp;nbsp;&lt;br&gt;
&lt;span style="font-style:italic;"&gt;Note: after some more googling about currying in JavaScript, it's very interesting to see that &lt;a href="http://www.coryhudson.com/blog/2007/03/10/javascript-currying-redux/"&gt;http://www.coryhudson.com/blog/2007/03/10/javascript-currying-redux/&lt;/a&gt; contains an almost identical implementation.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17318314-7237657699235319204?l=herhangibiri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://herhangibiri.blogspot.com/feeds/7237657699235319204/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17318314&amp;postID=7237657699235319204' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/7237657699235319204'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/7237657699235319204'/><link rel='alternate' type='text/html' href='http://herhangibiri.blogspot.com/2007/08/currying-in-javascript.html' title='Currying in JavaScript'/><author><name>herhangibiri</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17318314.post-6767926277294326249</id><published>2007-07-30T17:46:00.000-07:00</published><updated>2007-07-30T18:24:48.283-07:00</updated><title type='text'>JavaScript'de eval ve closure'un gucu</title><content type='html'>Kendi halinde basit bir fonksiyonumuz olsun:
&lt;pre&gt;
function myEval(code) {
    return eval(code);
}
&lt;/pre&gt;

Simdi kendimize bir sayac yapalim:
&lt;pre&gt;
var inject = 'var n=0; var f=function(){return n++}; f';
var sayac = myEval(inject);

alert(sayac()); // 0
alert(sayac()); // 1
alert(sayac()); // 2
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17318314-6767926277294326249?l=herhangibiri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://herhangibiri.blogspot.com/feeds/6767926277294326249/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17318314&amp;postID=6767926277294326249' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/6767926277294326249'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/6767926277294326249'/><link rel='alternate' type='text/html' href='http://herhangibiri.blogspot.com/2007/07/javascriptde-eval-ve-closureun-gucu.html' title='JavaScript&apos;de eval ve closure&apos;un gucu'/><author><name>herhangibiri</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17318314.post-521700873120956234</id><published>2007-06-05T06:02:00.000-07:00</published><updated>2007-06-05T08:57:02.367-07:00</updated><title type='text'>vim ile dosya calistirmaca</title><content type='html'>bakiniz:
&lt;a href="http://blog.arsln.org/vim-icinden-python-kodu-calistirmak/"&gt;http://blog.arsln.org/vim-icinden-python-kodu-calistirmak/&lt;/a&gt;

Simdi bunu F8'e basildiginda her dosyayi calistirir hale getirmek gerek. Bunu daha once emacs icin yapmistim, ancak isin mantigini da elisp ile yaptirmaya ugrastigim icin karman corman birsey olmustu ne yazik ki. Simdi aklim basima geldi, bu isi bir shell script'e yaptirmak gerek.

Bu ~/bin/calistir dosyasinin icerigi:
&lt;pre&gt;#!/bin/bash

dosya=$1

case $dosya in

"")
   echo "Kullanim: $0 &amp;lt;dosya_ismi&amp;gt;"
   ;;
*.js)
   js $dosya
   ;;
*.py)
   python $dosya
   ;;
*.sh)
   /bin/bash $dosya
   ;;
*.rb)
   ruby $dosya
   ;;
*.c)
   gcc $dosya
   ./a.out
   ;;
*.cpp)
   g++ $dosya
   ./a.out
   ;;
/*)
   $dosya
   ;;
*)
   ./$dosya
   ;;

esac&lt;/pre&gt;

Ve ~/.vimrc dosyasina su satiri ekliyoruz:
&lt;pre&gt;map &amp;lt;F8&amp;gt; :!/home/kullanici/bin/calistir % &amp;lt;ENTER&amp;gt;&lt;/pre&gt;

Bu da ~/.emacs dosyasina:
&lt;pre&gt;(defun exec-file () 
  "Execute a file, if possible."
  (interactive)
  (let ((curr-buf (buffer-name))
        (exec-buffer "execute-buffer"))
    (if (get-buffer exec-buffer) 
    
      ;; su anda bir calistirma buffer'i acik, kapat
      (kill-buffer exec-buffer)
      
      ;; calistir
      (progn
        (call-process "/home/kullanici/bin/calistir" nil exec-buffer t curr-buf)
        (switch-to-buffer-other-window exec-buffer)
        (switch-to-buffer-other-window curr-buf)))))

(global-set-key [f12] 'exec-file)&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17318314-521700873120956234?l=herhangibiri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://herhangibiri.blogspot.com/feeds/521700873120956234/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17318314&amp;postID=521700873120956234' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/521700873120956234'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/521700873120956234'/><link rel='alternate' type='text/html' href='http://herhangibiri.blogspot.com/2007/06/vim-ile-dosya-calistirmaca.html' title='vim ile dosya calistirmaca'/><author><name>herhangibiri</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17318314.post-3679667688271119144</id><published>2007-05-22T07:03:00.000-07:00</published><updated>2007-05-22T08:17:25.024-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><title type='text'>En cok kullandigim linux komutlari</title><content type='html'>&lt;a href="http://blog.arsln.org/en-cok-kullandiginiz-ilk-10-bash-komutlari-hangileridir/"&gt;Burada&lt;/a&gt; en cok kullandiginiz linux komutlarini ogrenmek icin bir yontem gosterilmis. Ben de hemen denedim, sonuc soyle:
&lt;pre&gt;$ history|awk '{print $2}'|awk 'BEGIN {FS="|"} {print $1}'|sort|uniq -c|sort -rn|head -10
  77 ls
  76 make
  50 cd
  34 pjs
  31 nano
  20 parrot
  19 rm
  18 js
  17 new
  16 svn&lt;/pre&gt;
ls'in en cok kullandigim komut olmasina sasirmamak gerek. Terminalde yaptigim her hareketten once cagiririm onu. parrot, pjs, js, make ve svn komutlari da yapmakta oldugum proje nedeniyle bolca kullandigim komutlar.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17318314-3679667688271119144?l=herhangibiri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://herhangibiri.blogspot.com/feeds/3679667688271119144/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17318314&amp;postID=3679667688271119144' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/3679667688271119144'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/3679667688271119144'/><link rel='alternate' type='text/html' href='http://herhangibiri.blogspot.com/2007/05/en-cok-kullandigim-linux-komutlari.html' title='En cok kullandigim linux komutlari'/><author><name>herhangibiri</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17318314.post-5343949245887983028</id><published>2007-04-25T07:38:00.000-07:00</published><updated>2007-04-25T07:43:09.405-07:00</updated><title type='text'>Nurikabe</title><content type='html'>Vakit oldurmek icin birebir. Sudoku bana pek eglenceli gelmemisti, ama nurikabe bayagi zevkli geldi. Biraz &lt;a href="http://en.wikipedia.org/wiki/Nurikabe"&gt;bilgi&lt;/a&gt; edindikten sonra oynamaya &lt;a href="http://www.logicgamesonline.com/nurikabe/"&gt;buradan&lt;/a&gt; baslayabilirsiniz.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17318314-5343949245887983028?l=herhangibiri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://herhangibiri.blogspot.com/feeds/5343949245887983028/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17318314&amp;postID=5343949245887983028' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/5343949245887983028'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/5343949245887983028'/><link rel='alternate' type='text/html' href='http://herhangibiri.blogspot.com/2007/04/nurikabe.html' title='Nurikabe'/><author><name>herhangibiri</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17318314.post-115158624638105092</id><published>2006-06-29T05:29:00.000-07:00</published><updated>2007-05-27T08:46:38.207-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><title type='text'>Elisp ile dosya calistirma</title><content type='html'>Emacs'da bir dosyayi calistirip, ciktisini yeni bir buffer'da gormek icin yazdigim bir script. &lt;a href="http://ileriseviye.org/blog/?p=469"&gt;Buradan&lt;/a&gt; da kopya cektim biraz. Eminim ki tekeri bastan icad ediyorum, hem de kagni tekeri (aklima &lt;a href="http://en.wikipedia.org/wiki/Greenspun's_Tenth_Rule"&gt;bunu&lt;/a&gt; getirdi). Ama kucuk olsun benim olsun :) Bir de hala su degiskenlere dogru duzgun isim vermeyi ogrenemedim. Zamanimin yarisi bunu ne diye adlandirayim diye geciyor.

&lt;p&gt;Not: daha duzgun degisken isimleri vermeye calistim.&lt;/p&gt;

&lt;pre&gt;
; a list of triples that contain:
;  - the regex for the file name
;  - the name of the buffer that will be created
;  - a list containing the command to execute the file
(defvar exec-list nil)

(defun add-exec (regex buffer-name command-list)
  (let ((entry (list regex buffer-name command-list)))
    (setf exec-list (cons entry exec-list))))

(defun get-exec-help (filename execs)
  (unless (null execs)
    (let* ((entry (car execs))
       (regex (car entry)))
      (if (string-match regex filename)
      (cdr entry)
    (get-exec-help filename (cdr execs))))))

(defun get-exec (filename)
  (get-exec-help filename exec-list))


(defun exec-file () 
  "Execute a file, if possible."
  (interactive)
  (let* ((curr-buf (buffer-name))
     (exec-params (get-exec curr-buf)))
    (if exec-params
    (let ((exec-buffer (car exec-params))
          (exec-command-list (cadr exec-params)))
      (if (get-buffer exec-buffer) 
          (kill-buffer exec-buffer)
        (progn
          (eval (append
             (list 'start-process 
               exec-buffer
               exec-buffer)
             exec-command-list
             (list curr-buf)))
          (switch-to-buffer-other-window exec-buffer)
          (switch-to-buffer-other-window curr-buf)))))))

(add-exec "\\.js$" 
      "javascript" 
      (list "/usr/bin/rhino" "-f"))

(add-exec "\\.\\(pir\\|pasm\\)$" 
      "parrot" 
      (list "/home/yavuz/parrot_svn/parrot/parrot"))

(add-exec "\\.html$" 
      "html" 
      (list "/usr/bin/firefox"))

(global-set-key [f12] 'exec-file)
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17318314-115158624638105092?l=herhangibiri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://herhangibiri.blogspot.com/feeds/115158624638105092/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17318314&amp;postID=115158624638105092' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/115158624638105092'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/115158624638105092'/><link rel='alternate' type='text/html' href='http://herhangibiri.blogspot.com/2006/06/elisp-ile-dosya-calistirma.html' title='Elisp ile dosya calistirma'/><author><name>herhangibiri</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17318314.post-114912006948700280</id><published>2006-05-31T16:34:00.000-07:00</published><updated>2006-06-02T16:15:36.220-07:00</updated><title type='text'>Iyi huylu böcek</title><content type='html'>&lt;p&gt;Ruby ile yazdigim basit bir programda kullanicinin attigi her adim @lines adinda bir listede tutuluyor. Kullanici istedigi zaman bu adimlari gorebiliyor, ve "undo &amp;lt;n&amp;gt;" diyerek &amp;lt;n&amp;gt;'inci siradaki adimi iptal edebiliyor. Kullanicinin kafasini karistirmamak icin &amp;lt;n&amp;gt; 1'den basliyor (her ne kadar bu programi benden baska hickimse kullanmayacak olsa da :-) ). Iptal edici fonksiyon soyle birsey:
&lt;pre&gt;
def undo(line)
    n = line.gsub(/undo\W+([^\W]*)/, '\1').to_i
    @lines.delete_at(n-1)
    rescue print("You did not give a valid line number!\n")
end
&lt;/pre&gt;
&lt;p&gt;Daha sonra kullanici sadece "undo" yazdigi takdirde en son yaptigi islemin iptal edilmesinin faydali olacagini dusundum. Bunu programlamadan once su anda bu durumda ne oluyor bir bakayim dedim. Cok garip: tam da istedigim sey oluyordu.
&lt;p&gt;Ben bir sayi ifade etmeyen bir string'e to_i metodu uygulandiginda hata firlatacagini dusunuyordum, fakat 0 donduruyormus. Yani kullanici "undo" komutunu verdiginde gsub'un sonucu regex uymadigi icin yine "undo" oluyor, onun da to_i metodu 0 donduruyor. Bir sonraki satirda @lines.delete(-1) ifadesi calisiyor, yani @lines'in son elemani siliniyor :)
&lt;p&gt;Keske butun bocekler de bunun gibi olsa... demiyorum, bocegin gizlenmeyeni makbuldur.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17318314-114912006948700280?l=herhangibiri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://herhangibiri.blogspot.com/feeds/114912006948700280/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17318314&amp;postID=114912006948700280' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/114912006948700280'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/114912006948700280'/><link rel='alternate' type='text/html' href='http://herhangibiri.blogspot.com/2006/05/iyi-huylu-bcek.html' title='Iyi huylu böcek'/><author><name>herhangibiri</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17318314.post-114631176713749283</id><published>2006-04-29T04:49:00.000-07:00</published><updated>2007-05-27T08:46:38.208-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><title type='text'>Emacs notlari</title><content type='html'>&lt;p&gt;Bir ogrendigimi fazla kullanmayinca kisa sure icerisinde unutuyorum. Bu da bilgi bir daha gerektiginde zaman kaybina neden oluyor. Not tutmaya karar verdim.
&lt;br&gt;Buraya emacs notlarimi yazayim:&lt;/p&gt;

&lt;p&gt;


&lt;ul&gt;
&lt;li&gt;C-h k : tus kombinasyonunun hangi komutu calistirdigini ogrenmek&lt;/li&gt;
&lt;li&gt;C-x ({ | }) : (enlarge | shrink)-window-horizontally&lt;/li&gt;
&lt;li&gt;C-x ^ : enlarge window&lt;/li&gt;
&lt;li&gt;C-x C-e : evaluate lisp expression&lt;/li&gt;
&lt;/ul&gt;

&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;not: Rickdangerous'un tavsiyesi uzerine &lt;a href="http://lug.fivecolleges.net/emacs20refcard.pdf"&gt;kopya cekmeye&lt;/a&gt; karar verdim. Isime de geldi. Ne de olsa ben tembel bir adamim.&lt;/i&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17318314-114631176713749283?l=herhangibiri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://herhangibiri.blogspot.com/feeds/114631176713749283/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17318314&amp;postID=114631176713749283' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/114631176713749283'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/114631176713749283'/><link rel='alternate' type='text/html' href='http://herhangibiri.blogspot.com/2006/04/emacs-notlari.html' title='Emacs notlari'/><author><name>herhangibiri</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17318314.post-114602418541937998</id><published>2006-04-25T20:49:00.000-07:00</published><updated>2007-05-27T08:46:38.209-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><title type='text'>xmms-ruby</title><content type='html'>&lt;a href="http://www.fazlamesai.net"&gt;fazlamesai.net&lt;/a&gt;'ten FZ ruby ile emacs icinden xmms'e parca sectiren bir &lt;a href="http://ileriseviye.org/blog/?p=425"&gt;program&lt;/a&gt; yazmis. Hazir ruby tutorial'ini biraz karistirmisken ruby ile birseyler yapayim dedim. Programi biraz daha gelistirdim.&lt;br&gt;
Ekledigim seyler: 
&lt;ul&gt;
&lt;li&gt;Birden fazla kelime aranabiliyor, hepsinin parca ismine/dosya ismine uymasi lazim&lt;/li&gt;
&lt;li&gt;Sadece sayi girilirse xmms o siradaki parcaya atliyor&lt;/li&gt;
&lt;li&gt;Girdi ':' ile baslarsa xmms'e direkt ruby kodu ile hukmedebiliyoruz (:stop, :play :next gibi). &lt;i&gt;eval&lt;/i&gt; fonksiyonu sagolsun.&lt;/li&gt;
&lt;li&gt;Eger ilk arguman --dialog ise girdi bir dialog yardimiyla aliniyor. &lt;/li&gt;
&lt;/ul&gt;
Ben gconf-editor yardimiyla C-M-j tus kombinasyonunu --dialog opsiyonuna atadim. Biraz yavas da olsa idare ediyor. Aslina bakarsaniz bunu zaten birinin yapmis olabilecegini dusunup kisa bir aramadan sonra &lt;a href="http://xmmsfind.sourceforge.net/"&gt;xmmsfind&lt;/a&gt;'i buldum, fakat ne yazik ki cani istemedigi zaman acilmama gibi bir sorunu var.&lt;br&gt;

&lt;pre&gt;
&lt;font color="#444444"&gt;#!/usr/bin/env ruby

&lt;/font&gt;&lt;font color="a52a2a"&gt;&lt;strong&gt;require&lt;/strong&gt;&lt;/font&gt; &lt;font color="#008000"&gt;'xmms'&lt;/font&gt;

&lt;strong&gt;def&lt;font color="ff0000"&gt; nextSong&lt;/font&gt;&lt;font color="2040a0"&gt;&lt;font color="4444FF"&gt;(&lt;/font&gt;args, xr&lt;font color="4444FF"&gt;)&lt;/font&gt;&lt;/font&gt;&lt;/strong&gt; 
  matching &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;[&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;]&lt;/strong&gt;&lt;/font&gt;
  i &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#FF0000"&gt;0&lt;/font&gt;
  xr.playlist.each &lt;strong&gt;do&lt;/strong&gt; |entry|
    &lt;strong&gt;if&lt;/strong&gt; match&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;entry&lt;font color="4444FF"&gt;,&lt;/font&gt; args&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; 
      matching &lt;font color="4444FF"&gt;&amp;lt;&amp;lt;&lt;/font&gt; i
      &lt;font color="#2040a0"&gt;&lt;strong&gt;$stderr&lt;/strong&gt;&lt;/font&gt;.&lt;font color="a52a2a"&gt;&lt;strong&gt;puts&lt;/strong&gt;&lt;/font&gt; &lt;font color="#008000"&gt;'Matched: '&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; entry&lt;font color="4444FF"&gt;&lt;strong&gt;[&lt;/strong&gt;&lt;/font&gt;&lt;font color="#FF0000"&gt;0&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;]&lt;/strong&gt;&lt;/font&gt;
    &lt;strong&gt;end&lt;/strong&gt;
    i &lt;font color="4444FF"&gt;+=&lt;/font&gt; &lt;font color="#FF0000"&gt;1&lt;/font&gt;
  &lt;strong&gt;end&lt;/strong&gt;
  &lt;strong&gt;if&lt;/strong&gt; matching.length &lt;font color="4444FF"&gt;==&lt;/font&gt; &lt;font color="#FF0000"&gt;0&lt;/font&gt;
    &lt;strong&gt;return&lt;/strong&gt; &lt;strong&gt;false&lt;/strong&gt;
  &lt;strong&gt;else&lt;/strong&gt;
    xr.position &lt;font color="4444FF"&gt;=&lt;/font&gt; matching&lt;font color="4444FF"&gt;&lt;strong&gt;[&lt;/strong&gt;&lt;/font&gt;&lt;font color="a52a2a"&gt;&lt;strong&gt;rand&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;matching.length&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;]&lt;/strong&gt;&lt;/font&gt;
    &lt;strong&gt;return&lt;/strong&gt; &lt;strong&gt;true&lt;/strong&gt;
  &lt;strong&gt;end&lt;/strong&gt;
&lt;strong&gt;end&lt;/strong&gt;

&lt;strong&gt;def&lt;font color="ff0000"&gt; match&lt;/font&gt;&lt;font color="2040a0"&gt;&lt;font color="4444FF"&gt;(&lt;/font&gt;entry, args&lt;font color="4444FF"&gt;)&lt;/font&gt;&lt;/font&gt;&lt;/strong&gt; 
  title&lt;font color="4444FF"&gt;,&lt;/font&gt; file&lt;font color="4444FF"&gt;,&lt;/font&gt; time &lt;font color="4444FF"&gt;=&lt;/font&gt; entry
  args.each &lt;strong&gt;do&lt;/strong&gt; |arg|
    regex &lt;font color="4444FF"&gt;=&lt;/font&gt;&lt;font color="b000d0"&gt; /&lt;font color="#2040a0"&gt;#{arg}&lt;/font&gt;/i&lt;/font&gt;
    &lt;strong&gt;return&lt;/strong&gt; &lt;strong&gt;false&lt;/strong&gt; &lt;strong&gt;unless&lt;/strong&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;title &lt;font color="4444FF"&gt;=&lt;/font&gt;~ regex &lt;strong&gt;or&lt;/strong&gt; file &lt;font color="4444FF"&gt;=&lt;/font&gt;~ regex&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;
  &lt;strong&gt;end&lt;/strong&gt;
  &lt;strong&gt;return&lt;/strong&gt; &lt;strong&gt;true&lt;/strong&gt;
&lt;strong&gt;end&lt;/strong&gt;

&lt;strong&gt;def&lt;font color="ff0000"&gt; is_int&lt;/font&gt;&lt;font color="2040a0"&gt;&lt;font color="4444FF"&gt;(&lt;/font&gt;str&lt;font color="4444FF"&gt;)&lt;/font&gt;&lt;/font&gt;&lt;/strong&gt;
  &lt;strong&gt;return&lt;/strong&gt; str &lt;font color="4444FF"&gt;=&lt;/font&gt;~&lt;font color="b000d0"&gt; /^[0-9]+$/&lt;/font&gt;
&lt;strong&gt;end&lt;/strong&gt;


&lt;font color="#2040a0"&gt;&lt;strong&gt;$stderr&lt;/strong&gt;&lt;/font&gt;.&lt;font color="a52a2a"&gt;&lt;strong&gt;puts&lt;/strong&gt;&lt;/font&gt; &lt;font color="#008000"&gt;'Xmms-Ruby version '&lt;/font&gt; &lt;font color="4444FF"&gt;&amp;lt;&amp;lt;&lt;/font&gt; Xmms&lt;font color="4444FF"&gt;::&lt;/font&gt;Remote&lt;font color="4444FF"&gt;::&lt;/font&gt;VERSION

&lt;font color="#444444"&gt;# allocate a new Xmms::Remote object
&lt;/font&gt;xr &lt;font color="4444FF"&gt;=&lt;/font&gt; Xmms&lt;font color="4444FF"&gt;::&lt;/font&gt;Remote&lt;font color="4444FF"&gt;::&lt;/font&gt;new

&lt;strong&gt;if&lt;/strong&gt; &lt;font color="#2040a0"&gt;&lt;strong&gt;ARGV&lt;/strong&gt;&lt;/font&gt;.length &lt;font color="4444FF"&gt;==&lt;/font&gt; &lt;font color="#FF0000"&gt;1&lt;/font&gt; &lt;strong&gt;and&lt;/strong&gt; &lt;font color="#2040a0"&gt;&lt;strong&gt;ARGV&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;[&lt;/strong&gt;&lt;/font&gt;&lt;font color="#FF0000"&gt;0&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;]&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;==&lt;/font&gt; &lt;font color="#008000"&gt;'--dialog'&lt;/font&gt;
  cmd &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="a52a2a"&gt;&lt;strong&gt;open&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;'| zenity --entry --text &amp;quot;xmms: give some keywords&amp;quot;'&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;
  argStr &lt;font color="4444FF"&gt;=&lt;/font&gt; cmd.&lt;font color="a52a2a"&gt;&lt;strong&gt;gets&lt;/strong&gt;&lt;/font&gt;.strip
  args &lt;font color="4444FF"&gt;=&lt;/font&gt; argStr.&lt;font color="a52a2a"&gt;&lt;strong&gt;split&lt;/strong&gt;&lt;/font&gt;
  cmd.close
  &lt;font color="a52a2a"&gt;&lt;strong&gt;puts&lt;/strong&gt;&lt;/font&gt; args.to_s
  &lt;font color="a52a2a"&gt;&lt;strong&gt;exit&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;if&lt;/strong&gt; args.length &lt;font color="4444FF"&gt;==&lt;/font&gt; &lt;font color="#FF0000"&gt;0&lt;/font&gt;
&lt;strong&gt;else&lt;/strong&gt;
  argStr &lt;font color="4444FF"&gt;=&lt;/font&gt; &lt;font color="#2040a0"&gt;&lt;strong&gt;ARGV&lt;/strong&gt;&lt;/font&gt;.map&lt;font color="4444FF"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/font&gt;|s| s.strip&lt;font color="4444FF"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/font&gt;.join&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;' '&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;
  args &lt;font color="4444FF"&gt;=&lt;/font&gt; argStr.&lt;font color="a52a2a"&gt;&lt;strong&gt;split&lt;/strong&gt;&lt;/font&gt;
&lt;strong&gt;end&lt;/strong&gt;

&lt;strong&gt;if&lt;/strong&gt; args.length &lt;font color="4444FF"&gt;==&lt;/font&gt; &lt;font color="#FF0000"&gt;0&lt;/font&gt;
  xr.&lt;strong&gt;next&lt;/strong&gt;
  &lt;font color="#2040a0"&gt;&lt;strong&gt;$stderr&lt;/strong&gt;&lt;/font&gt;.&lt;font color="a52a2a"&gt;&lt;strong&gt;puts&lt;/strong&gt;&lt;/font&gt; &lt;font color="#008000"&gt;'next song'&lt;/font&gt;
&lt;strong&gt;elsif&lt;/strong&gt; is_int&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;argStr&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt; &lt;strong&gt;and&lt;/strong&gt; argStr.to_i &lt;font color="4444FF"&gt;&amp;lt;=&lt;/font&gt; xr.playlist.length &lt;strong&gt;and&lt;/strong&gt; argStr.to_i &lt;font color="4444FF"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#FF0000"&gt;0&lt;/font&gt;
  xr.position &lt;font color="4444FF"&gt;=&lt;/font&gt; argStr.to_i - &lt;font color="#FF0000"&gt;1&lt;/font&gt;
  &lt;font color="#2040a0"&gt;&lt;strong&gt;$stderr&lt;/strong&gt;&lt;/font&gt;.&lt;font color="a52a2a"&gt;&lt;strong&gt;puts&lt;/strong&gt;&lt;/font&gt; &lt;font color="#008000"&gt;'jump to position: '&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; argStr
&lt;strong&gt;elsif&lt;/strong&gt; argStr&lt;font color="4444FF"&gt;&lt;strong&gt;[&lt;/strong&gt;&lt;/font&gt;&lt;font color="#FF0000"&gt;0&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;]&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;==&lt;/font&gt; &lt;font color="#008000"&gt;&amp;quot;:&amp;quot;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;[&lt;/strong&gt;&lt;/font&gt;&lt;font color="#FF0000"&gt;0&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;]&lt;/strong&gt;&lt;/font&gt;
  &lt;font color="#2040a0"&gt;&lt;strong&gt;$stderr&lt;/strong&gt;&lt;/font&gt;.&lt;font color="a52a2a"&gt;&lt;strong&gt;puts&lt;/strong&gt;&lt;/font&gt; &lt;font color="#008000"&gt;'Evaluate: '&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; argStr&lt;font color="4444FF"&gt;&lt;strong&gt;[&lt;/strong&gt;&lt;/font&gt;&lt;font color="#FF0000"&gt;1..&lt;/font&gt;-&lt;font color="#FF0000"&gt;1&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;]&lt;/strong&gt;&lt;/font&gt;
  &lt;font color="a52a2a"&gt;&lt;strong&gt;eval&lt;/strong&gt;&lt;/font&gt; &lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;'xr.'&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt; argStr&lt;font color="4444FF"&gt;&lt;strong&gt;[&lt;/strong&gt;&lt;/font&gt;&lt;font color="#FF0000"&gt;1..&lt;/font&gt;-&lt;font color="#FF0000"&gt;1&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;]&lt;/strong&gt;&lt;/font&gt;&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;
&lt;strong&gt;elsif&lt;/strong&gt; &lt;strong&gt;not&lt;/strong&gt; nextSong&lt;font color="4444FF"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/font&gt;args&lt;font color="4444FF"&gt;,&lt;/font&gt; xr&lt;font color="4444FF"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;
  &lt;font color="#2040a0"&gt;&lt;strong&gt;$stderr&lt;/strong&gt;&lt;/font&gt;.&lt;font color="a52a2a"&gt;&lt;strong&gt;puts&lt;/strong&gt;&lt;/font&gt; &lt;font color="#008000"&gt;'No match: '&lt;/font&gt; &lt;font color="4444FF"&gt;+&lt;/font&gt;  argStr
&lt;strong&gt;end&lt;/strong&gt;

&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17318314-114602418541937998?l=herhangibiri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://herhangibiri.blogspot.com/feeds/114602418541937998/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17318314&amp;postID=114602418541937998' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/114602418541937998'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/114602418541937998'/><link rel='alternate' type='text/html' href='http://herhangibiri.blogspot.com/2006/04/xmms-ruby.html' title='xmms-ruby'/><author><name>herhangibiri</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17318314.post-113526594857205138</id><published>2005-12-22T06:41:00.000-08:00</published><updated>2007-05-27T08:46:38.209-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><title type='text'>/dev/dsp ile gurultu alarmi</title><content type='html'>&lt;p&gt;cat /dev/dsp dedigimde ve yeteri kadar ses cikardigimda ekranda {}|~[] gibi karakterler goruyorum. Sessizlikte ise octal olarak 200 ile temsil edilen bir deger uretiliyor (fakat bu ekranda gorunmuyor). Gurultuyu yakalamak icin sunu yapiyorum:&lt;/p&gt;

&lt;pre&gt;cat /dev/dsp | tr '\200' '\n' | egrep '[{}|~]' -m 1&lt;/pre&gt;

&lt;p&gt;-m 1 parametresi grep'in ilk bulunan sonuctan sonra sona ermesini sagliyor.&lt;/p&gt;

&lt;p&gt;Tamam, simdi gurultuyu yakaladik. Peki alarmi nasil verecegiz? Mesela bir ses dosyasi calabiliriz, veya aygitlarla oynamaya devam edebiliriz:&lt;/p&gt;
&lt;pre&gt;cp /dev/urandom /dev/dsp&lt;/pre&gt;

&lt;p&gt;Yani tek komut olarak yazmak istersek:&lt;/p&gt;
&lt;pre&gt;cat /dev/dsp | tr '\200' '\n' | egrep '[{}|~]' -m 1 ; cp /dev/urandom /dev/dsp&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17318314-113526594857205138?l=herhangibiri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://herhangibiri.blogspot.com/feeds/113526594857205138/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17318314&amp;postID=113526594857205138' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/113526594857205138'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/113526594857205138'/><link rel='alternate' type='text/html' href='http://herhangibiri.blogspot.com/2005/12/devdsp-ile-gurultu-alarmi.html' title='/dev/dsp ile gurultu alarmi'/><author><name>herhangibiri</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17318314.post-113525264697709586</id><published>2005-12-22T03:52:00.000-08:00</published><updated>2007-05-27T08:46:38.209-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><title type='text'>/dev</title><content type='html'>Bugun biraz /dev klasorundeki aygitlarin icerigini ekrana yazdirarak eglendim. Ilginc  komutlar:&lt;br&gt;
&lt;ul&gt;
 &lt;li&gt;&lt;ul&gt;Fare veya klavye icin:
  &lt;li&gt;sudo cat /dev/input/herhangibir_dosya&lt;/li&gt;
  &lt;li&gt;sudo cat /dev/psaux&lt;/li&gt;
 &lt;/ul&gt;&lt;/li&gt;
 &lt;li&gt;&lt;ul&gt;Asagidaki komuttan sonra microfona konusun:
  &lt;li&gt;cat /dev/audio&lt;/li&gt;
  &lt;li&gt;cat /dev/dsp&lt;/li&gt;
 &lt;/ul&gt;&lt;/li&gt;
 &lt;li&gt;&lt;ul&gt;Rastgele veri:
  &lt;li&gt;cat /dev/urandom&lt;/li&gt;
  &lt;li&gt;cat /dev/random&lt;/li&gt;
 &lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;/dev/zero 'nun ekrana 0 yazdirmasini bekliyordum, ama hicbirsey olmadi. Daha sonra jeton dustu:&lt;br&gt;
cat /dev/zero | tr '\0' 'x'&lt;/p&gt;
&lt;p&gt;Harddiskinizin icinde neler var?&lt;br&gt;
sudo head /dev/hda (bolumler icin hda1, hda2 ...)&lt;/p&gt;
&lt;p&gt;Asagidaki komutu uygulamadan once acik dokumanlari kaydedin, linux'u gocertmeye hazir olun. Sorumluluk kabul etmiyorum. Ne yaptigi konusunda emin degilim:&lt;br&gt;
sudo cat /dev/console&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17318314-113525264697709586?l=herhangibiri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://herhangibiri.blogspot.com/feeds/113525264697709586/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17318314&amp;postID=113525264697709586' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/113525264697709586'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/113525264697709586'/><link rel='alternate' type='text/html' href='http://herhangibiri.blogspot.com/2005/12/dev.html' title='/dev'/><author><name>herhangibiri</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17318314.post-113266867746941035</id><published>2005-11-22T06:09:00.000-08:00</published><updated>2006-05-17T00:07:28.053-07:00</updated><title type='text'>Hastalik</title><content type='html'>Şu grip yaz gribi, şu grip kuş gribi, ortada Yavuz garibi...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17318314-113266867746941035?l=herhangibiri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://herhangibiri.blogspot.com/feeds/113266867746941035/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17318314&amp;postID=113266867746941035' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/113266867746941035'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17318314/posts/default/113266867746941035'/><link rel='alternate' type='text/html' href='http://herhangibiri.blogspot.com/2005/11/hastalik.html' title='Hastalik'/><author><name>herhangibiri</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
