Thursday, April 17, 2014
Changing Directories Faster
Wednesday, April 16, 2014
IntelliJ: Multiple Cursors and Selection
Friday, April 11, 2014
Writing Fast Javascript - Compiler Optimization (V8, Node.js)
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.
V8 has been making waves through Google's mail service, Gmail, and their suite of office apps, Google Docs.
http://www.ft.com/intl/cms/s/0/03775904-177c-11de-8c9d-0000779fd2ac.html#axzz2ybGxAlPI
Considering the idea of creating Objects dynamically:
var point1 = {
x: 1,
y: 2
};
And modifying them:
point1.x = 5;
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.
Writing a function such as:
function Point(x, y) { ...
Causes the JIT to create a class definition. Assigning values within that function:
function Point(x, y) {
this.x = x;
this.y = y;
Then signals to the JIT to transition the class to a class definition with specific parameters this.x and this.y.
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.
Changing the structure of an object can cause it to degrade into a hash, which is tremendously slow.
I'd love to see how Dart makes headway and changes the landscape for Javascript.
Here Lars Bak talks about some optimizations in V8:
http://channel9.msdn.com/Shows/Going+Deep/Expert-to-Expert-Erik-Meijer-and-Lars-Bak-Inside-V8-A-Javascript-Virtual-Machine
Friday, January 17, 2014
Robomongo MongoDb Client
http://robomongo.org/
Wednesday, June 19, 2013
Here's a great reference for ECMA Script 5 features implemented in V8/Node.js
https://github.com/joyent/node/wiki/ECMA-5-Mozilla-Features-Implemented-in-V8
Saturday, March 02, 2013
Coordinating Nodejs Events EventAggregator
Henceforth, wrote up a quick module called EventAggregator.
npm install event-aggregator
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.
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.
Load the module:
var EventAggregator = require('event-aggregator').EventAggregator;
Subscribe to the events:
var aggregator = new EventAggregator();
// Resource 1 aggregator.waitEvent('complete', resource1, 'ready'); aggregator.waitEvent('complete', resource1, 'connect');
// Resource 2 resource2.createConnection(aggregator.waitCallback('complete'));
Set up a listener.
aggregator.on('complete', function() {
// ...
});Thursday, August 23, 2012
Choosing To Use PHP/Kohana
Let's get this straight though, the languages:
- PHP
- Ruby
- Python
- Kohana (PHP)
- Ruby on Rails (Ruby)
- Django (Python)
If you're not familiar with Kohana you can find it here.
http://kohanaframework.org/index
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.
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.
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.
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.
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.
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.
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.
A Comparison Between Ruby, PHP and Python from Udemy
Thursday, July 26, 2012
Tracking Application Build Versions Through Git Hooks
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.
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.
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.
Kohana has configuration files and we're updating application/config/version.php via a git post-commit hook.
So here's the version.php file:
<?php defined('SYSPATH') or die('No direct access allowed.');
return array(
'version' => '1.2.8',
'last_modified' => 'Thu, 26 Jul 2012 22:59:45 EDT',
);
As you can see the file is pretty basic. It simply stores a version and a timestamp.
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.
This Git script resides here in .git/hooks/post-commit
Here's the post-commit script
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-commit".
exec php bin/post-commit.php
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
<?php
define('SYSPATH', getcwd());
$config_path = 'application/config/version.php';
$config = include($config_path);
date_default_timezone_set('America/New_York');
function increase_minor_version($config) {
$new_ver = '1.0.1';
if(isset($config['version'])) {
$old_ver = $config['version'];
$parts = explode('.', $old_ver);
if(isset($parts[2])) {
$parts[2] = ((int) $parts[2]) + 1;
}
$new_ver = implode('.', $parts);
}
return $new_ver;
}
function store_config($version, $last_modified, $path) {
$content = " $content .= "return array(\n";
$content .= " 'version' => '".$version."',\n";
$content .= " 'last_modified' => '".$last_modified."',\n";
$content .= ");\n";
$fh = fopen($path, 'w+');
fwrite($fh, $content);
fclose($fh);
}
store_config(increase_minor_version($config), date("D, d M Y H:i:s T"), $config_path);
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).
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.
Monday, February 06, 2012
Spotify Apps API
Thursday, November 17, 2011
Safari Debug Menu: Changing User Agent, Debugging JavaScript
defaults write com.apple.safari IncludeDebugMenu 1This 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.
Tuesday, October 04, 2011
XAMPP Apache Could Not Bind to Port 80
I received the following error while trying to start Apache:
D:\xampp>apache_start.bat
Diese Eingabeforderung nicht waehrend des Running beenden
Bitte erst bei einem gewollten Shutdown schliessen
Please close this command only for Shutdown
Apache 2 is starting ...
(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
(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
no listening sockets available, shutting down
Unable to open logs
Apache konnte nicht gestartet werden
Apache could not be started
Press any key to continue . . .
D:\xampp>
Running a netstat I could see that something called SYSTEM was listening on port 80.
D:\canvas\xampp>netstat -aon | findstr :80
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4
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.
*EDIT
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.
Saturday, September 03, 2011
Scaling Bitmaps In Flash ActionScript 3 (AS3)
[Embed(source="assets/about/gfx.jpg")]For example:
var bitmap:Bitmap = new Bitmap(_bitmapData, 'never', true);
bitmap.scaleX = bitmap.scaleY = .99;
Tuesday, January 18, 2011
CakePHP Bake mysql.connect Error Running XAMPP
:$ ./cake schema create DbAcl
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
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
Welcome to CakePHP v1.3.6 Console
---------------------------------------------------------------
App : app
Path: /htdocs/app
---------------------------------------------------------------
Cake Schema Shell
---------------------------------------------------------------
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
Warning: mysql_connect(): No such file or directory in /htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 552
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
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
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
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
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
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 671The 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.
This can be easily corrected by correcting your $PATH with a quick visit to vi.
Tuesday, November 16, 2010
Taking screen captures of websites
Saturday, September 25, 2010
Reformatting XML with TextWrangler Script
#!/bin/shxmllint --c14n "$*" | XMLLINT_INDENT=$'\t' xmllint --format -
Thursday, September 02, 2010
Fixing Font Rendering Issues in Google Chrome for Mac OSX


Wednesday, September 01, 2010
How to Enable Flash Content Debugger Plugin on Google Chrome Browser for Mac OSX



Friday, April 30, 2010
Samba write error in Mac OSX

smb.conf configuration file. Add the following to the [global] sectionunix extensions = offFriday, January 15, 2010
Popular Programming Languages for 2010
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.
Also Adobe's Flash ActionScript is surprisingly rising the ranks now at #19.


