-
Notifications
You must be signed in to change notification settings - Fork 0
/
feed.xml
648 lines (454 loc) · 47.6 KB
/
feed.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Ryan Yang</title>
<description>Everything about Ryan Yang</description>
<link>http://localhost:4000</link>
<atom:link href="http://localhost:4000/feed.xml" rel="self" type="application/rss+xml" />
<item>
<title>Choose Grunt, GulpJS or NPM?</title>
<description><p>Grunt, Gulp, and npm are the three build tools most frequently used in front-end development workflows. What are the differences? Which should I use to start? In this article, I will briefly summarize the areas where each tool excels in and give you a glimpse of how you can easily utilize these tools to automate your workflows or even adopt best practices (if you haven’t already do so).</p>
<h3 id="grunt--configuration-over-coding">Grunt : Configuration over coding</h3>
<p>Favoring task configuration over implementation make the process of re-read and fix old scripts more easy, Grunt implements the concatenation and minification process for you, it’s smart enough to care of the rest, you only need to specify input and output files. Grunt configurations (JSON objects) are easy to understand when they are small, but as they grow, it is a bit more difficult to read and understand huge configurations.
Grunt looks for its configuration under a property with the same name. Multi-tasking can have multi configurations, defined using arbitrarily named “targets.” In the example below, the concat task has “foo” and “bar” targets, while the uglify task only has a “bar” target.</p>
<div class="language-js highlighter-rouge"><pre class="highlight"><code><span class="nx">grunt</span><span class="p">.</span><span class="nx">initConfig</span><span class="p">({</span>
<span class="na">concat</span><span class="p">:</span> <span class="p">{</span>
<span class="na">foo</span><span class="p">:</span> <span class="p">{</span>
<span class="c1">// concat task "foo" target options and files go here.</span>
<span class="p">},</span>
<span class="na">bar</span><span class="p">:</span> <span class="p">{</span>
<span class="c1">// concat task "bar" target options and files go here.</span>
<span class="p">},</span>
<span class="p">},</span>
<span class="na">uglify</span><span class="p">:</span> <span class="p">{</span>
<span class="na">bar</span><span class="p">:</span> <span class="p">{</span>
<span class="c1">// uglify task "bar" target options and files go here.</span>
<span class="p">},</span>
<span class="p">},</span>
<span class="p">});</span>
</code></pre>
</div>
<h3 id="gulp--code-driven-build-tool">Gulp : Code-driven build tool</h3>
<p>Gulp uses streams instead of temporary files/folders, it makes IO more faster. Gulp places a little more emphasis on code over configuration with the use of pipes and streams. Gulp tasks are also very readable and easy to debug since you can set breakpoints in it, compared to no debugging in the configuration aspects of Grunt.</p>
<p>As an example, we will pipe through gulp-size , which calculate the size of the library that are in the buffer, and print that to the terminal. Note that if you add it before Uglify then you’d get the unminified size :</p>
<div class="language-js highlighter-rouge"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">gulp</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'gulp'</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">uglify</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'gulp-uglify'</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">size</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'gulp-size'</span><span class="p">);</span>
<span class="nx">gulp</span><span class="p">.</span><span class="nx">task</span><span class="p">(</span><span class="s1">'build'</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">gulp</span>
<span class="p">.</span><span class="nx">src</span><span class="p">(</span><span class="s1">'./myscript.js'</span><span class="p">)</span>
<span class="p">.</span><span class="nx">pipe</span><span class="p">(</span><span class="nx">uglify</span><span class="p">())</span>
<span class="p">.</span><span class="nx">pipe</span><span class="p">(</span><span class="nx">size</span><span class="p">())</span>
<span class="p">.</span><span class="nx">pipe</span><span class="p">(</span><span class="nx">gulp</span><span class="p">.</span><span class="nx">dest</span><span class="p">(</span><span class="s1">'./build'</span><span class="p">));</span>
<span class="p">});</span>
</code></pre>
</div>
<h3 id="npm-as-a-build-tool">NPM as a build tool</h3>
<p>In order to use npm as a task runner, we add the required properties to our packages.json, the name of the property will be the task name. Using npm has several obvious advantages as it hosts tens of thousands of packages and also allows for the use of the command line. An added bonus is that it also removes complexity from your project since you don’t need any other specific APIs of another tool or the inherent dependencies of the tools that you are using.</p>
<p>As an example, in the following package file, we will just copy a directory in our JavaScript build flow and compile an Stylus stylesheet during our CSS build flow. In this case, we’re using a single “&amp;” to run the tasks asynchronously.</p>
<div class="language-js highlighter-rouge"><pre class="highlight"><code><span class="p">{</span>
<span class="s2">"scripts"</span><span class="err">:</span> <span class="p">{</span>
<span class="s2">"build-js"</span><span class="err">:</span> <span class="s2">"cp -r src/js/ dist/js"</span><span class="p">,</span>
<span class="s2">"build-css"</span><span class="err">:</span> <span class="s2">"stylus src/css/all.styl -o dist/css"</span><span class="p">,</span>
<span class="s2">"build"</span><span class="err">:</span> <span class="s2">"npm run build-js &amp; npm run build-css"</span>
<span class="p">},</span>
<span class="s2">"devDependencies"</span><span class="err">:</span> <span class="p">{</span>
<span class="s2">"stylus"</span><span class="err">:</span> <span class="s2">"latest"</span>
<span class="p">}</span>
<span class="p">}</span>
</code></pre>
</div>
<h3 id="wrap-up">Wrap Up</h3>
<p>I hope you’ve been able to learn a few things about using Grunt, Gulp, and npm as a build process in general. During rapid prototyping, automation tools might be a step that you wouldn’t consider, but once you begin to juggle multiple projects, maintenance becomes a chore and soon you find yourself appreciating these build tools which can help you quickly optimize your assets for quicker deployments and updates.</p>
<!-- {
"devDependencies": {
"jshint": "latest",
"uglify": "latest",
"stylus": "latest",
"cssmin": "latest"
},
"scripts": {
"scss": "node-sass --output-style compressed -o dist/css src/scss"
"lint": "lint src/js/*",
"uglify": "uglifyjs src/js/*.js -m -o dist/js/app.js"
"build:css": "npm run scss && npm run autoprefixer",
"build:js": "npm run lint && npm run uglify",
"build": "npm run build:css && npm run build:js"
"serve": "browser-sync start --server --files 'dist/css/*.css, dist/js/*.js'"
}
} -->
</description>
<pubDate>Thu, 03 Nov 2016 00:00:00 +0800</pubDate>
<link>http://localhost:4000/web/2016/11/03/choose-grunt-gulp-or-npm.html</link>
<guid isPermaLink="true">http://localhost:4000/web/2016/11/03/choose-grunt-gulp-or-npm.html</guid>
</item>
<item>
<title>Using subversion (GUI) SVNx to publish your WordPress plugin</title>
<description><p>You have just got approved by WordPress and handed your official WordPress repository and want to get up and running with publishing your WordPress plugin at the plugin directory.</p>
<p>But you have been using git have no time to learn all the nooks and crannies of SVN, what should you do?</p>
<p>If you are using a mac, I would recommend you to use SVNx. It is free and easy to use and you can download it <a href="https://code.google.com/p/svnx/">here</a>.</p>
<p>Once you downloaded, simply open up the app and go to the top menu bar and right under ‘Window’, you will see ‘<strong>Repositories</strong>’ and ‘<strong>Working Copies</strong>’.</p>
<p><img src="http://localhost:4000/assets/img/uploads/svnx-screenshot-1.jpg" /></p>
<p>Basically, ‘<strong>Repositories</strong>’ is the one where you specify your WordPress plugin repository.</p>
<p>So you can go ahead and hit the “+” sign to create a respository.</p>
<ul>
<li>Enter a <strong>Name</strong> for your repository (can be anything)</li>
<li><strong>Path</strong> which will be something like http://plugins.svn.wordpress.org/your-plugin-name/</li>
<li><strong>User</strong> and <strong>Pass</strong> which will be your wordpress.org credentials</li>
</ul>
<p><img src="http://localhost:4000/assets/img/uploads/svnx-screenshot-2.jpg" /></p>
<p>If your svn plugin url and credentials are right, at the GUI you will see that under ‘root’, there are 4 folders.</p>
<ul>
<li>assets</li>
<li>branches</li>
<li>tags</li>
<li>trunk</li>
</ul>
<p>Go ahead and svn checkout the files to a local directory.</p>
<p><img src="http://localhost:4000/assets/img/uploads/svnx-screenshot-3.jpg" /></p>
<p>Next go to Window -&gt; Working Copies and hit the “+” sign to create a “Working Copy”.</p>
<p><img src="http://localhost:4000/assets/img/uploads/svnx-screenshot-4.jpg" /></p>
<ul>
<li>Enter a <strong>Name</strong> for your working copy. (can be anything)</li>
<li><strong>Path</strong> which will be the location where you checked out your respository in the previous step.</li>
<li><strong>User</strong> and <strong>Pass</strong> which will be your wordpress.org credentials.</li>
</ul>
<p>2) Copy all your plugin files to the trunk folder. ( This is where your development files should be. )</p>
<p>Now when you double click on your <strong>Working Copy</strong>, you will see the files that have been added to your directory. If a new file is added, you will see an ‘A’ in front of the file path. If file has been changed, you will see an ‘M’ instead.</p>
<p>To upload your files to your repository is simple. Just select all the files you want and click ‘Add’ or ‘Update’ and then ‘Commit’ to commit your changes to the wordpress repository.</p>
<p><img src="http://localhost:4000/assets/img/uploads/svnx-screenshot-5.jpg" /></p>
<p>Once you have committed the changes, you will see a Rev # and date/time along with your commit message over at the Respositories window.</p>
<p><img src="http://localhost:4000/assets/img/uploads/svnx-screenshot-6.jpg" /></p>
<p>Now to tag your release, all you need to do is to svn copy the newly updated ‘trunk’ folder to the ‘tags’ folder and indicate a ‘version’. Make sure that this version corresponds to the version info specified in your plugin main php file.</p>
<p><img src="http://localhost:4000/assets/img/uploads/svnx-screenshot-7.jpg" /></p>
<p>Here is a simplified workflow of a WordPress plugin update using SVNx</p>
<ol>
<li>Do all your changes in the ‘trunk’ folder</li>
<li>Update the ‘Stable tag’ in the readme file.</li>
<li>Update the ‘Version’ in your plugin’s main PHP file.</li>
<li>Commit the additions/updates in the ‘trunk’ folder at ‘Working Copies’ window</li>
<li>Go over to ‘Repositories’ window</li>
<li>Tag the new version by copying the ‘trunk’ folder to a new tag under the ‘tags’ folder.</li>
</ol>
<h3 id="things-to-note">Things to note</h3>
<ul>
<li>Make sure you are selecting the trunk folder before you click on ‘svn copy’ and that you have selected the ‘tags’ folder for the target.</li>
<li>Always remember to update your ‘Stable tag’ in the readme.txt file</li>
<li>You need to include ‘Version’ info the plugin main php, your plugin page will not show the correct download version.</li>
</ul>
</description>
<pubDate>Thu, 03 Apr 2014 00:00:00 +0800</pubDate>
<link>http://localhost:4000/web/2014/04/03/using-subversion-gui-synx-to-publish-your-wordpress-plugin.html</link>
<guid isPermaLink="true">http://localhost:4000/web/2014/04/03/using-subversion-gui-synx-to-publish-your-wordpress-plugin.html</guid>
</item>
<item>
<title>Using subversion (Command Line) to publish your WordPress plugin</title>
<description><p>I recently had to write a WordPress plugin for my web application. Here is, step-by-step guide to publish your WordPress plugin.</p>
<h3 id="what-you-need">What you need.</h3>
<ol>
<li>A WordPress.org account</li>
<li>Learn how to use Subversion (SVN)</li>
</ol>
<h3 id="prerequistie">Prerequistie</h3>
<ol>
<li>Your own WordPress plugin</li>
</ol>
<h2 id="using-svn">Using SVN</h2>
<p>There are a number of ways to publish your WordPress.</p>
<ol>
<li>You can either use svn via the command line (or)</li>
<li>if you are new to svn and want to <a href="">get going with a GUI</a>. I recommend you to use <a href="https://code.google.com/p/svnx/">SVNx</a>.</li>
</ol>
<p>If you are more familar with the command line, you can simply open up Terminal on your mac.</p>
<p>If you don’t know if you have svn installed, check by using ‘which’ command.</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="gp">$ </span>which svn
/usr/bin/svn</code></pre></figure>
<p>1) Checkout the repository files from WordPress to your local directory</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="gp">$ </span>svn co http://plugins.svn.wordpress.org/your-plugin-name my-local-dir</code></pre></figure>
<p>You will notice that your my-local-dir now has 4 folders</p>
<ul>
<li>assets</li>
<li>branches</li>
<li>tags</li>
<li>trunk</li>
</ul>
<p>2) Copy all your plugin files to the trunk folder. ( This is where your development files should be. )</p>
<p>3) Add files to your repository trunk</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="gp">$ </span>svn add trunk/<span class="k">*</span>
<span class="gp">$ </span>svn ci -m <span class="s1">'First commit'</span></code></pre></figure>
<p>4) Tag your release version</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="gp">$ </span>svn cp trunk tags/1.0
<span class="gp">$ </span>svn ci -m <span class="s2">"Tagging version 1.0"</span></code></pre></figure>
<p>Here is a simplified workflow of a WordPress plugin update</p>
<ol>
<li>Do all your changes in the “trunk” folder</li>
<li>Update the “Stable tag” in the readme file.</li>
<li>Update the “Version” in your plugin’s main PHP file.</li>
<li>Commit the changes in the “trunk” folder</li>
<li>Tag the new version by copying the “trunk” folder to a new tag under the “tags” folder.</li>
</ol>
<h3 id="things-to-note">Things to note</h3>
<ul>
<li>Always remember to update your “Stable tag” in the readme.txt file</li>
<li>You need to include “Version” info the plugin main php, your plugin page will not show the Download Version 1.0 correctly.</li>
</ul>
</description>
<pubDate>Thu, 03 Apr 2014 00:00:00 +0800</pubDate>
<link>http://localhost:4000/web/2014/04/03/using-subversion-ci-to-publish-your-wordpress-plugin.html</link>
<guid isPermaLink="true">http://localhost:4000/web/2014/04/03/using-subversion-ci-to-publish-your-wordpress-plugin.html</guid>
</item>
<item>
<title>Using eval with redis-cli and lua</title>
<description><p>Recently, I had to use redis for some bash scripting and came across lua as the –eval option on redis command line.</p>
<p>Lua come across as a very simple scripting language and extremely lightweight and designed for easy integration into existing applications.</p>
<p>Because it has so few functions out of the box, you can learn it within a couple of hours and if you are only using it for the purpose of passing some key value stores to redis via the command line, all you need to do is to master some of the basic conditionals of lua.</p>
<p>This allows you to create all the redis commands you need to perform in a lua script and have the redis-cli evaluate the file for you.</p>
<p>So you can have a simple lua script like:</p>
<p><u>script.lua</u></p>
<figure class="highlight"><pre><code class="language-lua" data-lang="lua"><span class="kd">local</span> <span class="n">some_value</span> <span class="o">=</span> <span class="n">KEYS</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
<span class="n">redis</span><span class="p">.</span><span class="n">call</span><span class="p">(</span><span class="s1">'setnx'</span><span class="p">,</span><span class="s1">'counter'</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span>
<span class="k">if</span> <span class="n">some_value</span> <span class="o">~=</span> <span class="kc">nil</span> <span class="k">then</span>
<span class="n">redis</span><span class="p">.</span><span class="n">call</span><span class="p">(</span><span class="s1">'HSET'</span><span class="p">,</span><span class="s1">'member'</span><span class="p">,</span><span class="s1">'some_field'</span><span class="p">,</span><span class="s1">'some_value'</span><span class="p">)</span>
<span class="k">end</span></code></pre></figure>
<p>and then run your command like so</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">redis-cli -eval /path/to/script.lua</code></pre></figure>
<p>In a more real world situation, you are mostly like to use a command before piping to redis-cli like this.</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">cat file | redis-cli -eval /path/to/script.lua <span class="k">$(</span>awk <span class="s1">'{print $2}'</span><span class="k">)</span></code></pre></figure>
<p>With a simple lua script, you can avoid using an additional layer of abstraction to interact with redis - a fast key value storage system.</p>
</description>
<pubDate>Thu, 27 Feb 2014 00:00:00 +0800</pubDate>
<link>http://localhost:4000/web/2014/02/27/using-eval-with-redis-cli-and-lua.html</link>
<guid isPermaLink="true">http://localhost:4000/web/2014/02/27/using-eval-with-redis-cli-and-lua.html</guid>
</item>
<item>
<title>Optimizing Case sensitive unique key query without using utf8_bin-collation</title>
<description><p>Most users of mysql would likely to have the collation of their database set to <span class="impt">utf8_general_ci</span>.</p>
<p>Say you have a need to have a table of items with ‘name’ as a unique key and want a name like “Guns N’ Roses” to be different from “Guns n’ Roses”</p>
<p>Right away you would do something like:</p>
<figure class="highlight"><pre><code class="language-sql" data-lang="sql"><span class="k">ALTER</span> <span class="k">TABLE</span> <span class="n">bands</span> <span class="k">ALTER</span> <span class="k">COLUMN</span> <span class="n">name</span> <span class="n">varchar</span><span class="p">(</span><span class="mi">255</span><span class="p">)</span> <span class="k">COLLATE</span> <span class="n">utf8_bin</span>
<span class="k">ALTER</span> <span class="k">TABLE</span> <span class="n">bands</span> <span class="k">ADD</span> <span class="k">UNIQUE</span> <span class="p">(</span><span class="n">name</span><span class="p">)</span></code></pre></figure>
<p>Alternatively, you can do a one way hash for ‘name’ field with md5 and store it as ‘name_hash’.</p>
<p><strong>**Note you still need to set it as a unique key but because md5 strings are all in 32 digit hexadecimal number, you don’t have to collate your hash column differently from the rest of your table.</strong></p>
<p>This is similar to how <span class="impt">utf8_bin compares characters in binary format</span>. This means that characters like “å” will not be treated like “a”.</p>
<hr />
<p>In doing so, you can simply do a search</p>
<figure class="highlight"><pre><code class="language-php" data-lang="php"><span class="cp">&lt;?php</span>
<span class="nv">$name</span> <span class="o">=</span> <span class="s1">'Romeo &amp; Juliet'</span><span class="p">;</span>
<span class="nv">$name_hash</span> <span class="o">=</span> <span class="nb">md5</span><span class="p">(</span><span class="nv">$name</span><span class="p">);</span>
<span class="cp">?&gt;</span></code></pre></figure>
<figure class="highlight"><pre><code class="language-php" data-lang="php"><span class="cp">&lt;?php</span>
<span class="nv">$sql</span> <span class="o">=</span> <span class="s2">"SELECT * FROM bands WHERE name_hash = "</span><span class="o">.</span><span class="nb">md5</span><span class="p">(</span><span class="nv">$name</span><span class="p">);</span>
<span class="cp">?&gt;</span></code></pre></figure>
<p>Now, you may think, why use a hash when you can let mysql do all the heavy lifting? The benefit comes when there are times you have <strong>multiple unique keys</strong> and have no real use for the unique keys except to check if the row exist.</p>
<p>You can combine all the unique fields into one <span class="impt">single hash column</span> where you can query like so.</p>
<figure class="highlight"><pre><code class="language-php" data-lang="php"><span class="cp">&lt;?php</span>
<span class="nv">$sql</span> <span class="o">=</span> <span class="s2">"SELECT id FROM bands WHERE hash = "</span><span class="o">.</span><span class="nb">md5</span><span class="p">(</span><span class="s2">"</span><span class="nv">$field_1</span><span class="s2"> , </span><span class="nv">$field_2</span><span class="s2"> , </span><span class="nv">$field_3</span><span class="s2"> , </span><span class="nv">$field_4</span><span class="s2">"</span><span class="p">);</span>
<span class="cp">?&gt;</span></code></pre></figure>
<p>This saves mysql from checking multiple columns for matches simply to fulfill a check exist query.</p>
</description>
<pubDate>Wed, 01 Jan 2014 00:00:00 +0800</pubDate>
<link>http://localhost:4000/web/2014/01/01/optimizing-case-sensitive-unique-key-query-without-using-utf8_cs-collation.html</link>
<guid isPermaLink="true">http://localhost:4000/web/2014/01/01/optimizing-case-sensitive-unique-key-query-without-using-utf8_cs-collation.html</guid>
</item>
<item>
<title>How to install luarocks (Unix)</title>
<description><p>LuaRocks, a deployment and management system for Lua modules. Like homebrew for mac users, luarocks has a repository that makes the installation of lua modules a breeze.</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">wget http://luarocks.org/releases/luarocks-2.1.2.tar.gz
tar -zxvf luarocks-2.1.2.tar.gz
<span class="nb">cd </span>luarocks-2.1.2</code></pre></figure>
<p>Depending on your setup, you may need to specify the lua location. The default is /usr</p>
<p>For my setup, I have installed the lua at /usr/local/bin/lua</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">./configure --with-lua<span class="o">=</span>/usr/local/bin
make
sudo make install</code></pre></figure>
<p>The full list of available configurations is <a href="http://luarocks.org/en/Installation_instructions_for_Unix">here</a>.</p>
<p>Once install you can install your modules like so</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">luarocks install luafilesystem</code></pre></figure>
</description>
<pubDate>Thu, 28 Nov 2013 00:00:00 +0800</pubDate>
<link>http://localhost:4000/web/2013/11/28/how-to-install-luarocks-on-ubuntu.html</link>
<guid isPermaLink="true">http://localhost:4000/web/2013/11/28/how-to-install-luarocks-on-ubuntu.html</guid>
</item>
<item>
<title>Package management command cheat sheet for Redhat Linux</title>
<description><p>Here is my list of mostly frequently used <strong>yum</strong> commmnds that will help you handle most if not all of the package management <u>you will ever need</u>.</p>
<p>##Updating repositories</p>
<p>If you are using <strong>Fedora</strong>, then you usually have the latest repository without doing much.</p>
<p>If you are using <strong>CentOS</strong> or <strong>RHEL</strong>, then you best bet is to get the repo from <a href="https://webtatic.com/projects/yum-repository/">webtatic</a>.
The installation of the repo is simply “rpm -Uvh” followed by the repo url.</p>
<h3 id="yum">YUM</h3>
<p>Searching for package</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="c"># search package name &amp; description by term
</span>
<span class="gp">$ </span>yum search tomcat
<span class="c"># search package name that start with term
</span>
<span class="gp">$ </span>yum list tomcat
tomcat7-common
tomcat7
tomcat7-admin
tomcat7-examples
tomcat7-docs
tomcat7-user
<span class="c"># list all installed packages in system
</span>
<span class="gp">$ </span>yum list installed</code></pre></figure>
<p>Upgrading packages</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="c"># upgrade packages (safe)
</span>
<span class="gp">$ </span>yum update
<span class="c"># upgrade packages and remove existing obsolete packages
</span>
<span class="c"># which you may be using
</span>
<span class="gp">$ </span>yum upgrade</code></pre></figure>
<p>Installing packages</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="c"># install specific package
</span>
<span class="gp">$ </span>yum install tomcat7
<span class="c"># remove wildcard package
</span>
<span class="gp">$ </span>yum install <span class="s1">'tomcat7*'</span>
<span class="c"># install package group
</span>
<span class="gp">$ </span>yum groupinstall <span class="s1">'Development Tools'</span></code></pre></figure>
<p>Removing packages</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="c"># install specific package
</span>
<span class="gp">$ </span>yum erase tomcat7
<span class="c"># remove wildcard package
</span>
<span class="gp">$ </span>yum erase <span class="s1">'tomcat7*'</span></code></pre></figure>
<p>Checking for broken packages/ dependencies</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="c"># update package cache and check for broken dependencies
</span>
<span class="gp">$ </span>yum check
<span class="c"># check for packages to update
</span>
<span class="gp">$ </span>yum check-update
<span class="c"># reinstall package and dependencies
</span>
<span class="gp">$ </span>yum reinstall</code></pre></figure>
<p>Cleaning up archive files</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="c"># delete all cached data
</span>
<span class="gp">$ </span>yum clean</code></pre></figure>
</description>
<pubDate>Wed, 20 Nov 2013 00:00:00 +0800</pubDate>
<link>http://localhost:4000/web/2013/11/20/package-management-command-cheat-sheet-for-redhat-linux.html</link>
<guid isPermaLink="true">http://localhost:4000/web/2013/11/20/package-management-command-cheat-sheet-for-redhat-linux.html</guid>
</item>
<item>
<title>Package management command cheat sheet for Debian Linux</title>
<description><p>Here is my list of mostly frequently used <strong>apt-cache</strong> and <strong>apt-get</strong> commmands that will help you handle most if not all of the package management <u>you will ever need</u>.</p>
<h3 id="apt-cache">APT-CACHE</h3>
<p>Searching for package</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="c"># search package name &amp; description by term
</span>
<span class="gp">$ </span>apt-cache search tomcat7
libtomcat7-java - Servlet and JSP engine -- core libraries
tomcat7 - Servlet and JSP engine
tomcat7-admin - Servlet and JSP engine -- admin web applications
tomcat7-common - Servlet and JSP engine -- common files
tomcat7-docs - Servlet and JSP engine -- documentation
tomcat7-examples - Servlet and JSP engine -- example web applications
tomcat7-user - Servlet and JSP engine -- tools to create user instances
<span class="c"># search package name that start with term
</span>
<span class="gp">$ </span>apt-cache pkgnames tomcat7
tomcat7-common
tomcat7
tomcat7-admin
tomcat7-examples
tomcat7-docs
tomcat7-user</code></pre></figure>
<h3 id="apt-get">APT-GET</h3>
<p>Updating package source list</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="gp">$ </span>sudo apt-get update</code></pre></figure>
<p>Upgrading packages</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="c"># upgrade packages (safe)
</span>
<span class="gp">$ </span>sudo apt-get upgrade
<span class="c"># upgrade may add or remove existing packages
</span>
<span class="gp">$ </span>sudo apt-get dist-upgrade</code></pre></figure>
<p>Installing packages</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="c"># install specific package
</span>
<span class="gp">$ </span>sudo apt-get install tomcat7
<span class="c"># remove wildcard package
</span>
<span class="gp">$ </span>sudo apt-get install <span class="s1">'tomcat7*'</span></code></pre></figure>
<p>Removing packages</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="c"># install specific package
</span>
<span class="gp">$ </span>sudo apt-get remove tomcat7
<span class="c"># remove wildcard package
</span>
<span class="gp">$ </span>sudo apt-get remove <span class="s1">'tomcat7*'</span>
<span class="c"># remove package &amp; config files
</span>
<span class="gp">$ </span>sudo apt-get purge tomcat7</code></pre></figure>
<p>Checking for broken packages/ dependencies</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="c"># update package cache and check for broken dependencies
</span>
<span class="gp">$ </span>sudo apt-get check
<span class="c"># install dependencies for package
</span>
<span class="gp">$ </span>sudo apt-get build-dep</code></pre></figure>
<p>Cleaning up archive files</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="c"># delete all stored archived .deb files
</span>
<span class="gp">$ </span>sudo apt-get clean
<span class="c"># only delete .deb files that can no longer be downloaded
</span>
<span class="gp">$ </span>sudo apt-get autoclean</code></pre></figure>
</description>
<pubDate>Wed, 20 Nov 2013 00:00:00 +0800</pubDate>
<link>http://localhost:4000/web/2013/11/20/package-management-command-cheat-sheet-for-debian-linux.html</link>
<guid isPermaLink="true">http://localhost:4000/web/2013/11/20/package-management-command-cheat-sheet-for-debian-linux.html</guid>
</item>
<item>
<title>Difference between redis EVAL command and redis-cli --eval</title>
<description><p>There are a number of tutorials that focus on the redis eval command (which is the interactive mode).</p>
<p>Most of it demostrates with using the cli like so</p>
<figure class="highlight"><pre><code class="language-sh" data-lang="sh">redis-cli
EVAL <span class="s2">"</span><span class="k">$(</span>cat update_members.lua<span class="k">)</span><span class="s2">"</span> 2 members:counter members:email username@example.com</code></pre></figure>
<p>where the <u>update_members.lua</u> is something like:</p>
<figure class="highlight"><pre><code class="language-lua" data-lang="lua"><span class="n">counter</span> <span class="o">=</span> <span class="n">KEYS</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
<span class="n">member_emails</span> <span class="o">=</span> <span class="n">KEYS</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
<span class="n">email</span> <span class="o">=</span> <span class="n">ARGV</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
<span class="kd">local</span> <span class="n">member_id</span> <span class="o">=</span> <span class="n">redis</span><span class="p">.</span><span class="n">call</span><span class="p">(</span><span class="s2">"INCR"</span><span class="p">,</span> <span class="n">counter</span><span class="p">)</span>
<span class="n">redis</span><span class="p">.</span><span class="n">call</span><span class="p">(</span><span class="s2">"HSET"</span><span class="p">,</span> <span class="n">member_emails</span><span class="p">,</span> <span class="n">member_id</span><span class="p">,</span> <span class="n">email</span><span class="p">)</span>
<span class="k">return</span> <span class="n">member_id</span></code></pre></figure>
<p>While this is not wrong, most of you might be confuse this with the –eval option available on redis-cli which is awfully similar. You might end up wondering why your KEYS[1] and ARG[1] are gumbled up and the error messages are not making any sense.</p>
<p>If you type redis-cli –help, you get the <strong>typical bullshit documentation</strong>.</p>
<p>It doesn’t offer any explanation why your arguments are not working, the way it should (or least the way you expected it to be like the EVAL command in interactive mode).</p>
<figure class="highlight"><pre><code class="language-sh" data-lang="sh">redis-cli --help
Usage: redis-cli <span class="o">[</span>OPTIONS] <span class="o">[</span>cmd <span class="o">[</span>arg <span class="o">[</span>arg ...]]]
--eval &lt;file&gt; Send an EVAL <span class="nb">command </span>using the Lua script at &lt;file&gt;</code></pre></figure>
<blockquote>
<p>If you are using the command line format — <strong>redis-cli –eval</strong>, there is no ARGV variable in the file.</p>
</blockquote>
<p>You only have <strong>KEYS</strong>, and can assess them like KEYS[1], KEYS[2], etc and <span class="impt">you don’t have to specify the number of arguments</span> like you do in the EVAL command.</p>
<p>And so you only need to do something like:</p>
<figure class="highlight"><pre><code class="language-sh" data-lang="sh">redis-cli -eval /path/to/script.lua key1 key2 key3</code></pre></figure>
<p>And there you go, you can do call your redis operations using redis.call() and go ahead to script in lua.</p>
<p>Personally, I find that more use for the redis-cli –eval because I use to pipe variables from other input to redis-cli.</p>
</description>
<pubDate>Thu, 14 Nov 2013 00:00:00 +0800</pubDate>
<link>http://localhost:4000/web/2013/11/14/difference-between-redis-eval-command-and-redis-cli-eval.html</link>
<guid isPermaLink="true">http://localhost:4000/web/2013/11/14/difference-between-redis-eval-command-and-redis-cli-eval.html</guid>
</item>
<item>
<title>What is your use for Redis?</title>
<description><p>Personally, I use redis for storing/ caching simple stats like google analytics, caching mysql queries and counter stats for applications.</p>
<p>I think the main use for redis is strictly to caching at abstract query level. If you are planning to store records, I think using solr will a more suitable option.</p>
<p>Stackoverflow also primary uses redis for <a href="http://meta.stackexchange.com/questions/69164/does-stack-overflow-use-caching-and-if-so-how/69172#69172">caching</a>.</p>
</description>
<pubDate>Thu, 23 May 2013 00:00:00 +0800</pubDate>
<link>http://localhost:4000/web/2013/05/23/what-is-your-use-for-redis.html</link>
<guid isPermaLink="true">http://localhost:4000/web/2013/05/23/what-is-your-use-for-redis.html</guid>
</item>
</channel>
</rss>