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

<channel>
	<title>گنجه &#187; دست‌نوشته</title>
	<atom:link href="http://blog.ebrahim.ir/tag/script/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ebrahim.ir</link>
	<description># tail -f /var/log/experience</description>
	<lastBuildDate>Wed, 25 Aug 2010 22:16:39 +0000</lastBuildDate>
	<language>fa</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>میمون چرب؛ دوست روباه آتشین</title>
		<link>http://blog.ebrahim.ir/1387/09/grease-monkey-a-friend-of-fire-fox/</link>
		<comments>http://blog.ebrahim.ir/1387/09/grease-monkey-a-friend-of-fire-fox/#comments</comments>
		<pubDate>Sat, 13 Dec 2008 22:50:36 +0000</pubDate>
		<dc:creator>ابراهیم</dc:creator>
				<category><![CDATA[رایانه]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Greasemonkey]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[ابزار]]></category>
		<category><![CDATA[برنامه‌نویسی]]></category>
		<category><![CDATA[تار]]></category>
		<category><![CDATA[دست‌نوشته]]></category>
		<category><![CDATA[فارسی]]></category>
		<category><![CDATA[مرورگر]]></category>
		<category><![CDATA[نرم‌افزار آزاد]]></category>

		<guid isPermaLink="false">http://blog.ebrahim.ir/?p=123</guid>
		<description><![CDATA[از وقتی با Greasemonkey آشنا شده‌ام توقعم از تار1 خیلی بالا رفته. با این افزونهٔ Firefox می‌شه در طرف مخدوم2، به هر صفحه‌ای کدهای JavaScript دل‌خواه رو اضافه کرد. علاوه بر کلی دست‌نوشتهٔ3 آماده که توی http://userscripts.org براش وجود داره، خودمون هم می‌تونیم به راحتی براش دست‌نوشته بنویسیم. حالا اگر قدرت JavaScript رو بیاری تو [...]]]></description>
			<content:encoded><![CDATA[<p>از وقتی با <a href="https://addons.mozilla.org/firefox/748/">Greasemonkey</a> آشنا شده‌ام توقعم از تار<sup><a href="http://blog.ebrahim.ir/1387/09/grease-monkey-a-friend-of-fire-fox/#footnote_0_123" id="identifier_0_123" class="footnote-link footnote-identifier-link" title="Web">1</a></sup> خیلی بالا رفته.</p>
<p>با این افزونهٔ Firefox می‌شه در طرف مخدوم<sup><a href="http://blog.ebrahim.ir/1387/09/grease-monkey-a-friend-of-fire-fox/#footnote_1_123" id="identifier_1_123" class="footnote-link footnote-identifier-link" title="Client Side">2</a></sup>، به هر صفحه‌ای کدهای JavaScript دل‌خواه رو اضافه کرد. علاوه بر کلی دست‌نوشتهٔ<sup><a href="http://blog.ebrahim.ir/1387/09/grease-monkey-a-friend-of-fire-fox/#footnote_2_123" id="identifier_2_123" class="footnote-link footnote-identifier-link" title="Script">3</a></sup> آماده که توی <a href="http://userscripts.org/">http://userscripts.org</a> براش وجود داره، خودمون هم می‌تونیم به راحتی براش دست‌نوشته بنویسیم. حالا اگر قدرت JavaScript رو بیاری تو ذهنت می‌بینی که چه کارها می‌شه به کمک این میمون چرب (!) کرد.</p>
<p>برای شروع ماجراجویی، کمی از <a href="http://diveintogreasemonkey.org/">http://diveintogreasemonkey.org</a> رو خوندم. نقطهٔ شروع بسیار خوبی بود.</p>
<p>یک دست‌نوشته به نام <a href="http://userscripts.org/scripts/show/38610">فارسنده یا Persianizer</a> که به شیوهٔ بِکَن-بچسبون<sup><a href="http://blog.ebrahim.ir/1387/09/grease-monkey-a-friend-of-fire-fox/#footnote_3_123" id="identifier_3_123" class="footnote-link footnote-identifier-link" title="Copy-Paste">4</a></sup> ساخته‌ام، همهٔ رقم‌های انگلیسی و «ي» و «ك»های عربی توی صفحهٔ بارگذاری شده رو به معادل فارسیشون تبدیل می‌کنه. بس که اون صفحه‌های فارسی پر از «ي» حالم رو بد می‌کنه! فقط موقع استفاده حواست باشه پایگاه‌هایی که قراره فارسنده روشون کار بکنه رو خوب انتخاب کنی؛ پیش‌فرض‌هاش خوب نیستند.</p>
<p>البته یکی از شرایط من (و خیلی‌های دیگر) برای استفاده از یک فن‌آوری، انحصاری نبودنش هست که خوش‌بختانه افزونه‌هایی سازگار با Greasemonkey برای مرورگرهای مهم دیگه (از جمله Konqueror) هم وجود داره.</p>
<p>نکتهٔ پایانی این که اگر کاربر Greasemonkey باشی، افزونهٔ <a href="https://addons.mozilla.org/firefox/addon/8352">Greasefire</a> هم احتمالاً برات جالب هست.</p>
<p>این هم فهرست دست‌نوشته‌های محبوب من:<br />
<a href="http://userscripts.org/users/73214/favorites">http://userscripts.org/users/73214/favorites</a></p>
<ol class="footnotes"><li id="footnote_0_123" class="footnote">Web</li><li id="footnote_1_123" class="footnote">Client Side</li><li id="footnote_2_123" class="footnote">Script</li><li id="footnote_3_123" class="footnote">Copy-Paste</li></ol>]]></content:encoded>
			<wfw:commentRss>http://blog.ebrahim.ir/1387/09/grease-monkey-a-friend-of-fire-fox/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>از پیغام‌های خطای STL نجات یافتم</title>
		<link>http://blog.ebrahim.ir/1387/09/got-rid-of-stl-error-messages/</link>
		<comments>http://blog.ebrahim.ir/1387/09/got-rid-of-stl-error-messages/#comments</comments>
		<pubDate>Sat, 22 Nov 2008 21:51:30 +0000</pubDate>
		<dc:creator>ابراهیم</dc:creator>
				<category><![CDATA[رایانه]]></category>
		<category><![CDATA[BASH]]></category>
		<category><![CDATA[C++‎]]></category>
		<category><![CDATA[STL]]></category>
		<category><![CDATA[ابزار]]></category>
		<category><![CDATA[برنامه‌نویسی]]></category>
		<category><![CDATA[دست‌نوشته]]></category>
		<category><![CDATA[نرم‌افزار آزاد]]></category>
		<category><![CDATA[هم‌گردان]]></category>

		<guid isPermaLink="false">http://blog.ebrahim.ir/?p=70</guid>
		<description><![CDATA[اگر برنامه‌نویس C++‎ باشی، حتماً تا حالا مورد آزار و اذیت پیغام‌های خطای سرسام‌آور هم‌گردان0 در مورد STL قرار گرفته‌ای. مثلاً این: testmm2.cpp:31: error: no matching function for call to ‘std::multimap&#60;int*, int, std::less&#60;int*&#62;, std::allocator&#60;std::pair&#60;int* const, int&#62; &#62; &#62;::insert(int)’ /usr/include/c++/4.3/bits/stl_multimap.h:407: note: candidates are: typename std::_Rb_tree&#60;_Key, std::pair&#60;const _Key, _Tp&#62;, std::_Select1st&#60;std::pair&#60;const_Key, _Tp&#62; &#62;, _Compare, typename _Alloc::rebind&#60;std::pair&#60;const _Key, _Tp&#62; [...]]]></description>
			<content:encoded><![CDATA[<p><!--startnum=0--></p>
<p>اگر برنامه‌نویس C++‎ باشی، حتماً تا حالا مورد آزار و اذیت پیغام‌های خطای سرسام‌آور هم‌گردان<sup><a href="http://blog.ebrahim.ir/1387/09/got-rid-of-stl-error-messages/#footnote_0_70" id="identifier_0_70" class="footnote-link footnote-identifier-link" title="Compiler">0</a></sup> در مورد STL قرار گرفته‌ای. مثلاً این:</p>

<div class="wp_syntax" dir="ltr"><div class="code"><pre class="none" style="font-family:monospace;">testmm2.cpp:31: error: no matching function for call to ‘std::multimap&lt;int*, int, std::less&lt;int*&gt;, std::allocator&lt;std::pair&lt;int* const, int&gt; &gt; &gt;::insert(int)’
/usr/include/c++/4.3/bits/stl_multimap.h:407: note: candidates are: typename std::_Rb_tree&lt;_Key, std::pair&lt;const _Key, _Tp&gt;, std::_Select1st&lt;std::pair&lt;const_Key, _Tp&gt; &gt;, _Compare, typename _Alloc::rebind&lt;std::pair&lt;const _Key, _Tp&gt; &gt;::other&gt;::iterator std::multimap&lt;_Key, _Tp, _Compare, _Alloc&gt;::insert(const std::pair&lt;const _Key, _Tp&gt;&amp;) [with _Key = int*, _Tp = int, _Compare = std::less&lt;int*&gt;, _Alloc = std::allocator&lt;std::pair&lt;int* const, int&gt; &gt;]
/usr/include/c++/4.3/bits/stl_multimap.h:431: note:                 typename std::_Rb_tree&lt;_Key, std::pair&lt;const _Key, _Tp&gt;, std::_Select1st&lt;std::pair&lt;const _Key, _Tp&gt; &gt;, _Compare, typename _Alloc::rebind&lt;std::pair&lt;const _Key, _Tp&gt; &gt;::other&gt;::iterator std::multimap&lt;_Key, _Tp, _Compare, _Alloc&gt;::insert(typename std::_Rb_tree&lt;_Key, std::pair&lt;const _Key, _Tp&gt;, std::_Select1st&lt;std::pair&lt;const _Key, _Tp&gt; &gt;, _Compare, typename _Alloc::rebind&lt;std::pair&lt;const _Key, _Tp&gt; &gt;::other&gt;::iterator, const std::pair&lt;const _Key, _Tp&gt;&amp;) [with _Key = int*, _Tp = int, _Compare = std::less&lt;int*&gt;, _Alloc = std::allocator&lt;std::pair&lt;int* const, int&gt; &gt;]</pre></div></div>

<p>‎<br />
حالا این یکی بود. وقتی ده-پونزده تا از این‌ها یک‌جا رخ می‌ده، خیلی افتضاح می‌شه.</p>
<p>مدت‌ها با این مشکل کنار اومده بودم و دردش رو تحمل می‌کردم. اما اخیراً یک راه نجات یافتم: ابزاری  به نام <a href="http://www.bdsoft.com/tools/stlfilt.html">STLFilt</a>. یک نرم‌افزار آزاد هست که خروجی هم‌گردان C++‎ رو می‌گیره و اون پیغام‌های وحشت‌ناک رو مهربون می‌کنه. مثلاً پیغام بالا رو تبدیل می‌کنه به این:</p>

<div class="wp_syntax" dir="ltr"><div class="code"><pre class="none" style="font-family:monospace;">testmm2.cpp:31: error: No match for ‘multimap&lt;int *, int&gt;::insert(int)’
stl_multimap.h:407: candidates are: map&lt;int *, int&gt;::iter multimap&lt;int *, int&gt;
    ::insert(const pair&lt;const int *, int&gt; &amp;)
stl_multimap.h:431: map&lt;
        int *, int
    &gt;::iter multimap&lt;
        int *, int
    &gt;::insert(map&lt;int *, int&gt;::iter, const pair&lt;const int *, int&gt; &amp;)</pre></div></div>

<p>آخش! حالا می‌شه خوندش!</p>
<p>برای استفاده از STLFilt اول باید بستهٔ مربوط به هم‌گردانت رو بگیری. مثلاً gstlfilt.zip برای G++‎. توش کلی پرونده هست که همه رو بی‌خیال می‌شی به جز gSTLFilt.pl که اصل کار رو انجام می‌ده. از stdin می‌خونه و توی stdout می‌نویسه. کاری که من کردم این بود<sup><a href="http://blog.ebrahim.ir/1387/09/got-rid-of-stl-error-messages/#footnote_1_70" id="identifier_1_70" class="footnote-link footnote-identifier-link" title="مثل همیشه نقل به مضمون و آزمایش&zwnj;نشده">1</a></sup>:</p>

<div class="wp_syntax" dir="ltr"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">su</span>
<span style="color: #007800;">F</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>stlfilt.pl
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'#!/usr/bin/perl'</span> <span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #007800;">$F</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> gSTLFilt.pl <span style="color: #000000; font-weight: bold;">&gt;&gt;</span><span style="color: #007800;">$F</span>
<span style="color: #c20cb9; font-weight: bold;">chmod</span> +x <span style="color: #007800;">$F</span></pre></div></div>

<p>و برای استفاده:</p>

<div class="wp_syntax" dir="ltr"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">|</span> stlfilt.pl</pre></div></div>

<p>برای این که هر بار نخوام stderr دستور ساخت<sup><a href="http://blog.ebrahim.ir/1387/09/got-rid-of-stl-error-messages/#footnote_2_70" id="identifier_2_70" class="footnote-link footnote-identifier-link" title="Build">2</a></sup> (مثلاً make)  رو به stdoutش redirect<sup><a href="http://blog.ebrahim.ir/1387/09/got-rid-of-stl-error-messages/#footnote_3_70" id="identifier_3_70" class="footnote-link footnote-identifier-link" title="معادل خوبی براش داری بگو">3</a></sup> کنم، دست‌نوشتهٔ<sup><a href="http://blog.ebrahim.ir/1387/09/got-rid-of-stl-error-messages/#footnote_4_70" id="identifier_4_70" class="footnote-link footnote-identifier-link" title="Script">4</a></sup> <code>/usr/local/bin/stlfilt</code> رو با این محتوا ساختم:</p>

<div class="wp_syntax" dir="ltr"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #ff0000;">&quot;$@&quot;</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">|</span> stlfilt.pl</pre></div></div>

<p>و <code>chmod +x</code> هم یادم نره. <img src='http://blog.ebrahim.ir/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
حالا این‌جوری استفاده می‌شه:</p>

<div class="wp_syntax" dir="ltr"><div class="code"><pre class="bash" style="font-family:monospace;">stlfilt <span style="color: #c20cb9; font-weight: bold;">make</span></pre></div></div>

<p>با دست‌نوشته‌ها زندگی زیباتره! <img src='http://blog.ebrahim.ir/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>ویرایش: امید آن می‌رود که با معرفی «مفهوم»<sup><a href="http://blog.ebrahim.ir/1387/09/got-rid-of-stl-error-messages/#footnote_5_70" id="identifier_5_70" class="footnote-link footnote-identifier-link" title="Concept">5</a></sup>ها در C++0x (به زودی!) کل مشکل از بیخ حل بشه و دیگه نیازی به ابزار اضافی نباشه.</p>
<ol start="0" class="footnotes"><li id="footnote_0_70" class="footnote">Compiler</li><li id="footnote_1_70" class="footnote">مثل همیشه نقل به مضمون و آزمایش‌نشده</li><li id="footnote_2_70" class="footnote">Build</li><li id="footnote_3_70" class="footnote">معادل خوبی براش داری بگو</li><li id="footnote_4_70" class="footnote">Script</li><li id="footnote_5_70" class="footnote">Concept</li></ol>]]></content:encoded>
			<wfw:commentRss>http://blog.ebrahim.ir/1387/09/got-rid-of-stl-error-messages/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (user agent is rejected)

Served from: blog.ebrahim.ir @ 2012-02-07 00:16:16 -->
