<?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>Voland.com.cn</title>
	<atom:link href="http://www.voland.com.cn/feed" rel="self" type="application/rss+xml" />
	<link>http://www.voland.com.cn</link>
	<description>人生百年,诸事记之</description>
	<lastBuildDate>Thu, 02 Feb 2012 23:09:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Myeclipse6.5破解类</title>
		<link>http://www.voland.com.cn/en/myeclipse6-5-po-jie-lei</link>
		<comments>http://www.voland.com.cn/en/myeclipse6-5-po-jie-lei#comments</comments>
		<pubDate>Mon, 10 Oct 2011 07:52:21 +0000</pubDate>
		<dc:creator>Nortan</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[usefulness]]></category>
		<category><![CDATA[Myeclipse6.5]]></category>

		<guid isPermaLink="false">http://www.voland.com.cn/?p=716</guid>
		<description><![CDATA[Myeclipse6.5可能大家也不常用了,我也基本不用,不过用到的时候,没有注册码也难受,在网上找到这个类来生成注册码,还是比较好用的.放在这里备忘: import java.text.DecimalFormat; import java.text.NumberFormat; import java.text.SimpleDateFormat; import java.util.Calendar; &#160; public class Crack &#123; //myeclipseBlue6.5破解,运行即可得到key public static final void main&#40;String&#91;&#93; args&#41;&#123; String id=&#34;nortan&#34;; //这是指注册的名称 String num=&#34;999&#34;; System.out.println&#40;getSerial&#40;id,&#34;100&#34;,num,false&#41;&#41;; &#125; public static String getSerial&#40;String userId, String version, String licenseNum, boolean selected&#41; &#123; Calendar cal = Calendar.getInstance&#40;&#41;; cal.add&#40;1, 3&#41;; cal.add&#40;6, -1&#41;; NumberFormat nf = new DecimalFormat&#40;&#34;000&#34;&#41;; licenseNum = [...]]]></description>
			<content:encoded><![CDATA[<p>Myeclipse6.5可能大家也不常用了,我也基本不用,不过用到的时候,没有注册码也难受,在网上找到这个类来生成注册码,还是比较好用的.放在这里备忘:<span id="more-716"></span></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.text.DecimalFormat</span><span style="color: #339933;">;</span>   
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.text.NumberFormat</span><span style="color: #339933;">;</span>   
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.text.SimpleDateFormat</span><span style="color: #339933;">;</span>   
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Calendar</span><span style="color: #339933;">;</span>   
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Crack <span style="color: #009900;">&#123;</span>   
<span style="color: #666666; font-style: italic;">//myeclipseBlue6.5破解,运行即可得到key  </span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>   
        <span style="color: #003399;">String</span> id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nortan&quot;</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">//这是指注册的名称  </span>
        <span style="color: #003399;">String</span> num<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;999&quot;</span><span style="color: #339933;">;</span>   
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>getSerial<span style="color: #009900;">&#40;</span>id,<span style="color: #0000ff;">&quot;100&quot;</span>,num,<span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    
    <span style="color: #009900;">&#125;</span>   
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> getSerial<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> userId, <span style="color: #003399;">String</span> version,   
            <span style="color: #003399;">String</span> licenseNum, <span style="color: #000066; font-weight: bold;">boolean</span> selected<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>   
        <span style="color: #003399;">Calendar</span> cal <span style="color: #339933;">=</span> <span style="color: #003399;">Calendar</span>.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        cal.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        cal.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">6</span>, <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        <span style="color: #003399;">NumberFormat</span> nf <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">DecimalFormat</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;000&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        licenseNum <span style="color: #339933;">=</span> nf.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Integer</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>licenseNum<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        <span style="color: #003399;">String</span> verTime <span style="color: #339933;">=</span> selected <span style="color: #339933;">?</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringBuffer</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>   
                <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">SimpleDateFormat</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;yyMMdd&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span>cal.<span style="color: #006633;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>   
                <span style="color: #0000ff;">&quot;0&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;-1312310&quot;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//这的时间是指注册到期时间，可以自己修改  </span>
        <span style="color: #003399;">String</span> type <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;YE3MB-&quot;</span><span style="color: #339933;">;</span>   
        <span style="color: #003399;">String</span> need <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringBuffer</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>userId.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>   
                .<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>type<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>version<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>licenseNum<span style="color: #009900;">&#41;</span>   
                .<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>verTime<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        <span style="color: #003399;">String</span> dx <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringBuffer</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>need<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>   
                .<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>   
                        <span style="color: #0000ff;">&quot;Decompiling this copyrighted software is a violation of both your license agreement and the Digital Millenium Copyright Act of 1998 (http://www.loc.gov/copyright/legislation/dmca.pdf). Under section 1204 of the DMCA, penalties range up to a $500,000 fine or up to five years imprisonment for a first offense. Think about it; pay for a license, avoid prosecution, and feel better about yourself.&quot;</span><span style="color: #009900;">&#41;</span>   
&nbsp;
                        .<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>userId<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        <span style="color: #000066; font-weight: bold;">int</span> suf <span style="color: #339933;">=</span> decode<span style="color: #009900;">&#40;</span>dx<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        <span style="color: #003399;">String</span> code <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringBuffer</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>need<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>   
                <span style="color: #003399;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>suf<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        <span style="color: #000000; font-weight: bold;">return</span> change<span style="color: #009900;">&#40;</span>code<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
    <span style="color: #009900;">&#125;</span>   
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">int</span> decode<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> s<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>   
        <span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>   
        <span style="color: #000066; font-weight: bold;">char</span> ac<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> s.<span style="color: #006633;">toCharArray</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        <span style="color: #000066; font-weight: bold;">int</span> j <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>   
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> k <span style="color: #339933;">=</span> ac.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> k<span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>   
            i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">31</span> <span style="color: #339933;">*</span> i <span style="color: #339933;">+</span> ac<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>   
&nbsp;
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #003399;">Math</span>.<span style="color: #006633;">abs</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
    <span style="color: #009900;">&#125;</span>   
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> change<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> s<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>   
        <span style="color: #000066; font-weight: bold;">byte</span> abyte0<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> s.<span style="color: #006633;">getBytes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        <span style="color: #000066; font-weight: bold;">char</span> ac<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">char</span><span style="color: #009900;">&#91;</span>s.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>   
        <span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>   
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> k <span style="color: #339933;">=</span> abyte0.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> k<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>   
            <span style="color: #000066; font-weight: bold;">int</span> j <span style="color: #339933;">=</span> abyte0<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>   
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">48</span> <span style="color: #339933;">&amp;&amp;</span> j <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">57</span><span style="color: #009900;">&#41;</span>   
                j <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>j <span style="color: #339933;">-</span> <span style="color: #cc66cc;">48</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">48</span><span style="color: #339933;">;</span>   
            <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">65</span> <span style="color: #339933;">&amp;&amp;</span> j <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">90</span><span style="color: #009900;">&#41;</span>   
                j <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>j <span style="color: #339933;">-</span> <span style="color: #cc66cc;">65</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">13</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">26</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">65</span><span style="color: #339933;">;</span>   
            <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">97</span> <span style="color: #339933;">&amp;&amp;</span> j <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">122</span><span style="color: #009900;">&#41;</span>   
                j <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>j <span style="color: #339933;">-</span> <span style="color: #cc66cc;">97</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">13</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">26</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">97</span><span style="color: #339933;">;</span>   
            ac<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">char</span><span style="color: #009900;">&#41;</span>j<span style="color: #339933;">;</span>   
        <span style="color: #009900;">&#125;</span>   
&nbsp;
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #003399;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>ac<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
    <span style="color: #009900;">&#125;</span>   
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.voland.com.cn/en/myeclipse6-5-po-jie-lei/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu下Subclipse报failed to load javahl library的解决办法</title>
		<link>http://www.voland.com.cn/en/subclipse-under-ubuntu-report-failed-to-load-javahl-library-solution</link>
		<comments>http://www.voland.com.cn/en/subclipse-under-ubuntu-report-failed-to-load-javahl-library-solution#comments</comments>
		<pubDate>Thu, 01 Sep 2011 02:00:05 +0000</pubDate>
		<dc:creator>Nortan</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[usefulness]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.voland.com.cn/?p=698</guid>
		<description><![CDATA[最近买了一T61p,买回后直接安装Ubuntu 10.04,安装Eclipse并安装Subclipse1.6x插件后,使用svn过程中报 Failed to load JavaHL Library. These are the errors that were encountered: no libsvnjavahl-1 in java.library.path no svnjavahl-1 in java.library.path /opt/local/lib/libsvnjavahl-1.0.0.0.dylib: no suitable image found. Did find: /opt/local/lib/libsvnjavahl-1.0.0.0.dylib: mach-o, but wrong architecture 原来是缺少一些关联文件,去subclipse的Wiki看了看,说需要安装libsvn-java,在Ubuntu 下安装很简单,命令如下: sudo apt-get install libsvn-java 安装完后,这文件在/usr/lib/jni目录下,这个目录并不是eclipse的java.library.path路径之一,所以还需要修改eclipse.ini来告诉eclipse去哪找这个libsvn-java相关的文件. 打开eclipse.ini,在最后行加入如下内容(注意换行) -Djava.library.path=/usr/lib/jni]]></description>
			<content:encoded><![CDATA[<p>最近买了一T61p,买回后直接安装Ubuntu 10.04,安装Eclipse并安装Subclipse1.6x插件后,使用svn过程中报<br />
<code><br />
Failed to load JavaHL Library.<br />
These are the errors that were encountered:<br />
no libsvnjavahl-1 in java.library.path<br />
no svnjavahl-1 in java.library.path<br />
/opt/local/lib/libsvnjavahl-1.0.0.0.dylib:  no suitable image found.  Did find:  /opt/local/lib/libsvnjavahl-1.0.0.0.dylib: mach-o, but wrong architecture<br />
</code><br />
原来是缺少一些关联文件,去subclipse的Wiki看了看,说需要安装libsvn-java,在Ubuntu 下安装很简单,命令如下:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">sudo apt-get install libsvn-java</pre></div></div>

<p>安装完后,这文件在/usr/lib/jni目录下,这个目录并不是eclipse的java.library.path路径之一,所以还需要修改eclipse.ini来告诉eclipse去哪找这个libsvn-java相关的文件.<br />
打开eclipse.ini,在最后行加入如下内容(注意换行)</p>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">-Djava.library.path=/usr/lib/jni</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.voland.com.cn/en/subclipse-under-ubuntu-report-failed-to-load-javahl-library-solution/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add a User on Ubuntu Server Or Debian Server</title>
		<link>http://www.voland.com.cn/en/add-a-user-on-ubuntu-server-or-debian-server-on-debian-or-ubuntu-server-to-add-users</link>
		<comments>http://www.voland.com.cn/en/add-a-user-on-ubuntu-server-or-debian-server-on-debian-or-ubuntu-server-to-add-users#comments</comments>
		<pubDate>Fri, 29 Jul 2011 01:31:51 +0000</pubDate>
		<dc:creator>Nortan</dc:creator>
				<category><![CDATA[OS]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.voland.com.cn/?p=669</guid>
		<description><![CDATA[Debian (Ubuntu) Server is like any Linux variety, and has full multi-user capabilities, and a common task on any server is adding users. We can use useradd or adduser command to manage users. 1.useradd The useradd command will let you add a new user easily from the command line: useradd username This command adds the [...]]]></description>
			<content:encoded><![CDATA[<p>Debian (Ubuntu) Server is like any Linux variety, and has full multi-user capabilities, and a common task on any server is adding users. We can use useradd or adduser command to manage users.</p>
<p><strong>1.useradd</strong></p>
<p>The useradd command will let you add a new user easily from the command line:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">useradd username</pre></div></div>

<p>This command adds the user, but without any extra options your user won’t have a password or a home directory.</p>
<p>You can use the -d option to set the home directory for the user. The -m option will force useradd to create the home directory. We’ll try creating a user account with those options, and then use the passwd command to set the password for the account. You can alternatively set a password using -p on the useradd command, but I prefer to set the password using passwd.</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">sudo useradd -d /home/nortan -m nortan
sudo passwd nortan</pre></div></div>

<p>This will create the user named nortan and give them their own home directory in /home/nortan. The files in the new home directory are copied from the /etc/skel folder, which contains default home directory files. If you wanted to set default values for your users, you would do so by modifying or adding files in that directory. If we take a look at the new home directory for the user:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">voland@localhost:~$ls -la /home/nortan
total 20
drwxr-xr-x 2 nortan nortan 4096 2006-12-15 11:34 .
drwxr-xr-x 5 root root 4096 2006-12-15 11:37 ..
-rw-r–r– 1 nortan nortan 220 2006-12-15 11:34 .bash_logout
-rw-r–r– 1 nortan nortan 414 2006-12-15 11:34 .bash_profile
-rw-r–r– 1 nortan nortan 2227 2006-12-15 11:34 .bashrc</pre></div></div>

<p>You’ll notice that there are bash scripts in this directory. If you wanted to set default path options for all new users, you would do so by modifying the files in /etc/skel, which would then be used to create these files by the useradd command.</p>
<p><strong>2.adduser</strong></p>
<p>The adduser command is even easier than the useradd command, because it prompts you for each piece of information. I find it slightly funny that there are two virtually identically named commands that do the same thing, but that’s linux for you. Here’s the syntax:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">adduser username</pre></div></div>

<p>Example:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">voland@localhost:~$ sudo adduser nortan
Password:
Adding user `nortan’…
Adding new group `nortan’ (1004).
Adding new user `nortan’ (1004) with group `nortan’.
Creating home directory `/home/nortan’.
Copying files from `/etc/skel’
Enter new UNIX password:
Retype new UNIX password:
No password supplied
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for nortan
Enter the new value, or press ENTER for the default
Full Name []: The Geek
Room Number []: 0
Work Phone []: 555-1312
Home Phone []: 555-1312
Other []:
Is the information correct? [y/N] y</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.voland.com.cn/en/add-a-user-on-ubuntu-server-or-debian-server-on-debian-or-ubuntu-server-to-add-users/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>(中文) Debian安装配置Iptables防火墙</title>
		<link>http://www.voland.com.cn/en/debian-install-and-configure-iptables-firewall</link>
		<comments>http://www.voland.com.cn/en/debian-install-and-configure-iptables-firewall#comments</comments>
		<pubDate>Sat, 23 Jul 2011 04:07:58 +0000</pubDate>
		<dc:creator>Nortan</dc:creator>
				<category><![CDATA[OS]]></category>
		<category><![CDATA[Configure]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Firewalls]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[防火墙]]></category>

		<guid isPermaLink="false">http://www.voland.com.cn/?p=652</guid>
		<description><![CDATA[服务器通常会安装防火墙,Debian上有很防火墙,Iptables为比较常用的免费防火墙,Iptables能够提供数据包过滤,网络地址转换(NAT)等功能.在Debian上手工配置Iptables的资料比较少,本文做一个详细的介绍. 第一步,首先确定你的系统已经安装Iptables.打开SSH终端,输入 whereis iptables 如果能看到如下类似信息,说明你已经安装了iptables iptables: /sbin/iptables /usr/share/iptables /usr/share/man/man8/iptables.8.gz 如果不是这个提示,或者没有任何提示,那你的Debian上可能没有安装iptables 请使用如下命令安装: sudo apt-get install iptables 注意:本文所有命令在普通帐号下完成,本普通帐号使用sudo具有root权限,本人不建议直接使用root用户 第二步:查看Iptables目前的配置信息 可以使用如下命令查看 sudo iptables -L 如果你是第一次安装配置iptables,你可能会看到如下结果: Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination 这个结果,也就是防火墙充许所有的请求,就如没有设置防火墙一样. 第三步:配置Iptables 配置Iptables,我们先把一个基本的Iptables的规则文章保存起来,这个规则文章做为测试用 sudo vim /etc/iptables.test.rules [...]]]></description>
			<content:encoded><![CDATA[<p>服务器通常会安装防火墙,Debian上有很防火墙,Iptables为比较常用的免费防火墙,Iptables能够提供数据包过滤,网络地址转换(NAT)等功能.在Debian上手工配置Iptables的资料比较少,本文做一个详细的介绍.</p>
<p>第一步,首先确定你的系统已经安装Iptables.打开SSH终端,输入</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">whereis iptables</pre></div></div>

<p>如果能看到如下类似信息,说明你已经安装了iptables<br />
<code>iptables: /sbin/iptables /usr/share/iptables /usr/share/man/man8/iptables.8.gz</code><br />
如果不是这个提示,或者没有任何提示,那你的Debian上可能没有安装iptables<br />
请使用如下命令安装:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">sudo apt-get install iptables</pre></div></div>

<p>注意:本文所有命令在普通帐号下完成,本普通帐号使用sudo具有root权限,本人不建议直接使用root用户<span id="more-652"></span></p>
<p>第二步:查看Iptables目前的配置信息<br />
可以使用如下命令查看</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">sudo iptables -L</pre></div></div>

<p>如果你是第一次安装配置iptables,你可能会看到如下结果:<br />
<code><br />
Chain INPUT (policy ACCEPT)<br />
target     prot opt source               destination<br />
Chain FORWARD (policy ACCEPT)<br />
target     prot opt source               destination<br />
Chain OUTPUT (policy ACCEPT)<br />
target     prot opt source               destination<br />
</code><br />
这个结果,也就是防火墙充许所有的请求,就如没有设置防火墙一样.</p>
<p>第三步:配置Iptables<br />
配置Iptables,我们先把一个基本的Iptables的规则文章保存起来,这个规则文章做为测试用</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">sudo vim /etc/iptables.test.rules</pre></div></div>

<p>然后在这个文章中输入如下规则内容,这个内容是debian官方给出的基本配置</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">*filter
&nbsp;
# Allows all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT -i ! lo -d 127.0.0.0/8 -j REJECT
&nbsp;
# Accepts all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
&nbsp;
# Allows all outbound traffic
# You could modify this to only allow certain traffic
-A OUTPUT -j ACCEPT
&nbsp;
# Allows HTTP and HTTPS connections from anywhere (the normal ports for websites)
-A INPUT -p tcp --dport 80 -j ACCEPT
-A INPUT -p tcp --dport 443 -j ACCEPT
&nbsp;
# Allows SSH connections for script kiddies
# THE -dport NUMBER IS THE SAME ONE YOU SET UP IN THE SSHD_CONFIG FILE
-A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT
&nbsp;
# Now you should read up on iptables rules and consider whether ssh access 
# for everyone is really desired. Most likely you will only allow access from certain IPs.
&nbsp;
# Allow ping
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
&nbsp;
# log iptables denied calls (access via 'dmesg' command)
-A INPUT -m limit --limit 5/min -j LOG --log-prefix &quot;iptables denied: &quot; --log-level 7
&nbsp;
# Reject all other inbound - default deny unless explicitly allowed policy:
-A INPUT -j REJECT
-A FORWARD -j REJECT
&nbsp;
COMMIT</pre></div></div>

<p>保存本文件,然后把本规则加载,使之生效,注意,iptables不需要重启,加载一次规则就成了</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">sudo iptables-restore &lt; /etc/iptables.test.rules</pre></div></div>

<p>然后再查看最新的配置,应该所有的设置都生效了.</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">sudo iptables -L</pre></div></div>

<p>第四小:保存生效的配置,让系统重启的时候自动加载有效配置<br />
iptables提供了保存当前运行的规则功能</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">iptables-save &gt; /etc/iptables.up.rules</pre></div></div>

<p>注意,如果当前用户不是root,即使使用了sudo,也会提示你没有权限,无法保存,所以执行本命令,你必须使用root用户.<br />
可以使用sudo -i快速转到root,使用完成,请及时使用su username切换到普通帐户.</p>
<p>为了重启服务器后,规则自动加载,我们创建如下文件:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">sudo vim /etc/network/if-pre-up.d/iptables</pre></div></div>

<p>本文章的内容如下:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">#!/bin/bash
/sbin/iptables-restore &lt; /etc/iptables.up.rules</pre></div></div>

<p>最后,设置本文章具体可执行仅限</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">chmod +x /etc/network/if-pre-up.d/iptables</pre></div></div>

<p>第五:其它<br />
如果你想设置某ip段可以访问所有服务,你需要在iptables.test.rules文件中加入<br />
-A INPUT -m iprange &#8211;src-range 192.168.1.1-192.168.1.199 -j ACCEPT<br />
然后从第三步再设置一次.注意iptables.test.rules不是必须的,它只是让你的修改时,能更好的测试.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voland.com.cn/en/debian-install-and-configure-iptables-firewall/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to install Byte UnixBench on debian lenny</title>
		<link>http://www.voland.com.cn/en/how-to-install-byte-unixbench-on-debian-lenny-install-unixbench-in-debain</link>
		<comments>http://www.voland.com.cn/en/how-to-install-byte-unixbench-on-debian-lenny-install-unixbench-in-debain#comments</comments>
		<pubDate>Wed, 29 Dec 2010 09:50:05 +0000</pubDate>
		<dc:creator>Nortan</dc:creator>
				<category><![CDATA[sharing]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[UnixBench]]></category>

		<guid isPermaLink="false">http://www.voland.com.cn/?p=575</guid>
		<description><![CDATA[UnixBench is the original BYTE UNIX benchmark suite, updated and revised by many people over the years. The purpose of UnixBench is to provide a basic indicator of the performance of a Unix-like system; hence, multiple tests are used to test various aspects of the system’s performance. These test results are then compared to the [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>    UnixBench is the original BYTE UNIX benchmark suite, updated and revised by many people over the years.</p>
<p>    The purpose of UnixBench is to provide a basic indicator of the performance of a Unix-like system; hence, multiple tests are used to test various aspects of the system’s performance. These test results are then compared to the scores from a baseline system to produce an index value, which is generally easier to handle than the raw scores. The entire set of index values is then combined to make an overall index for the system.</p>
<p>    Some very simple graphics tests are included to measure the 2D and 3D graphics performance of the system.</p>
<p>    Multi-CPU systems are handled. If your system has multiple CPUs, the default behaviour is to run the selected tests twice — once with one copy of each test program running at a time, and once with N copies, where N is the number of CPUs. This is designed to allow you to assess:</p>
<p>        * the performance of your system when running a single task<br />
        * the performance of your system when running multiple tasks<br />
        * the gain from your system’s implementation of parallel processing</p>
<p>    Do be aware that this is a system benchmark, not a CPU, RAM or disk benchmark. The results will depend not only on your hardware, but on your operating system, libraries, and even compiler. </p></blockquote>
<p>First install required libraries for compilation :<br />
<code>#apt-get install libx11-dev libgl1-mesa-dev libxext-dev perl  perl-modules make</code><br />
Then get the unixbench and run it :<br />
<code><br />
#wget http://byte-unixbench.googlecode.com/files/unixbench-5.1.2.tar.gz<br />
#tar zxvf unixbench-5.1.2.tar.gz<br />
#cd unixbench-5.1.2<br />
#./Run<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.voland.com.cn/en/how-to-install-byte-unixbench-on-debian-lenny-install-unixbench-in-debain/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>(中文) 安装win7旗舰版系统后程序激活办法</title>
		<link>http://www.voland.com.cn/en/after-the-installation-process-win7-ultimate-system-activation-means</link>
		<comments>http://www.voland.com.cn/en/after-the-installation-process-win7-ultimate-system-activation-means#comments</comments>
		<pubDate>Sat, 07 Aug 2010 02:03:01 +0000</pubDate>
		<dc:creator>Nortan</dc:creator>
				<category><![CDATA[usefulness]]></category>

		<guid isPermaLink="false">http://www.voland.com.cn/?p=511</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voland.com.cn/en/after-the-installation-process-win7-ultimate-system-activation-means/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>(中文) 免费并支持私有库的代码管理平台</title>
		<link>http://www.voland.com.cn/en/free-and-support-the-private-library-of-code-management-platform</link>
		<comments>http://www.voland.com.cn/en/free-and-support-the-private-library-of-code-management-platform#comments</comments>
		<pubDate>Tue, 25 May 2010 03:04:38 +0000</pubDate>
		<dc:creator>Nortan</dc:creator>
				<category><![CDATA[sharing]]></category>
		<category><![CDATA[usefulness]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.voland.com.cn/?p=491</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voland.com.cn/en/free-and-support-the-private-library-of-code-management-platform/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to configure sudo in debian or ubuntu</title>
		<link>http://www.voland.com.cn/en/use-the-sudo-command-to-install-debian</link>
		<comments>http://www.voland.com.cn/en/use-the-sudo-command-to-install-debian#comments</comments>
		<pubDate>Wed, 28 Apr 2010 06:15:56 +0000</pubDate>
		<dc:creator>Nortan</dc:creator>
				<category><![CDATA[Configure]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[sudo]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.voland.com.cn/?p=439</guid>
		<description><![CDATA[Sudo is a program designed to allow a sysadmin to give limited root privileges to users and log root activity in debian. The basic philosophy is to give as few privileges as possible but still allow people to get their work done.]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction</strong><br />
Sudo is a program designed to allow a sysadmin to give limited root privileges to users and log root activity. The basic philosophy is to give as few privileges as possible but still allow people to get their work done.</p>
<p>Debian&#8217;s sudo package has the password timeout set to 15 minutes. This means that when you first enter your password, as long as you don&#8217;t wait more than 15 minutes between sudo commands, you won&#8217;t have to enter it again. The password timeout can be immediately expired with sudo -k.<span id="more-439"></span></p>
<p>Debian&#8217;s sudo is compiled with<br />
<code>--with-exempt=sudo<br />
--with-secure-path="/usr/local/sbin:/usr/local/bin:/usr/sbin:</code><br />
As a consequence, the PATH of the user is ignored except if the user is in group sudo.</p>
<p><strong>Installing SUDO in Debian</strong><br />
<code># apt-get install sudo</code><br />
sudo is configured entirely through the file /etc/sudoers. This file controls the commands which users are allowed to run.<br />
<code># vim /etc/sudoers</code><br />
add a line:<br />
<code>user ALL=(ALL) ALL</code></p>
<p>To run one command as root:<br />
<code> #sudo command</code><br />
For more commands, run your shell with sudo.<br />
<code> #sudo sh      (if sh is your shell.)</code><br />
Be careful when you are root. When you are done, type exit<br />
For more details about sudo options check man pages of sudo.Click <a href="http://www.linuxmanpages.com/man8/sudo.8.php">here</a> for sudo man page.<br />
some random SUDO examples</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;"># groups</span>
User_Alias  ROOT <span style="color: #339933;">=</span> user1<span style="color: #339933;">,</span> user2<span style="color: #339933;">,</span> user3
User_Alias  WEBMASTERS <span style="color: #339933;">=</span> user4<span style="color: #339933;">,</span> user5<span style="color: #339933;">,</span> user6
&nbsp;
<span style="color: #339933;"># commands</span>
Cmnd_Alias  APACHE <span style="color: #339933;">=</span> <span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span>local<span style="color: #339933;">/</span>sbin<span style="color: #339933;">/</span>kickapache
Cmnd_Alias  TAIL <span style="color: #339933;">=</span> <span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span>bin<span style="color: #339933;">/</span>tail
Cmnd_Alias      SHUTDOWN <span style="color: #339933;">=</span> <span style="color: #339933;">/</span>sbin<span style="color: #339933;">/</span>shutdown
Cmnd_Alias      APT <span style="color: #339933;">=</span> <span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span>bin<span style="color: #339933;">/</span>apt<span style="color: #339933;">-</span>get<span style="color: #339933;">,</span> <span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span>bin<span style="color: #339933;">/</span>dpkg
&nbsp;
<span style="color: #339933;"># privileges </span>
ROOT        ALL <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>ALL<span style="color: #009900;">&#41;</span> ALL
WEBMASTERS  ALL <span style="color: #339933;">=</span> PASSWD <span style="color: #339933;">:</span> APACHE<span style="color: #339933;">,</span> TAIL
admin       ALL <span style="color: #339933;">=</span> NOPASSWD <span style="color: #339933;">:</span> <span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>init.<span style="color: #202020;">d</span><span style="color: #339933;">/</span>apache</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.voland.com.cn/en/use-the-sudo-command-to-install-debian/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to run a rake task from cron</title>
		<link>http://www.voland.com.cn/en/how-to-run-a-rake-task-from-cron</link>
		<comments>http://www.voland.com.cn/en/how-to-run-a-rake-task-from-cron#comments</comments>
		<pubDate>Wed, 21 Apr 2010 07:07:17 +0000</pubDate>
		<dc:creator>Nortan</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[rake]]></category>
		<category><![CDATA[run a rake task from cron]]></category>

		<guid isPermaLink="false">http://www.voland.com.cn/?p=415</guid>
		<description><![CDATA[Say you want to do run some stats on your Ruby on Rails application nightly. Create a rake task to do what you want then use cron to execute it. 1.Preflight information First we need to create the RoR application. rails cron cd cron script/generate model my_model vi config/database.yml &#40;set the database username/password, and databases [...]]]></description>
			<content:encoded><![CDATA[<p>Say you want to do run some stats on your Ruby on Rails application nightly. Create a rake task to do what you want then use cron to execute it.</p>
<p><strong>1.Preflight information</strong></p>
<p>First we need to create the RoR application.</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;">rails cron
cd cron
script<span style="color:#006600; font-weight:bold;">/</span>generate model my_model
vi config<span style="color:#006600; font-weight:bold;">/</span>database.<span style="color:#9900CC;">yml</span> <span style="color:#006600; font-weight:bold;">&#40;</span>set the database username<span style="color:#006600; font-weight:bold;">/</span>password, <span style="color:#9966CC; font-weight:bold;">and</span> databases created <span style="color:#9966CC; font-weight:bold;">in</span> your environment<span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p><strong>2. Creating the rake task(s)</strong></p>
<p><strong>2.1 Simple task</strong></p>
<p>First lets see how to call any ruby code from rake. Rake code is placed in lib/tasks/FILENAME.rake. So lets create a lib/tasks/cron.rake and place this code in it: <span id="more-415"></span></p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;">namespace <span style="color:#ff3333; font-weight:bold;">:cron</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  desc <span style="color:#996600;">&quot;Just what Date is it really&quot;</span>
  task<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:dummy</span> <span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#CC0066; font-weight:bold;">p</span> <span style="color:#CC00FF; font-weight:bold;">Date</span>::today.<span style="color:#5A0A0A; font-weight:bold;">to_s</span>  <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>running rake -T cron gives us this:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;">rake <span style="color:#006600; font-weight:bold;">-</span>T cron
<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#006600; font-weight:bold;">/</span>Users<span style="color:#006600; font-weight:bold;">/</span>linda<span style="color:#006600; font-weight:bold;">/</span>example<span style="color:#006600; font-weight:bold;">/</span>cron<span style="color:#006600; font-weight:bold;">&#41;</span>
rake cron:dummy  <span style="color:#008000; font-style:italic;"># Just what Date is it really</span></pre></div></div>

<p>now lets execute the the rake task</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;">rake cron:dummy
<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#006600; font-weight:bold;">/</span>Users<span style="color:#006600; font-weight:bold;">/</span>linda<span style="color:#006600; font-weight:bold;">/</span>example<span style="color:#006600; font-weight:bold;">/</span>cron<span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#996600;">&quot;2010-04-21&quot;</span></pre></div></div>

<p>Ok so that shows us how to call any kind of ruby code from rake. But what happens when you want to do something fancy and work with the database. </p>
<p><strong>2.2 Model task</strong></p>
<p>This is actually how I use the rake tasks the most. To do some expensive calculations on the database. For example lets say there is a model called MyModel which has a method called calc_stats. Add the following code to your model:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> MyModel <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">calc_stats</span>
    <span style="color:#008000; font-style:italic;"># Do something spiffy with the model here</span>
    <span style="color:#996600;">&quot;Finished!&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>So the additional rake code /lib/tasks/cron.rake would look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;">  desc <span style="color:#996600;">&quot;Example of calling a model&quot;</span>
  task<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:calcstats</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:environment</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#CC0066; font-weight:bold;">p</span> MyModel.<span style="color:#9900CC;">calc_stats</span>  <span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p><code>Did you notice the difference between the first task(:dummy) {} and now task(:calcstats ⇒ :environment){}. That is the magic to get the rails environment passed into your rake task. </code></p>
<p>running rake -T cron gives us this:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;">rake <span style="color:#006600; font-weight:bold;">-</span>T cron
<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#006600; font-weight:bold;">/</span>Users<span style="color:#006600; font-weight:bold;">/</span>linda<span style="color:#006600; font-weight:bold;">/</span>example<span style="color:#006600; font-weight:bold;">/</span>cron<span style="color:#006600; font-weight:bold;">&#41;</span>
rake cron:dummy        <span style="color:#008000; font-style:italic;"># Just what Date is it really</span>
rake cron:calcstats    <span style="color:#008000; font-style:italic;"># Example of calling a model</span></pre></div></div>

<p>Lets execute the rake task</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;">rake RAILS_ENV=production cron:calcstats
<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#006600; font-weight:bold;">/</span>Users<span style="color:#006600; font-weight:bold;">/</span>linda<span style="color:#006600; font-weight:bold;">/</span>example<span style="color:#006600; font-weight:bold;">/</span>cron<span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#996600;">&quot;Finished!&quot;</span></pre></div></div>

<p><strong>3. Setting up the cron job</strong></p>
<p>Simple rake tasks Command</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;">cd <span style="color:#006600; font-weight:bold;">/</span>path<span style="color:#006600; font-weight:bold;">/</span>to<span style="color:#006600; font-weight:bold;">/</span>rails<span style="color:#006600; font-weight:bold;">/</span>app <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> <span style="color:#006600; font-weight:bold;">/</span>opt<span style="color:#006600; font-weight:bold;">/</span>csw<span style="color:#006600; font-weight:bold;">/</span>bin<span style="color:#006600; font-weight:bold;">/</span>rake cron:dummy</pre></div></div>

<p>Rake tasks which need the rails environment Command</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;">cd <span style="color:#006600; font-weight:bold;">/</span>path<span style="color:#006600; font-weight:bold;">/</span>to<span style="color:#006600; font-weight:bold;">/</span>rails<span style="color:#006600; font-weight:bold;">/</span>app <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> <span style="color:#006600; font-weight:bold;">/</span>opt<span style="color:#006600; font-weight:bold;">/</span>csw<span style="color:#006600; font-weight:bold;">/</span>bin<span style="color:#006600; font-weight:bold;">/</span>rake RAILS_ENV=production cron:calcstats</pre></div></div>

<p>Note:This is for accelerators paths for Shared accelerators are different. Use which rake to find out the correct path to use for your system. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.voland.com.cn/en/how-to-run-a-rake-task-from-cron/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Config static ip in debian OS</title>
		<link>http://www.voland.com.cn/en/debian-configuration-of-static-ip</link>
		<comments>http://www.voland.com.cn/en/debian-configuration-of-static-ip#comments</comments>
		<pubDate>Wed, 21 Apr 2010 05:24:17 +0000</pubDate>
		<dc:creator>Nortan</dc:creator>
				<category><![CDATA[Configure]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[配置静态ip]]></category>

		<guid isPermaLink="false">http://www.voland.com.cn/?p=405</guid>
		<description><![CDATA[Config static ip in debian,There are two files need to be modified,the one is “/etc/network/interfaces”,the other is “/etc/resolv.conf”./etc/network/interfaces used to config IP,netmask,gateway and so on,/etc/resolv.conf used to config DNS server address。]]></description>
			<content:encoded><![CDATA[<p>Config static ip in debian,There are two files need to be modified,the one is “/etc/network/interfaces”,the other is “/etc/resolv.conf”./etc/network/interfaces used to config IP,netmask,gateway and so on,/etc/resolv.conf used to config DNS server address。<br />
these are two examples：<span id="more-405"></span></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">#<span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>network<span style="color: #339933;">/</span>interfaces
# The loopback network <span style="color: #000000; font-weight: bold;">interface</span>
auto lo
iface lo inet loopback
#iface eth0 inet dhcp
# The primary network <span style="color: #000000; font-weight: bold;">interface</span>
auto eth0
iface eth0 inet <span style="color: #000000; font-weight: bold;">static</span>
address 192.168.1.180
network 192.168.1.0
netmask 255.255.255.0
gateway 192.168.1.1</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">#<span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>resolv.<span style="color: #006633;">conf</span>
nameserver 202.106.0.20
nameserver 202.106.195.68
nameserver 202.106.46.151
search localhost</pre></div></div>

<p>Note,after modification,please type following command to restart your network.<br />
<code>#/etc/init.d/networking restart </code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.voland.com.cn/en/debian-configuration-of-static-ip/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

