OS X – clang: error unknown argument…

I want to post this because it took me awhile to figure it out. If you need PyOpenSSL or PyCrypto on Mac OS X 10.8, 10.9 you may come across this problem when using easy_install to get it installed.

Processing pycrypto-2.6.1.tar.gz
Running pycrypto-2.6.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-YmqMpv/pycrypto-2.6.1/egg-dist-tmp-vI68Ck
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
error: Setup script exited with error: command 'cc' failed with exit status 1

Personally I’m running on Mavericks. Turns out this is due to an Xcode change and the correct command to run to make it work is:

sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future easy_install -Z pycrypto

Easily Build White Lists Using Google Chrome

If you work in IT or have ever had the opportunity to compile a white list for a customer, you’ll know that it can be a little complicated to find all the dependencies for a web site that you want to white list.

For example if you want to allow a single web site such as canadiantire.ca, you’ll find that you will also need to allow scene7.com and ajax.googleapis.com just to name a couple.

I’ve used Astaro (now Sophos) UTM and firewall appliance to do whitelisting as well as our new solution at DNSthingy.
Sophos does web filtering via proxy while DNSthingy uses DNS to do the filtering.

The Solution

I’ve been working on a Chrome extension (add-on) that takes care of the hard leg work of building a white (or black) list.

Whitelist Assistant will detect all the domains that resources are being loaded from inside the browser, and keep track of them and display them to you in a very simple and easy to understand list.

You can copy and paste this list straight into most UTMs or filtering solutions including Sophos and DNSthingy.

I’ll be adding features that will make it even easier for DNSthingy users. For example if you are a user you can create a whitelist for your network with a single click instead of even having to copy and paste.

Have fun, and enjoy the internet!

New YouTube Channel, Did You Know?

Last week we launched a new YouTube channel at youtube.com/fingertipknowledge

Why? Mostly because I enjoy making little videos and I enjoy cool facts and I enjoy doing stuff with my son Adam. We we are going to start making fun videos like this for a little while and see what happens. Maybe if enough people enjoy them we’ll continue!

Subscribe if you want to see more.

YouTube Preview Image

Run WordPress as a Module on Google App Engine

With the release of Google App Engine SDK version 1.8.5 it is now possible to run WordPress as a module instead of being the default module on appengine. This is a really powerful thing for SEO purposes. Let’s say for example that you’ve written your web application in Python and have it running at www.myapp.com
Now conventionally if you’d want to run a blog using WordPress you’d have to create a subdomain and make it something like blog.myapp.com because WordPress is written in PHP which means you’d need a separate runtime altogether.
That solution breaks down your domain’s SEO juice. How about instead you run the WordPress blog as a module under www.myapp.com/blog. Now that’s the power of Google App Engine (GAE) and what we can now do starting at version 1.8.5.

Beware, there are a few rough edges at the moment. But the talented team at Google is constantly improving the platform.

As you follow the steps below, please note the following conventions:

  • <application_id> is your Application Identifier on Google App Engine.

Step 1) Create the Config Files

You’ll need to create 2 configuration files. dispatch.yaml and wordpress.yaml

The dispatch.yaml file determines which URL requests are sent to which module. In this case we’ll have the default module (configured by app.yaml) and the wordpress module (configured by wordpress.yaml)

The file should look like this:

dispatch.yaml

application: <application_id>
dispatch:
 - url: "*/"
 module: default
- url: "*/blog*"
 module: wordpress

 

Like we mentioned you also need a file called wordpress.yaml which defines your wordpress blog module.

wordpress.yaml

application: <application_id>
module: wordpress
version: wp
runtime: php
api_version: 1
handlers:
- url: /blog/(.*\.(htm$|html$|css$|js$))
 static_files: wordpress/\1
 upload: wordpress/(.*\.(htm$|html$|css$|js$))
 application_readable: true
- url: /blog/wp-content/(.*\.(ico$|jpg$|png$|gif$))
 static_files: wordpress/wp-content/\1
 upload: wordpress/wp-content/(.*\.(ico$|jpg$|png$|gif$))
 application_readable: true
- url: /blog/(.*\.(ico$|jpg$|png$|gif$))
 static_files: wordpress/\1
 upload: wordpress/(.*\.(ico$|jpg$|png$|gif$))
- url: /blog/wp-admin/(.+)
 script: wordpress/wp-admin/\1
 secure: always
- url: /blog/wp-admin/
 script: wordpress/wp-admin/index.php
 secure: always
- url: /blog/wp-login.php
 script: wordpress/wp-login.php
 secure: always
- url: /blog/wp-cron.php
 script: wordpress/wp-cron.php
 login: admin
- url: /blog/xmlrpc.php
 script: wordpress/xmlrpc.php
- url: /blog(.+)?/?
 script: wordpress/index.php

 

Step 2) Install WordPress

Please follow the steps at https://developers.google.com/appengine/articles/wordpress but skip the app.yaml instructions.

Note that to run WordPress in the SDK you can run one of the following commands:

$ dev_appserver.py wordpress.yaml

This will make WordPress run under http://localhost:8080

$ dev_appserver.py dispatch.yaml app.yaml wordpress.yaml

This will make WordPress run under http://localhost:8080/blog using the dispatch routing configuration.

Step 3) Deploy to Cloud

I’m expecting that you followed the instructions linked to above and created your Cloud SQL database. Note that you can’t use your own MySQL server you have to use Cloud SQL when running PHP on App Engine.
When running locally using the SDK you have to use your own MySQL server for testing.

Now the deployment is what can be a little tricky. You have to specifically update the dispatch file using the appcfg.py command. And then update the rest of the app as well.
Also due to a current bug you cannot use the git push to deploy feature anymore because of the dispatch.yaml file.

So to deploy your app run the following 2 commands assuming you’re in the main app directory.

$ appcfg.py update_dispatch ./
$ appcfg.py update app.yaml wordpress.yaml

And once that’s done your app will be live and WordPress should be running at http://<application_id>.appspot.com/blog

Step 4) Custom Domain Fix

Due to another bug that Google is working on, in order for image uploads to work you cannot use your custom domain when using WordPress admin (wp-admin) to create blog posts, pages, etc.

The workaround for this is to adjust a couple settings in WordPress under General.

WordPress Address (URL) should be set to http://<application_id>.appspot.com/blog

Screen Shot 2013-10-09 at 8.36.11 AM

Site Address (URL) should be set to http://www.myapp.com/blog (where www.myapp.com is of course whatever domain you are running)

 

Hope you enjoyed this how-to! Now have fun with App Engine.

Enable WMM for AirPlay to Work

Screen Shot 2013-08-30 at 4.41.41 PMIf you come across a situation where your MacBook, MacBook Air, iMac or whatever computer you’re using is not able to find your Apple TV or other AirPlay enabled device over a wifi connection. And you happen to be using a Cisco RV series wireless router/access point. I would suggest that you trying turning on the WMM feature on the wifi network.

I have not determined why but for some reason if the WMM option is disabled, AirPlay won’t work. This has been tested on a RV120W and a RV220W. I think it would be the same with RV180W.

Hope this helps someone out there one day!

UPDATE Oct 2013

Screen Shot 2013-10-09 at 1.18.02 PMThanks to David Redekop we discovered one more setting that should be adjusted.

Under Wireless->Advanced Settings make sure that “Protection Mode” is set to None. And click the Save button.

 

How to check if a user has folder permissions in batch file

G_127Here is a quick tip for anyone else who comes across a need to do this. I was writing a logon.cmd batch script that will create a desktop shortcut for any user that logs in and has access to a specific folder. You can’t just do IF EXIST E:\Management because even though the user doesn’t have access to the folder, it does exists so that returns true.

The trick is to check IF EXIST E:\Management\*

See how I put the wildcard there? That wildcard forces the condition to actually check inside the folder in which case access is denied and the statement returns false.

So my entire code that I’m using looks like this: (of course replace E:\Management with whatever you’re trying to do.)

IF NOT EXIST "E:\Management\*" goto everyone
C:\Shortcut.exe /F:"%USERPROFILE%\Desktop\Management.lnk" /A:C /T:"E:\Management"
:everyone

Windows 8 Clean install with Upgrade Product Key

So maybe you did a clean install of Windows 8 on a new hard drive or something like that, and now you’re not able to activate Windows because of it. You will get a message that says something like this:

“the software licensing service determined that this specific product key can only be used for upgrading not for clean installations”

So here’s what you do. Upgrade your clean installation.

In my case I took my Windows 8 DVD disk and ran setup.exe and performed a clean upgrade. After that was done the product key activated like it should have in the first place.

Perhaps one day Microsoft will figure out how to make software that’s not a pain every way you turn.

Cross Platform Browser HTML5 Desktop Notifications

Yelling_protester_at_health_care_reform_town_hall_meeting_in_West_Hartford,_Connecticut,_2009-09-02You might have heard of window.webkitNotifications. It’s a crazy simple JavaScript API to do desktop notifications in webkit based browsers. It works great in Chrome and Safari.

But what about Firefox? It took a bit of digging for me to figure out how to make this work for all browsers that support HTML5 notifications. It’s actually not that hard once you have the correct information.

You can try it out using our new Drop Chat app which is designed for distributed teams needing to communicate. It works a lot like IRC except it’s web based and persistent. Which means when you come back all the messages are still there and you can keep going at any point. Still a work in progress but check it out on github!

So there is an official “living standard” available at http://notifications.spec.whatwg.org/ and that’s what I’m basing my work on. The problem comes in one slight difference between the way webkit implements the standard and Firefox doing it a bit differently.

So the first thing you need to do is ask the user if it’s OK that you send them desktop notifications. It will prompt them with a permission request interface.
The code to do so is very simple:

Notification.requestPermission(function (perm) {
    if (perm == 'granted') {
        // Tell your app it's OK to send notifications
    }
});

There is a callback function which returns one argument telling you if it was accepted or not. The value could either be “granted” which is what I’m checking for, or it could be “denied”.

Now the strange thing is, in Firefox you can run that code automatically without a problem. But in webkit user interaction is required for the requestPermission function to work. This is a good thing, I don’t understand why Firefox did not implement this check, but perhaps they will yet. I’ve only tested this in Firefox 22 beta 4. It does not work at all in Firefox 21 which is the currently stable release at the time of writing.

So the correct method would be to have a button that the user clicks on to enable notifications.

$('#mybtn').click(function () {
    Notification.requestPermission(function (perm) {
        if (perm == 'granted') {
            // Tell your app it's OK to send notifications
        }
    });
}

Now another problem (or maybe the 1st problem) is that according to the specification, there should be a variable called permission that is part of the Notification object. Well the problem is in Firefox it doesn’t exist at all, and in Chrome it only exists after you send a notification. So let’s send a notification:

try {
    test_notification = new Notification('This is a test!', {
       body: 'Just showing how HTML5 notifications work!',
       dir: "auto",
       lang: "",
       tag: 'test',
       icon: '/images/icon.png'
    });
    console.log('Permission is: ' + test_notification.permission);
}
catch {
   // Browser does not support notifications
}

This time I’ve placed this code inside a try statement so that way if the browser does not support the Notification API, it doesn’t break everything. You should be doing the same thing with the requestPermission function, and design your app so if the browser does not support the API that functionality just doesn’t show up.

The code above is all you need to send a desktop notification.  As you can see I included a console.log line which should print to the console what permission the browser has granted this web page. Unfortunately on Firefox that currently prints “Permission is: undefined” but I expect that will change soon.

Of course if you’d like to see some code that actually uses this, checkout https://github.com/artooro/dropchatapp

Simple Password Generator Function for PHP

WorstPassword-InfographicAnyone who works with PHP a lot will very quickly come across a need to generate good passwords. I wrote the function below so that I had something simple, and as secure as it needs to be. This function will generate a password and a salt to go with it.


function generate_password() {
    $bits = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ1234567890!#$*';
    $random_bits = str_shuffle($bits);
    $start = rand(0, 50);
    $password = substr($random_bits, $start, 8);
    $salt = mt_rand(100, 1000);
    return array($password, $salt);
 }

We really don’t need much more than that. This function will generate an 8 character password which is pretty much the standard these days. It will use any character that is contained in the bits variable so you can easily adjust what letter/numbers/characters are used in the generated passwords.

Have fun!

See Our Web Site Hits in Real Time

Using a bit of AngularJS (which I like to call HTML6) and a little API, we have a page where you can see at any given time how many people are visiting web sites on CirrusLab servers.

Take a look at the real-time stats page and view the source. Literally next to nothing. A simple 2-second check to update the number, everything from the template to the ajax is handled using AngularJS.

Driver Missing for C90LEW Wireless Adapter

wyseWyse (now owned by Dell) seems to have started shipping an updated version of the C90LEW thin client that has a new wi-fi chip. The strange thing is they have not updated the image. So all the images that we have are not compatible with the new wireless chipset included on these thin clients.

You’ll get a message saying Windows can’t find the wireless adapter driver or something similar to that.

Luckily a co-worker quickly looked up the driver needed, and the link is here: https://downloadcenter.intel.com/Detail_Desc.aspx?lang=eng&DwnldID=19654

I’ve updated our image to include this driver, and hope it helps someone out there on the big wide Internet.

How to, troubleshooting, and more.