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

<channel>
	<title>yusuketsutsumi</title>
	<atom:link href="http://yusuketsutsumi.parisaaalami.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://yusuketsutsumi.parisaaalami.com/blog</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Thu, 08 Mar 2012 01:18:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Passing perforce batch files</title>
		<link>http://yusuketsutsumi.parisaaalami.com/blog/?p=142&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=passing-perforce-batch-files</link>
		<comments>http://yusuketsutsumi.parisaaalami.com/blog/?p=142#comments</comments>
		<pubDate>Thu, 08 Mar 2012 01:17:44 +0000</pubDate>
		<dc:creator>tsutsumi</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://yusuketsutsumi.parisaaalami.com/blog/?p=142</guid>
		<description><![CDATA[My coworker showed this to me today: if you want to use a perforce command from the command line, and pass it a batch of filenames from a command (such as find or grep), simply use: p4 COMMAND ${ENTER_COMMAND_HERE}]]></description>
			<content:encoded><![CDATA[<p>My coworker showed this to me today: if you want to use a perforce command from the command line, and pass it a batch of filenames from a command (such as find or grep), simply use:</p>
<pre>p4 COMMAND ${ENTER_COMMAND_HERE}</pre>
]]></content:encoded>
			<wfw:commentRss>http://yusuketsutsumi.parisaaalami.com/blog/?feed=rss2&#038;p=142</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Automatic Package installation using ELPA in Emacs 24</title>
		<link>http://yusuketsutsumi.parisaaalami.com/blog/?p=138&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=automatic-package-installation-using-elpa-in-emacs-24</link>
		<comments>http://yusuketsutsumi.parisaaalami.com/blog/?p=138#comments</comments>
		<pubDate>Thu, 16 Feb 2012 23:59:48 +0000</pubDate>
		<dc:creator>tsutsumi</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://yusuketsutsumi.parisaaalami.com/blog/?p=138</guid>
		<description><![CDATA[Emacs 24 includes many improvements over 23, but there is one particular addition that makes me run around and go crazy with joy: a built-in package management system, ELPA (Emacs 24 is still in development, Bozhidar Batsov has a good guide &#8230; <a href="http://yusuketsutsumi.parisaaalami.com/blog/?p=138">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Emacs 24 includes many improvements over 23, but there is one particular addition that makes me run around and go crazy with joy: a built-in package management system, <a title="ELPA" href="http://tromey.com/elpa/" target="_blank">ELPA</a> (Emacs 24 is still in development, <a href="http://batsov.com/articles/2011/10/09/getting-started-with-emacs-24/" target="_blank">Bozhidar Batsov</a> has a good guide on how to get it set up). I switched over to Emacs almost a year ago, searching for something that would give me an IDE with the following attributes:</p>
<ul>
<li>Functionality (context-based completion, on the fly syntax checking)</li>
<li>Customization (key bindings, easily extensible)</li>
<li>Portability (minimal setup on new environments)</li>
</ul>
<p>There are a lot of nice extensions that do well for the first two. However, Portability was always tricky. To get some of the more power coding features in Emacs, one needed to install large packages, and there was no way to move these around short of zipping the whole thing up or finding and installing all these packages again.</p>
<p>ELPA completes the trifecta I have been looking for. It was now easy to have a list of packages to install. I have a GitHub repository to contain all of my .emacs setup, so I can just clone a repository with every new environment. To make the setup completely automatic, I needed a method to automatically install packages that did not exist. After a little research, I was able to figure it out:</p>
<pre>;; Packages to install first (check if emacs is 24 or higher)
(if (&gt;= emacs-major-version 24)
  (progn
  ;; Add a larger package list
    (setq package-archives '(("ELPA" . "http://tromey.com/elpa/")
      ("gnu" . "http://elpa.gnu.org/packages/")
      ("marmalade" . "http://marmalade-repo.org/packages/")))
       (package-refresh-contents)
       ;; Install flymake mode if it doesn't exist, then configure
       (when (not (require 'flymake nil t))
         (package-install 'flymake))
       (global-set-key (kbd "C-; C-f") 'flymake-mode)
       ;; flymake-cursor
       (when (not (require 'flymake-cursor nil t))
         (package-install 'flymake-cursor))
       ;; Install rainbow mode if it doesn't exist, then configure
       (when (not (require 'rainbow-mode nil t))
         (package-install 'rainbow-mode))
       (defun all-css-modes() (css-mode)
         (rainbow-mode))
       (add-to-list 'auto-mode-alist '("\\.css$" . all-css-modes))
    )
)</pre>
<p><strong>NOTE!!!</strong> This must be run after ALL OTHER INITIALIZATIONS are run! You can do this by placing it within a hook:</p>
<pre>(add-hook 'after-init-hook '(lambda ()
	  (load "~/.emacs.loadpackages"))) ;; anything within the lambda will run after everything has initialized.</pre>
<p>As you can see, I&#8217;ve put the above logic into a file called &#8220;.emacs.loadpackages&#8221;. This is so I can remove it at easy if I want a more bare environment.</p>
<p>I&#8217;d like to talk about this a little bit in detail. The first line ensures that emacs is version 24 or higher:</p>
<pre>(if (&gt;= emacs-major-version 24) PACKAGE_STUFF_HERE)</pre>
<p>I then add more repositories to the package manager, gnu and Marmalade (the base package is a bit limited, in my opinion)</p>
<pre>(setq package-archives '(
    ("ELPA" . "http://tromey.com/elpa/")
    ("gnu" . "http://elpa.gnu.org/packages/")
    ("marmalade" . "http://marmalade-repo.org/packages/")))</pre>
<p>This requires a refresh:</p>
<pre>(package-refresh-contents)</pre>
<p>And then onto the logic to see if a package exists! You can use require to see if a package exists, nullifying the error message it usually return by adding the true statement at the end. For example, this will return true when the package fly-make cursor is not installed:</p>
<pre>(not (require 'flymake-cursor nil t))</pre>
<p>You can then add this to a complete clause:</p>
<pre>(when (not (require 'flymake-cursor nil t))
    (package-install 'flymake-cursor))</pre>
<p>And you&#8217;re done!</p>
<h2>Issues:</h2>
<p>There a couple of things I&#8217;m still working on regarding this setup. Although I haven&#8217;t gotten any environment breaking errors so far, there&#8217;s not a lot of error checking, so I&#8217;m sure it can break if things are not completely right. In addition, this does not work very well for portable programmers, as Emacs will try to initialize ELPA, resulting in an exception due to not being able to contact the server.</p>
<p>Please leave comments and suggestions!</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://yusuketsutsumi.parisaaalami.com/blog/?feed=rss2&#038;p=138</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Python Pet Peeves</title>
		<link>http://yusuketsutsumi.parisaaalami.com/blog/?p=128&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=python-pet-peeves</link>
		<comments>http://yusuketsutsumi.parisaaalami.com/blog/?p=128#comments</comments>
		<pubDate>Thu, 26 Jan 2012 19:14:14 +0000</pubDate>
		<dc:creator>tsutsumi</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://yusuketsutsumi.parisaaalami.com/blog/?p=128</guid>
		<description><![CDATA[As of this posting, Python has been my main programming language for over three years. Although I definitely feel that Python is not a good fit for all programming projects, the speed and efficiency with which I can code in &#8230; <a href="http://yusuketsutsumi.parisaaalami.com/blog/?p=128">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As of this posting, Python has been my main programming language for over three years. Although I definitely feel that Python is not a good fit for all programming projects, the speed and efficiency with which I can code in it has made it my go-to language whenever possible.</p>
<p>As such, I&#8217;ve seen a lot of Python code, and have had ample time to think about some of the more nuanced issues regarding coding standards. Here&#8217;s a few of my pet peeves, and opinions about them:</p>
<h4>from module import *</h4>
<p>When I first started python, I used this particular import for a lot of things. I&#8217;m using so many methods from this module, why not just import the whole thing? It was definitely a pain in the neck fixing those include issues.</p>
<p>Well, time in the industry has made me realize the error of my ways. This isn&#8217;t just python related, this is related to any programming language. <strong>Includes/Import should always be as obvious as possible</strong>. The correct import methodology, is to do as such:</p>
<pre>from module import w,x,y,z</pre>
<p>or, if you want to be even nicer:</p>
<pre>import module
module.x()</pre>
<p>But what if we&#8217;re using ten methods from that module? still gotta do it.<br/><br />
What about 20 methods? still gotta do it<br/><br />
What about 100 methods? don&#8217;t know how there&#8217;s 100 methods in a single module, but <strong>you still gotta do it</strong>.<br/> </p>
<p>The reasoning is simple: you&#8217;re providing a very helpful hint that future coders can use to debug your code years from now. That hint is : where the method is actually found.</p>
<p>While you yourself don&#8217;t save any time off of doing this, you&#8217;re saving hours of development time for future coders, giving them a roadmap to exactly what your function&#8217;s stack actually is. Although this can be given by any IDE that has an understanding of the language and it&#8217;s dependencies, one shouldn&#8217;t assume that this is so. In my experience, when debugging, I have spent anywhere between a good ten to twenty minutes looking for methods, especially in python files with twenty lines of imports. To know exactly where a particular method or module comes from goes a long way to making one&#8217;s code maintainable.</p>
<p>For example, suppose I was a programmer who had to debug, and was able to pinpoint the bug to a method that had been previously written, called a_func. The file calling it looks like:</p>
<pre>from foo import *
from bar import *

def b_func():
    ...
    a_func()
    ...
    return</pre>
<p>Now if I had no knowledge of the modules foo and bar, I would have to look through BOTH foo and bar, and see if either of those had the function a_func. This is only a minor inconvenience if your code only has two of these imports, but the larger a script gets, and the more includes it brings in over the years, could result in one having to look through several files in various locations, to debug one call. Precious time that could have been saved, had the original code just written:</p>
<pre>from bar import a_func</pre>
<h4>Use ternary&#8217;s, but only where it makes sense</h4>
<p>If you&#8217;re not familiar with tenary operators, I&#8217;d suggest acquainting yourself now. After all, ternary operators only exist because the problem they solve is so prevalent in coding everywhere. Specifically, the strict point where you want a variable to be one of two things. In Python, ternary operators are represented differently than other programming languages (the typical ( condition ? do_this_if_true : do_this_if_false ) operation). Python has:</p>
<pre>do_this_if_true if condition else do_this_if_false</pre>
<p>Ternary&#8217;s in general have several uses. The big one is providing a default value:</p>
<pre>var = (value if value else default_value)</pre>
<p>Basically, in any situation where you have:</p>
<pre>if this:
	just_one_procedure()
else:
	just_one_other_procedure()</pre>
<p>One should consider using a ternary. You can also nested ternarys, although I wouldn&#8217;t suggest doing so for more than one level deep. This is especially useful when you have a variable assignment with four different possible outcomes:</p>
<pre>x = ( (1 if a else 0) if b
else (2 if c else 3))</pre>
<p>To do so with regular if else statements, one would need ten lines of logic. Ternarys are a lesser known function within Python, and it belongs in any programmer&#8217;s set of tools.</p>
]]></content:encoded>
			<wfw:commentRss>http://yusuketsutsumi.parisaaalami.com/blog/?feed=rss2&#038;p=128</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Search and replace multi-line expressions with SED</title>
		<link>http://yusuketsutsumi.parisaaalami.com/blog/?p=111&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=search-and-replace-multi-line-expressions-with-sed</link>
		<comments>http://yusuketsutsumi.parisaaalami.com/blog/?p=111#comments</comments>
		<pubDate>Wed, 26 Oct 2011 23:55:10 +0000</pubDate>
		<dc:creator>tsutsumi</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Installation/Configuration]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://toumorokoshi.wordpress.com/?p=111</guid>
		<description><![CDATA[Now here&#8217;s an interesting problem: I wanted to do a recursive search and replace in unix, AND I wanted to do an expression that spans multiple lines. Here&#8217;s what I came up with: find ./ -type f &#124; xargs sed &#8230; <a href="http://yusuketsutsumi.parisaaalami.com/blog/?p=111">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Now here&#8217;s an interesting problem:<br />
I wanted to do a recursive search and replace in unix, AND I wanted to do an expression that spans multiple lines. Here&#8217;s what I came up with:</p>
<pre>find ./ -type f | xargs sed -E -i -n
'1h;1!H;${;g;s/&lt;/fileSet&gt;.*&lt;fileSet&gt;.*RevisionVersion.*
&lt;/fileSet&gt;.*&lt;/fileSets&gt;/&lt;/fileSet&gt;n&lt;/fileSets&gt;/g;p}'</pre>
<p>There a lot of examples showing you how to do this.<br />
The first argument lists all files recursively. These are the piped to sed, which uses an inline search and replace (-i or &#8211;in-line), then using the expression &#8216;{}&#8217; which is then modified for multi-line expressions (1h;1!H;).</p>
]]></content:encoded>
			<wfw:commentRss>http://yusuketsutsumi.parisaaalami.com/blog/?feed=rss2&#038;p=111</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WebPageTest and IE9</title>
		<link>http://yusuketsutsumi.parisaaalami.com/blog/?p=105&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=webpagetest-and-ie9</link>
		<comments>http://yusuketsutsumi.parisaaalami.com/blog/?p=105#comments</comments>
		<pubDate>Tue, 25 Oct 2011 00:25:56 +0000</pubDate>
		<dc:creator>tsutsumi</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://toumorokoshi.wordpress.com/?p=105</guid>
		<description><![CDATA[Recently, I tried updating the browser for a WebPageTest instance to IE9. This proved to have some issues, specifically due to the pop-up dialogues that IE9 has now to tell you when something suspicious occurs. Logging into WPT, I was &#8230; <a href="http://yusuketsutsumi.parisaaalami.com/blog/?p=105">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Recently, I tried updating the browser for a WebPageTest instance to IE9. This proved to have some issues, specifically due to the pop-up dialogues that IE9 has now to tell you when something suspicious occurs.</p>
<p>Logging into WPT, I was greeted with an error on an IE9 browser opened by URLblast. Something along the lines of:<br />
&#8220;Are you sure you want to use this Non-Verified plugin?&#8221;</p>
<p>Of course, the non-verified plugin was the WebPageTest hook. In order to get that working, I modified the security settings on my browser to not care about non-verified plugins:</p>
<p>Internet Options (clicking on that gear icon in IE9) -&gt; Security -&gt; Custom Level.</p>
<p>I modified two settings:</p>
<ul>
<li>&#8220;Download unsigned ActiveX controls&#8221; to Enable (not secure)</li>
<li>&#8220;Initialize and script ActiveX controls not marked as safe for scripting&#8221; to Enable (not secure)</li>
</ul>
<p>This then brought me to another error, with IE9 complaining about not using secure settings. Something like:</p>
<p>&#8220;Your current settings are insecure&#8221;</p>
<p>Well, after some searching, there&#8217;s apparently a policy that you can set that disables this specific message:</p>
<p>http://windowsconnected.com/forums/p/959/3087.aspx#3087</p>
<p>Basically it says:</p>
<p>Run gpedit.msc (if you type &#8216;gpedit.msc&#8217; in the search bar it comes up)</p>
<p>Then Navigate to Computer Configuration -&gt; Administrative Templates -&gt; Windows Components -&gt; Internet Exporer, and right click and enable the &#8220;Turn off the Security Settings Check feature&#8221; policy.</p>
<p>This gets rid of the error, but then WebPageTest just seems to freeze on a run. After some more searching, there was one final step in the solution. It seems that urlblast has to open the browser using the user&#8217;s account. By default, urlblast creates and uses a specific account on which it opens a browser, not necessarily the user that is running urlblast. Having the account opening the browser be an administrator did the trick, and in my situation, I just had it be the same account running urlblast. This can be done with a change in urlblast.ini:</p>
<pre>
Use Current Account=1
</pre>
<p>And that did it for me!</p>
]]></content:encoded>
			<wfw:commentRss>http://yusuketsutsumi.parisaaalami.com/blog/?feed=rss2&#038;p=105</wfw:commentRss>
		<slash:comments>222</slash:comments>
		</item>
		<item>
		<title>Getting Python2.5 to Build with sqlite3 and zlib on Ubuntu Natty 2.5</title>
		<link>http://yusuketsutsumi.parisaaalami.com/blog/?p=53&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=getting-python2-5-to-build-with-sqlite3-and-zlib-on-ubuntu-natty-2-5</link>
		<comments>http://yusuketsutsumi.parisaaalami.com/blog/?p=53#comments</comments>
		<pubDate>Mon, 19 Sep 2011 19:21:28 +0000</pubDate>
		<dc:creator>tsutsumi</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Python2.5]]></category>
		<category><![CDATA[sqlite3]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[zlib]]></category>

		<guid isPermaLink="false">http://toumorokoshi.wordpress.com/?p=53</guid>
		<description><![CDATA[I had a really hard time finding this, so I&#8217;m posting it here: First one must install all the proper packages on Natty (these are the packages needed for zlib and sqlite in general, not just specifically for Python): sudo &#8230; <a href="http://yusuketsutsumi.parisaaalami.com/blog/?p=53">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I had a really hard time finding this, so I&#8217;m posting it here:</p>
<p>First one must install all the proper packages on Natty (these are the packages needed for zlib and sqlite in general, not just specifically for Python):</p>
<pre>sudo apt-get install zlibc zlib1g zlib1g-dev
sudo apt-get install sqlite3-dev</pre>
<p>Then one must add an LDFlag to the new lib directories (apparently Natty has a new directory for X86_64 lib files):</p>
<pre>after the ./configure open your Makefile and find the line with
LDFLAGS =

edit to LDFLAGS = -L/usr/lib//x86_64-linux-gnu

and make</pre>
<p>Credit for the above snippet goes to Awin Abi and source is below:</p>
<p>http://groups.google.com/group/google-appengine/browse_thread/thread/a8bd0a71270a3ce6</p>
<p>Basically, setting up Python2.5 ( and presumably any version of Python) properly involves downloading the proper package libraries , then building Python2.5 with those packages. In order to do this, the LDFlags variable must have the new library location (the /usr/lib/x86-64-linux-gnu) for Natty and 64-bit processors added.</p>
<p>I have not tried this on a 32-bit machine. This may not be required then, or you may need to point the flag to load the proper directory.</p>
]]></content:encoded>
			<wfw:commentRss>http://yusuketsutsumi.parisaaalami.com/blog/?feed=rss2&#038;p=53</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My IDE in Emacs (mainly for Python)</title>
		<link>http://yusuketsutsumi.parisaaalami.com/blog/?p=86&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=my-ide-in-emacs-mainly-for-python</link>
		<comments>http://yusuketsutsumi.parisaaalami.com/blog/?p=86#comments</comments>
		<pubDate>Tue, 23 Aug 2011 00:26:56 +0000</pubDate>
		<dc:creator>tsutsumi</dc:creator>
				<category><![CDATA[Emacs]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://toumorokoshi.wordpress.com/?p=86</guid>
		<description><![CDATA[I&#8217;m writing this article up to mainly keep track of the current state of my IDE in Emacs, how to set one up, and to keep my to-do list. Implemented Features Default Emacs Library Includes I use the following from &#8230; <a href="http://yusuketsutsumi.parisaaalami.com/blog/?p=86">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m writing this article up to mainly keep track of the current state of my IDE in Emacs, how to set one up, and to keep my to-do list.</p>
<h2>Implemented Features</h2>
<h5>Default Emacs Library Includes</h5>
<p>I use the following from the library that comes with Emacs (as of version 23)</p>
<ul>
<li>Viper-mode (viper-mode 3, though I&#8217;m sure 5 would be good too)</li>
<li>Windmove (through keybindings, for moving around windows easier)</li>
<li>hideshow (for code folding)</li>
<li>ibuffer (for listing on buffers when buffer switching)</li>
<li>ido (for listing of file in a directory in the minibuffer</li>
</ul>
<div>
<p>Code to instantiate:</p>
<pre>(setq viper-mode t)
(require 'viper)
(load-library "hideshow")
(add-hook 'python-mode-hook 'hs-minor-mode)
(require 'ido)
(ido-mode 'both)</pre>
</div>
<h5>Keybindings</h5>
<pre>(global-set-key (kbd "C-x C-l") 'windmove-right)
(global-set-key (kbd "C-x C-h") 'windmove-left)
(global-set-key (kbd "C-x C-k") 'windmove-up)
(global-set-key (kbd "C-x C-j") 'windmove-down)
(global-set-key (kbd "C-x C-;") 'hippie-expand)
(global-set-key (kbd "C-x C-g") 'find-name-dired)
(global-set-key (kbd "C-c C-t") 'ansi-term)</pre>
<h5>Viper Keybindings (in .viper)</h5>
<pre>(setq viper-expert-level '3)
(setq viper-inhibit-startup-message 't)
(setq-default indent-tabs-mode nil) ; I think this makes tabs into spaces
(setq viper-shift-width 4) ; don't touch or else...

;; Makes searching w/ regex default
(setq viper-re-search t) ; don't touch or else...

;; The following is for hideshow to work ALMOST similar to vi folding
;; (there were keybindings I didn't like)
(define-key viper-vi-global-user-map "zt" 'hs-toggle-hiding)
(define-key viper-vi-global-user-map "zM" 'hs-hide-all)
(define-key viper-vi-global-user-map "zm" 'hs-hide-block)
(define-key viper-vi-global-user-map "zR" 'hs-show-all)
(define-key viper-vi-global-user-map "zr" 'hs-show-block)</pre>
<h2>Features implemented using external files</h2>
<h5>Yasnippet (for bundling and snippets)</h5>
<p>Yasnippet provides me features along the lives of textmates bundling, which I think definitely makes things faster in the long run. After all, who wants to write boilerplate code?<br />
<a title="textmate bundling" href="http://manual.macromates.com/en/bundles">http://manual.macromates.com/en/bundles</a><br />
Yasnippet site:<br />
<a title="Yasnippet" href="http://code.google.com/p/yasnippet/">http://code.google.com/p/yasnippet/</a></p>
<h5>lusty-explorer.el (for a great tab completion file navigator)</h5>
<p>Followed this emacs-fu guide:<br />
<a title="Emacs-fu" href="http://emacs-fu.blogspot.com/2010/07/navigating-through-files-and-buffers.html">http://emacs-fu.blogspot.com/2010/07/navigating-through-files-and-buffers.html</a></p>
<p>And downloaded the .el here:</p>
<p><a title="LustyExplorer" href="http://www.emacswiki.org/emacs/LustyExplorer" target="_blank">http://www.emacswiki.org/emacs/LustyExplorer</a></p>
<p>Specifically I have the following in my .emacs:</p>
<pre>(when (require 'lusty-explorer nil 'noerror)

  ;; overrride the normal file-opening, buffer switching
  (global-set-key (kbd "C-x C-f") 'lusty-file-explorer)
  (global-set-key (kbd "C-x b")   'lusty-buffer-explorer))</pre>
<h2>Desired features</h2>
<p>I have yet to implement this, but I would like:</p>
<ul>
<li>Better file search (the ones I could find don&#8217;t do what I&#8217;m looking for)</li>
<ul>
<li>Specifically, looking for a smart find that allow autocompletion</li>
<li>Looking for something along the lines of eclipse</li>
</ul>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://yusuketsutsumi.parisaaalami.com/blog/?feed=rss2&#038;p=86</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ax_check_mysql introduction and example</title>
		<link>http://yusuketsutsumi.parisaaalami.com/blog/?p=67&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ax_check_mysql-introduction-and-example</link>
		<comments>http://yusuketsutsumi.parisaaalami.com/blog/?p=67#comments</comments>
		<pubDate>Sat, 20 Aug 2011 18:30:18 +0000</pubDate>
		<dc:creator>tsutsumi</dc:creator>
				<category><![CDATA[ax_check_mysql]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[autoconf]]></category>

		<guid isPermaLink="false">http://toumorokoshi.wordpress.com/?p=67</guid>
		<description><![CDATA[I previously mentioned ax_check_mysql.m4 in one of my posts, an m4 macro written for autoconf. So here&#8217;s a bit more information about it, and some examples on how to use it. Introduction So ax_check_mysql is essentially an m4 macro for autoconf that &#8230; <a href="http://yusuketsutsumi.parisaaalami.com/blog/?p=67">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I previously mentioned <a title="ax_check_mysql" href="http://www.gnu.org/software/autoconf-archive/ax_check_mysql.html" target="_blank">ax_check_mysql.m4</a> in one of my posts, an m4 macro written for autoconf. So here&#8217;s a bit more information about it, and some examples on how to use it.</p>
<h2>Introduction</h2>
<p>So ax_check_mysql is essentially an m4 macro for autoconf that was written with MySQL plugin developers in mind. When one runs the macro, a detected MySQL installation will give you the following information:</p>
<ul>
<li>The path to the directory containing the MySQL executables</li>
<li>The path to the directory containing MySQL includes (if they exist)</li>
<li>The path to the directory where MySQL plugins go</li>
<li>The version of MySQL</li>
<li>Whether MySQL is 32 or 64 bit</li>
</ul>
<div>Basically providing most of the information, MySQL-wise, needed to install the plugin.</div>
<p>In the situation where an installation can not be detected or an incomplete one is found, arguments can also be entered manually with:</p>
<pre> --with-mysql</pre>
<p>(where the root directory of the MySQL installation is passed (such as /usr/local/mysql or some other custom directory)  and</p>
<pre> --with-mysql-command, --with-mysql-plugin, --with-mysql-include</pre>
<p>Which would just passing all the directories directly.</p>
<h2>Examples</h2>
<p>One can include the macro in the same fashion as any other macro in the configure.ac file:</p>
<pre>AC_INIT(ax_check_mysql_example,version-1.0)

m4_include([m4_ax_check_mysql.m4])
AX_CHECK_MYSQL([no],[yes],[5.0],[no])
AC_MSG_NOTICE($MYSQL)
AC_MSG_NOTICE($MYSQL_COMMANDS)</pre>
<p>Now if I run this script on a computer with MySQL installed, you should something along the lines of:</p>
<pre>$ autoconf &amp;&amp; ./configure
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
Testing if MySQL was installed to common source/binary directory
checking for mysql... no
Testing if MySQL was installed to common package manager directory
checking for mysql... yes
checking /usr/include/mysql/mysql_version.h/mysql_version.h usability...
 no
checking /usr/include/mysql/mysql_version.h/mysql_version.h presence...
no
checking for /usr/include/mysql/mysql_version.h/mysql_version.h... no
checking /usr/include/mysql_version.h/mysql_version.h usability... no
checking /usr/include/mysql_version.h/mysql_version.h presence... no
checking for /usr/include/mysql_version.h/mysql_version.h... no
checking if /usr/lib/mysql/plugin/ exists...... yes
checking for mysql... /usr/bin/
configure: WARNING: A package install was detected, but the include dire
ctory could not be found! MySQL development library may not be installed
. If development library is installed please use --with-mysql-include --
with-mysql-plugin --with-mysql-command to manually assign directory loca
tions
checking MySQL Architecture... 32
checking MySQL Version... 5.1.41
checking if MySQL install supports Plugins... yes
checking if MySQL version is equal or greater than 5.0... yes
configure: yes
configure: /usr/bin/</pre>
<p>Note that the last two lines of output were echoing the MYSQL and MYSQL_COMMAND variables respectively, and that I do not have the development library installed. A full list of variables available are listed in the documentation.</p>
<p>One can pass four arguments when running the macro:</p>
<p>MYSQL-PLUGIN-NEEDED: if the MySQL version doesn&#8217;t support plugins (&lt; 5.1), this will cause failure.</p>
<p>MYSQL-REQUIRED: say if MySQL is required or not.</p>
<p>MINIMUM-VERSION: minimum version required for MySQL (i.e. 5.0 or 5.5)</p>
<p>INCLUDES-REQUIRED: whether the MySQL includes are required (will fail if includes are not found)</p>
<p>For example, If I wanted MySQL 5.5 or higher, I could enter:</p>
<pre>AC_INIT(ax_check_mysql_example,version-1.0)

m4_include([m4_ax_check_mysql.m4])

AX_CHECK_MYSQL([no],[yes],[5.5],[no])</pre>
<p>And as my MySQL installation is 5.1.41, ./configure will fail:</p>
<pre>checking MySQL Architecture... 32
checking MySQL Version... 5.1.41
checking if MySQL install supports Plugins... yes
checking if MySQL version is equal or greater than 5.5... no
configure: error: installed MySQL version is not above 5.5. 
Please upgrade your version of MySQL</pre>
<p>Entering nothing in the version field will allow any version.</p>
<p>Warnings will be outputted instead of errors if components aren&#8217;t required (such as includes or MySQL itself).</p>
<p>And there&#8217;s a brief example! Feel free to comment or contact me (tsutsumi.yusuke@gmail.com) if there are any questions/ comments.</p>
<p>The script is maintained by myself on github:</p>
<p><a href="https://github.com/Toumorokoshi/ax_check_mysql">https://github.com/Toumorokoshi/ax_check_mysql</a></p>
]]></content:encoded>
			<wfw:commentRss>http://yusuketsutsumi.parisaaalami.com/blog/?feed=rss2&#038;p=67</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code folding in Emacs Viper-Mode</title>
		<link>http://yusuketsutsumi.parisaaalami.com/blog/?p=45&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=code-folding-in-emacs-viper-mode</link>
		<comments>http://yusuketsutsumi.parisaaalami.com/blog/?p=45#comments</comments>
		<pubDate>Wed, 17 Aug 2011 23:06:41 +0000</pubDate>
		<dc:creator>tsutsumi</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[folding]]></category>
		<category><![CDATA[viper-mode]]></category>

		<guid isPermaLink="false">http://toumorokoshi.wordpress.com/?p=45</guid>
		<description><![CDATA[Code folding is a feature I&#8217;ve never really used, and for the most part seem to have done find without. I generally use search to navigate from place to place in my code, but I realize this isn&#8217;t always the &#8230; <a href="http://yusuketsutsumi.parisaaalami.com/blog/?p=45">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Code folding is a feature I&#8217;ve never really used, and for the most part seem to have done find without. I generally use search to navigate from place to place in my code, but I realize this isn&#8217;t always the most efficient way to go, and code folding is very useful in a couple aspects:</p>
<ul>
<li>It helps focus me on what particular method or class I&#8217;m working on (way harder to tell when you&#8217;ve got several bunches of code in front of you at once)</li>
<li>Getting a good idea of the structure of the code (with everything folded, it&#8217;s much easier to see)</li>
</ul>
<p>So I decided to play around with folding with my current development environment. I use Emacs as my base, but <a title="Viper-Mode" href="http://www.emacswiki.org/emacs/ViperMode" target="_blank">viper-mode</a> for the actual text editing.</p>
<p>Emacs has some pretty good folding tools built-in. Namely, these are <a title="FoldingMode" href="http://www.emacswiki.org/emacs/FoldingMode" target="_blank">FoldingMode</a> and <a title="HideShow" href="http://www.emacswiki.org/emacs/HideShow" target="_blank">HideShow</a>. I admit I didn&#8217;t play around with FoldingMode a lot, as using it seems to involve manually adding the folding points, something which I think is unnecessary 90% of the time. Ideally, I&#8217;m looking for a folding extension that automatically determines folding points, and leaves things as hands-off for me as possible. One should be able to open a file, fold it up, and then open and fold as necessary. I&#8217;m not looking to waste time adding commented blocks of folding everywhere.</p>
<p>Thats where HideShow comes in. Armed with rules for an array of programming languages, HideShow automatically looks for these patterns and sets folding points appropriately. Exactly what I&#8217;m looking for. Simply loading hideshow using .emacs:</p>
<pre>(load-library "hideshow")</pre>
<p>And activate the hideshow minor mode whenever you load the major mode of your choice (for me it&#8217;s Python):</p>
<pre>(add-hook 'python-mode-hook 'hs-minor-mode)</pre>
<p>Now you have all the access to the wonderful world of dynamic folding! Unfortunately, I didn&#8217;t really like the cumbersome keystrokes:</p>
<ul>
<li>C-c @ M-C-s to unfold all</li>
<li>C-c @ C-h to fold</li>
<li>C-c @ C-s to unfold</li>
<li>C-c @ M-C-h to fold all</li>
<li>C-c @ C-c to toggle folding</li>
</ul>
<p>Yeah, a six key-stroke succession is too much for me. So I assigned these bindings to almost the same folding commands as VIM:</p>
<ul>
<li>zm to unfold</li>
<li>zr to fold</li>
<li>zM to unfold all</li>
<li>zR to fold all</li>
<li>zt to toggle</li>
</ul>
<p>To do this, I added configuration into the .viper file:</p>
<pre>(define-key viper-vi-global-user-map "zt" 'hs-toggle-hiding)
(define-key viper-vi-global-user-map "zM" 'hs-hide-all)
(define-key viper-vi-global-user-map "zm" 'hs-hide-block)
(define-key viper-vi-global-user-map "zR" 'hs-show-all)
(define-key viper-vi-global-user-map "zr" 'hs-show-block)</pre>
<p>(viper-vi-global-user-map tell viper it&#8217;s for any buffer in any state with viper as a major mode). So far, this is working like a charm for me. Here&#8217;s a screenshot with it at work:</p>
<p><a href="http://yusuketsutsumi.parisaaalami.com/blog/wp-content/uploads/2011/08/foldingexample.png"><img class="alignnone size-full wp-image-58" title="FoldingExample" src="http://yusuketsutsumi.parisaaalami.com/blog/wp-content/uploads/2011/08/foldingexample.png" alt="" width="600" height="300" /></a></p>
<p>Feel free to comment if you have ideas/improvements!</p>
]]></content:encoded>
			<wfw:commentRss>http://yusuketsutsumi.parisaaalami.com/blog/?feed=rss2&#038;p=45</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Autoconf: ax_check_mysql</title>
		<link>http://yusuketsutsumi.parisaaalami.com/blog/?p=7&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=autoconf-ax_check_mysql</link>
		<comments>http://yusuketsutsumi.parisaaalami.com/blog/?p=7#comments</comments>
		<pubDate>Mon, 27 Jun 2011 16:19:26 +0000</pubDate>
		<dc:creator>tsutsumi</dc:creator>
				<category><![CDATA[ax_check_mysql]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[My Stuff]]></category>
		<category><![CDATA[autoconf]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://toumorokoshi.wordpress.com/?p=4</guid>
		<description><![CDATA[Just mentioning a little m4 script I wrote a little while ago. ax_check_mysql is used to find a valid MySQL installation, and gives you the binary, include, and plugin directories. If you have an autoconf project, and you need MySQL, &#8230; <a href="http://yusuketsutsumi.parisaaalami.com/blog/?p=7">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Just mentioning a little m4 script I wrote a little while ago. ax_check_mysql is used to find a valid MySQL installation, and gives you the binary, include, and plugin directories.</p>
<p>If you have an autoconf project, and you need MySQL, definitely consider it!</p>
<p><a title="http://www.gnu.org/software/autoconf-archive/ax_check_mysql.html#ax_check_mysql" href="http://www.gnu.org/software/autoconf-archive/ax_check_mysql.html#ax_check_mysql">http://www.gnu.org/software/autoconf-archive/ax_check_mysql.html#ax_check_mysql</a></p>
]]></content:encoded>
			<wfw:commentRss>http://yusuketsutsumi.parisaaalami.com/blog/?feed=rss2&#038;p=7</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

