<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns: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'><id>tag:blogger.com,1999:blog-7470785286909857088</id><updated>2024-11-01T03:40:34.949-07:00</updated><category term="command line tools"/><category term="node.js module"/><category term="npmjs"/><category term="bind"/><category term="closures"/><category term="coffeescript"/><category term="fat arrow"/><category term="javascript"/><category term="module"/><category term="node.js"/><title type='text'>Asynchronous Thougths</title><subtitle type='html'>Musing and information about &#xa;payment technology, entrepreneurship and geeky things.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://robkuz-blog.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7470785286909857088/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://robkuz-blog.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>robertj</name><uri>http://www.blogger.com/profile/08094923479637589925</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='29' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQBv8P_JmY99GpoOmn45FVPzxnAUQLN1oQ-7qoT9w6WGs9GqNgFrRfT5quOQjMUQC1tgiQUbW_ULdbadurrddhUqCVDDOTtkxdVLFz0DKFFT2p_8wUD2X_c4zVGiTgPqw/s220/rk_twitter.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7470785286909857088.post-289203239080055057</id><published>2013-03-11T01:36:00.000-07:00</published><updated>2013-03-11T02:09:47.090-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bind"/><category scheme="http://www.blogger.com/atom/ns#" term="coffeescript"/><category scheme="http://www.blogger.com/atom/ns#" term="fat arrow"/><title type='text'></title><content type='html'>&lt;h1&gt;
Binding of CoffeeScripts Fat Arrow&lt;/h1&gt;
&lt;style&gt;
  h2 {
    padding-top: 20px;
    font-size: 20px;
  }
  .code {
    padding-top: 10px;
    padding-bottom: 10px;
  }
&lt;/style&gt;
Again this is a  frequently asked questions on StackOverflow.
I have already answered it &lt;a href=&quot;http://stackoverflow.com/questions/13184209/when-does-the-fat-arrow-bind-to-this-instance&quot;&gt;there&lt;/a&gt; however I think its hard to find.&lt;br /&gt;
So I will reproduce it here again.&lt;br /&gt;
&lt;h2&gt;
When does the fat arrow bind?&lt;/h2&gt;
The fat arrow binds at 3 occasions&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;when declaring a method within a class&lt;/li&gt;
&lt;li&gt;when declaring a function within a method or function&lt;/li&gt;
&lt;li&gt;when declaring a function in global context&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
Declaring a method within a class&lt;/h2&gt;
When the Coffeescript compiler encouters the following syntactical pattern within a class declaration
&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;script src=&quot;https://gist.github.com/robkuz/5132668.js&quot;&gt;&lt;/script&gt;
&lt;/div&gt;
This will yield the following code within the constructor of class A
&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;script src=&quot;https://gist.github.com/robkuz/5132709.js&quot;&gt;&lt;/script&gt;
&lt;/div&gt;
Within the constructor of A &lt;b&gt;somemethod&lt;/b&gt; is now called via &lt;b&gt;apply&lt;/b&gt; using &lt;b&gt;_this&lt;/b&gt;.&lt;br /&gt;
So regardless which context you call &lt;b&gt;somemethod&lt;/b&gt; it will allways use the creating instance as the execution context.
&lt;br /&gt;
&lt;h2&gt;
When declaring a function within a method or function&lt;/h2&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;script src=&quot;https://gist.github.com/robkuz/5132770.js&quot;&gt;&lt;/script&gt;
&lt;/div&gt;
When you define a function with a fat arrow within a method or function the Coffeescript compiler automatically creates a &lt;b&gt;closure&lt;/b&gt; and and shadows &lt;b&gt;this&lt;/b&gt; of the outer method into the variable &lt;b&gt;_this&lt;/b&gt;. Any reference to &lt;b&gt;@&lt;/b&gt; within the inner function will use the variable &lt;b&gt;_this&lt;/b&gt; in the generated javascript code.
&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;script src=&quot;https://gist.github.com/robkuz/5132776.js&quot;&gt;&lt;/script&gt;
&lt;/div&gt;
A definition of a function without the fat arrow doesn&#39;t create that closure for you.
&lt;br /&gt;
&lt;h2&gt;
When declaring a function in global context&lt;/h2&gt;
If you define a free floating function (meaning as a method in a class and not within another function/method) just like this
&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;script src=&quot;https://gist.github.com/robkuz/5132803.js&quot;&gt;&lt;/script&gt;
&lt;/div&gt;
Then the corresponding Javascript will look like this
&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;script src=&quot;https://gist.github.com/robkuz/5132804.js&quot;&gt;&lt;/script&gt;
&lt;/div&gt;
The interesting thing here again is that &lt;b&gt;this&lt;/b&gt; is being assigned to &lt;b&gt;_this&lt;/b&gt; which enables the definition of foo to close over &lt;b&gt;_this&lt;/b&gt;.
&lt;br /&gt;
The important part however is that &lt;b&gt;this&lt;/b&gt; is now always the global context of your execution environment. If you are in the browser it will be the window object. If you are running node.js it will be the module you are just running.
&lt;br /&gt;
&lt;b style=&quot;color: red;&quot;&gt;Warning:&lt;/b&gt; You shouldn&#39;t define any function accessing your global context anyway. This calls for trouble.
&lt;br /&gt;
Did you find this entry useful? Please upvote it on &lt;a href=&quot;http://stackoverflow.com/questions/13184209/when-does-the-fat-arrow-bind-to-this-instance&quot;&gt;StackOverflow&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://robkuz-blog.blogspot.com/feeds/289203239080055057/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://robkuz-blog.blogspot.com/2013/03/binding-of-coffeescripts-fat-arrow-h2.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7470785286909857088/posts/default/289203239080055057'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7470785286909857088/posts/default/289203239080055057'/><link rel='alternate' type='text/html' href='http://robkuz-blog.blogspot.com/2013/03/binding-of-coffeescripts-fat-arrow-h2.html' title=''/><author><name>robertj</name><uri>http://www.blogger.com/profile/08094923479637589925</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='29' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQBv8P_JmY99GpoOmn45FVPzxnAUQLN1oQ-7qoT9w6WGs9GqNgFrRfT5quOQjMUQC1tgiQUbW_ULdbadurrddhUqCVDDOTtkxdVLFz0DKFFT2p_8wUD2X_c4zVGiTgPqw/s220/rk_twitter.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7470785286909857088.post-7124533155475322303</id><published>2013-03-05T03:53:00.000-08:00</published><updated>2013-03-11T02:11:24.466-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="closures"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><title type='text'>About Closures And Loops</title><content type='html'>&lt;h1&gt;
About Closures And Loops&lt;/h1&gt;
A frequently asked questions on StackOverflow is why the value of a variable that a function closes over isn&#39;t the value the programmer expects but another one. Usually this kind of question comes in combination with loop. Lets have a look on an example
&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;script src=&quot;https://gist.github.com/robkuz/5089248.js&quot;&gt;&lt;/script&gt;&lt;br /&gt;&lt;/div&gt;
The expected outcome of this would certainly be &lt;b&gt;1,4,9&lt;/b&gt; but its &lt;b&gt;16,16,16&lt;/b&gt;.&lt;br /&gt;
&lt;h2 style=&quot;padding-top: 20px;&quot;&gt;
What went wrong?&lt;/h2&gt;
Less experienced programmers might think that creating a closures somehow
copies the values of the accessed context during the creation of that closure.
However that is not true.
&lt;br /&gt;
&lt;h2 style=&quot;padding-top: 20px;&quot;&gt;
What really happens!&lt;/h2&gt;
When a function &lt;b&gt;closes&lt;/b&gt; over a surrounding context it &lt;b&gt;saves a reference&lt;/b&gt; to that
enclosing context - that includes all variables within that context.&lt;br /&gt;
Now when accessing the context and its variables one gets the state of that 
context as it is &lt;b&gt;at the time of access&lt;/b&gt; and &lt;i&gt;not as it was during the creation
of the closure.&lt;/i&gt;&lt;br /&gt;
In this specific case the value of the variable &amp;gt;&amp;gt;i&amp;lt;&amp;lt; after the finishing the
first loop is 4. When executing the functions within the second loop its still 4.
&lt;br /&gt;
&lt;h2 style=&quot;padding-top: 20px;&quot;&gt;
What is the solution?&lt;/h2&gt;
What you need is a way to create different context for each of the functions that you create.&lt;br /&gt;
The best way is to define a function that returns a function as a result. The returned function
again closes over the defining function and its variables and parameters.
&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;script src=&quot;https://gist.github.com/robkuz/5089575.js&quot;&gt;&lt;/script&gt;&lt;br /&gt;&lt;/div&gt;
This will yield the expected outcome of &lt;b&gt;1,4,9&lt;/b&gt;.
</content><link rel='replies' type='application/atom+xml' href='http://robkuz-blog.blogspot.com/feeds/7124533155475322303/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://robkuz-blog.blogspot.com/2013/03/about-closures-and-loops.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7470785286909857088/posts/default/7124533155475322303'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7470785286909857088/posts/default/7124533155475322303'/><link rel='alternate' type='text/html' href='http://robkuz-blog.blogspot.com/2013/03/about-closures-and-loops.html' title='About Closures And Loops'/><author><name>robertj</name><uri>http://www.blogger.com/profile/08094923479637589925</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='29' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQBv8P_JmY99GpoOmn45FVPzxnAUQLN1oQ-7qoT9w6WGs9GqNgFrRfT5quOQjMUQC1tgiQUbW_ULdbadurrddhUqCVDDOTtkxdVLFz0DKFFT2p_8wUD2X_c4zVGiTgPqw/s220/rk_twitter.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7470785286909857088.post-3740807981075479469</id><published>2011-12-19T01:17:00.001-08:00</published><updated>2011-12-19T03:50:22.957-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="command line tools"/><category scheme="http://www.blogger.com/atom/ns#" term="module"/><category scheme="http://www.blogger.com/atom/ns#" term="node.js"/><category scheme="http://www.blogger.com/atom/ns#" term="npmjs"/><title type='text'>Intro into Node Modules Part III - CLI FAQ</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-large;&quot;&gt;FAQ on Command Line&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;My last post on&amp;nbsp;&lt;a href=&quot;http://robkuz-blog.blogspot.com/2011/12/npm-modules-step-by-step-part-ii.html&quot;&gt;Command Line Tools&lt;/a&gt;&amp;nbsp;is missing some questions that you might find valuable when&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;creating your own command line tools.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;&lt;i&gt;A) Can I create multiple command line tools within one package?&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Yes. Just add new scripts and the associated keys into your package.json&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Lets say we would like to write&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt; ccap foo&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;instead&lt;/span&gt; of &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;cap -c foo&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;and&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;dcap FOO&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;instead of&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;cap -d FOO&lt;/span&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;First we will create the 2 missing scripts in our bin directory and make them executable&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: white; color: #585858; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize&amp;nbsp;j$ cd bin&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #585858; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize/bin $ touch ccap.js&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #585858; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;&quot;&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize/bin $ chmod +x ccap.js&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize/bin $ touch dcap.js&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize/bin $ chmod +x dcap.js&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #585858; font-size: 15px; line-height: 20px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: black; font-size: small; line-height: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Then add the following code into this new files (&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;ccap.js and dcap.js&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #585858; font-size: 15px; line-height: 20px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: black; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: normal;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/1496436.js?file=ccap.js&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/1496454.js?file=dcap.js&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Then change the the package.json to have a new version number and to include the new entries within the bin key.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/1496485.js?file=package.json&quot;&gt;
&lt;/script&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
Finally publish the package and install it globally&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #585858; font-size: 15px; line-height: 20px;&quot;&gt;Hector:~/capitalize $&amp;nbsp;&lt;/span&gt;&amp;nbsp;npm update&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #585858; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 15px; line-height: 20px;&quot;&gt;Hector:~/capitalize $&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;cd ..&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #585858; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 15px; line-height: 20px;&quot;&gt;Hector:~ $ &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;sudo npm install capitalize -g&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;/opt/local/bin/&lt;b&gt;ccap&lt;/b&gt; -&amp;gt; /opt/local/lib/node_modules/capitalize/bin/&lt;b&gt;ccap&lt;/b&gt;.js&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;/opt/local/bin/&lt;b&gt;dcap&lt;/b&gt; -&amp;gt; /opt/local/lib/node_modules/capitalize/bin/&lt;b&gt;dcap&lt;/b&gt;.js&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;/opt/local/bin/cap -&amp;gt; /opt/local/lib/node_modules/capitalize/bin/cap.js&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;capitalize@0.3.0 /opt/local/lib/node_modules/capitalize&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;As you see ccap and dcap are now linked into /opt/local/bin and available anywhere on your command line&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;i style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-large;&quot;&gt;B) Can I install a command line tool only locally?&lt;/i&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Yes - but what is the purpose of that?!&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;If you install a package containing a command line tool locally then you would have to create a symlink yourself and you need adjust your PATH variable manually to include the symlink etc.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;i style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-large;&quot;&gt;C) Can I install a command line tool that overwrites an already installed one?&lt;/i&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;No!&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Lets say we want to overwrite the coffee command as we have already installed CoffeeScript on our machine. First we will change the version number of our package again and add a new key called coffee to our bin key.&lt;/span&gt;&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/1496761.js?file=package.json&quot;&gt;&lt;/script&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Now publish and install globally&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize robertj$ npm publish&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize robertj$ cd ..&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~ robertj$ sudo npm install -g capitalize&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;npm ERR! error installing capitalize@0.4.0&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;/usr/local/bin/cap -&amp;gt; /usr/local/lib/node_modules/capitalize/bin/cap.js&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;/usr/local/bin/ccap -&amp;gt; /usr/local/lib/node_modules/capitalize/bin/ccap.js&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;/usr/local/bin/dcap -&amp;gt; /usr/local/lib/node_modules/capitalize/bin/dcap.js&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;npm ERR! error rolling back capitalize@0.4.1 Error: Refusing to delete: /usr/local/bin/coffee not in /usr/local/lib/node_modules/capitalize&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Unluckily for you from now on you will be punished. The package has been installed partly and any attempt to update or uninstall it will be greeted with the message that&amp;nbsp;/usr/local/bin/coffee can&#39;t be deleted.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Your last help is to use the force to uninstall&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~ robertj$ sudo npm uninstall --force -g capitalize&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;I hope you enjoyed the show. Next time as promised &quot;pre/post/installation&quot; scripts.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://robkuz-blog.blogspot.com/feeds/3740807981075479469/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://robkuz-blog.blogspot.com/2011/12/intro-into-node-modules-part-iii-cli.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7470785286909857088/posts/default/3740807981075479469'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7470785286909857088/posts/default/3740807981075479469'/><link rel='alternate' type='text/html' href='http://robkuz-blog.blogspot.com/2011/12/intro-into-node-modules-part-iii-cli.html' title='Intro into Node Modules Part III - CLI FAQ'/><author><name>robertj</name><uri>http://www.blogger.com/profile/08094923479637589925</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='29' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQBv8P_JmY99GpoOmn45FVPzxnAUQLN1oQ-7qoT9w6WGs9GqNgFrRfT5quOQjMUQC1tgiQUbW_ULdbadurrddhUqCVDDOTtkxdVLFz0DKFFT2p_8wUD2X_c4zVGiTgPqw/s220/rk_twitter.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7470785286909857088.post-8350131847585987827</id><published>2011-12-14T08:39:00.000-08:00</published><updated>2011-12-19T03:51:23.085-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="command line tools"/><category scheme="http://www.blogger.com/atom/ns#" term="node.js module"/><category scheme="http://www.blogger.com/atom/ns#" term="npmjs"/><title type='text'>NPM Modules Step by Step (Part II) - Command Line Tools</title><content type='html'>Having created our first module and having published as described in this blog post (&lt;a href=&quot;http://robkuz-blog.blogspot.com/2011/12/introduction-into-node-modules-part-i.html&quot;&gt;Introduction into Node Modules Part I&lt;/a&gt;)&amp;nbsp;wouldn&#39;t it be cool if we could use this extremely sophisticated capitalize and decapitalize functions as a command line tool as well?&lt;br /&gt;
&lt;br /&gt;
Lets say we want to be able to do this on the command line:&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~ $ cap -c foo&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;(yields =&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;FOO)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~ $ cap -d FOO (yields =&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;foo)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Where &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;b&gt;cap -c&lt;/b&gt;&lt;/span&gt; capitalizes the given argument and &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;b&gt;-d&lt;/b&gt;&lt;/span&gt; decapitalizes it.&lt;br /&gt;
&lt;br /&gt;
Actually that is very easy.&lt;br /&gt;
First we have to change our package.json file&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/1476528.js?file=package.json&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
Please take care of the 2 changes that we made against the previous version of that file.&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;we changed the version from &quot;0.1.0&quot; to &quot;0.2.0&quot; (line 5)&lt;br /&gt;
If we don&#39;t change that version to a higher version than the one that has been published previously npm will complain about that fact.&lt;/li&gt;
&lt;li&gt;We need to add the key &quot;bin&quot; and the name of the command line tool and the associated script that shall be executed on calling that command (line 18-21)&lt;br /&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
Lets start hacking on our command line tool. First of all we will create a subdirectory for our command line tool. The standard name for the command line directory is &quot;bin&quot;. This is no hard requirement however most npm packages seem to adhere to it. So will we.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize $ mkdir bin&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize&amp;nbsp;j$ cd bin&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize/bin $ touch cap.js&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
now add the following code to ~/capitalize/bin/cap.js&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/1476604.js?file=cap.js&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
Please take care of to a hash-bang in line 1. This is needed (at least under *nix systems).&lt;br /&gt;
Lines 4 and 5 are the ones that return the command line arguments.&lt;br /&gt;
Argument 0 is the node itself and argument 1 is the script being executed (in this case cap.js).&lt;br /&gt;
&lt;br /&gt;
We are almost done. Actually our script wont be executed (on *nix systems) we have forgotten to change the execution rights. Please do&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize/bin $ chmod +x cap.js&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize/bin&amp;nbsp;$ ls -ls&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;total 0&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;0 -rwxr-xr-x &amp;nbsp;1 robertj &amp;nbsp;staff &amp;nbsp;0 14 Dez 14:20 cap.js&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Now we move back to our directory containing our package.json and publish it.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize/bin $ cd ..&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize $ npm publish&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Finally install the package globally&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~ $ sudo npm install capitalize -g&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;/opt/local/bin/cap -&amp;gt; /opt/local/lib/node_modules/capitalize/bin/cap.js&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;capitalize@0.2.0 /opt/local/lib/node_modules/capitalize&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
this will install the the command &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;cap&lt;/span&gt; as a global link into your global node_modules directory.&lt;br /&gt;
&lt;br /&gt;
I hope you enjoyed the show. Next time: &quot;installation/deinstallation scripts&quot;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://robkuz-blog.blogspot.com/feeds/8350131847585987827/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://robkuz-blog.blogspot.com/2011/12/npm-modules-step-by-step-part-ii.html#comment-form' title='2 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7470785286909857088/posts/default/8350131847585987827'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7470785286909857088/posts/default/8350131847585987827'/><link rel='alternate' type='text/html' href='http://robkuz-blog.blogspot.com/2011/12/npm-modules-step-by-step-part-ii.html' title='NPM Modules Step by Step (Part II) - Command Line Tools'/><author><name>robertj</name><uri>http://www.blogger.com/profile/08094923479637589925</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='29' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQBv8P_JmY99GpoOmn45FVPzxnAUQLN1oQ-7qoT9w6WGs9GqNgFrRfT5quOQjMUQC1tgiQUbW_ULdbadurrddhUqCVDDOTtkxdVLFz0DKFFT2p_8wUD2X_c4zVGiTgPqw/s220/rk_twitter.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7470785286909857088.post-8687951139378320617</id><published>2011-12-08T02:07:00.000-08:00</published><updated>2011-12-08T02:28:41.971-08:00</updated><title type='text'>A Small Rant On Twitter Followers</title><content type='html'>I admit I am pretty late to that whole twitter thing. So I am probably astonished by things that the more experienced of you might simply put aside.&lt;br /&gt;
&lt;br /&gt;
Nevertheless it is intriguing to me how sometimes people start to follow me on tweets without obviously reading my bio or at least reading that tweet. My impression is that my bio is pretty clear&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;b&gt;Payment expert, entrepreneur &amp;amp; geek&lt;/b&gt;&lt;/blockquote&gt;No mentioning of any kind of interest in shoes or vegan products or sex contacts in the Netherlands.&lt;br /&gt;
Nevertheless sometimes when twittering or retweeting I get a new hilarious follower ...&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;u&gt;Shoes&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
Lets start with a post about Zalando (the German copy of Zapatos in the US). I had this post which is telling the story of our first shoe delivery by Zalando and has an implicit reference to a german TV-spot.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLpaDix8HOJEZl_hqmoZ9TA8KCNX92WI4hyOvdcnEoUV28nW1tRn4y5jDOiGG2MaHIYDhHwm7VDVYRJzpCoQgUhYVDApDzTQrI38THSowl1cUoOa_99mnR-9eJr4EDoSXHd1DZzUglWc8/s1600/zalando.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;196&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLpaDix8HOJEZl_hqmoZ9TA8KCNX92WI4hyOvdcnEoUV28nW1tRn4y5jDOiGG2MaHIYDhHwm7VDVYRJzpCoQgUhYVDApDzTQrI38THSowl1cUoOa_99mnR-9eJr4EDoSXHd1DZzUglWc8/s400/zalando.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;This brought me @rueschen as new follower.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;Very nice - she searches for the perfect shoe meanwhile she walks bare foot and sells shoes from Prada and D&amp;amp;G etc. - seems like the more expensive option.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgqO7HLuUi6X5nsCSdzh7Y3ADPIkkj5rFL9uMk83sSfI6N87Gp4NWynOh9LfQuoXWkibwumbWkY7oUP98kZ4uLJ4j4e8s_MWN1RWjoJoT1y4zFjgpc1BkPD3h8jNP7LhbH6SRiktA1Cig/s1600/%2540rueschen.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgqO7HLuUi6X5nsCSdzh7Y3ADPIkkj5rFL9uMk83sSfI6N87Gp4NWynOh9LfQuoXWkibwumbWkY7oUP98kZ4uLJ4j4e8s_MWN1RWjoJoT1y4zFjgpc1BkPD3h8jNP7LhbH6SRiktA1Cig/s1600/%2540rueschen.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;I am wondering if she is more into my tweets about software development or if she is more interested in payment technology?&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;u&gt;Opodo&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
Actually I made a mistake by booking my travel arrangements via Opodo.&lt;br /&gt;
Big service fail which I tweeted about here.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYKF83Vu7-Brvb0UeWhjJRdFNl2N9jAjwmNMCAk9otAni0zW6tBb9dxBZBQQ6XtNpDT2m0OiFQsiSg6Awzv_ePwKt1qJkM6uz2SUwwCmsZAip_DA2RwqaTJGsYM1Nc-r8VIrEuMSsdouk/s1600/opodo.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;198&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYKF83Vu7-Brvb0UeWhjJRdFNl2N9jAjwmNMCAk9otAni0zW6tBb9dxBZBQQ6XtNpDT2m0OiFQsiSg6Awzv_ePwKt1qJkM6uz2SUwwCmsZAip_DA2RwqaTJGsYM1Nc-r8VIrEuMSsdouk/s400/opodo.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;The decision to book my travel arrangements via Opodo is certainly more than foolish. Consequently &amp;nbsp;those 2 guys started to follow me - probably in the hope that if I was so foolish once I will even more foolish in the future and might buy from them as well.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiDthvzySSDieRjQkXIgWMExkupdGtOm0b6w-Cerxe3WKpaRwbq2Ix5BG40wSDVrFp-lKqU_PcjJFFbWOghNTsSbxXVXjH99jhR37AABrD46vwLfP60LA5ZVJdpSCwyoMtbAUuSUUiF9w/s1600/%2540orlando.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiDthvzySSDieRjQkXIgWMExkupdGtOm0b6w-Cerxe3WKpaRwbq2Ix5BG40wSDVrFp-lKqU_PcjJFFbWOghNTsSbxXVXjH99jhR37AABrD46vwLfP60LA5ZVJdpSCwyoMtbAUuSUUiF9w/s1600/%2540orlando.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;This one is certainly a candidate for news about CoffeeScript&lt;br /&gt;
&lt;br /&gt;
The next guy is even funnier - he is so obviously trying to sell a multi level marketing scheme while pretending he doesn&#39;t want to sell you anything that it almost hurts.&lt;br /&gt;
His bio says: #entrepreneur #earn money #freelance #wellness #sidejob # fun etc.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBc5V_a1Sswpe1qnLMQQOBIfupQ23Yq5xlmLQH8NPdWpAfacQWSoaocHYCSmos0FLMnKjExiMfy7D9kMmgKL3HFG9pE5psesTKCLKUh8OcmywB-8KbJQA2er_08nFI_0gI8_kFbn9_RwM/s1600/%2540luckythorsten.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBc5V_a1Sswpe1qnLMQQOBIfupQ23Yq5xlmLQH8NPdWpAfacQWSoaocHYCSmos0FLMnKjExiMfy7D9kMmgKL3HFG9pE5psesTKCLKUh8OcmywB-8KbJQA2er_08nFI_0gI8_kFbn9_RwM/s1600/%2540luckythorsten.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Just because I made the dumb mistake to book my travel via Opodo doesn&#39;t mean I will fall into you MLM ponzi scheme.&lt;br /&gt;
Or is he realy into node.js?&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;u&gt;Vegan&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
Then I stumbled about a link for vegan shoes which I loudly wondered about&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLBKYhIkvFNpQZvgC2repv28YwWH8UOmtQoaeAcnp6bg9YBmFEWDPNpmaZnVxbYC4UoCyX6Ma-oONwP8MboijCBixlC8tC-pF-rEJ8h1-_ngaiq2s5XHwPCA4L5AP7Rl2mKaSJfTnmt-A/s1600/vegan.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLBKYhIkvFNpQZvgC2repv28YwWH8UOmtQoaeAcnp6bg9YBmFEWDPNpmaZnVxbYC4UoCyX6Ma-oONwP8MboijCBixlC8tC-pF-rEJ8h1-_ngaiq2s5XHwPCA4L5AP7Rl2mKaSJfTnmt-A/s1600/vegan.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Which made Gordon an avid follower of mine&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM60NAvVRpjpvw3pF5e0iP1eCcrwv3GIfjRLtsOhrDGhn9EaSyxRios06q6liAQZbckPRQbTYFE4o06TpcSsBZMb-Qjrz2CohHJaImlo_MtE4S_F_lzl3NuD4XAlaCjTXB4jpe4uRQFec/s1600/gordon.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;183&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM60NAvVRpjpvw3pF5e0iP1eCcrwv3GIfjRLtsOhrDGhn9EaSyxRios06q6liAQZbckPRQbTYFE4o06TpcSsBZMb-Qjrz2CohHJaImlo_MtE4S_F_lzl3NuD4XAlaCjTXB4jpe4uRQFec/s400/gordon.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;Gordon is vegan, balanced and informed - sadly he lacks any kind of bull shit detector.&lt;br /&gt;
Hey LuckyThorsten I think I got a new customer for you!&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;u&gt;Adult Dating&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
My last and most curious follower started to follow me after this blog post:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIJXkKkTqxXA206mrJN1dw065qm25VFkkxGbMjO6KogzkS6uBK8ZOcwh8Op0zmAuHTfoF4uERIGrxDUKV-yR9a6f5g_ImtxMgyDOAy1WOZSkH_PNcPPVWqVxb1ac26hOvpZOmISFuG1IU/s1600/blog.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;214&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIJXkKkTqxXA206mrJN1dw065qm25VFkkxGbMjO6KogzkS6uBK8ZOcwh8Op0zmAuHTfoF4uERIGrxDUKV-yR9a6f5g_ImtxMgyDOAy1WOZSkH_PNcPPVWqVxb1ac26hOvpZOmISFuG1IU/s400/blog.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;This one really opens up a whole bunch of questions:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6X_zahQW-S2377SqXXynx88kWEF8HrjlLWh3HBDh-JJaQ096UcPkQVHDeMYyAsyOwbHZ_bAsU76IVkFJ69ksyr1Qsy-cBL4QA-OgXAeQjHkPc2bYXwBTEy_0wzMtghpUXpQ_PervLKRw/s1600/dates.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;176&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6X_zahQW-S2377SqXXynx88kWEF8HrjlLWh3HBDh-JJaQ096UcPkQVHDeMYyAsyOwbHZ_bAsU76IVkFJ69ksyr1Qsy-cBL4QA-OgXAeQjHkPc2bYXwBTEy_0wzMtghpUXpQ_PervLKRw/s400/dates.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;what kind of sexual techniques is nodejs or npmjs?&lt;/li&gt;
&lt;li&gt;I am located in Munich - why should I follow adult dating contacts in the Netherlands&lt;/li&gt;
&lt;li&gt;Wouldn&#39;t it be fare more cheaper if I got my self a professional instead of travelling to Amsterdam for example&lt;/li&gt;
&lt;li&gt;How should participate in your web site? Everything is in Dutch! The pictures on your frontpage are universally understood thou.&lt;/li&gt;
&lt;li&gt;How should I know that you are the best sex dates site in the Netherlands. Have you been audited? By whom? KPMG? Please show me the certificate!&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;Obviously I will twitter about this blog. Lets see who starts to follow me ...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://robkuz-blog.blogspot.com/feeds/8687951139378320617/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://robkuz-blog.blogspot.com/2011/12/on-twitter-followers.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7470785286909857088/posts/default/8687951139378320617'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7470785286909857088/posts/default/8687951139378320617'/><link rel='alternate' type='text/html' href='http://robkuz-blog.blogspot.com/2011/12/on-twitter-followers.html' title='A Small Rant On Twitter Followers'/><author><name>robertj</name><uri>http://www.blogger.com/profile/08094923479637589925</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='29' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQBv8P_JmY99GpoOmn45FVPzxnAUQLN1oQ-7qoT9w6WGs9GqNgFrRfT5quOQjMUQC1tgiQUbW_ULdbadurrddhUqCVDDOTtkxdVLFz0DKFFT2p_8wUD2X_c4zVGiTgPqw/s220/rk_twitter.JPG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLpaDix8HOJEZl_hqmoZ9TA8KCNX92WI4hyOvdcnEoUV28nW1tRn4y5jDOiGG2MaHIYDhHwm7VDVYRJzpCoQgUhYVDApDzTQrI38THSowl1cUoOa_99mnR-9eJr4EDoSXHd1DZzUglWc8/s72-c/zalando.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7470785286909857088.post-3967789560111784827</id><published>2011-12-07T00:40:00.000-08:00</published><updated>2011-12-07T00:40:21.877-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="node.js module"/><title type='text'>Introduction into Node Modules Part I</title><content type='html'>Lets start with a bit of advertising from Node Package Managers (npm - ww.npmjs.org) own home page:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: inherit;&quot;&gt;&lt;i style=&quot;color: #b45f06;&quot;&gt;npm is a package manager for&amp;nbsp;&lt;/i&gt;&lt;a href=&quot;http://nodejs.org/&quot; style=&quot;text-decoration: none;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;node&lt;/span&gt;&lt;/b&gt;&lt;/a&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #b45f06;&quot;&gt;. You can use it to install and publish your node programs. It manages dependencies and does other cool stuff&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;div class=&quot;p1&quot;&gt;There is really nothing I can add to this.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Goal&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;The goal of this blog post is to show you the simplest way to build your own package.&lt;br /&gt;
Therefore I will lead&amp;nbsp;you through the creation of a trivial module which will export 2 functions that capitalize and decapitalize a string -&amp;nbsp;Just toUpperCase and toLoverCase by a more fancy name.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;This blog post assumes that you have installed node and npm.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Preparation&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;First create a new directory named &quot;capitalize&quot; and change into that new directory.&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;code&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~ $ mkdir capitalize&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~ $ cd capitalize/&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;within that directory issue the command &quot;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;npm init&lt;/span&gt;&quot; and follow the &quot;wizard&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize $ npm init&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Package name: (capitalize)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Description: capitalizes and decapitalizes a string&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Package version: (0.0.0) 0.1.0&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Project homepage: (none) &lt;a href=&quot;http://www.capitalize.org/&quot;&gt;&lt;span class=&quot;s1&quot;&gt;www.capitalize.org&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Project git repository: (none)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Author name: robert kuzelj&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Author email: (none) &lt;a href=&quot;mailto:robert@capitalize.org&quot;&gt;&lt;span class=&quot;s1&quot;&gt;robert@capitalize.org&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Author url: (none)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Main module/entry point: (none) main.js&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Test command: (none)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;What versions of node does it run on? (~0.6.0)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;This will create the following &quot;package.json&quot; file. Which is by far the most important&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;file when creating and managing node packages.&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&quot;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;npm publish&lt;/span&gt;&quot; will use this file when publishing your module locally or to the internet.&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Code&lt;/span&gt;&lt;br /&gt;
Lets start hacking some serious code. First we will create a sub directory called &quot;lib&quot;&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;that contains&amp;nbsp;the actual code. We will split our code into 2 files for illustration purposes.&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize $ mkdir lib&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize $ cd lib&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize/lib $ touch capitalize.js&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize/lib $ touch decapitalize.js&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;br /&gt;
Now enter this extremely sophisticated code in the file &quot;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;~/capitalize/lib/capitalize.js&lt;/span&gt;&quot;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;script src=&quot;https://gist.github.com/1439867.js?file=gistfile1.js&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;Now enter the following code in the file &quot;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;~/capitalize/lib/decapitalize.js&lt;/span&gt;&quot;&lt;/div&gt;&lt;script src=&quot;https://gist.github.com/1439878.js?file=gistfile1.js&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;Finally add the code for the file&amp;nbsp;&quot;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;~/capitalize/main.js&lt;/span&gt;&quot;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;script src=&quot;https://gist.github.com/1439902.js?file=gistfile1.js&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
Obviously the code within capitalize.js and decapitalize.js could have also&amp;nbsp;been directly in main.js. However I wanted to show you 2 things:&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;it is good practice to split your module into smaller files and put&amp;nbsp;those files under the lib directory and into lib&#39;s child directories.&lt;br /&gt;
You can use a different directory name however the node community has implicitly agreed on &quot;lib&quot; as the default name.&lt;/li&gt;
&lt;li&gt;it is good practice to have the entry point of your module require any&amp;nbsp;files in the lib subfolder and reexport those functions that should be accessible&amp;nbsp;from any client code.&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Local Publishing&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;Now lets test our industry strength module before we are going to publish it.&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;First we will create a symbolic link within the npm system&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize/lib $ cd ..&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize $ npm link&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;br /&gt;
npm link reads the package.json file and creates a symbolic name using the &quot;name&quot;-entry on top of&amp;nbsp;your OS&#39;s symbolic links (at least thats what I assume).&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;Now lets create some test Javascript that uses our new module. First we create a new directory and create a new npm link within.&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize $ cd ..&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~ $ mkdir cap-test&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~ $ cd cap-test&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/cap-test $ touch test.js&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/cap-test $ npm link capitalize&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;capitalize@0.1.0 /opt/local/lib/node_modules/capitalize&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;./node_modules/capitalize -&amp;gt; /opt/local/lib/node_modules/capitalize&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;br /&gt;
If you execute &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;npm link &amp;lt;module-name&amp;gt;&lt;/span&gt;&amp;nbsp;a symbolic OS link&amp;nbsp;that points to the source directory of &amp;lt;module-name&amp;gt; will be created. Any changes within the source directory&amp;nbsp;will be visible within the client directory and can immediatly tested.&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;Now add the following code to your&amp;nbsp;&quot;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;~/cap-test/test.js&lt;/span&gt;&quot;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;script src=&quot;https://gist.github.com/1439940.js?file=gistfile1.js&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;This will (hopefully) yield the following output&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:package-03 $ node test.js&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;FOO&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;bar&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Public publishing&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;We are almost there ;-) only on small final thing.&amp;nbsp;We need to add a user&amp;nbsp;to the registry at www.npmjs.org.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~ $ npm adduser&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Username: robkuz&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Password:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Email: robert@capitalize.org&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;br /&gt;
This will create a file named ~/.npmrc that includes your email and your authentication token. This file is &amp;nbsp;used when you publish anything to the global npm registry.&lt;br /&gt;
&lt;br /&gt;
Now its time to begin our journey into land of the rich and famous.&amp;nbsp;Change back into the root directory of your module and issue npm publish&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~ $ cd capitalize&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/capitalize $ npm publish&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;br /&gt;
Finally everybody can find our module&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hector:~/cap-test $ npm find capitalize&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;NAME &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DESCRIPTION &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AUTHOR &amp;nbsp; KEYWORDS&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;capitalize &amp;nbsp;capitalizes and lowercases strings (example - No Production!) install scripts =robkuz&lt;/span&gt;&lt;br /&gt;
or install our module by simply issuing the command&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;npm install capitalize&lt;/span&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Parting Words&lt;/span&gt;&lt;br /&gt;
Please change the &quot;name&quot; key &amp;nbsp;in the package.json when you following this post.&lt;br /&gt;
you can&#39;t use &quot;capitalize&quot; as a name on the global npm registry as it is already exclusively assigned to me.&lt;br /&gt;
&lt;br /&gt;
I hope you enjoyed the show.&lt;br /&gt;
ps: the next blog will show you how to create command line tools with node.js&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://robkuz-blog.blogspot.com/feeds/3967789560111784827/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://robkuz-blog.blogspot.com/2011/12/introduction-into-node-modules-part-i.html#comment-form' title='3 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7470785286909857088/posts/default/3967789560111784827'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7470785286909857088/posts/default/3967789560111784827'/><link rel='alternate' type='text/html' href='http://robkuz-blog.blogspot.com/2011/12/introduction-into-node-modules-part-i.html' title='Introduction into Node Modules Part I'/><author><name>robertj</name><uri>http://www.blogger.com/profile/08094923479637589925</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='29' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQBv8P_JmY99GpoOmn45FVPzxnAUQLN1oQ-7qoT9w6WGs9GqNgFrRfT5quOQjMUQC1tgiQUbW_ULdbadurrddhUqCVDDOTtkxdVLFz0DKFFT2p_8wUD2X_c4zVGiTgPqw/s220/rk_twitter.JPG'/></author><thr:total>3</thr:total></entry></feed>