tag:blogger.com,1999:blog-205949332024-03-13T07:27:27.531-04:00Henry Tseng: BlogSome engineering mumbo-jumbo. Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.comBlogger54125tag:blogger.com,1999:blog-20594933.post-8417657331431168182014-04-17T00:36:00.000-04:002014-06-13T13:14:14.922-04:00Changing Directories Faster <div>
Having a rough time navigating around? Try using these couple of commands to help speed you up:</div>
<div>
<br /></div>
<div>
Use pushd and popd (manage a stack of directories you'll revisit):</div>
<div>
<span style="font-family: Courier New, Courier, monospace;">pushd /etc/</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">popd</span></div>
<div>
<br /></div>
<div>
Change to the previous directory you were in:</div>
<div>
<span style="font-family: Courier New, Courier, monospace;">cd -</span></div>
<div>
<br /></div>
<div>
Home directory: /home/user</div>
<div>
<span style="font-family: Courier New, Courier, monospace;">cd ~</span></div>
<div>
<br /></div>
<div>
Evaluate code inline to change directories:</div>
<div>
<span style="font-family: Courier New, Courier, monospace;">cd /home/`whoami`</span></div>
<div>
<br /></div>
<div>
Search for a previous command that you've entered via reverse-i-search:</div>
<span style="font-family: Courier New, Courier, monospace;">Use <span style="font-size: 14px; line-height: 22px;">⌃</span>R</span><br />
<div>
<br /></div>
<div>
Also, popularly use your history up/down arrows. </div>
<div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com0tag:blogger.com,1999:blog-20594933.post-85442506760191154362014-04-16T13:14:00.001-04:002014-04-16T13:18:45.933-04:00IntelliJ: Multiple Cursors and Selection As a programming who's worked in IDE's such as Eclipse/IntelliJ and now works with Sublime you'll be excited to hear that IntelliJ now supports multiple selections and editting:<br />
<div>
<br /></div>
<div>
<a href="http://blog.jetbrains.com/ruby/2014/03/whats-mining-multiple-cursors-and-selection/">http://blog.jetbrains.com/ruby/2014/03/whats-mining-multiple-cursors-and-selection/</a></div>
<div>
<br /></div>
<div>
Woot woot!</div>
<div>
<br /></div>
<div>
For Mac OSX:</div>
<div>
<br /></div>
<div>
<b>Multiple Cursors with mouse:</b></div>
<div>
Visit <span style="font-family: Courier New, Courier, monospace;">Settings > Keymap > Editor Actions > Add or Remove Caret</span> <span style="font-family: inherit;">and enable <span style="line-height: 24px;">⌥⇧ + Mouse Click. </span></span></div>
<div>
<br /></div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIItRLSOEGgBSYA460-pWp7ZFQ7p9SMJ0phwZ5dTCO8jHaOAvk5AzScLKJ9unIb_8rLBsCBxBoqdBzf_FirWYxZXg73T4Oaem8K0AKmDJYINTeG3ED8nJrDaS2LDUwHkznLZGG/s1600/mouse.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIItRLSOEGgBSYA460-pWp7ZFQ7p9SMJ0phwZ5dTCO8jHaOAvk5AzScLKJ9unIb_8rLBsCBxBoqdBzf_FirWYxZXg73T4Oaem8K0AKmDJYINTeG3ED8nJrDaS2LDUwHkznLZGG/s1600/mouse.jpg" height="183" width="400" /></a></div>
<br /></div>
<div>
<b>Change Multiple Occurrences:</b></div>
<div>
Press <span style="font-family: Georgia, 'Bitstream Charter', serif; font-size: 16px; line-height: 24px;">⌃⌘G </span>to change multiple occurrences of selection in your code. </div>
<div>
<br /></div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkyevEOV9OsydLSyfGu_05njKL1s09dGpczuOKFKoxGFuabQk4lTXDibxaW5Blo-7lSTmhK6dcJMppASRKmAenFX7tzGhnmeFAjyKDqT58NHdluXH8whlHs65Gm__gEWjcg341/s1600/selection.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkyevEOV9OsydLSyfGu_05njKL1s09dGpczuOKFKoxGFuabQk4lTXDibxaW5Blo-7lSTmhK6dcJMppASRKmAenFX7tzGhnmeFAjyKDqT58NHdluXH8whlHs65Gm__gEWjcg341/s1600/selection.jpg" height="183" width="400" />
</a>
</div>
Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com0tag:blogger.com,1999:blog-20594933.post-42624525601846081802014-04-11T18:45:00.000-04:002014-04-11T19:04:28.026-04:00Writing Fast Javascript - Compiler Optimization (V8, Node.js)Understanding how a compiler optimizes code can add significantly increase the efficiency of code. Working within a team we've run into all kinds of styles/preferences of Javascript code. Of course, with a language like Javascript it's important to understand that one style/preference can have penalties. <br />
So for the last few years, Lars Bak has been getting a bit of attention for bringing speed to Javascript through the implementation of OOP compiler technology to the Javascript JIT (Just-In-Time compiler) in V8. Bak worked on several compilers in the past and has a great deal of experience he brings from writing many VM's. <br />
<br />
V8 has been making waves through Google's mail service, Gmail, and their suite of office apps, Google Docs.<br />
<br />
<a href="http://www.ft.com/intl/cms/s/0/03775904-177c-11de-8c9d-0000779fd2ac.html#axzz2ybGxAlPI">http://www.ft.com/intl/cms/s/0/03775904-177c-11de-8c9d-0000779fd2ac.html#axzz2ybGxAlPI</a><br />
<br />
Considering the idea of creating Objects dynamically:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">var point1 = {</span><br />
<span style="font-family: Courier New, Courier, monospace;"> x: 1,</span><br />
<span style="font-family: Courier New, Courier, monospace;"> y: 2</span><br />
<span style="font-family: Courier New, Courier, monospace;">};</span><br />
<br />
And modifying them:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">point1.x = 5;</span><br />
<br />
It's important to note the way these optimizations work is through an assumption that dynamic languages have a inherit structure. And the JIT in V8 takes advantage of this structure. <br />
<br />
Writing a function such as:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">function Point(x, y) { ...</span><br />
<br />
Causes the JIT to create a class definition. Assigning values within that function:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">function Point(x, y) {</span><br />
<span style="font-family: Courier New, Courier, monospace;"> this.x = x;</span><br />
<span style="font-family: Courier New, Courier, monospace;"> this.y = y;</span><br />
<div>
<span style="font-family: Courier New, Courier, monospace;">...</span></div>
<br />
Then signals to the JIT to transition the class to a class definition with specific parameters <span style="font-family: Courier New, Courier, monospace;">this.x</span> and <span style="font-family: Courier New, Courier, monospace;">this.y</span>. <br />
<br />
This allows the engine to run highly optimized. V8 does not use the traditional technique of compiling Javascript to intermediary bytecode but instead compiles Javascript to native machine code. <br />
<br />
Changing the structure of an object can cause it to degrade into a hash, which is tremendously slow. <br />
<br />
I'd love to see how <a href="http://news.dartlang.org/2013/11/dart-10-stable-sdk-for-structured-web.html">Dart</a> makes headway and changes the landscape for Javascript. <br />
<br />
Here Lars Bak talks about some optimizations in V8:<br />
<br />
<a href="http://channel9.msdn.com/Shows/Going+Deep/Expert-to-Expert-Erik-Meijer-and-Lars-Bak-Inside-V8-A-Javascript-Virtual-Machine">http://channel9.msdn.com/Shows/Going+Deep/Expert-to-Expert-Erik-Meijer-and-Lars-Bak-Inside-V8-A-Javascript-Virtual-Machine</a><br />
<div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com0tag:blogger.com,1999:blog-20594933.post-67585773371877342032014-01-17T10:58:00.000-05:002014-01-17T10:58:06.186-05:00Robomongo MongoDb ClientBeen looking for a good MongoDb client for a while. Robomongo by Paralect has been promising. <br />
<br />
<a href="http://robomongo.org/">http://robomongo.org/</a><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://robomongo.org/images/full-power-of-shell.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://robomongo.org/images/full-power-of-shell.png" height="320" width="320" /></a></div>
<br />Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com0tag:blogger.com,1999:blog-20594933.post-6168950480585737812013-06-19T11:50:00.001-04:002013-06-19T11:50:11.104-04:00Here's a great reference for ECMA Script 5 features implemented in V8/Node.jsHere's a great reference for ECMA Script 5 features implemented in V8/Node.js<br />
<br />
<a href="https://github.com/joyent/node/wiki/ECMA-5-Mozilla-Features-Implemented-in-V8">https://github.com/joyent/node/wiki/ECMA-5-Mozilla-Features-Implemented-in-V8</a>Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com0tag:blogger.com,1999:blog-20594933.post-41831485864188319222013-03-02T02:08:00.002-05:002013-03-02T02:11:31.646-05:00Coordinating Nodejs Events EventAggregatorBeen looking for a quick way to synchronize multiple events and callbacks. Looked around and found a few solutions but nothing exactly what I was looking for. <br />
<br />
Henceforth, wrote up a quick module called EventAggregator.<br />
<br />
<code>npm install event-aggregator
</code>
<br />
<br />
So here's the problem. There's multiple resources we're waiting for these asynchronous operations to complete. Since we're looking to avoid nesting the code several levels deep inside of some functions, what we'll do is subscribe to several events and execute the necessary actions when they've completed. <br />
<br />
EventAggregator allows management of several triggering events each with their own lists. Multiple triggers can be set up by passing an array instead of a string for the triggering event. <br />
<br />
Load the module:<br />
<br />
<code>
var EventAggregator = require('event-aggregator').EventAggregator;
</code>
<br />
<br />
Subscribe to the events:
<br />
<br />
<code>var aggregator = new EventAggregator(); </code><br />
<code><br /></code>
<code>// Resource 1 </code><br />
<code>aggregator.waitEvent('complete', resource1, 'ready'); </code><br />
<code>aggregator.waitEvent('complete', resource1, 'connect'); </code><br />
<code><br /></code>
<code>// Resource 2 </code><br />
<code>resource2.createConnection(aggregator.waitCallback('complete'));
</code>
<br />
<br />
Set up a listener.
<br />
<br />
<code>
aggregator.on('complete', function() {
// ...
});</code><br />
<div>
<br /></div>
It's up on npm (<a href="https://npmjs.org/package/event-aggregator">https://npmjs.org/package/event-aggregator</a>). It's also up on git (<a href="https://github.com/henrytseng/event-aggregator">https://github.com/henrytseng/event-aggregator</a>). Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com0tag:blogger.com,1999:blog-20594933.post-87545311382485435302012-08-23T23:58:00.003-04:002012-08-23T23:58:35.019-04:00Choosing To Use PHP/KohanaThere seem to be so many blog posts about using Ruby on Rails or Python/Django these days that I thought I'd voice some thoughts about how PHP/Kohana is relevant and still a strong choice. <br />
<br />
Let's get this straight though, the languages:<br />
<ul>
<li>PHP</li>
<li>Ruby</li>
<li>Python</li>
</ul>
And the frameworks I'm talking about are:<br />
<ul>
<li>Kohana (PHP)</li>
<li>Ruby on Rails (Ruby)</li>
<li>Django (Python)</li>
</ul>
It can be a tremendous ear sore when people mix these up. On the other side of the spectrum, it's also annoying to hear people rant about which languages are better than another. It's very important to understand that the 3 of these languages can accomplish the similar goals.<br />
<br />
If you're not familiar with Kohana you can find it here.<br />
<a href="http://kohanaframework.org/index">http://kohanaframework.org/index</a><br />
<br />
Kohana is still a growing framework, but it's very strong and has a lot of potential. There have been some ORMs such as Sprig and Jelly developed by some talented developers. It has very fast benchmarks and good code organization through an HMVC structure.<br />
<br />
All software is built for a purpose, the goal should always be reaching that purpose while maximizing the return and minimizing the energy expenditure. And the value I'm talking about is not always quantifiable but there is tremendous value in building a team or growing a technology. <br />
<br />
The choice is clearest when cost is a very prohibitive factor. PHP developers are in the greatest quantity out there and hosting costs for Apache-PHP-MySQL services are amongst the lowest. In addition, while some give a notion that PHP is growing dated is still amongst the higher performers. <br />
<br />
There is something to be said about appreciating a language because of its elegance. When it comes down to keystrokes the fewer the better. It's true that when we're talking about development the real work that gets accomplished is physical work. But the greatest deal of work that gets done is the architectural work. Designing well thought out software is 80% of the battle. When we talk about debugging problems in software the more teammates getting involved later in the development process the most costly the issue becomes. Practicing unit testing and regression testing properly goes a long way. And when there is a launch making repairs post launch can require migration strategies and all kinds of headache. While debugging in inevitable, a poorly thought out project can cost ten fold in comparison to a well built project. <br />
<br />
I've heard that there are many unskilled PHP developers in the market. I think it's appropriate to say that using Ruby or Python can also befall unskilled developers or even skilled developers who are poor decision makers (e.g. - tunnel or narrow visioned). The important part of building a team and therefore executing a project when you're a team lead is to spend time with each of the resources you bring into the project. Getting on the same page with all of your team members is always key. As with PHP, there are skilled PHP developers who can build strong object oriented code. Also, in the same vein, PHP is also closer to C/C++. Most C/C++ developers tend to have stronger backgrounds. <br />
<br />
Ruby has gained loads of ground from people hearing that it is able to build applications in months rather than years, but the real benefit is the best practices followed by its developers which can translate into other languages. <br />
<br />
Don't get me wrong though. Ruby and Python are great languages and I fully appreciate their respective frameworks when I work with them. Python also has a large number of highly optimized routines. Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com0tag:blogger.com,1999:blog-20594933.post-67719790227658510452012-08-23T23:00:00.001-04:002012-08-23T23:21:26.818-04:00A Comparison Between Ruby, PHP and Python from UdemyHere's a great info graphic that compares Ruby, PHP and Python from Udemy. It makes a good comparison of the popularity of PHP versus the execution speed of Python and highlights PHP and Python as languages you should know if you're looking for work or looking to hire. <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://henrytseng.com/storage/blog/language_comparison/info_graphic.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://henrytseng.com/storage/blog/language_comparison/info_graphic.jpg" /></a></div>
<br />Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com1tag:blogger.com,1999:blog-20594933.post-8002228313579255412012-07-26T23:51:00.000-04:002012-07-27T00:14:32.322-04:00Tracking Application Build Versions Through Git Hooks<p>One thing I notice that development teams often lack is unified conventions. Most people like to do things their own way. That makes it hard to build a strong development process, but when everyone can agree on flexible, robust methods of approach we can do a whole lot to make everyone's lives on the team easier.
<p>Tracking software version is important. It becomes even more important when you need to constantly push files to production environments or coordinate versions between developers.
<p>Here's we're doing more and more in our development process at Canvas to coordinate multiple versions for an application we're building on Kohana PHP Framework. As an aside, Kohana is a great up and rising HMVC framework for PHP. Our team has been building on it for about a year now and we're pleased with the results.
<p>Kohana has configuration files and we're updating application/config/version.php via a git post-commit hook.
<p>So here's the version.php file:
<blockquote style="font-family: 'Courier New', Courier, monospace;">
<?php defined('SYSPATH') or die('No direct access allowed.');<br>
return array(<br>
'version' => '1.2.8',<br>
'last_modified' => 'Thu, 26 Jul 2012 22:59:45 EDT',<br>
);<br>
</blockquote>
<p>As you can see the file is pretty basic. It simply stores a version and a timestamp.
<p>Git hooks are simply scripts which get called automatically when a specific git command is made. We've set up our script as a post-commit so that each time a commit is made our script fires off.
<p>This Git script resides here in .git/hooks/post-commit
<p>Here's the post-commit script
<blockquote style="font-family: 'Courier New', Courier, monospace;">
#!/bin/sh<br>
#<br>
# An example hook script to prepare a packed repository for use over<br>
# dumb transports.<br>
#<br>
# To enable this hook, rename this file to "post-commit".<br>
exec php bin/post-commit.php<br>
</blockquote>
<p>As you can see its a bash script that calls a PHP script. Here's an example of a simple version of our post-commit.php script
<blockquote style="font-family: 'Courier New', Courier, monospace;">
<?php <br>
define('SYSPATH', getcwd());<br>
<br>
$config_path = 'application/config/version.php';<br>
$config = include($config_path);<br>
<br>
date_default_timezone_set('America/New_York');<br>
<br>
function increase_minor_version($config) {<br>
$new_ver = '1.0.1';<br>
if(isset($config['version'])) {<br>
$old_ver = $config['version'];<br>
$parts = explode('.', $old_ver);<br>
if(isset($parts[2])) {<br>
$parts[2] = ((int) $parts[2]) + 1;<br>
}<br>
$new_ver = implode('.', $parts);<br>
}<br>
<br>
return $new_ver;<br>
}<br>
<br>
function store_config($version, $last_modified, $path) {<br>
$content = "<?php defined('SYSPATH') or die('No direct access allowed.');\n";<br>
$content .= "return array(\n";<br>
$content .= " 'version' => '".$version."',\n";<br>
$content .= " 'last_modified' => '".$last_modified."',\n";<br>
$content .= ");\n";<br>
<br>
$fh = fopen($path, 'w+');<br>
fwrite($fh, $content);<br>
fclose($fh);<br>
}<br>
<br>
store_config(increase_minor_version($config), date("D, d M Y H:i:s T"), $config_path);<br>
</blockquote>
<p>We're not doing much with this script here but as with our development team we can do all sorts of automation. For example, we can fire off notifications, collate version updates for our team meetings, and/or update QA bug list databases or bootstrap our application and make CLI calls in our application (which is the real reason we're firing another PHP script).
<p>Our teams are organized so that each team member develops in separate branches. And when we coordinate our version files are consolidated and incremented accordingly. Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com0tag:blogger.com,1999:blog-20594933.post-2450755235465465842012-02-06T15:15:00.005-05:002012-02-24T14:48:08.293-05:00Spotify Apps APISpotify recently released their developer API and we already have clients asking for small apps. <div><br /></div><div>Here's their API:</div><div><a href="http://developer.spotify.com/en/">http://developer.spotify.com/en/</a> </div><div><br /></div><div>They have a Javascript API that communicates with the rest of their application. It seems that a lot of neat Apps can be built to leverage existing Spotify functionality and add a little more to the environment. </div><div><br /></div><div>The apps are built through HTML5, CSS and Javascript. We noticed that they don't support WebGL but they do seem to support Flash *unofficially. </div><div><br /></div><div>They've got a quick tutorial you can run through that is very straight forward. </div><div><br /></div><div><a href="http://developer.spotify.com/download/spotify-apps-api/tutorial/">http://developer.spotify.com/download/spotify-apps-api/tutorial/</a> </div>Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com0tag:blogger.com,1999:blog-20594933.post-38514767076835509952011-11-17T17:14:00.004-05:002011-12-26T02:20:22.580-05:00Safari Debug Menu: Changing User Agent, Debugging JavaScriptI usually don't use Safari, but here's a great item to note if you need to use it. You can enable development tools through a preference setting. Simply open up a terminal window and execute the following:<br /><pre>defaults write com.apple.safari IncludeDebugMenu 1</pre>This will enable a new menu in Safari containing controls to change the user agent, disable various functions like javascript or caching, and/or start javascript debugging.Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com0tag:blogger.com,1999:blog-20594933.post-84874621824702264502011-10-04T11:24:00.004-04:002011-10-27T17:49:18.815-04:00XAMPP Apache Could Not Bind to Port 80Recently, I had an issue starting up Apache. My Apache instance runs on a Windows 7 development box and also shares the box with IIS 7. Immediately I thought that it was IIS and of course that's a valid assumptions but binding IIS to port 81 did not solve the issue. <br /><br />I received the following error while trying to start Apache:<br /><pre>D:\xampp>apache_start.bat<br />Diese Eingabeforderung nicht waehrend des Running beenden<br />Bitte erst bei einem gewollten Shutdown schliessen<br />Please close this command only for Shutdown<br />Apache 2 is starting ...<br />(OS 10013)An attempt was made to access a socket in a way forbidden by its access permissions. : make_sock: could not bind to address [::]:80<br />(OS 10013)An attempt was made to access a socket in a way forbidden by its access permissions. : make_sock: could not bind to address 0.0.0.0:80<br />no listening sockets available, shutting down<br />Unable to open logs<br /><br />Apache konnte nicht gestartet werden<br />Apache could not be started<br />Press any key to continue . . .<br />D:\xampp></pre><br />Running a netstat I could see that something called SYSTEM was listening on port 80. <br /><pre>D:\canvas\xampp>netstat -aon | findstr :80<br /> TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4</pre><br />It turns out that another service called SQL Server Reporting Services (SQLEXPRESS) was causing the conflict. Stopping the service through Component Services > Services allows you to start Apache on port 80.<br /><br />*EDIT<br />On another machine at work a service called "Web Deployment Agent Service", part of Microsoft's WebMatrix, was also preventing Apache from binding to port 80.Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com4tag:blogger.com,1999:blog-20594933.post-18624196764083731032011-09-03T16:04:00.005-04:002011-09-03T16:14:29.773-04:00Scaling Bitmaps In Flash ActionScript 3 (AS3)<div>I was working on composing large Bitmaps and scaling them and noticed an optimization that might have included a bug. The images I was scaling were pixel snapping and were not smoothed. This resulted in a choppy tween.</div><div>
<br /></div><div>In the past avoiding choppy image animations required setting the quality to "best". Now ActionScript allows granular control of images. In my project they were embeded as external assets and pulled from a SWF file. </div><div> </div><div> <p class="p1"><span class="s1"></span></p><pre>[Embed(source="assets/about/gfx.jpg"<span class="s1">)]</span></pre><p></p></div>As of Flash Player version 10.3.183.5, when scaling Bitmaps in Flash smoothing and PixelSnapping are ignored when the scale is equal to 1. In order to force smooth set the Bitmap to a scale not equal to 1.0.
<br />
<br />For example:
<br /><pre>var bitmap:Bitmap = new Bitmap(_bitmapData, 'never', true);<br>bitmap.scaleX = bitmap.scaleY = .99;
<br /></pre>
<br />Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com2tag:blogger.com,1999:blog-20594933.post-17865559872555119402011-01-18T12:58:00.004-05:002011-01-18T13:19:02.431-05:00CakePHP Bake mysql.connect Error Running XAMPPI ran into the following error baking with CakePHP. I was trying to create the cake schema for ACL tables. <br /><br /><code><br />:$ ./cake schema create DbAcl<br /><br />Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EST/-5.0/no DST' instead in /htdocs/cake/libs/cache.php on line 570<br /><br />Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EST/-5.0/no DST' instead in /htdocs/cake/libs/cache.php on line 570<br /><br /><br />Welcome to CakePHP v1.3.6 Console<br />---------------------------------------------------------------<br />App : app<br />Path: /htdocs/app<br />---------------------------------------------------------------<br />Cake Schema Shell<br />---------------------------------------------------------------<br /><br />Warning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in /htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 552<br /><br />Warning: mysql_connect(): No such file or directory in /htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 552<br /><br />Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in /htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 558<br /><br />Warning: mysql_get_server_info() expects parameter 1 to be resource, boolean given in /htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 566<br /><br />Warning: mysql_real_escape_string() expects parameter 2 to be resource, boolean given in /htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 671<br /><br />Warning: mysql_real_escape_string() expects parameter 2 to be resource, boolean given in /htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 671<br /><br />Warning: mysql_real_escape_string() expects parameter 2 to be resource, boolean given in /htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 671<br /><br />Warning: mysql_real_escape_string() expects parameter 2 to be resource, boolean given in /htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 671</code><br /><br />The issue that I didn't realize quick enough was that the CakePHP script wasn't using my XAMPP's PHP executable. Another instance of PHP was being run since it was located in my $PATH. <br /><br />This can be easily corrected by correcting your $PATH with a quick visit to vi.Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com0tag:blogger.com,1999:blog-20594933.post-12615632207439830722010-11-16T17:58:00.003-05:002010-11-16T18:03:49.369-05:00Taking screen captures of websitesHere's a great way to programmatically create screen captures of sites. It uses a python script to access WebKit and generate a PNG. It would be fairly easy to add some logic to make it crawl a site to show clients. We had to use this to grab some shots of a site for a routing phase of a pharmaceutical project. <div><br /></div><div><a href="http://www.paulhammond.org/webkit2png/">http://www.paulhammond.org/webkit2png/</a></div><div><br /></div><div>There is also another program called Paparazzi! It provides a GUI and allows a little bit of interactivity for clicking through. </div><div><br /></div><div><a href="http://derailer.org/paparazzi/">http://derailer.org/paparazzi/</a></div>Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com0tag:blogger.com,1999:blog-20594933.post-71175050584151178692010-09-25T11:30:00.002-04:002010-09-25T11:34:20.957-04:00Reformatting XML with TextWrangler ScriptHere's a great tip for reformatting XML. I'm reposting this. I use TextWrangler and use the UNIX Script. <div><br /></div><div>Use Unix Filters and create the following script to use, <span class="Apple-style-span" ><span class="Apple-style-span" style="font-size: small;">Reformat XML.sh</span></span>:</div><div><br /></div><div><div></div><blockquote><div><span class="Apple-style-span" style="font-size: small;"><span class="Apple-style-span" >#!/bin/sh</span></span></div><div><span class="Apple-style-span" style="font-size: small;"><span class="Apple-style-span" >xmllint --c14n "$*" | XMLLINT_INDENT=$'\t' xmllint --format -</span></span></div></blockquote><div></div></div><div><br /></div><div>Thanks <a href="http://magp.ie/">Magpie</a>. </div><div><br /></div><div><a href="http://magp.ie/2010/02/15/format-xml-with-textwrangler/">http://magp.ie/2010/02/15/format-xml-with-textwrangler/</a></div><div><br /></div>Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com0tag:blogger.com,1999:blog-20594933.post-47152973122547912652010-09-02T19:37:00.003-04:002010-09-02T19:55:33.001-04:00Fixing Font Rendering Issues in Google Chrome for Mac OSX<div>While I'm writing this the Google Chrome browser is still a beta. But I still want to use it. </div><div><br /></div><div>So the problem is that I open up Chrome and it runs into a font issue when I'm using fonts installed with my font management software (i.e. - Linotype FontExplorer X, FontAgent Pro, etc...). </div><div><br /></div><div>I see the following characters:</div><div><br /></div><img src="http://www.henrytseng.com/storage/blog/chrome_fonterror/missing_font_a.jpg" /><div><br /></div><div>The problem is that Chrome for Mac OSX is looking for font files at the following location:</div><div><br /></div><div>/Library/Fonts/</div><div><br /></div><div>Where these font management software programs install fonts to a different location. To remedy the problem simply change your font folder and Chrome should read the fonts fine. </div><div><br /></div><div><br /></div><img src="http://www.henrytseng.com/storage/blog/chrome_fonterror/prefs.png" /><div>On FontExplorer X 1.2.3, you can simply open up Preferences and go to the Advanced tab. Here you can change the location of font files. Yeah I run it because it's free. </div><div><br /></div><div>Font Book which is provided by Apple on Leopard and up, seems to install for use with Chrome with out any issues. But then again, Font Book isn't exactly the best solution for font management when you have six thousand fonts. </div>Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com1tag:blogger.com,1999:blog-20594933.post-34664574354781095072010-09-01T23:47:00.009-04:002010-11-12T00:12:03.655-05:00How to Enable Flash Content Debugger Plugin on Google Chrome Browser for Mac OSXThis is applicable to Google Chrome 5.0.375.127 for Mac OSX. <div><br /></div><div>To enable the Flash Content Debugger Plugin on Google Chrome. Simple disable the plugin distributed with Chrome. Of course, you'll also need to install the content debugger version of the plugin as well. <div><br /></div><div>To disable the plugin distributed with Chrome open your Preferences and select the tab entitled "Under the Hood":</div><img border="0" src="http://www.henrytseng.com/storage/blog/chrome_flash/under_the_hood.png" /><div><br /></div><div>Then open Content Settings:</div><img border="0" src="http://www.henrytseng.com/storage/blog/chrome_flash/content_settings.png" /><div><br /></div><div>Now click on the link "Disable Individual Plugins":</div><img border="0" src="http://www.henrytseng.com/storage/blog/chrome_flash/plugins.png" /><div>On the plugins page both the plugin distributed with Chrome and the plugin installed from Adobe are listed. Simply disable the plugin located within the Chrome files at the location:</div><div><br /></div><div>/Applications/Google Chrome.app/Contents/Versions/5.0.375.127/Flash Player Plugin for Chrome.plugin</div></div><div><br /></div><div>On PC the distributed plugin can be disabled by opening the +Details button in the upper right and then disabling the plugin individually. </div>Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com0tag:blogger.com,1999:blog-20594933.post-85541993908495999722010-04-30T17:22:00.004-04:002010-04-30T17:30:31.739-04:00Samba write error in Mac OSXI've been experiencing this write error for a long time.<div><br /></div><div><img border="0" src="http://www.henrytseng.com/storage/blog/samba-write-access-error/error.png" /><div><br /></div><div>And for the longest time I had no clue where it was occurring until I did some research and found a solution. </div><div><br /></div><div>Here's the entry:</div><div><a href="http://splatdot.com/fixing-snow-leopard-10-6-3-samba-write-access">http://splatdot.com/fixing-snow-leopard-10-6-3-samba-write-access</a></div><div><br /></div><div>Basically, the solution is to turn off Unix extensions in Samba's <code>smb.conf</code> configuration file. Add the following to the <code>[global]</code> section</div><div><br /></div><div><code>unix extensions = off</code></div><div><br /></div><div>And restart your samba server. </div></div>Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com0tag:blogger.com,1999:blog-20594933.post-19596215215009692682010-01-15T16:41:00.003-05:002010-01-15T16:52:51.784-05:00Popular Programming Languages for 2010Here's TIOBE's Programming Community index gives an indication of how popular some programming languages are becoming.<br /><br />It is certainly surprising to see how fast some languages are rising up. Not to mention that Apple's Objective-C (which runs on the iPhone) is certainly up and rising at #12 and Google's Go language is right behind it at #13.<br /><br />Also Adobe's Flash ActionScript is surprisingly rising the ranks now at #19. <br /><br /><img src="http://www.henrytseng.com/storage/blog/tiobe_programming_index.jpg" />Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com0tag:blogger.com,1999:blog-20594933.post-20037652787829247102009-12-19T11:01:00.008-05:002009-12-23T17:54:23.433-05:00Harajuku Lovers Fragrance receives FWAHarajuku Lovers Fragrance receives an FWA Site of the Day award. Woot woot. <br /><br /><a href="http://www.hlfragrance.com">http://www.hlfragrance.com</a><br /><br /><img src='http://www.henrytseng.com/storage/blog/hl_fwa/Picture-1.jpg'><br><br /><img src='http://www.henrytseng.com/storage/blog/hl_fwa/Picture-2.jpg'>Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com0tag:blogger.com,1999:blog-20594933.post-17988774042468377072009-11-30T18:12:00.004-05:002009-11-30T18:13:55.669-05:00Neat AR ExperimentsBeen working on Augmented Reality (AR) on a few projects and it seems that a number of other people are making great experiments. Take a look at this from <span style="font-style: italic;">zero point nine</span>:<br /><a href="http://www.zeropointnine.com/blog/augmented-reality-texture-extraction-experiment/"><br />http://www.zeropointnine.com/blog/augmented-reality-texture-extraction-experiment/</a>Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com0tag:blogger.com,1999:blog-20594933.post-29334021362529985862009-07-20T22:31:00.006-04:002015-08-20T12:37:26.277-04:00Disc Collision - An Open Source AS3 Collision Detection SystemI whipped up a distance based collision detection system, dubbed Disc Collision. A very basic model for collision detection, but also very fast in comparison to the vector based hitTest() in the Flash API. <br />
<br />
Collisions are detected by a request-only model. The collision detection simply manages a collection of points and distances associated with each point. So you could easily put this into your a game engine and run an update call to get colliding points. <br />
<br />
The algorithm is robust and has a few things to optimize. The collection of points is subdivided into multiple lists according to a spatial grid. To reduce the amount of work required detection. Then all of our points are sorted through a BST by distance so that we always know the largest distance to use when selecting grid sections. <br />
<br />
Hold the red button down below to create objects to test collisions. <br />
<br />
<div style="position:relative; overflow:hidden; width:551px; height:441px;">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" height="452" id="Untitled-1" width="552"><param name="allowScriptAccess" value="sameDomain"><param name="allowFullScreen" value="false"><param name="movie" value="http://henrytseng.com/storage/blog/disccollision_ex1/test_random_points.swf"><param name="quality" value="high"><br /><param name="scale" value="noscale"><param name="bgcolor" value="#ffffff"><embed src="http://henrytseng.com/storage/blog/disccollision_ex1/test_random_points.swf" quality="high" bgcolor="#ffffff" scale="noscale" name="Untitled-1" allowscriptaccess="sameDomain" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="552" height="452"></embed></object>
</div>
<br />
You can get code here:<br />
<a href="http://code.google.com/p/disccollision/">http://code.google.com/p/disccollision/</a><br />
<a href="https://github.com/henrytseng/disccollision">https://github.com/henrytseng/disccollision</a>Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com0tag:blogger.com,1999:blog-20594933.post-2893128771654325492009-07-11T23:13:00.002-04:002009-07-11T23:15:23.263-04:00Invert the colors on your MacJust found this out, to invert the colors on your Mac hold ctrl-option-command and press 8. This is really useful if you're staring at white screens all day long your eyes will get tired really quickly.Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com0tag:blogger.com,1999:blog-20594933.post-74433527361545260042009-07-02T00:57:00.004-04:002009-07-02T01:03:32.019-04:00Motor2 PhysicsI bought a new Macbook Pro and got it up and running. Funny how I've been using Mac's for a while now but never owned one myself. A computer is a computer. <br /><br />I've been playing around with the Motor2 physics engine. I'm working on some games using it right now. I'll post and follow up when they're ready. <br /><br />For now check out this new Flash port of the Box2D engine by Eric Catto here:<br /><br /><a href="http://lab.polygonal.de/motor_physics/">http://lab.polygonal.de/motor_physics/</a><br /><br />I suggest reading the code and using the original Box2D documentation:<br /><br /><a href="http://www.box2d.org/manual.html">http://www.box2d.org/manual.html</a><br /><br />Enjoy.Anonymoushttp://www.blogger.com/profile/04474043919105140986noreply@blogger.com0