<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-3185832723933442141</atom:id><lastBuildDate>Sat, 24 Dec 2016 12:13:43 +0000</lastBuildDate><category>java</category><category>linux</category><category>math</category><category>firefox</category><category>projecteuler</category><category>scala</category><category>ubuntu</category><category>programming</category><category>sql</category><category>debian</category><category>hibernate</category><category>maven</category><category>wmii</category><category>javascript</category><category>php</category><category>spring</category><category>thinkpad</category><category>windows</category><category>clojure</category><category>mysql</category><category>netbeans</category><category>ruby</category><category>eclipse</category><category>gaming</category><category>git</category><category>ibatis</category><category>ibm</category><category>jquery</category><category>tomcat</category><category>adblock</category><category>android</category><category>axis</category><category>cygwin</category><category>dbunit</category><category>eeepc</category><category>ehcache</category><category>gedit</category><category>gutsy</category><category>hosts</category><category>i3</category><category>jdbc</category><category>jdk</category><category>lighttpd</category><category>pear</category><category>putty</category><category>quartz</category><category>rails</category><category>reflection</category><category>resin</category><category>s9y</category><category>selenium</category><category>self</category><category>ssl</category><category>testing</category><category>testng</category><category>vim</category><category>webservices</category><category>wicd</category><title>LousyCoder Blog</title><description>My development misadventures.</description><link>http://lousycoder.blogspot.com/</link><managingEditor>noreply@blogger.com (Min Huang)</managingEditor><generator>Blogger</generator><openSearch:totalResults>95</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-964376348131992931</guid><pubDate>Fri, 31 May 2013 06:19:00 +0000</pubDate><atom:updated>2014-07-22T14:26:04.390-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">clojure</category><category domain="http://www.blogger.com/atom/ns#">math</category><category domain="http://www.blogger.com/atom/ns#">projecteuler</category><title>Project Euler #70: Totient permutation</title><description>Here is &lt;a href=&quot;http://projecteuler.net/problem=70&quot;&gt;problem #70&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The problem asks to find a value for $$n$$ for which $$\phi(n)$$ is a permutation of the digits of $$n$$, and for which $$n/\phi(n)$$ is at a minimum.  A brief refresher of what the totient function is &lt;a href=&quot;http://en.wikipedia.org/wiki/Totient&quot;&gt;might be helpful here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Basically (lifted right from Wikipedia):&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;In number theory, Euler&#39;s totient or phi function, $$\phi(n)$$ is an arithmetic function that counts the number of positive integers less than or equal to n that are relatively prime to n. That is, if n is a positive integer, then $$\phi(n)$$ is the number of integers k in the range 1 ≤ k ≤ n for which $$gcd(n, k) = 1$$.&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Notably, $$\phi(p) = p - 1$$ if $$p$$ is prime.  This is because $$p$$ has no other divisors besides itself and 1, so all positive integers less than $$p$$ are relatively prime to it.&lt;br /&gt;&lt;br /&gt;This gives a little insight on how to solve the problem: if $$n$$ happens to be prime, then $$n/\phi(n)$$ = $$n/(n - 1)$$, which is basically the smallest you can get that ratio to be.  If it so happened that $$n$$&#39;s digits are a permutation of $$\phi(n)$$ in that case, I&#39;d have the winning number.  With this strategy, all I would have to do is find a bunch of primes around the vicinity of $$10^8$$ and check the permutation constraint.&lt;br /&gt;&lt;br /&gt;Unfortunately, since $$\phi(p) = p - 1$$, $$p$$ and $$\phi(p)$$ must differ by at least one digit, so that idea is out the window.&lt;br /&gt;&lt;br /&gt;However, the ratio $$n/\phi(n)$$ also happens to be small if $$n$$ is a &lt;a href=&quot;http://en.wikipedia.org/wiki/Semiprime&quot;&gt;semi-prime&lt;/a&gt; (that is, if $$n$$ is the product of two primes).  In this case, $$n$$ will have one or two other divisors besides $$n$$ itself (one in the case that the two primes are not distinct), so looking for semi-primes is the next best thing after looking for primes.&lt;br /&gt;&lt;br /&gt;Having no idea where to start looking for these primes, I just started by poking around primes near $$\sqrt{10^8}$$, and testing if they had the two properties I was looking for.  The following Clojure program eventually happens upon the result in less than a minute&#39;s time:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;clojure&quot;&gt;; lib/core.clj contains some general functions for calculating the integer&lt;br /&gt;; square root, and for loading in a big list of pre-calculated primes.&lt;br /&gt;(load-file &quot;lib/core.clj&quot;)&lt;br /&gt;(use&lt;br /&gt;  &#39;[clojure.math.combinatorics]&lt;br /&gt;  &#39;[lib.core :only (isqrt load-primes)])&lt;br /&gt;&lt;br /&gt;(def primes&lt;br /&gt;  (load-primes &quot;../data/primes.txt&quot;))&lt;br /&gt;&lt;br /&gt;(def limit (int 1e7))&lt;br /&gt;&lt;br /&gt;; Search around the radius of (sqrt 1e7)&lt;br /&gt;(def ps&lt;br /&gt;  (take-while #(&amp;lt;= % (* 2 (inc (isqrt limit)))) primes))&lt;br /&gt;&lt;br /&gt;; Create pairs for semi-primes&lt;br /&gt;(def pairs&lt;br /&gt;  (combinations ps 2))&lt;br /&gt;&lt;br /&gt;(defn permutation?&lt;br /&gt;  &quot;Returns true if a&#39;s digits are a permutation of b&#39;s.&quot;&lt;br /&gt;  [a b]&lt;br /&gt;  (let [digits #(sort (into [] (str %)))]&lt;br /&gt;    (= (digits a) (digits b))))&lt;br /&gt;&lt;br /&gt;(defn phi&lt;br /&gt;  &quot;Calculates the totient of a semi-prime created from p and q.&quot;&lt;br /&gt;  [p q]&lt;br /&gt;  (* (dec p) (dec q)))&lt;br /&gt;&lt;br /&gt;(defn f&lt;br /&gt;  &quot;Creates a map entry of n/phi(n) -&amp;gt; [p q].&quot;&lt;br /&gt;  [pair]&lt;br /&gt;  (let [p (first pair)&lt;br /&gt;        q (second pair)&lt;br /&gt;        n (* p q)]&lt;br /&gt;    [(/ n (phi p q)) [p q]]))&lt;br /&gt;&lt;br /&gt;(defn g&lt;br /&gt;  &quot;Returns true if the totient of the semi-prime generated from [p q] is a&lt;br /&gt;  permutation of that semi-prime.&quot;&lt;br /&gt;  [pair]&lt;br /&gt;  (let [p (first pair)&lt;br /&gt;        q (second pair)&lt;br /&gt;        n (* p q)]&lt;br /&gt;    (permutation? n (phi p q))))&lt;br /&gt;&lt;br /&gt;; Create a map of n/phi(n) -&amp;gt; [p q], filtering out semi-primes who are&lt;br /&gt;; larger than 1e7&lt;br /&gt;(def h&lt;br /&gt;  (filter #(&amp;lt;= (apply * (second %)) 10000000)&lt;br /&gt;          (apply merge (cons {} (map f pairs)))))&lt;br /&gt;&lt;br /&gt;(let [entry (first (drop-while #(not (g (second %))) (sort h)))&lt;br /&gt;      pair (second entry)&lt;br /&gt;      p (first pair)&lt;br /&gt;      q (second pair)]&lt;br /&gt;  (println (* p q)))&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;You can view the &lt;a href=&quot;https://github.com/retiman/project-euler/blob/master/clojure/70.clj&quot;&gt;full source here&lt;/a&gt;.</description><link>http://lousycoder.blogspot.com/2013/05/project-euler-70.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-3926418265041087268</guid><pubDate>Fri, 24 May 2013 03:26:00 +0000</pubDate><atom:updated>2013-05-30T23:22:52.746-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">math</category><category domain="http://www.blogger.com/atom/ns#">projecteuler</category><title>Project Euler #69: Totient maximum</title><description>Here is a &lt;a href=&quot;http://projecteuler.net/problem=69&quot;&gt;link to problem #69&lt;/a&gt;.  Basically this problem serves as a gentle introduction to Euler&#39;s totient function.  Just by looking at the definition you can get a hint about how to solve this problem.&lt;br /&gt;&lt;br /&gt;Note that:&lt;br /&gt;&lt;br /&gt;$$\phi(n) = n\prod_{p|n}(1 - \dfrac{1}{p})$$&lt;br /&gt;&lt;br /&gt;...a proof of which can be found on the &lt;a href=&quot;http://en.wikipedia.org/wiki/Totient&quot;&gt;wikipedia page for the totient function&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Armed with that, we can consider maximizing this value:&lt;br /&gt;&lt;br /&gt;$$\dfrac{n}{\phi(n)} = \dfrac{1}{\prod_{p|n}(1 - \dfrac{1}{p})}$$&lt;br /&gt;&lt;br /&gt;It is plain to see that to maximize that ratio, we have to minimize the denominator.  This will happen if there are a lot of $$p_{i}$$&#39;s and each of them are very small, so basically we can hunt for this number by taking the product of the first few primes  (a concept known as the &lt;a href=&quot;http://en.wikipedia.org/wiki/Primorial&quot;&gt;primorial&lt;/a&gt;) such that the product is under 1000000.&lt;br /&gt;&lt;br /&gt;As it turns out,&lt;br /&gt;&lt;br /&gt;$$p_{7}\# = 510510 &amp;lt; 1000000$$ and $$p_{8}\# = 9699690 &amp;gt; 1000000$$&lt;br /&gt;&lt;br /&gt;...so the number we want is 510510.</description><link>http://lousycoder.blogspot.com/2013/05/project-euler-69.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-4141882478398643837</guid><pubDate>Fri, 17 Feb 2012 06:51:00 +0000</pubDate><atom:updated>2014-07-22T16:06:31.580-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">java</category><title>Java Fun: When 128 != 128</title><description>I didn&#39;t discover this, but I did think it was fun to share:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;java&quot;&gt;public class JavaWTF {&lt;br /&gt;  public static void main(String[] args) {&lt;br /&gt;    System.out.println(isSame(127, 127));  // true&lt;br /&gt;    System.out.println(isSame(128, 128));  // false&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  private static boolean isSame(Integer i1, Integer i2) {&lt;br /&gt;    return i1 == i2;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;This is still true as of JDK 1.6.  Why is this so?  I took a look at the bytecode to see what&#39;s going on, and here&#39;s what we have:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;text&quot;&gt;Compiled from &quot;JavaWTF.java&quot;&lt;br /&gt;public class JavaWTF extends java.lang.Object{&lt;br /&gt;public JavaWTF();&lt;br /&gt;  Code:&lt;br /&gt;   0: aload_0&lt;br /&gt;   1: invokespecial #1; //Method java/lang/Object.&quot;&amp;lt;init&amp;gt;&quot;:()V&lt;br /&gt;   4: return&lt;br /&gt;&lt;br /&gt;public static void main(java.lang.String[]);&lt;br /&gt;  Code:&lt;br /&gt;   0: bipush  127&lt;br /&gt;   2: istore_1&lt;br /&gt;   3: getstatic #2; //Field java/lang/System.out:Ljava/io/PrintStream;&lt;br /&gt;   6: new #3; //class java/lang/Integer&lt;br /&gt;   9: dup&lt;br /&gt;   10:  iload_1&lt;br /&gt;   11:  invokespecial #4; //Method java/lang/Integer.&quot;&amp;lt;init&amp;gt;&quot;:(I)V&lt;br /&gt;   14:  new #3; //class java/lang/Integer&lt;br /&gt;   17:  dup&lt;br /&gt;   18:  iload_1&lt;br /&gt;   19:  invokespecial #4; //Method java/lang/Integer.&quot;&amp;lt;init&amp;gt;&quot;:(I)V&lt;br /&gt;   22:  if_acmpne 29&lt;br /&gt;   25:  iconst_1&lt;br /&gt;   26:  goto  30&lt;br /&gt;   29:  iconst_0&lt;br /&gt;   30:  invokevirtual #5; //Method java/io/PrintStream.println:(Z)V&lt;br /&gt;   33:  getstatic #2; //Field java/lang/System.out:Ljava/io/PrintStream;&lt;br /&gt;   36:  iload_1&lt;br /&gt;   37:  invokestatic  #6; //Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;&lt;br /&gt;   40:  iload_1&lt;br /&gt;   41:  invokestatic  #6; //Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;&lt;br /&gt;   44:  if_acmpne 51&lt;br /&gt;   47:  iconst_1&lt;br /&gt;   48:  goto  52&lt;br /&gt;   51:  iconst_0&lt;br /&gt;   52:  invokevirtual #5; //Method java/io/PrintStream.println:(Z)V&lt;br /&gt;   55:  return&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;(Incidentally, you can get this output by running &lt;tt&gt;javap -c JavaWTF&lt;/tt&gt;.)&lt;br /&gt;&lt;br /&gt;So basically, &lt;tt&gt;Integer.valueOf&lt;/tt&gt; is being called to do the &lt;tt&gt;Integer&lt;/tt&gt; boxing.  From the 1.6 JavaDocs, I see:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;hljs no-highlight&quot;&gt;public static Integer valueOf(int i)&lt;br /&gt;&lt;br /&gt;Returns a Integer instance representing the specified int value. If a new Integer instance is not required, this method should generally be used in preference to the constructor Integer(int), as this method is likely to yield significantly better space and time performance by caching frequently requested values.&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;So sometimes it returns cached values, and sometimes it doesn&#39;t.  If this functions returns an Integer via &lt;tt&gt;new Integer&lt;/tt&gt; all the time, then all &lt;tt&gt;==&lt;/tt&gt; comparisons will fail.  However, if it returns the same object for some invocations, we&#39;ll get the observed behavior.&lt;br /&gt;&lt;br /&gt;At this point, I was stuck - I didn&#39;t know where to go to look at some real Java 6 source code, but I bet the Apache Harmony guys knew a thing or two about all the quirks of the Java platform, so I took a peak at their &lt;tt&gt;Integer.java&lt;/tt&gt; class:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;java&quot;&gt;public static Integer valueOf(int i) {&lt;br /&gt;    if (i &lt; -128 || i &gt; 127) {&lt;br /&gt;        return new Integer(i);&lt;br /&gt;    }&lt;br /&gt;    return valueOfCache.CACHE [i+128];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;static class valueOfCache {&lt;br /&gt;    /**&lt;br /&gt;     * &amp;lt;p&amp;gt;&lt;br /&gt;     * A cache of instances used by {@link Integer#valueOf(int)} and auto-boxing.&lt;br /&gt;     */&lt;br /&gt;    static final Integer[] CACHE = new Integer[256];&lt;br /&gt;   &lt;br /&gt;    static {&lt;br /&gt;        for(int i=-128; i&lt;=127; i++) {&lt;br /&gt;            CACHE[i+128] = new Integer(i);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Ha!  So I guess &quot;most frequently used&quot; integers means any integer between -128 and 127 (not integers your program has used before).  No wonder!</description><link>http://lousycoder.blogspot.com/2012/02/java-fun-when-128-128.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-2034658544279830944</guid><pubDate>Wed, 21 Dec 2011 23:10:00 +0000</pubDate><atom:updated>2014-07-22T14:29:25.318-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">debian</category><category domain="http://www.blogger.com/atom/ns#">i3</category><category domain="http://www.blogger.com/atom/ns#">wmii</category><title>Goodbye wmii. Hello i3!</title><description>A colleague recently recommend &lt;a href=&quot;http://i3wm.org/&quot;&gt;i3&lt;/a&gt; to me, and I thought it was a rather good idea considering the problems I&#39;ve been having with &lt;a href=&quot;http://wmii.suckless.org/&quot;&gt;wmii&lt;/a&gt; (weirdly &lt;a href=&quot;https://github.com/retiman/homekeeper/blob/06e209238a639bd9ee693515516da68919b60644/dotfiles/wmii/wmiirc&quot;&gt;complicated&lt;/a&gt; configuration syntax, and problems with AWT).&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;wmii&lt;/h1&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-HBNAGBi9R-Y/UXm5EYFnJkI/AAAAAAAAbSs/HnFLm5N7sZs/s1600/wmii-java-broken.png&quot; imageanchor=&quot;1&quot; &gt;&lt;img border=&quot;0&quot; src=&quot;http://3.bp.blogspot.com/-HBNAGBi9R-Y/UXm5EYFnJkI/AAAAAAAAbSs/HnFLm5N7sZs/s320/wmii-java-broken.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;(Notice the dialog box is not rendered correctly on the bottom right)&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;i3&lt;/h1&gt;&lt;a href=&quot;http://1.bp.blogspot.com/--c-WOMLHLTg/UXm5I1gxXSI/AAAAAAAAbTE/XOwoahSz_jQ/s1600/i3-java-fixed.png&quot; imageanchor=&quot;1&quot; &gt;&lt;img border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/--c-WOMLHLTg/UXm5I1gxXSI/AAAAAAAAbTE/XOwoahSz_jQ/s320/i3-java-fixed.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The Swing problems are fixed in the HEAD of wmii&#39;s &lt;a href=&quot;http://code.google.com/p/wmii/issues/detail?id=5&quot;&gt;development branch&lt;/a&gt;, but I didn&#39;t notice that before I already committed to i3 (which is quite similar to wmii, but is &lt;a href=&quot;https://github.com/retiman/homekeeper/blob/master/dotfiles/i3/config&quot;&gt;less complicated&lt;/a&gt; to configure).&lt;br /&gt;&lt;br /&gt;In the Debian/Ubuntu repositories, the latest version of i3 is 3.e (I think), but due to the configuration changes between 3 and 4, there may be some confusion about how to set up a status bar.  The way to do it is to use &lt;tt&gt;i3status&lt;/tt&gt; with the &lt;tt&gt;bar&lt;/tt&gt; configuration directive with a 4.x+ release.  You&#39;ll have to grab both &lt;a href=&quot;http://code.i3wm.org/i3&quot;&gt;i3wm&lt;/a&gt; and &lt;a href=&quot;http://code.i3wm.org/i3status&quot;&gt;i3status&lt;/a&gt; from their respective repos and build the packages yourself.  On Squeeze, apply this patch to i3 version 4.1 to make sure it builds correctly:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;diff&quot;&gt;diff -rupN a/debian/control b/debian/control&lt;br /&gt;--- a/debian/control    2011-11-11 14:40:38.000000000 -0800&lt;br /&gt;+++ b/debian/control    2012-03-12 17:26:12.809273870 -0700&lt;br /&gt;@@ -3,7 +3,7 @@ Section: utils&lt;br /&gt; Priority: extra&lt;br /&gt; Maintainer: Michael Stapelberg &amp;lt;michael@stapelberg.de&amp;gt;&lt;br /&gt; DM-Upload-Allowed: yes   &lt;br /&gt;-Build-Depends: debhelper (&amp;gt;= 7.0.50~), libx11-dev, libxcb-util0-dev (&amp;gt;= 0.3.8), libxcb-ke&lt;br /&gt;ysyms1-dev, libxcb-xinerama0-dev (&amp;gt;= 1.1), libxcb-randr0-dev, libxcb-icccm4-dev, libxcurso&lt;br /&gt;r-dev, asciidoc (&amp;gt;= 8.4.4), xmlto, docbook-xml, pkg-config, libev-dev, flex, bison, libyaj&lt;br /&gt;l-dev, texlive-latex-base, texlive-latex-recommended, texlive-latex-extra, libpcre3-dev, l&lt;br /&gt;ibstartup-notification0-dev (&amp;gt;= 0.10)&lt;br /&gt;+Build-Depends: debhelper (&amp;gt;= 7.0.50~), libx11-dev, libxcb-aux0-dev, libxcb-atom1-dev, lib&lt;br /&gt;xcb-keysyms1-dev, libxcb-xinerama0-dev (&amp;gt;= 1.1), libxcb-randr0-dev, libxcb-icccm1-dev, lib&lt;br /&gt;xcursor-dev, asciidoc (&amp;gt;= 8.4.4), xmlto, docbook-xml, pkg-config, libev-dev, flex, bison,&lt;br /&gt;libyajl-dev, texlive-latex-base, texlive-latex-recommended, texlive-latex-extra, libpcre3-&lt;br /&gt;dev, libstartup-notification0-dev (&amp;gt;= 0.10)&lt;br /&gt; Standards-Version: 3.9.2&lt;br /&gt; Homepage: http://i3wm.org/&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;You can apply this patch and build with:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;cd i3-4.1&lt;br /&gt;patch -p0 &amp;lt; /path/to/i3.patch&lt;br /&gt;dpkg-buildpackage -uc -us&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;One other thing to note is that the i3status bar will not display correctly if there any errors; you also won&#39;t get any notification of errors if the font you specify is not correct (or missing).&lt;br /&gt;&lt;br /&gt;Here is the result of switching to i3:&lt;br /&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-5JSuDo_YBoA/UXm5I6oPf6I/AAAAAAAAbTI/luG7JTKanhg/s1600/i3-desktop.png&quot; imageanchor=&quot;1&quot; &gt;&lt;img border=&quot;0&quot; src=&quot;http://2.bp.blogspot.com/-5JSuDo_YBoA/UXm5I6oPf6I/AAAAAAAAbTI/luG7JTKanhg/s320/i3-desktop.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You can find my i3 configuration &lt;a href=&quot;https://github.com/retiman/homekeeper/blob/master/dotfiles/i3/config&quot;&gt;here&lt;/a&gt;.</description><link>http://lousycoder.blogspot.com/2011/12/goodbye-wmii-hello-i3.html</link><author>noreply@blogger.com (Min Huang)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-HBNAGBi9R-Y/UXm5EYFnJkI/AAAAAAAAbSs/HnFLm5N7sZs/s72-c/wmii-java-broken.png" height="72" width="72"/><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-8884789421220495953</guid><pubDate>Mon, 19 Sep 2011 02:47:00 +0000</pubDate><atom:updated>2013-04-23T18:55:38.324-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">git</category><category domain="http://www.blogger.com/atom/ns#">programming</category><title>Ditz bash completion</title><description>I just had an &quot;Oh, so that&#39;s how you do it&quot; moment.  The boss likes &lt;a href=&quot;http://ditz.rubyforge.org/&quot;&gt;ditz&lt;/a&gt; for issue management; but for a while, I&#39;ve been agonizing about how to do bash completion in ditz.  The answer is you have to source this file: &lt;tt&gt;/var/lib/gems/1.8/gems/ditz-0.5/contrib/completion/ditz.bash&lt;/tt&gt;.  Oh, so that&#39;s how you do it!</description><link>http://lousycoder.blogspot.com/2011/09/ditz-bash-completion.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-8533952577981809616</guid><pubDate>Thu, 28 Jul 2011 23:45:00 +0000</pubDate><atom:updated>2014-07-22T14:31:15.200-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">debian</category><category domain="http://www.blogger.com/atom/ns#">linux</category><title>Getting my Logitech headset to work in Debian</title><description>I&#39;m on Debian Squeeze at work, and I don&#39;t have any external speakers, but I do want to use a USB headset for pair programming and meetings and such.  Getting the headset to work with Skype actually pretty easy; you just do some clicky click GUI monkey business and you&#39;re set.  But having sound play for Youtube and other video sites (you know, stuff to do when NOT in meeting or pair programming), is trickier than I thought.&lt;br /&gt;&lt;br /&gt;Here&#39;s what I did.  First figure out which number the headset is:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;$ cat /proc/asound/cards&lt;br /&gt; 0 [Headset        ]: USB-Audio - Logitech USB Headset&lt;br /&gt;                      Logitech Logitech USB Headset at usb-0000:00:1d.1-1, full speed&lt;br /&gt; 1 [Intel          ]: HDA-Intel - HDA Intel&lt;br /&gt;                      HDA Intel at 0xfebdc000 irq 16&lt;br /&gt; 2 [HDMI           ]: HDA-Intel - HDA ATI HDMI&lt;br /&gt;                      HDA ATI HDMI at 0xfe9ec000 irq 17&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Okay, so it&#39;s index 0.  Then I made a new file called &lt;tt&gt;/etc/modprobe.d/sound&lt;/tt&gt; and jammed this text in it:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;options snd-usb-audio index=0&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;And then bingo bango bongo, there is sound in my Youtubes.</description><link>http://lousycoder.blogspot.com/2011/07/getting-my-logitech-headset-to-work-in.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-3571445826542227652</guid><pubDate>Mon, 09 May 2011 00:17:00 +0000</pubDate><atom:updated>2014-07-22T14:31:45.507-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">android</category><title>Using adb to copy files from your android device over wireless</title><description>Actually, I don&#39;t know why this is so hard.  I poked around in various forums and the android docs to deduce this process:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Install &lt;a href=&quot;http://developer.android.com/sdk/index.html&quot;&gt;android SDK&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Run &lt;tt&gt;tools/android&lt;/tt&gt; and install the platform tools.&lt;/li&gt;&lt;li&gt;The &lt;tt&gt;adb&lt;/tt&gt; tool will be under &lt;tt&gt;platform-tools/adb&lt;/tt&gt;.&lt;/li&gt;&lt;li&gt;Run the following as root: &lt;tt&gt;adb kill-server &amp;&amp; adb start-server&lt;/tt&gt;.&lt;/li&gt;&lt;li&gt;Download the &lt;a href=&quot;http://www.androidcentral.com/android-quick-app-adb-wireless&quot;&gt;adb wireless app&lt;/a&gt; and click the big green button.&lt;/li&gt;&lt;li&gt;Run &lt;tt&gt;adb connect xxx.xxx.xxx.xxx:5555&lt;/tt&gt;, and put the IP of your android device in there (the adb wireless app will show you what it is).&lt;/li&gt;&lt;li&gt;Push and pull stuff willy nilly!  Here&#39;s a &lt;a href=&quot;http://developer.android.com/guide/developing/tools/adb.html#copyfiles&quot;&gt;list of pertinent commands&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Run &lt;tt&gt;adb disconnect&lt;/tt&gt; and press the big red button.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;The main commands you&#39;ll be interested in are:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;adb shell ls / &lt;br /&gt;adb pull REMOTE LOCAL&lt;br /&gt;adb push LOCAL REMOTE&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;</description><link>http://lousycoder.blogspot.com/2011/05/using-adb-to-copy-files-from-your.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-5712264154189035618</guid><pubDate>Wed, 03 Nov 2010 23:30:00 +0000</pubDate><atom:updated>2014-07-22T14:32:38.156-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">clojure</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">maven</category><title>Showing transitive dependencies with Leiningen</title><description>When you specify a dependency on a Java library in Leiningen, you might pull in all sorts of random transitive dependencies (eg there are &lt;a href=&quot;http://tapestryjava.blogspot.com/2007/08/so-long-commons-logging-hello-slf4j.html&quot;&gt;no less than three logging frameworks/facades&lt;/a&gt; that could be pulled in).  Figuring out which artifacts pull in those transitive dependencies is a snap in Leiningen; just do this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;# Generate a pom for Maven to parse&lt;br /&gt;lein pom&lt;br /&gt;# Create a dependency tree with Maven&lt;br /&gt;mvn dependency:tree&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;You&#39;ll get some output that looks like this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;[INFO] +- org.clojure:clojure:jar:1.2.0:compile&lt;br /&gt;[INFO] +- org.clojure:clojure-contrib:jar:1.2.0:compile&lt;br /&gt;[INFO] +- org.clojars.sids:htmlcleaner:jar:2.1:compile&lt;br /&gt;[INFO] +- commons-lang:commons-lang:jar:2.5:compile&lt;br /&gt;[INFO] +- commons-io:commons-io:jar:1.4:compile&lt;br /&gt;[INFO] +- clj-file-utils:clj-file-utils:jar:0.1.2:compile&lt;br /&gt;[INFO] +- log4j:log4j:jar:1.2.15:compile&lt;br /&gt;[INFO] +- lein-daemon:lein-daemon:jar:0.2.1:compile&lt;br /&gt;[INFO] |  \- commons-daemon:commons-daemon:jar:1.0.1:compile&lt;br /&gt;[INFO] +- org.apache.hadoop:hadoop-core:jar:0.20.2-dev:compile&lt;br /&gt;[INFO] |  +- commons-logging:commons-logging:jar:1.0.4:compile&lt;br /&gt;[INFO] |  +- org.slf4j:slf4j-api:jar:1.4.3:runtime&lt;br /&gt;[INFO] |  +- org.slf4j:slf4j-log4j12:jar:1.4.3:runtime&lt;br /&gt;[INFO] |  +- commons-httpclient:commons-httpclient:jar:3.1:runtime&lt;br /&gt;[INFO] |  +- commons-cli:commons-cli:jar:1.2:compile&lt;br /&gt;[INFO] |  +- commons-net:commons-net:jar:1.4.1:runtime&lt;br /&gt;[INFO] |  |  \- oro:oro:jar:2.0.8:runtime&lt;br /&gt;[INFO] |  +- javax.servlet:servlet-api:jar:2.5:runtime&lt;br /&gt;[INFO] |  +- org.mortbay.jetty:jetty:jar:6.1.14:compile&lt;br /&gt;[INFO] |  |  +- org.mortbay.jetty:jetty-util:jar:6.1.14:compile&lt;br /&gt;[INFO] |  |  \- org.mortbay.jetty:servlet-api-2.5:jar:6.1.14:compile&lt;br /&gt;[INFO] |  +- org.mortbay.jetty:jsp-2.1:jar:6.1.14:compile&lt;br /&gt;[INFO] |  |  +- org.eclipse.jdt:core:jar:3.1.1:compile&lt;br /&gt;[INFO] |  |  \- ant:ant:jar:1.6.5:compile&lt;br /&gt;[INFO] |  +- org.mortbay.jetty:jsp-api-2.1:jar:6.1.14:compile&lt;br /&gt;[INFO] |  +- commons-el:commons-el:jar:1.0:runtime&lt;br /&gt;[INFO] |  +- org.apache.ant:ant:jar:1.7.0:runtime&lt;br /&gt;[INFO] |  |  \- org.apache.ant:ant-launcher:jar:1.7.0:runtime&lt;br /&gt;[INFO] |  +- net.java.dev.jets3t:jets3t:jar:0.6.1:runtime&lt;br /&gt;[INFO] |  \- xmlenc:xmlenc:jar:0.52:runtime&lt;br /&gt;[INFO] \- clj-http:clj-http:jar:0.1.1:compile&lt;br /&gt;[INFO]    +- org.apache.httpcomponents:httpclient:jar:4.0.1:compile&lt;br /&gt;[INFO]    |  \- org.apache.httpcomponents:httpcore:jar:4.0.1:compile&lt;br /&gt;[INFO]    \- commons-codec:commons-codec:jar:1.4:compile&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Easy peasy.</description><link>http://lousycoder.blogspot.com/2010/11/showing-transitive-dependencies-with.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-3368350752975126578</guid><pubDate>Tue, 02 Nov 2010 07:00:00 +0000</pubDate><atom:updated>2013-06-27T17:12:28.410-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">git</category><category domain="http://www.blogger.com/atom/ns#">programming</category><title>Tips for ignoring files with Git</title><description>There are 3 different ways to ignore files in Git:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Global: create a &lt;tt&gt;.gitignore&lt;/tt&gt; file in your home directory&lt;/li&gt;&lt;li&gt;Per project: create a &lt;tt&gt;.gitignore&lt;/tt&gt; file in the project&#39;s root source directory&lt;/li&gt;&lt;li&gt;Per project: create a &lt;tt&gt;.git/info/exclude&lt;/tt&gt; file in the project&#39;s hidden git directory&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;h1&gt;Update&lt;/h1&gt;Well... okay, so really, there are 4 ways, but the 4th way I haven&#39;t found a good use case for.&lt;br /&gt;&lt;br /&gt;Amazingly, this flexibility in design does have a purpose (I don&#39;t believe the original intention was for the developer to close his eyes and pick a gitignore to stick files in randomly).  The granularity offered in this design allows you to have a clear separation of what is generated by the build, and what is ignored by personal preference.  For example, you can commit a &lt;tt&gt;.gitignore&lt;/tt&gt; that only ignores logs and test output, while using a global gitignore file to ignore your vim or emacs swap files.&lt;br /&gt;&lt;br /&gt;If you don&#39;t pollute your project space with files or data that may not be useful to everybody, it&#39;s easier for new developers to jump onto your project and figure out what&#39;s going on without wading through the fluff.  For example, here&#39;s a &lt;a href=&quot;/2008/09/arguments-against-checking-in-your.html&quot;&gt;good reason&lt;/a&gt; for not checking in your &lt;tt&gt;.classpath&lt;/tt&gt; or &lt;tt&gt;.project&lt;/tt&gt; files in Eclipse.  Going one step further, it&#39;s probably not even a good idea to commit a gitignore file that names them.&lt;br /&gt;&lt;br /&gt;On a project with enough people, it&#39;s simply not feasible to commit a &lt;tt&gt;.gitignore&lt;/tt&gt; that names swap files for every editor, project files for every IDE, DS_Store for people who only use macs, thumb.db files for people who only use windows, and so on.  For smaller projects, it doesn&#39;t hurt anything, but there are other places where this information could possibly be stored.  Here is what I propose for each method of ignoring files:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Global &lt;tt&gt;.gitignore&lt;/tt&gt; should ignore your favorite editor&#39;s swap files, the &lt;tt&gt;.DS_Store&lt;/tt&gt; on a mac, or &lt;tt&gt;thumbs.db&lt;/tt&gt; on windows; basically anything you personally need ignored for every project.&lt;/li&gt;&lt;li&gt;Per project &lt;tt&gt;.gitignore&lt;/tt&gt; should ignore only files generated by the build (logs, test output, build targets).&lt;/li&gt;&lt;li&gt;Per project &lt;tt&gt;.git/info/exclude&lt;/tt&gt; should ignore files you personally need, but only for this project.  For example, if you are normally an Eclipse user, your global &lt;tt&gt;.gitignore&lt;/tt&gt; should contain the &lt;tt&gt;.classpath&lt;/tt&gt; and &lt;tt&gt;.project&lt;/tt&gt; files, but for a particular project where you must use Netbeans, consider placing the &lt;tt&gt;nbproject&lt;/tt&gt; directory in this file.&lt;/li&gt;&lt;/ol&gt;</description><link>http://lousycoder.blogspot.com/2010/11/tips-for-ignoring-files-with-git.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-783460559260498539</guid><pubDate>Sat, 23 Oct 2010 09:52:00 +0000</pubDate><atom:updated>2014-07-22T14:33:27.831-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">clojure</category><category domain="http://www.blogger.com/atom/ns#">vim</category><title>Installing VimClojure 2.2.0</title><description>I spent a good morning trying to figure out how to set this darned thing up so I could write some Clojure, so I&#39;m sure as hell going to document it in case somebody else wants to know (or I get one of those mind erasing kits and forget how to do this)!&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Install the VimClojure plugin&lt;/h1&gt;&lt;ol&gt;&lt;li&gt;Download the VimClojure script &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2501&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Unzip &lt;tt&gt;vimclojure-2.2.0.zip&lt;/tt&gt; in your &lt;tt&gt;~/.vim&lt;/tt&gt; directory, but take the files in the &lt;tt&gt;bin&lt;/tt&gt; directory and put them in your &lt;tt&gt;PATH&lt;/tt&gt; (in particular, you&#39;ll want the &lt;tt&gt;ng-server&lt;/tt&gt; script).&lt;/li&gt;&lt;li&gt;Add the following to your &lt;tt&gt;~/.vimrc&lt;/tt&gt;: &lt;tt&gt;let vimclojure#WantNailgun = 1&lt;/tt&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;h1&gt;Install the VimClojure Nailgun client&lt;/h1&gt;&lt;ol&gt;&lt;li&gt;Download the appropriate sources for VimClojure 2.2.0; they are located &lt;a href=&quot;http://kotka.de/projects/vimclojure/vimclojure-nailgun-client-2.2.0.zip.&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Unzip the sources and enter the &lt;tt&gt;vimclojure-nailgun-client&lt;/tt&gt; directory.&lt;/li&gt;&lt;li&gt;Run &lt;tt&gt;make&lt;/tt&gt; and move the generated binary into your &lt;tt&gt;PATH&lt;/tt&gt;.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;h1&gt;Install the VimClojure Nailgun server&lt;/h1&gt;You can get these from &lt;a href=&quot;&quot;&gt;Clojars&lt;/a&gt; using &lt;a href=&quot;http://github.com/technomancy/leiningen&quot;&gt;Leiningen&lt;/a&gt; or Maven.  For example, if you run &lt;tt&gt;lein deps&lt;/tt&gt; on a simple project like the one below, it will download the VimClojure server:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;clojure&quot;&gt;(defproject vimclojure-test &quot;1.0.0-SNAPSHOT&quot;     &lt;br /&gt;  :dependencies [[org.clojure/clojure &quot;1.2.0&quot;] [org.clojure/clojure-contrib &quot;1.2.0&quot;]]&lt;br /&gt;  :dev-dependencies [[vimclojure/server &quot;2.2.0&quot;]])&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h1&gt;Set up your environment to run the Nailgun server&lt;/h1&gt;Export the following environment variables, telling the &lt;tt&gt;ng-server&lt;/tt&gt; script where to find the server, Clojure, and the contrib libraries.  Here&#39;s what mine looks like:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;export CLOJURE_EXT=/opt/clojure:/opt/clojure-contrib/target:$M2_REPO/vimclojure/server/2.2.0&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h1&gt;Run the server and start Vim&lt;/h1&gt;Finally, you can run the &lt;tt&gt;ng-server&lt;/tt&gt; script, and write some Clojure with Vim!&lt;br /&gt;</description><link>http://lousycoder.blogspot.com/2010/10/installing-vimclojure-220.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-1419348133349715530</guid><pubDate>Tue, 21 Sep 2010 01:35:00 +0000</pubDate><atom:updated>2013-04-23T20:58:18.140-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">firefox</category><category domain="http://www.blogger.com/atom/ns#">javascript</category><category domain="http://www.blogger.com/atom/ns#">jquery</category><title>More considerations for using jQuery 1.4.2 in Firefox 3.5 extensions</title><description>I wrote about these considerations in an &lt;a href=&quot;http://lousycoder.com/blog/index.php?/archives/156-Considerations-for-using-jQuery-1.4.2-in-a-Firefox-3.5-extension.html&quot;&gt;earlier post&lt;/a&gt;, but that post only touched on the efforts involved to actually get it working in the first place.  There are more security issues to consider once it&#39;s actually done (no matter which route you&#39;ve taken to get things working).&lt;br /&gt;&lt;br /&gt;As background for this post, you are invited to read the MDC documentation about &lt;a href=&quot;https://developer.mozilla.org/en/XPCNativeWrapper&quot;&gt;XPCNativeWrapper&lt;/a&gt;, but it is not necessary.  Suffice it to say that it is not safe to manipulate DOM elements within privileged (aka chrome aka extension) code.  For example, if I, as a malicious web page author, have overridden &lt;tt&gt;document.getElementById&lt;/tt&gt; to do something nasty (or even something benign like &lt;tt&gt;alert(&quot;hi&quot;);&lt;/tt&gt;), when you use the &lt;tt&gt;document&lt;/tt&gt; object as a context in jQuery, you&#39;ll get &lt;em&gt;my&lt;/em&gt; behavior instead of the intended selection behavior.  This problem is circumvented by wrapping unsafe DOM elements from my webpage in a wrapper that does not allow unsafe function calls (hence the XPCNativeWrapper).&lt;br /&gt;&lt;br /&gt;The problem is that the wrapper limits access to unsafe properties, meaning that some properties that jQuery &lt;em&gt;could&lt;/em&gt; expect, &lt;em&gt;could&lt;/em&gt; be missing (depending on what you are doing).  A tempting alternative is to simply reference the &lt;tt&gt;wrappedJSObject&lt;/tt&gt; property of the wrapper, which will get you the underlying object, but that opens you up to a whole slew of injection attacks (so don&#39;t do it).&lt;br /&gt;&lt;br /&gt;I don&#39;t really have a solution for this either, outside of just making sure you only access what you need.  In my mind though, I think the best solution is to simply not use jQuery at all.&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;References&lt;/h1&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en/XPConnect_wrappers#XPCSafeJSObjectWrapper&quot;&gt;https://developer.mozilla.org/en/XPConnect_wrappers#XPCSafeJSObjectWrapper&lt;/a&gt;&lt;/li &gt;&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en/XPCNativeWrapper&quot;&gt;https://developer.mozilla.org/en/XPCNativeWrapper&lt;/a&gt;&lt;/li &gt;&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en/Safely_accessing_content_DOM_from_chrome&quot;&gt;https://developer.mozilla.org/en/Safely_accessing_content_DOM_from_chrome&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;</description><link>http://lousycoder.blogspot.com/2010/09/more-considerations-for-using-jquery.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-9126889638512804777</guid><pubDate>Thu, 09 Sep 2010 04:58:00 +0000</pubDate><atom:updated>2013-04-23T20:54:46.115-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">debian</category><category domain="http://www.blogger.com/atom/ns#">linux</category><title>Converting e-books to PDF</title><description>The &lt;tt&gt;djvulibre-bin&lt;/tt&gt; package allows you to convert djvu files in Debian.  You can covert these to ps files using &lt;tt&gt;djvups&lt;/tt&gt;, and then use &lt;tt&gt;ps2pdf&lt;/tt&gt; to convert them to pdf form.&lt;br /&gt;&lt;br /&gt;CHM files can be converted using &lt;tt&gt;chm2pdf&lt;/tt&gt;; just pass in the &lt;tt&gt;--book&lt;/tt&gt; or &lt;tt&gt;--webpage&lt;/tt&gt; switch and you&#39;re good to go.&lt;br /&gt;&lt;br /&gt;Time to normalize my e-book collection...</description><link>http://lousycoder.blogspot.com/2010/09/converting-e-books-to-pdf.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-8512544017203366613</guid><pubDate>Tue, 10 Aug 2010 20:04:00 +0000</pubDate><atom:updated>2014-07-22T14:35:11.767-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">hibernate</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">maven</category><category domain="http://www.blogger.com/atom/ns#">scala</category><title>Maven, Spring, Hibernate, Struts2, same old same old.. and what? Scala!</title><description>I recently had a project using the standard J2EE technology stack, but with an added twist of using Scala (in addition to Java).  It was relatively smooth, with a few gotchas, which I will note here.&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Lack of IDE support&lt;/h1&gt;I enjoy using vi much more than any of the Big Three IDEs for Java, so it wasn&#39;t as much of an issue for me, but my teammate was using IDEA, and he was having all sorts of problems (one reason is because one of the Scala plugins for IDEA seems to be completely busted as of this writing).  I did try researching the plugins for other IDEs, and I found the Eclipse plugin to be the most sensible (unsurprising, as most of the developers of Scala seem to be using Eclipse).&lt;br /&gt;&lt;br /&gt;If you have Scala code that depends on Java code, it&#39;s not much of a problem (as you can just compile the Java first, then compile the Scala).  On the flip side, if both Scala and Java code depend on each other, you&#39;ll have trouble in the form of red squiggly underlines in Netbeans and IDEA that &lt;em&gt;you simply cannot turn off&lt;/em&gt;.&lt;br /&gt;&lt;br /&gt;Luckily though...&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Maven support works beautifully&lt;/h1&gt;You won&#39;t have any trouble building your project from the command line with Maven - even if there are you have Scala and Java code with interdependencies.  Here&#39;s what I added to my POM, updated for Scala 2.8.0, to make the whole thing work:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;xml&quot;&gt;&amp;lt;plugin&amp;gt;&lt;br /&gt;  &amp;lt;groupId&amp;gt;org.scala-tools&amp;lt;/groupId&amp;gt;&lt;br /&gt;  &amp;lt;artifactId&amp;gt;maven-scala-plugin&amp;lt;/artifactId&amp;gt;&lt;br /&gt;  &amp;lt;version&amp;gt;2.12&amp;lt;/version&amp;gt;&lt;br /&gt;  &amp;lt;configuration&amp;gt;&lt;br /&gt;    &amp;lt;args&amp;gt;&lt;br /&gt;      &amp;lt;arg&amp;gt;-deprecation&amp;lt;/arg&amp;gt;&lt;br /&gt;      &amp;lt;arg&amp;gt;-unchecked&amp;lt;/arg&amp;gt;&lt;br /&gt;    &amp;lt;/args&amp;gt;&lt;br /&gt;  &amp;lt;/configuration&amp;gt;&lt;br /&gt;  &amp;lt;executions&amp;gt;&lt;br /&gt;    &amp;lt;execution&amp;gt;&lt;br /&gt;      &amp;lt;id&amp;gt;compile&amp;lt;/id&amp;gt;&lt;br /&gt;      &amp;lt;goals&amp;gt;&lt;br /&gt;        &amp;lt;goal&amp;gt;compile&amp;lt;/goal&amp;gt;&lt;br /&gt;      &amp;lt;/goals&amp;gt;&lt;br /&gt;      &amp;lt;phase&amp;gt;compile&amp;lt;/phase&amp;gt;&lt;br /&gt;    &amp;lt;/execution&amp;gt;&lt;br /&gt;    &amp;lt;execution&amp;gt;&lt;br /&gt;      &amp;lt;id&amp;gt;test-compile&amp;lt;/id&amp;gt;&lt;br /&gt;      &amp;lt;goals&amp;gt;&lt;br /&gt;        &amp;lt;goal&amp;gt;testCompile&amp;lt;/goal&amp;gt;&lt;br /&gt;      &amp;lt;/goals&amp;gt;&lt;br /&gt;      &amp;lt;phase&amp;gt;test-compile&amp;lt;/phase&amp;gt;&lt;br /&gt;    &amp;lt;/execution&amp;gt;&lt;br /&gt;    &amp;lt;execution&amp;gt;&lt;br /&gt;      &amp;lt;id&amp;gt;process-resources&amp;lt;/id&amp;gt;&lt;br /&gt;      &amp;lt;phase&amp;gt;process-resources&amp;lt;/phase&amp;gt;&lt;br /&gt;      &amp;lt;goals&amp;gt;&lt;br /&gt;        &amp;lt;goal&amp;gt;compile&amp;lt;/goal&amp;gt;&lt;br /&gt;      &amp;lt;/goals&amp;gt;&lt;br /&gt;    &amp;lt;/execution&amp;gt;&lt;br /&gt;    &amp;lt;execution&amp;gt;&lt;br /&gt;      &amp;lt;id&amp;gt;process-test-resources&amp;lt;/id&amp;gt;&lt;br /&gt;      &amp;lt;phase&amp;gt;process-test-resources&amp;lt;/phase&amp;gt;&lt;br /&gt;      &amp;lt;goals&amp;gt;&lt;br /&gt;        &amp;lt;goal&amp;gt;testCompile&amp;lt;/goal&amp;gt;&lt;br /&gt;      &amp;lt;/goals&amp;gt;&lt;br /&gt;    &amp;lt;/execution&amp;gt;&lt;br /&gt;  &amp;lt;/executions&amp;gt;&lt;br /&gt;&amp;lt;/plugin&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;If you put your sources in &lt;tt&gt;src/main/scala&lt;/tt&gt;, IDEs should be able to pick them up without a problem.&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;No more generating getters and setters&lt;/h1&gt;In Java, you&#39;d navigate through something like 5 menu options so the IDE could generate 20 lines of boilerplate to make your class a &quot;JavaBean&quot;.  The nice folks who wrote Scala understand your pain and offer the &lt;tt&gt;@BeanProperty&lt;/tt&gt; annotation:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;scala&quot;&gt;import scala.reflect.BeanProperty&lt;br /&gt;import java.io.Serializable&lt;br /&gt;import java.lang.{Long =&amp;gt; JLong}&lt;br /&gt;import java.lang.{Integer =&amp;gt; JInt}&lt;br /&gt;import javax.persistence._&lt;br /&gt;&lt;br /&gt;@Entity &lt;br /&gt;@Table(name = &quot;reviews&quot;)&lt;br /&gt;class Review extends Serializable {&lt;br /&gt;    @BeanProperty&lt;br /&gt;    @Id&lt;br /&gt;    @GeneratedValue(strategy = GenerationType.AUTO)&lt;br /&gt;    var id: JLong = _&lt;br /&gt;&lt;br /&gt;    @BeanProperty var rating: JInt = _&lt;br /&gt;    @BeanProperty var content: String = _&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;That&#39;s a standard Hibernate entity, written in Scala (Hibernate is none the wiser).  The &lt;tt&gt;@BeanProperty&lt;/tt&gt; annotation generates the &lt;tt&gt;getX&lt;/tt&gt; and &lt;tt&gt;setX&lt;/tt&gt; methods for you, so that Hibernate will be happy (the regular &lt;tt&gt;x&lt;/tt&gt; and &lt;tt&gt;x_=&lt;/tt&gt; Scala methods exist also).&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Hibernate really only wants the Java classes, dammit!&lt;/h1&gt;Notice in the above example that Hibernate will barf if you try to make your &lt;tt&gt;id&lt;/tt&gt; a &lt;tt&gt;scala.Long&lt;/tt&gt; instead of &lt;tt&gt;java.lang.Long&lt;/tt&gt;.  The same holds for other types like &lt;tt&gt;Double&lt;/tt&gt; and &lt;tt&gt;Float&lt;/tt&gt; (&lt;tt&gt;Integer&lt;/tt&gt; is &lt;tt&gt;Int&lt;/tt&gt; in Scala, but I made the import alias just to be explicit).&lt;br /&gt;&lt;br /&gt;Hibernate also really wants your collections to be Java collections instead of Scala collections.  You can still work with Scala collections, but you&#39;ll have to import implicit conversions for them:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;scala&quot;&gt;import scala.collection.JavaConversions._&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;For the performance wary, all that does is wrap the Java collections so you can interact with them in a more idiomatic way (it won&#39;t copy the collection).&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Struts2&lt;/h1&gt;Struts seems to work quite well with Scala.  Stacktraces will even show the specific line (in the Scala source) where the error occurred.  The only minor gotcha I had was that when your &lt;tt&gt;Action&lt;/tt&gt; classes extend &lt;tt&gt;ActionSupport&lt;/tt&gt;, the &lt;tt&gt;SUCCESS&lt;/tt&gt;, &lt;tt&gt;ERROR&lt;/tt&gt;, etc constants are not in scope.  You&#39;ll have to import them from &lt;tt&gt;Action&lt;/tt&gt; directly:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;scala&quot;&gt;import com.opensymphony.xwork2.Action._&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h1&gt;Conclusion&lt;/h1&gt;Opinions on the project varied on our 2 person team.  I was able to crank out much more code at a faster pace, but my coworker struggled a lot with the IDE support.  On the flip side, integrating Scala into a Java project was a heck of a lot smoother than I thought.&lt;br /&gt;&lt;br /&gt;</description><link>http://lousycoder.blogspot.com/2010/08/maven-spring-hibernate-struts2-same-old.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-4942945032062039439</guid><pubDate>Tue, 20 Jul 2010 06:25:00 +0000</pubDate><atom:updated>2014-07-22T14:36:20.134-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">linux</category><category domain="http://www.blogger.com/atom/ns#">wmii</category><title>Fix Java application focus issues by upgrading to wmii 3.9</title><description>I&#39;ve been using &lt;a href=&quot;http://wmii.suckless.org&quot;&gt;wmii&lt;/a&gt; as my window manager for quite a while now, and I like it a lot.  However, the latest version in Debian Lenny is 3.6, and it&#39;s quite dated.  I was made painfully aware of this fact when I discovered that Netbeans (yea, I know; I&#39;m forced to use it at work) would not regain focus after opening up a floating menu.  This little annoyance drove me nuts and caused me to upgrade to wmii-3.9, which could&#39;ve been a fairly painless process (but I like to make things hard on myself).  &lt;br /&gt;&lt;br /&gt;Firstly, installing the newer wmii is a relatively simple task: you&#39;ll want to grab the &lt;a href=&quot;http://dl.suckless.org/wmii/wmii+ixp-3.9.2.tbz&quot;&gt;3.9.2&lt;/a&gt; sources from &lt;a href=&quot;http://wmii.suckless.org/&quot;&gt;here&lt;/a&gt; (don&#39;t check them out of mercurial; it will only make the process more painful for you).  Then untar the tbz and issue the following commands in the source directory:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;make deb-dep&lt;br /&gt;make deb&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;The deb will be built for you in the directory above, and you can install it at your leisure.&lt;br /&gt;&lt;br /&gt;Secondly, configuring wmii could be a simple task, but I thought I&#39;d try out this new fangled Ruby &lt;a href=&quot;http://github.com/sunaku/rumai&quot;&gt;gem&lt;/a&gt; for configuring wmii.  It was a mistake.&lt;br /&gt;&lt;br /&gt;There&#39;s no documentation on which version of the gem the bundled config.yml is to work against, nor is it mentioned whether or not I should be using Ruby 1.8.7 or 1.9.1.  I would assume that it would work against both, but after hours of suffering through incessant broken pipe errors and trying to optimize the configuration (switching views taking almost half a second - wtf?!), I decided to just go with the bundled wmiirc configuration.&lt;br /&gt;&lt;br /&gt;As it turns out, the 3.9 configuration has changed, so my old wmiirc didn&#39;t work.  Upon closer examination, the changes weren&#39;t that huge, and I was able to port my old settings over pretty easily.&lt;br /&gt;&lt;br /&gt;You may see them &lt;a href=&quot;http://github.com/retiman/homekeeper/blob/master/dotfiles/wmii/wmiirc&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Update&lt;/h1&gt;Woops.  I recall the instructions say to do &lt;tt&gt;make deb&lt;/tt&gt;, but that doesn&#39;t work.  Try this instead:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;make deb-dep&lt;br /&gt;dpkg-buildpackage -us -uc -b&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;</description><link>http://lousycoder.blogspot.com/2010/07/fix-java-application-focus-issues-by.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-6008775611960597968</guid><pubDate>Wed, 07 Jul 2010 20:14:00 +0000</pubDate><atom:updated>2014-07-22T14:37:12.321-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">linux</category><category domain="http://www.blogger.com/atom/ns#">thinkpad</category><category domain="http://www.blogger.com/atom/ns#">wmii</category><title>Setting up my X100e with Debian Sid</title><description>I had some fun adventures putting Debian sid on my X100e!  I&#39;m eagerly awaiting the release of the 2.6.35 kernel (which has acpi support for the X100e amongst other yummy goodies), so I decided to dist-upgrade to sid (and use the 2.6.32 kernel in sid while waiting).  Oh!  But what wonderful adventures there were to be had!&lt;br /&gt;&lt;br /&gt;First of all, wmii was totally busted as it wouldn&#39;t respond to any commands involving my mod key (which is alt).  I noticed (using xev) that shift+alt did not register properly, so of course wmii wouldn&#39;t respond.  Here&#39;s the fix (don&#39;t ask me what it means):&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;setxkbmap -symbols &#39;pc+us+inet(evdev)+level3(ralt_switch)+ctrl(swapcaps)+compose(lwin)&#39;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Then I discovered that I couldn&#39;t use the middle mouse button to scroll with the trackpoint.  Since the &lt;tt&gt;xorg.conf&lt;/tt&gt; file has mostly gone the way of the dodo, here are the magic &lt;tt&gt;xinput&lt;/tt&gt; commands to get that working:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;xinput set-int-prop &#39;TPPS/2 IBM TrackPoint&#39; &#39;Evdev Wheel Emulation&#39; 8 1&lt;br /&gt;xinput set-int-prop &#39;TPPS/2 IBM TrackPoint&#39; &#39;Evdev Wheel Emulation Button&#39; 8 2&lt;br /&gt;xinput set-int-prop &#39;TPPS/2 IBM TrackPoint&#39; &#39;Evdev Wheel Emulation Timeout&#39; 8 200&lt;br /&gt;xinput set-int-prop &#39;TPPS/2 IBM TrackPoint&#39; &#39;Evdev Wheel Emulation Axes&#39; 8 6 7 4 5&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now, I just take all that stuff and jam it into my &lt;a href=&quot;http://github.com/retiman/homekeeper/blob/thinx/dotfiles/xinitrc&quot;&gt;xinitrc&lt;/a&gt;, then I never think about what any of it means and use wmii happily.&lt;br /&gt;&lt;br /&gt;Of course, I still had to build the fglrx kernel modules and modify the xorg.conf to make the video card sing:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;text&quot;&gt;Section &quot;Device&quot;&lt;br /&gt; Identifier &quot;Radeon 3200 HD&quot;&lt;br /&gt; Driver &quot;fglrx&quot;&lt;br /&gt; BusID &quot;PCI:1:5:0&quot;&lt;br /&gt; Option &quot;VideoOverlay&quot; &quot;on&quot;&lt;br /&gt; Option &quot;OpenGLOverlay&quot; &quot;off&quot;&lt;br /&gt;EndSection&lt;br /&gt;&lt;br /&gt;Section &quot;Screen&quot;&lt;br /&gt; Identifier &quot;Thinkpad Screen&quot;&lt;br /&gt; Monitor &quot;Thinkpad LCD&quot;&lt;br /&gt; DefaultDepth 24&lt;br /&gt;EndSection&lt;br /&gt;&lt;br /&gt;Section &quot;Monitor&quot;&lt;br /&gt; Identifier &quot;Thinkpad LCD&quot;&lt;br /&gt; Option &quot;DPMS&quot;&lt;br /&gt;EndSection&lt;br /&gt;&lt;br /&gt;Section &quot;ServerLayout&quot;&lt;br /&gt; Identifier &quot;Thinkpad Layout&quot;&lt;br /&gt; Screen &quot;Thinkpad Screen&quot;&lt;br /&gt; Option &quot;AIGLX&quot; &quot;true&quot;&lt;br /&gt;EndSection&lt;br /&gt;&lt;br /&gt;Section &quot;DRI&quot;&lt;br /&gt; Mode 0666&lt;br /&gt;EndSection&lt;br /&gt;&lt;br /&gt;Section &quot;Extensions&quot;&lt;br /&gt; Option &quot;Composite&quot; &quot;enable&quot;&lt;br /&gt;EndSection&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Critical result: HAPPY!</description><link>http://lousycoder.blogspot.com/2010/07/setting-up-my-x100e-with-debian-sid.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-8296634174196513098</guid><pubDate>Fri, 04 Jun 2010 23:21:00 +0000</pubDate><atom:updated>2014-07-22T14:37:55.398-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">linux</category><category domain="http://www.blogger.com/atom/ns#">thinkpad</category><title>Getting thinkpad_acpi to work in a X100e on Debian Lenny</title><description>When I booted up my X100e, I got a message that said &lt;tt&gt;thinkpad_acpi: Not yet supported thinkpad detected&lt;/tt&gt;.  To fix this, I had to apply a &lt;a href=&quot;http://www.mail-archive.com/ibm-acpi-devel@lists.sourceforge.net/msg02222.html&quot;&gt;patch&lt;/a&gt; to the linux kernel.  I was already using the &lt;tt&gt;2.6.30-bpo.2-amd64&lt;/tt&gt; kernel from &lt;tt&gt;lenny-backports&lt;/tt&gt;, so I could just copy my old kernel configuration over (because I&#39;m too lazy to tweak what comes with the stock kernel).&lt;br /&gt;&lt;br /&gt;There&#39;s a nice &lt;a href=&quot;http://newbiedoc.sourceforge.net/system/kernel-pkg.html&quot;&gt;newbie friendly tutorial&lt;/a&gt; that teaches you how to use &lt;tt&gt;make-kpkg&lt;/tt&gt;, but the skinny is this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;cd /usr/src/linux&lt;br /&gt;cp /boot/config-2.6.30-bpo.2-amd64 .config&lt;br /&gt;make oldconfig&lt;br /&gt;fakeroot make-kpkg clean&lt;br /&gt;fakeroot make-kpkg --initrd --append-to-version=.20100604 kernel_image&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Incidentally, the only file I needed to change was &lt;tt&gt;thinkpad_acpi.c&lt;/tt&gt;, and it is a module, so if anybody knows how I can do this without compiling the entire kernel, I&#39;d love to know.</description><link>http://lousycoder.blogspot.com/2010/06/getting-thinkpadacpi-to-work-in-x100e.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-5098673002134582594</guid><pubDate>Tue, 25 May 2010 19:28:00 +0000</pubDate><atom:updated>2013-04-25T16:07:19.943-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">firefox</category><category domain="http://www.blogger.com/atom/ns#">sql</category><title>Transaction behavior in Firefox 3.0 SQLite API</title><description>Small gotcha if you are writing a Firefox 3.0 extension: while SQLite lets you do nested transactions, multiple concurrent transactions, and checkpoints, the Firefox API doesn&#39;t fully support those.  The &lt;tt&gt;beginTransaction&lt;/tt&gt;, &lt;tt&gt;commitTransaction&lt;/tt&gt;, and &lt;tt&gt;rollbackTransaction&lt;/tt&gt; methods in &lt;a href=&quot;https://developer.mozilla.org/en/mozIStorageConnection&quot;&gt;mozIStorageConnection&lt;/a&gt; fully expect only one transaction to be active at a time (you&#39;ll get an exception if you try to nest transactions by beginning a transaction while another is active).&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Update&lt;/h1&gt;For 3.5, it looks like this is still true; there is even a note that says the underlying engine does not support nested transactions (possibly an older version of SQLite is in use.. darn).</description><link>http://lousycoder.blogspot.com/2010/05/transaction-behavior-in-firefox-30.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-4030577923640847026</guid><pubDate>Thu, 13 May 2010 05:06:00 +0000</pubDate><atom:updated>2014-07-22T14:39:23.358-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">firefox</category><title>Storing Numbers in nsIPrefService</title><description>Tip of the day: don&#39;t use &lt;a href=&quot;https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIPrefService&quot;&gt;nsIPrefService&lt;/a&gt; to store JavaScript Number objects when writing a Firefox extension.  Take a look at what happens in XPCShell:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;js&gt; var prefService = Components.classes[&quot;@mozilla.org/preferences-service;1&quot;].&lt;br /&gt;    getService(Components.interfaces.nsIPrefService);&lt;br /&gt;js&gt; var branch = prefService.getBranch(&quot;foo&quot;);&lt;br /&gt;js&gt; Date.now();&lt;br /&gt;1273727558711&lt;br /&gt;js&gt; branch.setIntPref(&quot;date&quot;, Date.now());&lt;br /&gt;js&gt; branch.getIntPref(&quot;date&quot;);&lt;br /&gt;-1877723439&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;The reason for this is that while JavaScript Number objects do not overflow, underlying ints in the C++ code that &lt;tt&gt;nsIPrefService&lt;/tt&gt; is implemented in certainly will.  I really should&#39;ve been tipped off by the &lt;tt&gt;setIntPref&lt;/tt&gt; method name =P</description><link>http://lousycoder.blogspot.com/2010/05/storing-numbers-in-nsiprefservice.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-3897626752407029729</guid><pubDate>Mon, 10 May 2010 09:41:00 +0000</pubDate><atom:updated>2014-07-22T14:40:42.117-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">firefox</category><title>Peeking inside Components.classes for Firefox 3.5.8</title><description>For the longest time, I had wondered what kind of magical smurfs, krakens, and leprechauns lived inside of &lt;tt&gt;Components.classes&lt;/tt&gt;; but today I felt like sort of an idiot because I realized I could just do this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;echo &quot;for(var p in Components.classes){print(p)}&quot; | xpcshell | sort &gt; cc.txt&lt;br /&gt;echo &quot;for(var p in Components.interfaces){print(p)}&quot; | xpcshell | sort &gt; ci.txt&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;The &lt;tt&gt;xpcshell&lt;/tt&gt; function is just a little bash function I have for running &lt;a href=&quot;https://developer.mozilla.org/en/XPConnect/xpcshell&quot;&gt;XPCShell&lt;/a&gt; (on Debian, XULRunner binaries are located in &lt;tt&gt;/usr/lib/xulrunner-1.9.1&lt;/tt&gt;; they may vary for the reader):&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;function xpcshell {&lt;br /&gt;  local DIR=/usr/lib/xulrunner-1.9.1&lt;br /&gt;  $DIR/run-mozilla.sh $DIR/xpcshell $@&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;This is a pretty good tool for testing extension code out, as long as you don&#39;t want to do anything with a ChromeWindow; it&#39;ll crash if you try to get fresh with it like that!&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;$ xpcshell&lt;br /&gt;[loading &#39;xpcshell.js&#39;...]&lt;br /&gt;js&gt; var app = Components.classes[&quot;@mozilla.org/appshell/appShellService;1&quot;].&lt;br /&gt;  getService(Components.interfaces.nsIAppShellService);&lt;br /&gt;js&gt; var uri = Components.classes[&quot;@mozilla.org/network/io-service;1&quot;].&lt;br /&gt;  getService(Components.interfaces.nsIIOService).&lt;br /&gt;  newURI(&quot;http://developer.mozilla.org&quot;, null, null);&lt;br /&gt;js&gt; app.createTopLevelWindow(null, uri, 0, 0, 0, null);&lt;br /&gt;&lt;br /&gt;(process:8032): Gdk-CRITICAL **: gdk_screen_get_rgb_visual: assertion `GDK_IS_SCREEN (screen)&#39; failed&lt;br /&gt;/usr/lib/xulrunner-1.9.1/run-mozilla.sh: line 131:  8032 Segmentation fault      &quot;$prog&quot; ${1+&quot;$@&quot;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h1&gt;Sources&lt;/h1&gt;&lt;a href=&quot;https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIAppShellService&quot;&gt;https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIAppShellService&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://developer.mozilla.org/En/NsIURL&quot;&gt;https://developer.mozilla.org/En/NsIURL&lt;/a&gt;&lt;br /&gt;</description><link>http://lousycoder.blogspot.com/2010/05/peeking-inside-componentsclasses-for.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-6454054591329695852</guid><pubDate>Fri, 23 Apr 2010 00:04:00 +0000</pubDate><atom:updated>2014-07-22T14:40:03.496-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">firefox</category><category domain="http://www.blogger.com/atom/ns#">javascript</category><category domain="http://www.blogger.com/atom/ns#">jquery</category><title>Considerations for using jQuery 1.4.2 in a Firefox 3.5 extension</title><description>Due to certain project requirements, I found myself using jQuery within a Firefox 3.5 extension, and boy was it a doozy.  The problem is that most Firefox extensions just dump a bunch of code inside the script tag of an &lt;a href=&quot;https://developer.mozilla.org/en/XUL_Overlays&quot;&gt;overlay&lt;/a&gt; on top of &lt;tt&gt;browser.xul&lt;/tt&gt; (see more discussion &lt;a href=&quot;http://www.lousycoder.com/blog/index.php?/archives/157-The-Anatomy-of-a-Firefox-Extension.html&quot;&gt;here&lt;/a&gt;).  The ramifications of this are that any &lt;tt&gt;var&lt;/tt&gt; you declare is global to the browser and to &lt;em&gt;any other extension the user has installed&lt;/em&gt;.  Some extensions, like Firebug, get around this by prefixing every global variable with &lt;tt&gt;FB_&lt;/tt&gt;, but this solution will not work with jQuery.&lt;br /&gt;&lt;br /&gt;If I decide to include jQuery in my overlay like so:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;xml&quot;&gt;&amp;lt;script src=&quot;chrome://myextension/content/jquery-1.4.2.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;...this leads to a variety of problems.  Firstly, jQuery will automatically set the &lt;tt&gt;window.jQuery&lt;/tt&gt; and &lt;tt&gt;window.$&lt;/tt&gt; variables in the &lt;em&gt;chrome window&lt;/em&gt;, overriding the values that were already there.  This is not a terrible problem for &lt;tt&gt;$&lt;/tt&gt; (which jQuery is nice enough to give it back to you via a call to &lt;tt&gt;jQuery.noConflict()&lt;/tt&gt;), but the &lt;tt&gt;jQuery&lt;/tt&gt; variable is overridden as well.  This poses a problem for other not-so-nice extensions that actually use jQuery in this rude manner.  For example, if I included jQuery 1.4.2 in my extension and you included jQuery 1.3.2, it would be a crapshoot to determine whose jQuery gets loaded (depends on the overlay loading order).&lt;br /&gt;&lt;br /&gt;A second problem for jQuery 1.4.2 is that it actually manipulates the DOM to test for the availability of certain features, which is a big no-no for overlays.  The DOM isn&#39;t actually available in a XUL document until &lt;em&gt;after&lt;/em&gt; all of the overlays have loaded (after all, the overlays themselves dictate elements that should be in the DOM).  If you try to access the DOM in an overlay, your overlay will silently not be loaded.  Incidentally, all JavaScript in overlays should be executed by an event handler to avoid this problem:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;window.addEventListener(&lt;br /&gt;  &quot;load&quot;,&lt;br /&gt;  function () {&lt;br /&gt;    // Do stuff after the overlay has loaded&lt;br /&gt;  },&lt;br /&gt;  false&lt;br /&gt;);&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;One horrific solution to this is to load jQuery in a load handler, and edit the &lt;em&gt;actual jQuery source&lt;/em&gt; to stop it from installing itself onto &lt;tt&gt;window&lt;/tt&gt;.  For the sadists out there, here&#39;s what it would look like:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;window.addEventListener(&lt;br /&gt;  &quot;load&quot;,     &lt;br /&gt;  function () {&lt;br /&gt;    Components.classes[&quot;@mozilla.org/moz/jssubscript-loader;1&quot;].&lt;br /&gt;      getService(Components.interfaces.mozIJSSubScriptLoader).&lt;br /&gt;      loadSubScript(&quot;chrome://myextension/content/jquery.js&quot;);&lt;br /&gt;  },&lt;br /&gt;  false&lt;br /&gt;);&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Of course, &lt;tt&gt;chrome://myextension/content/jquery.js&lt;/tt&gt; would have to be a modified version of jQuery that simply sets the &lt;tt&gt;jQuery&lt;/tt&gt; and &lt;tt&gt;$&lt;/tt&gt; in the current scope, rather than on &lt;tt&gt;window&lt;/tt&gt; itself.  The details of such a hack are omitted (though it&#39;s simply a 2 line change within the jQuery source).  This solution; however, still allows jQuery itself to run free and wild, doing who-knows-what to the DOM after it has loaded, which is fine and dandy for a webpage but potentially ... explosive for a &lt;a href=&quot;https://developer.mozilla.org/en/Working_with_windows_in_chrome_code&quot;&gt;chrome window&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Another solution is to get jQuery loading within a Firefox &lt;a href=&quot;https://developer.mozilla.org/en/JavaScript/Code_modules&quot;&gt;code module&lt;/a&gt;.  Code modules are &quot;sort of&quot; like Google Chrome&#39;s content scripts in that any code in a code module will execute in its own context (thus it is unable to stomp on code in overlays unless you explicitly tell it to), but Firefox code modules do not give you access to &lt;em&gt;any&lt;/em&gt; sort of DOM, so loading jQuery naively will cause exceptions to be thrown.                              &lt;br /&gt;&lt;br /&gt;So far, I have not found any acceptable solution to this problem.  The &quot;cleanest&quot; possible solution may be a &lt;a href=&quot;http://jsdom.org/&quot;&gt;jsdom&lt;/a&gt; style fake DOM (taking advantage of the Firefox internals to provide implementations such as &lt;tt&gt;nsIDOMDocument&lt;/tt&gt;, and &lt;tt&gt;&lt;a href=&quot;https://developer.mozilla.org/en/nsIXMLHttpRequest&quot;&gt;nsIXMLHttpRequest&lt;/a&gt;&lt;/tt&gt;) to fool jQuery, but that&#39;s a lot of work.&lt;br /&gt;&lt;br /&gt;A poster on the &lt;a href=&quot;http://forum.jquery.com/topic/jquery-1-4-2-inside-a-firefox-extension&quot;&gt;jQuery forums&lt;/a&gt;, &lt;a href=&quot;http://forum.jquery.com/user/chewie1024&quot;&gt;chewie1024&lt;/a&gt;, suggests giving jQuery a real live browser window within a code module by simply giving it a reference to the main browser window.  This solution is nice and simple:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;var EXPORTED_SYMBOLS = [&quot;jQuery&quot;, &quot;$&quot;];&lt;br /&gt;&lt;br /&gt;var windowMediator = Components&lt;br /&gt;  .classes[&quot;@mozilla.org/appshell/window-mediator;1&quot;]&lt;br /&gt;  .getService(Components.interfaces.nsIWindowMediator);            &lt;br /&gt;var enumerator = windowMediator.getEnumerator(&quot;navigator:browser&quot;);&lt;br /&gt;if (enumerator.hasMoreElements()) { &lt;br /&gt;  var window = enumerator.getNext();&lt;br /&gt;  var location = window.location;&lt;br /&gt;  var document = window.document;&lt;br /&gt;  break;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// jQuery source follows here...&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;...however, you&#39;ll still have to hack jQuery to make it not install itself on the &lt;tt&gt;window&lt;/tt&gt; object, and you&#39;ll have to live with the fact that jQuery will muck around with the DOM on that window.  On the flip side, you&#39;ll have jQuery in a code module that you can import into any overlay, in any scope you like.          &lt;br /&gt;&lt;br /&gt;One thing to note is that in the above solution, jQuery will keep a reference to that main window, and anything you do &lt;em&gt;with&lt;/em&gt; jQuery will be done on that window by default.  That is, make sure that you pass in a &lt;a href=&quot;http://api.jquery.com/jQuery/&quot;&gt;context&lt;/a&gt; to jQuery or it will be operating on &lt;em&gt;the wrong thing&lt;/em&gt;.  Another thing to note is that the window that jQuery keeps a reference to &lt;em&gt;can be closed&lt;/em&gt; and some of its members &lt;em&gt;could&lt;/em&gt; be garbage collected.  Unknown behavior will result if that is the case, so keep an eye out if you use this solution (because the symptoms will be seemingly random).&lt;br /&gt;&lt;br /&gt;In conclusion, I have no satisfactory solutions to this problem, so if anybody knows of one, please send me a message.</description><link>http://lousycoder.blogspot.com/2010/04/considerations-for-using-jquery-142-in.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-4982215190307434338</guid><pubDate>Mon, 19 Apr 2010 09:04:00 +0000</pubDate><atom:updated>2014-07-22T14:41:20.054-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">maven</category><title>Maven: building a JAR with all the dependencies</title><description>One of my colleagues has requested this information of me a few times; in retrospect, it is rather a complicated thing to have to do to achieve the desired effect.  Stick this into your &lt;tt&gt;pom.xml&lt;/tt&gt; under the &lt;tt&gt;build&lt;/tt&gt; section; it will create the JAR along bundled with all the dependencies during the &lt;tt&gt;package&lt;/tt&gt; phase:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;xml&quot;&gt;&amp;lt;build&amp;gt;&lt;br /&gt;  &amp;lt;plugins&amp;gt;&lt;br /&gt;    &amp;lt;plugin&amp;gt;&lt;br /&gt;      &amp;lt;artifactId&amp;gt;maven-assembly-plugin&amp;lt;/artifactId&amp;gt;&lt;br /&gt;      &amp;lt;configuration&amp;gt;&lt;br /&gt;        &amp;lt;appendAssemblyId&amp;gt;true&amp;lt;/appendAssemblyId&amp;gt;&lt;br /&gt;        &amp;lt;descriptorRefs&amp;gt;&lt;br /&gt;          &amp;lt;descriptorRef&amp;gt;jar-with-dependencies&amp;lt;/descriptorRef&amp;gt;&lt;br /&gt;        &amp;lt;/descriptorRefs&amp;gt;&lt;br /&gt;        &amp;lt;archive&amp;gt;&lt;br /&gt;          &amp;lt;manifest&amp;gt;&lt;br /&gt;            &amp;lt;mainClass&amp;gt;my.package.Main&amp;lt;/mainClass&amp;gt;&lt;br /&gt;          &amp;lt;/manifest&amp;gt;&lt;br /&gt;        &amp;lt;/archive&amp;gt;&lt;br /&gt;      &amp;lt;/configuration&amp;gt;&lt;br /&gt;      &amp;lt;executions&amp;gt;&lt;br /&gt;        &amp;lt;execution&amp;gt;&lt;br /&gt;          &amp;lt;id&amp;gt;make-assembly&amp;lt;/id&amp;gt;&lt;br /&gt;          &amp;lt;phase&amp;gt;package&amp;lt;/phase&amp;gt;&lt;br /&gt;          &amp;lt;goals&amp;gt;&lt;br /&gt;            &amp;lt;goal&amp;gt;assembly&amp;lt;/goal&amp;gt;&lt;br /&gt;          &amp;lt;/goals&amp;gt;&lt;br /&gt;        &amp;lt;/execution&amp;gt;&lt;br /&gt;      &amp;lt;/executions&amp;gt;&lt;br /&gt;    &amp;lt;/plugin&amp;gt;&lt;br /&gt;  &amp;lt;/plugins&amp;gt;&lt;br /&gt;&amp;lt;/build&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;</description><link>http://lousycoder.blogspot.com/2010/04/maven-building-jar-with-all-dependencies.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-5159192566556907745</guid><pubDate>Mon, 19 Apr 2010 06:20:00 +0000</pubDate><atom:updated>2014-07-22T14:41:46.408-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">firefox</category><title>Hiding XUL elements on OSX on Firefox 3.5.8</title><description>I was recently confused as to why the following code would not work in a XUL overlay:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;var foo = document.getElementById(&quot;foo&quot;);&lt;br /&gt;foo.style.display = &quot;none&quot;;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;In this case, the element &lt;tt&gt;foo&lt;/tt&gt; was a XUL element; not HTML.  Further investigation found that the above code worked on Windows and Linux builds of Firefox, but not OSX; only the following appeased the Firefox gods:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;var foo = document.getElementById(&quot;foo&quot;);&lt;br /&gt;foo.hidden = true;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;This does what you want on all platforms; not especially obvious from the austere &lt;a href=&quot;https://developer.mozilla.org/en/XUL/Attribute/hidden&quot;&gt;MDC article&lt;/a&gt;!</description><link>http://lousycoder.blogspot.com/2010/04/hiding-xul-elements-on-osx-on-firefox.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-4053271459798272419</guid><pubDate>Sun, 04 Apr 2010 23:46:00 +0000</pubDate><atom:updated>2014-07-22T14:42:01.460-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">linux</category><category domain="http://www.blogger.com/atom/ns#">thinkpad</category><title>Wireless for Thinkpad X100e</title><description>There&#39;s a bit of trickery involved in getting the wireless to work on one of those sexy &lt;a href=&quot;http://shop.lenovo.com/us/landing_pages/thinkpad/2010/X100e&quot;&gt;X100e&lt;/a&gt;s.  &lt;tt&gt;lspci&lt;/tt&gt; will give this output:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;text&quot;&gt;03:00.0 Network controller: Realtek Semiconductor Co., Ltd. Device 8172 (rev 10)&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;...but the driver you want is the &lt;a href=&quot;http://www.realtek.com.tw/downloads/downloadsView.aspx?Langid=1&amp;PNid=41&amp;PFid=9&amp;Level=6&amp;Conn=5&amp;DownTypeID=3&amp;GetDown=false&quot;&gt;RTL8192E&lt;/a&gt; driver from Realtek&#39;s download site.  &lt;tt&gt;make&lt;/tt&gt; and &lt;tt&gt;make install&lt;/tt&gt; it the normal way, and stick &lt;tt&gt;r8192se_pci&lt;/tt&gt; into your &lt;tt&gt;/etc/modules&lt;/tt&gt;.&lt;br /&gt;&lt;br /&gt;I had a problem with WEP and WPA2 encryption; I could connect fine but after 15 minutes or so, the connection would drop and there would be no way to reconnect.  I find that WPA works fine.&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Update&lt;/h1&gt;This didn&#39;t work from me unless I used a 2.6.30 kernel.</description><link>http://lousycoder.blogspot.com/2010/04/wireless-for-thinkpad-x100e.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-1055376301202625625</guid><pubDate>Sun, 04 Apr 2010 23:40:00 +0000</pubDate><atom:updated>2013-04-25T15:58:09.769-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">gaming</category><title>Transferring data from one PS3 to another</title><description>Recently, I wanted to transfer my 320GB drive from my old first generation PS3 to a PS3 slim.  My initial thought was: &quot;Oh, I&#39;ll just remove the hard drive from the old one and stick it in the new one&quot;.  Ha!  How misguided that effort was.  The data in a hard drive is tied to that system; if not, you could just clone a bunch of drives and play your friends&#39; PSN network games for free.&lt;br /&gt;&lt;br /&gt;My second idea was to use the PS3&#39;s backup tool to export all my data to an external drive, and then restore from my new PS3.  Unfortunately, that doesn&#39;t work either because you can&#39;t restore copy protected data and games to a different system (for the same reason as above).  Here&#39;s what I ended up doing:&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Deactivate the old system&lt;/h1&gt;I had been sharing games with my girlfriend and cousins, and I realized that if I did not deactivate the old system, my games would not work on the new one.  This is done through a &quot;hidden&quot; menu under Account Management.  This is actually a pretty important step!  If I had bought videos and never deactivated the system, then I&#39;d never be able to watch them in my new system =X&lt;br /&gt;&lt;br /&gt;In my particular case, the old system had firmware 3.15, which still retains the OtherOS feature.  By the time I wanted to deactivate my system though, the new 3.21 firmware had been released, and I didn&#39;t really want to upgrade and &lt;a href=&quot;http://blog.eu.playstation.com/2010/03/29/ps3-firmware-3-21-coming-april-1st/&quot;&gt;remove that feature&lt;/a&gt;.  I ended up &lt;a href=&quot;http://thezerogameproject.com/forum/fw-321-work-around-tested-and-working&quot;&gt;spoofing the version number&lt;/a&gt; so I could login and deactivate my stuff.&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Use the Data Transfer Utility&lt;/h1&gt;So Sony realized that people might want to transfer data from an old PS3 to a new one, especially if their old PS3&#39;s are getting the &lt;a href=&quot;http://boardsus.playstation.com/t5/PlayStation-3-General/Unofficial-Yellow-Light-of-Death-YLOD-Informative-Still-Thread-R/m-p/40726489&quot;&gt;YLOD&lt;/a&gt;.  Unfortunately, their solution is an extremely annoying one: connect the two PS3&#39;s via and ethernet cable and have one transfer the data over to the other.&lt;br /&gt;&lt;br /&gt;I didn&#39;t want to lose my copy protected save data, so I did it :(  The Data Transfer Utility is extremely finicky.  If you don&#39;t follow these instructions, it will not work.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Both PS3&#39;s must be firmware version 3.15 or greater&lt;/li &gt;&lt;li&gt;Connect both PS3s to the TV and then connect them via a network cable (can be CAT5 or crossover)&lt;/li &gt;&lt;li&gt;Turn them both on and use the Data Transfer Utility from the source PS3 first; don&#39;t touch the destination PS3&lt;/li &gt;&lt;li&gt;Follow the instructions until it tells you to set the destination PS3 to receive, then do so&lt;/li &gt;&lt;li&gt;With about 70GB of data to transfer, this took a few hours&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;h1&gt;Use the Backup Utility&lt;/h1&gt;After following the steps above, my new PS3 had all my old data, but it was on the Slim&#39;s 120GB drive instead of the 320GB drive I had in my old PS3.  I finally used the Backup Utility to move my data to an external drive, swapped out the Slim&#39;s 120GB drive for my larger one, and then restored the backup onto the same machine.&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Conclusion&lt;/h1&gt;Sony needs to store my savegames in a fucking cloud like Steam.</description><link>http://lousycoder.blogspot.com/2010/04/transferring-data-from-one-ps3-to.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3185832723933442141.post-6633892102579404780</guid><pubDate>Fri, 26 Mar 2010 02:30:00 +0000</pubDate><atom:updated>2014-07-22T14:42:53.079-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">firefox</category><title>The Anatomy of a Firefox 3.5 Extension</title><description>The directory structure of a Firefox 3.5.x extension looks like this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;text&quot;&gt;.&lt;br /&gt;   |-chrome&lt;br /&gt;   |---content&lt;br /&gt;   |---modules&lt;br /&gt;   |---skin&lt;br /&gt;   |-----css&lt;br /&gt;   |-----images&lt;br /&gt;   |-defaults&lt;br /&gt;   |---preferences&lt;br /&gt;   |-locale&lt;br /&gt;   |---en-US&lt;br /&gt;   |-chrome.manifest&lt;br /&gt;   |-install.rdf&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h1&gt;chrome.manifest&lt;/h1&gt;This structure is not mandated by Firefox; you&#39;ll have to let it know in your &lt;tt&gt;chrome.manifest&lt;/tt&gt;, which looks like this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;text&quot;&gt;content  myextension chrome/content/&lt;br /&gt;content  myextension chrome/content/ contentaccessible=yes&lt;br /&gt;locale   myextension en-US locale/en-US/&lt;br /&gt;skin     myextension classic/1.0 chrome/skin/&lt;br /&gt;resource myextension chrome/modules/&lt;br /&gt;overlay  chrome://browser/content/browser.xul chrome://myextension/content/myOverlay.xul&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Old versions of Firefox allowed you to serve up images with chrome URI&#39;s (ie, starting with &lt;tt&gt;chrome://&lt;/tt&gt;), but that feature was removed in Firefox 3.x.  To emulate the old behavior, you&#39;ll need to add &lt;tt&gt;contentaccessible=yes&lt;/tt&gt;.  Since older versions of Firefox don&#39;t recognize that &lt;tt&gt;contentaccessible&lt;/tt&gt; (in fact, they ignore it; see below), you&#39;ll need to put both lines in the manifest.&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;install.rdf&lt;/h1&gt;The manifest is for describing some things about your extension, but you&#39;ll have to put the rest of the information in a file called &lt;tt&gt;install.rdf&lt;/tt&gt;.  Here&#39;s a sample:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;xml&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot;?&amp;gt;                            &lt;br /&gt;&amp;lt;RDF xmlns:em=&quot;http://www.mozilla.org/2004/em-rdf#&quot; &lt;br /&gt;     xmlns=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot;&amp;gt;&lt;br /&gt;  &amp;lt;Description about=&quot;urn:mozilla:install-manifest&quot;&amp;gt;&lt;br /&gt;    &amp;lt;em:id&amp;gt;myextension@lousycoder.com&amp;lt;/em:id&amp;gt;&lt;br /&gt;    &amp;lt;em:name&amp;gt;My Extension&amp;lt;/em:name&amp;gt;&lt;br /&gt;    &amp;lt;em:version&amp;gt;1.0.0&amp;lt;/em:version&amp;gt;&lt;br /&gt;    &amp;lt;em:type&amp;gt;2&amp;lt;/em:type&amp;gt;&lt;br /&gt;    &amp;lt;em:targetApplication&amp;gt;&lt;br /&gt;      &amp;lt;Description&amp;gt;&lt;br /&gt;        &amp;lt;em:id&amp;gt;{ec8030f7-c20a-464f-9b0e-13a3a9e97384}&amp;lt;/em:id&amp;gt;&lt;br /&gt;        &amp;lt;em:minVersion&amp;gt;3.5&amp;lt;/em:minVersion&amp;gt;&lt;br /&gt;        &amp;lt;em:maxVersion&amp;gt;3.6.*&amp;lt;/em:maxVersion&amp;gt;&lt;br /&gt;      &amp;lt;/Description&amp;gt;  &lt;br /&gt;    &amp;lt;/em:targetApplication&amp;gt;&lt;br /&gt;    &amp;lt;em:aboutURL&amp;gt;chrome://myextension/content/about.xul&amp;lt;/em:aboutURL&amp;gt;&lt;br /&gt;    &amp;lt;em:iconURL&amp;gt;chrome://myextension/skin/images/logo.png&amp;lt;/em:iconURL&amp;gt;&lt;br /&gt;    &amp;lt;em:updateURL&amp;gt;https://www.lousycoder.com/update.rdf&amp;lt;/em:updateURL&amp;gt;&lt;br /&gt;    &amp;lt;em:creator&amp;gt;Me!&amp;lt;/em:creator&amp;gt;&lt;br /&gt;    &amp;lt;em:description&amp;gt;&lt;br /&gt;      A test extension for funsies.&lt;br /&gt;    &amp;lt;/em:description&amp;gt;&lt;br /&gt;    &amp;lt;em:homepageURL&amp;gt;http://www.writeonglass.com&amp;lt;/em:homepageURL&amp;gt;&lt;br /&gt;  &amp;lt;/Description&amp;gt;&lt;br /&gt;&amp;lt;/RDF&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Most of the data there is self explanatory, but the version numbers can be tricky when it comes to auto update.  Extension versions must follow a very specific format, and auto-update does some very complicated logic to determine which version is greater than another.  For example, version 1.0 is considered the same as version 1.1-1 (because 1 - 1 = 0); yes arithmetic is conveniently done for you!  Also, strings are compared bytewise instead of alphabetically.  For this reason, I would advise extension version strings to only consist of numbers and periods... &lt;em&gt;unless&lt;/em&gt; the extension is being hosted by &lt;a href=&quot;http://addons.mozilla.org&quot;&gt;AMO&lt;/a&gt; in the beta channel (in which case, version strings are ignored, and the newest version is the one last uploaded).&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Overlays&lt;/h1&gt;XUL overlays are &quot;merged&quot; with whatever XUL document you are overlaying onto; in the case above it would be &lt;tt&gt;chrome://browser/content/browser.xul&lt;/tt&gt;.  In this way, you can add menus and/or buttons to Firefox&#39;s UI.  There are special considerations for Javascript executing in the context of a browser overlay; for example, the &lt;tt&gt;window&lt;/tt&gt; refers to a chrome window, and the &lt;tt&gt;document&lt;/tt&gt; object refers to a XUL document, as opposed to their normal web page counterparts.  Additionally, setting any global variables on &lt;tt&gt;window&lt;/tt&gt; makes them available for other overlays (and extensions), so it&#39;s quite easy to clobber other extensions if you are not careful.&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Modules&lt;/h1&gt;Code modules are executed in their own context, and the global object is not any window.  In fact, the &lt;tt&gt;window&lt;/tt&gt; and &lt;tt&gt;document&lt;/tt&gt; objects are not even defined within code modules.  There is no way to clobber variables with other extensions, as the only variables exposed by a module are the ones declared in the special &lt;tt&gt;EXPORTED_SYMBOLS&lt;/tt&gt; array (see &lt;a href=&quot;https://developer.mozilla.org/En/Code_snippets/Modules&quot;&gt;modules at MDC&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Gotchas&lt;/h1&gt;If you have any syntax errors in your XUL files (eg the overlay files), your extension will be shown as installed, but no errors will appear in the Error Console.  If you open the XUL file directly in Firefox, via File -&gt; Open -&gt; file://path/to/xul/file.xul, you&#39;ll see any errors that Firefox did not report.&lt;br /&gt;&lt;br /&gt;If you do not place the trailing slash after any path in &lt;tt&gt;chrome.manifest&lt;/tt&gt; (eg &lt;tt&gt;chrome/content&lt;/tt&gt; instead of &lt;tt&gt;chrome/content/&lt;/tt&gt;), then Firefox will silently ignore that line in the manifest.&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;References&lt;/h1&gt;&lt;a href=&quot;https://developer.mozilla.org/en/Chrome_Registration&quot;&gt;https://developer.mozilla.org/en/Chrome_Registration&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://developer.mozilla.org/en/Toolkit_version_format&quot;&gt;https://developer.mozilla.org/en/Toolkit_version_format&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://developer.mozilla.org/index.php?title=en/Extension_Versioning,_Update_and_Compatibility&quot;&gt;https://developer.mozilla.org/index.php?title=en/Extension_Versioning,_Update_and_Compatibility&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://addons.mozilla.org/en-US/developers/docs/policies/maintenance#beta-addons&quot;&gt;https://addons.mozilla.org/en-US/developers/docs/policies/maintenance#beta-addons&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://developer.mozilla.org/En/Code_snippets/Modules&quot;&gt;https://developer.mozilla.org/En/Code_snippets/Modules&lt;/a&gt;</description><link>http://lousycoder.blogspot.com/2010/03/the-anatomy-of-firefox-35-extension.html</link><author>noreply@blogger.com (Min Huang)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></item></channel></rss>