Using Trackpads to Sign a Digital Document

If you are trying to sign a digital document (a la DocuSign, RightSignature, etc) and are using a MacBook. I’ve found a method to use that will make sure your signature actually represents your signature, and not a doodle of a three year old.

It’s really easy.

      With your left thumb (or index finger), press and hold on the lower left-hand corner of your trackpad.
      While holding, use your right index finger to draw your signature.

Tada!

Normal method:

sig_without

This method:

sig_with

Zinnia (django blog) fix for “Continue reading” persistance

The template for zinnia in the version installed by pip always sets continue_reading to “1″, so the “Continue reading…” link always pops up on every article. Even articles with less than 100 words.

To remedy this, you need modify the content-loop block in entry_search.html and entry_list.html like so:

{% if object.html_content|truncatewords_html:100|length == object.html_content|length %}
        {% include object.content_template with object_content=object.html_content|safe continue_reading=0 %}
    {% else %}
        {% include object.content_template with object_content=object.html_content|truncatewords_html:100|safe continue_reading=1 %}
{% endif %}

Obviously, you will want to copy over the HTML files from the zinnia package into your project for modification before doing the above :)

Verizon and the HTC One: A match made in heaven

HTC One in Silver

I’ve been keeping up with the latest updates on Verizon getting the new HTC One, and found a rather puzzling comment from an article on AllThingsD:

“Meanwhile, the number people who care about this phone is falling through the floor.”

You must mean “falling through the floor” because the floor is not capable of supporting that many people. This phone is the best out there right now, you combine that with Verizon’s killer LTE network and you have a deadly combo.

A combo that is so deadly, I have a creeping feeling that there may be some sort of deal in place by big-red’s competitors to keep things hushed and drive more carrier switches to providers that are getting the device right away. More money in the bank initially for HTC, more new contracts for other providers, and then even more money for HTC once Verizon gets it… what do you think?

Also, remember the Droid DNA? Me neither.
Either way, I want the HTC One and I want it on Verizon.

Take my money, please, take my money.

Dropbox Linux CLI snippet — Exclude all root folders

I was trying to exclude all the root folders on my Dropbox sync to my development machine and found there was only a way to do it one by one:

./dropbox.py exclude add ~/Dropbox/abc ~/Dropbox/etc

So, I decided to use some bash / awk magic and make this little guy, which gets all the root directories in ~/Dropbox, escapes spaces and parenthesis in directory names, prepends ~/Dropbox/, and then spits them all out appended to the end of the “exlude add” command:

./dropbox.py exclude add `ls Dropbox/ -1D \
| awk '{ { gsub(" ","\ ") }; \
{gsub("\(","\\(")};\
{gsub("\)","\\)")};\
print "~/Dropbox/" $_ }' \
| tr '\n' ' '`

Enjoy.

Symfony + Doctrine: Single mapping file for multiple entities (global mapping)

Doctrine lets you define database ORM mapping using YAML, XML or PHP Annotations.
I wanted to put all my mapping information in a single file, in order to streamline updating for one or two of my own reasons.

I found this snippet:

<?php
$namespaces = array(
   '/path/to/files1' => 'MyProject\Entities',
   '/path/to/files2' => 'OtherProject\Entities'
);
$driver = new \Doctrine\ORM\Mapping\Driver\SimplifiedYamlDriver($namespaces);
$driver->setGlobalBasename('global'); // global.orm.yml

Which is nice but we are not implementing the Doctrine driver ourselves when using Symfony 2.1, so I did a quick search for setGlobalBaseName in the Symfony Doctrine ODM bundle and found that it was setting the global basename to mapping and not global.

So, if you wish to have a global YAML mapping definition file, you can create one like:
/www/src/Acme/TestBundle/Resources/config/doctrine/mapping.orm.yml

The mapping.orm.yml file should look something like this:

Acme\TestBundle\Entity\Employee:
  type: entity
  tableName: employees
  fields:
    ref: { type: char(6), primary: true, notnull: true }
    first_name:  { type: string(50), notnull: true }
    last_name:  { type: string(50), notnull: true }
    birthdate:    { type: timestamp, notnull: true }
    hiredate:     { type: timestamp, notnull: true }
    email:         { type: string(100), notnull: true }
  oneToOne:
    company:
      targetEntity: Company
      joinColumn:
        name: company_id
        referencedColumnName: id
Acme\TestBundle\Entity\Company:
  type: entity
  tableName: companies
  fields:
    ref:
      type: char(6)
      primary: true
      notnull: true
    name:  { type: string(50), notnull: true }

Then, we can generate the model classes (or entities) using:
$ php app/console doctrine:generate:entities TestBundle

This makes the Employee.php and Company.php in:
/www/src/Acme/TestBundle/Entity/

So there you have it, setting up a global YAML mapping file, and generating entity classes from it!

Hope this helps someone out there.

Wildcard host resolution for Windows/OSX

In a previous post, I detailed an Acrylic DNS setup for Windows in which you can have a regular expression match for host resolution. This is great for local testing, and vhosts (virtual hosts), but there was no simple way to replicate this setup on OSX.

I’ve known about the Automatic Proxy Configuration ability for a while but never really had a use for it, until now! This new solution works in both Windows and OSX, and probably Linux — for all modern browsers that take advantage of automatic proxy configuration scripts.

For example, I have a folder, /Volumes/I/_WORK/, where I put my projects.
I had setup Acrylic and my vhosts config so that I could access the project folders dynamically via my Apache server; *.stage adjusts the document root to the /Volumes/I/_WORK/*/www folder automatically, and I don’t have to add a line in my hosts file every time.

Examples:
tests.stage => /Volumes/I/_WORK/tests/www/
www2.tests.stage => /Volumes/I/_WORK/tests/www2/
project1.random.stage => /Volumes/I/_WORK/random/project1/

We’re going to set up resolution of *.stage to 127.0.0.1 with an Automatic Proxy Configuration script.

Without any further delay, to match *.stage — test.stage, websitename.stage etc — you can use the following setup:

For OSX

1) Create ~/.proxy.pac…

function FindProxyForURL(url, host) {
  if (shExpMatch(host,"*.stage")) {
    return "PROXY 127.0.0.1";
  }
return "DIRECT";
}

2) Setup ~/.proxy.pac in your network preferences:

  1. Open Network under System Preferences
  2. Select your active network connection and click “Advanced…”
  3. Open the “Proxies” tab
  4. Check “Automatic Proxy Configuration” under “Select a protocol to configure”
  5. For the Proxy Configuration file URL, enter the following — replacing USERNAME with your actual username:
    file:///Users/USERNAME/.proxy.pac
  6. Hit OK, and Apply.

For Windows

1) Create proxy.pac (same as above)…
2) Setup proxy.pac in your network preferences:

  1. Open “Internet Options” under Control Panel
  2. Click the “Connections” tab, and click “LAN Settings”
  3. Check “Use automatic configuration script” under “Automatic Configuration”
  4. For “Address” enter the path to your proxy.pac, ex: file:///C:/Dropbox/proxy.pac
  5. Hit OK, and Apply.

If you have setup your regular expression virtual hosts for Apache or nginx already, you should now be able to access your local webserver using *.stage hostnames.

If you need an example for nginx virtual hosts, here is my relative nginx config block:

	server {
		listen   127.0.0.1:80;
		index  index.html index.htm index.php;
		# regex magic to detect AAA.BBB.stage or AAA.stage hostnames, 
		server_name   ~^((?<subdomain>[^\.]+)\.(?<domain2>.+)\.stage|(?<domain>.+)\.stage)$;
		# my projects stay in I:/_WORK/AAA/ and have www folders or subfolders (I:/_WORK/AAA/BBB)
		set $new_root I:/_WORK/$domain/www/;
		if ($subdomain != '') { set $new_root I:/_WORK/$domain2/$subdomain/; }
		if (!-e $new_root$document_uri){return 404;}
		log_not_found off;
	        charset utf-8;
		access_log  logs/access.log  main;
		location ~ /\. {deny all;}
		location ~ \.php$ {
			root   $new_root;
			fastcgi_pass   127.0.0.1:9000;
			fastcgi_index  index.php;
			fastcgi_param  SCRIPT_FILENAME	$document_root$fastcgi_script_name;
			include        fastcgi_params;
			fastcgi_param  SERVER_NAME	$http_host;
	        }
		location / {
	        	root  $new_root;
	    	}
	}

Now my browsers hit the proxy script, see *.stage as 127.0.0.1, and hit my local nginx setup which recognizes the *.stage vhosts and routes the request to the correct project directory.

No more manually adding entries to the hosts file! (for website dev, anyways)

Update 12/28/2012: Added fastcgi_param for SERVER_NAME

Disclaimer: this is probably not a great configuration for production performance, so modify and test accordingly if you are going to use the nginx config w/ RegEx in a production environment.

Windows 8 tip: Fix for freeze-ups trying to access external drives

Believe it or not, try uninstalling all Flash player plugins.

Also make sure that your permissions were migrated correctly. My install showed my account was an administrator, but the property got mismatched somehow and I couldn’t access certain things.

I had to go in to user accounts in the control panel, set my account to a normal user, then back to administrator.

Now everything is working perfectly again.

FlashDevelop Script for CodeFormatter fixes

I’ve created a fix for single line if, while, and for statements, and adding a space between ){ for bracketed statement blocks.

There’s a Macro to run codeformatter, then execute the script, and relocate you back to the original cursor position.

If you find a bug post the test case and I’ll get around to it when I can :)

Macro Setup — CTRL+SHIFT+(~ or `)
AutoRun: False

Shortcut: Ctrl+Shift+Oemtilde

Entries:

InvokeMenuItem|RefactorMenu.CodeFormatter
InvokeMenuItem|RefactorMenu.OrganizeImports
ExecuteScript|Internal;C://pathto//fixifstatements.cs

** Make sure to change the path (C://pathto//fixifstatements.cs) to the correct location of the script! **

Script code is here: http://pastebin.com/Qt5W73mR

Hope this eases some minds :D

Modern Warfare 3: PS3 Multiplayer Issues

I found a solution to my own personal issues with trying to connect to multiplayer games, I would always get the “Unable to connect to host” or “Waiting for players” messages and get dropped back to the menu.

My solution was to disable blocking of anonymous internet requests on my router.

The setting was under “Security”, and “Firewall” tab. (For my Linksys)

Hope that helps someone :)

Local staging configuration for using Apache 2.0 and DNS wildcards

As a web developer / designer, I do a lot of things that make my workflow easier, one of them is using a local staging server for sites I am working on in the initial build phases.

The first step is modifying the httpd-vhosts.config to point to a local folder for a specific domain. This is better than using subfolders in a single public folder, because you can use absolute relative paths (ie: /css/, and in CSS files /images/logo.jpg)

Example insert into the vhosts configuration file:

<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "Q:\_WORK\projectname\www"
ServerName projectname.stage
</VirtualHost>
<Directory "Q:/_WORK/projectname/www">
AllowOverride All
Order allow,deny
Allow from all
</Directory>

The *:80 string tells Apache to listen on any IP address for the connection (ie: your internet IP address), you can change this to 127.0.0.1 if you don’t want the website to be available outside of your computer (you would need a real internet based DNS entry for that, and access to the DNS Zone for the domain).

The DocumentRoot directive should match the Directory path exactly, aside from the use of back/forwardslashes as used above.

So now to make the projectname.stage address actually work, we need to add a DNS entry pointing it to our IP address (127.0.0.1)… there’s a few ways to do this.

1) You can edit your hosts file (c:\windows\system32\drivers\etc\hosts in windows, /etc/hosts in most *nix based systems) to include a line:

127.0.0.1 projectname.stage

or 2) Use a local DNS proxy server (with wildcards!!)… I use Acrylic, which allows wildcards, so I don’t need to configure a new stage server name in my hosts every time.

You can edit the Acrylic hosts file (mine is at C:\Program Files (x86)\Acrylic DNS Proxy\AcrylicHosts.txt), adding the following line and restart the proxy:

127.0.0.1 *.stage

This will make it so any usage of the .stage TLD will point to your local machine. So all you need to do is have the virtual host configured and Bob’s your uncle!

Now whenever you hit projectname.stage in your browser it will point towards your loopback IP address. Hitting http://projectname.stage would connect to Apache, sending it the hostname in the requests, and Apache will render the files in the location specified in your vhost config!

*UPDATE*

As soon as I wrote this, I thought to myself, how AWESOME would it be to not even have to configure each virtual host??? With Apache 2 it’s totally possible (can I get a hell yes?)

As stated here you can use Regular Expressions to dynamically point to directories.

You need to uncomment / add the following to httpd.conf:

LoadModule vhost_alias_module modules/mod_vhost_alias.so

And then add the following to your vhosts config:

<VirtualHost *:80>
UseCanonicalName Off
ServerAdmin webmaster@dummy-host.example.com
VirtualDocumentRoot "Q:\_WORK\%1.0\www"
ServerAlias *.stage
ServerName *.stage
LogLevel Debug
</VirtualHost>
<Directory "Q:/_WORK/">
Options -Indexes FollowSymLinks
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>

This, along with your wilcard DNS setup, will point  *.stage to the appropriate folder;

blah.stage => q:\_WORK\blah\www
abc1234.stage => q:\_WORK\abc1234\www
Without ever needing to touch your config files again…. YEAAAAAAAAAAAAA!
Sorry. got super excited.