Sunday, October 4, 2015

Doing nothing is the wrong answer

The following is not something I copied.  These are my opinions written at 4am because the safety of my children is something that keeps me up at night.

Our nation has a few large problems, mental health, school security, and gun violence.  The combination of these problems has proven time and again to be disastrous.  Here is my proposal to address the problems because DOING NOTHING IS THE WRONG ANSWER.

1. Mental Healthcare should be free to anyone who wishes to receive it.
Hospitals should be required to provide mental health and counseling services for free to uninsured in the same way they are required to treat all patients who walk into the ER.  They would be required to absorb these treatment costs in the same way they currently have to write off uninsured/unpaying patients.

2. An improved mental health and counseling service should be federally mandated in our schools.
Students should be required to spend 5 minutes a day talking to a counselor.  This would serve two purposes.  First it would allow students to vocalize their issues and hopefully resolve them prior to letting the issues come to a boiling point where they feel the need to injure other students.  Second, it allows counselors an opportunity to identify at risk students who need further treatment, and notify parents to get them involved.  See for further information.

3.  School funding should be increased to provide enhanced security
This would include potentially hiring security personnel, installing metal detectors, and installing other monitoring and surveillance technology.  This would have to be funded by a tax increase, but certainly it would be worth it.

4. Firearm ownership should be treated like vehicle ownership
All firearms should be required to be numbered and registered with the government in a similar way that you register a vehicle.  This will help all firearm owners to do the things good firearm owners do.
In order to register a firearm an individual should be required to provide certification of training to operate said firearm (similar to a driver's test/training).
In order to register a firearm an owner should provide proof of ownership of a gun safe, too many of todays injuries are caused due to unsecured firearms.
In order to register a firearm an owner should provide proof of insurance - firearms should require an insurance policy similar to cars due to the damage they can cause to others and oneself.
These three requirements would make gun ownership a serious consideration due to the time and cost involved, instead of it being the casual purchase it currently is.

Purchasing of ammunition should require the user to present the proposed government issued license.  This is what will cause owners to want to license their firearms.  This is also what would help control a black market for ammunition. Excessive purchasing can be tracked and red flags can be raised.  Ammunition sellers should be required to keep it in a safe to curb theft.

Good, law abiding citizens should not have any issue complying with the rules listed above to retain their current gun ownership privileges.  It seems to me that these requirements would make it more difficult for criminals (and idiots) to obtain weapons and ammunition.  And force all firearm owners to take their ownership seriously.

While this proposal certainly isn't an overnight answer I think it would make strides in improving our country's current issues.  If these proposals would prevent even one more school massacre or cop dying in the line of duty, then I think it is worth it.  You may not agree with all of the proposals I’ve mentioned above, but please remember that DOING NOTHING IS THE WRONG ANSWER.

Thursday, May 21, 2015

jQuery event namespacing


var obj = $({});

function log(evt, obj, src) {
    $('#log').append(obj + ':' + evt.type + '.' + evt.namespace + ' ' + src + '\n');

obj.on('save.billing', function (evt, obj) {
    log(evt, obj, 'save base');

obj.on('save.billing.widget', function (evt, obj) {
    log(evt, obj, 'save widget');

obj.on('save.billing.consumer', function (evt, obj) {
    log(evt, obj, 'save consumer');

//triggers base, widget, and consumer
obj.trigger('save.billing', 1);
//remove widget listeners'.billing.widget');
//triggers base and consumer
obj.trigger('save.billing', 2);
//remove all billing listeners'.billing');
//triggers nobody
obj.trigger('save.billing', 3);

Monday, April 20, 2015

Grunt-JSDoc prevent output of source code

By default JSDoc will include your source code in the resulting documentation.  To prevent this from happening when using grunt-jsdoc you'll have to create an external configuration file:

build: {
    options: {
        destination: '<%= path %>/doc',
        configure: 'conf.json'

  "source": {
    "include": "app/js/ascendon.service.js"
  "templates": {
    "default": {
      "outputSourceFiles": false

Tuesday, April 7, 2015

Browserify and Grunt using jQuery from a CDN

Below is a sample configuration in which jQuery, backbone, and underscore are all referenced externally so that they are not included in the browserify bundle. Notice also that there is a transform for underscore templates in the grunt config. The resulting bundle is built as a standalone so that the module can be instantiated by our clients.  You'll need to npm install browserify-shim and modify your package.json file.  After building this module your html page will also need to reference jQuery because the jQuery code will not be in the bundle.

  "name": "packageName",
  "version": "15.3.1",
  "devDependencies": {
    "browserify": "9.0.7",
    "browserify-shim": "3.8.3",
    "grunt": "0.4.5",
    "grunt-browserify": "3.6.0",
  "browser": {
    "jquery": "./app/js/lib/jquery-1.11.2.min.js",
    "backbone": "./app/js/lib/backbone-1.1.2.min.js",
    "underscore": "./app/js/lib/underscore-1.8.3.min.js"
  "browserify": {
    "transform": [ "browserify-shim" ]
  "browserify-shim": {
    "jquery": "global:$",
    "underscore": "global:_",
    "backbone": "global:Backbone"

gruntfile browserify options
    js: {
        src: ['app/js/main.js'],
        dest: 'app/js/company.modulename.js'
    options: {
        transform: ['node-underscorify'],
        browserifyOptions: {
            standalone: 'company.modulename'

Tuesday, March 19, 2013

Code: C# when not to use var

I ran into a bug today that might have been avoided if we weren’t using var.  Both old/new methods return a byte array but the second method is incorrect as the ToUnixTime() in the new method returns an int.  Some might say better unit testing would have caught the issue, and that's true, but it's pretty hard to deny that using var introduced a bug.  As a general rule I try to use specific types instead of var for native types (int, long, string, datetime), the word var only saves me a few characters, and as shown below the return type is important.

Old method:
private static byte[] GenTimeStamp(DateTime currentTime)
    long FileTime = currentTime.ToFileTime();

    // convert to milliseconds since Jan 1, 1601 00:00 UTC
    // and subtract milliseconds between Jan 1, 1601 & Jan 1, 1970
    Int64 HostUnixTime = ((Int64)FileTime / 10000) - WINDOWS_TO_UNIX_MAGIC_NUMBER;
    Int64 NetUnixTime = IPAddress.HostToNetworkOrder(HostUnixTime);
    return BitConverter.GetBytes(NetUnixTime);

New/refactored method (data type is int instead of long):
private static byte[] GenTimeStamp(DateTime currentTime)
    var hostUnixTime = currentTime.ToUnixTime();
    var netUnixTime = IPAddress.HostToNetworkOrder(hostUnixTime);

    return BitConverter.GetBytes(netUnixTime);

Friday, February 8, 2013

Code as Craft

The team over at Etsy creates some pretty interesting software and they have a really interesting blog.  If you are a software developer its worth your time to read it.

Monday, November 19, 2012

VS2012 Active Line Highlight color

Dark theme in VS2012 a little too dark?  Here is how to change it:
Install the  Visual Studio 2012 color theme editor 
Tools - Customize Colors
Active line with default dark theme.
Change these values
New active line highlighting