Archive for the ‘Uncategorized’ category

Time for new content!!

December 12th, 2019

Well, our company is making the shift from using the Microsoft azure cloud all these years (since 2012) to moving everything to the Amazon cloud (AWS). I figured it would be as good a time as any to post about some things I have learned along the way, stay tuned!!

Using C# Interactive

January 5th, 2018

Here is a really cool feature that was introduced in Visual Studio 2017, the C# Interactive tool, here is a screenshot showing how to enable it.

Once you click that studio will load up all your libraries in real time and allow you to execute your code in the debugger!!  That is pretty freakin sweet!!

Tip for razor pages not refreshing on reload with Service Fabric

July 7th, 2017

If you are having issues with your razor pages only refreshing when you start/stop the project here is a tip I found.

First go to your Service Fabric project properties and change the Application Debug Mode to “Refresh Application (Preview)” as detailed in this blog post:

Then you have to make sure before you fire up your application to change the nodes to 1.  You can do this after you have installed the Service Fabric SDK and then right clicking on the tray app it installs and choosing “1 node”.  You have to be running in single node for the Refresh feature to work.

Hope this helps someone!!

Correct way to connect to mySQL from Node.js (at least for me)

April 3rd, 2015

Here is the code I used to connect to mySQL from node.js using this library:

I know he constantly refers to


But I just simply didn’t need those, I do use RedHat openshift for my project so your mileage may vary.

var express = require('express');
var mysql   = require('mysql');

var connection = mysql.createConnection({
  host     : 'MYSQL_DB_HOST',
  user     : 'MYSQL_DB_USERNAME',
  password : 'MYSQL_DB_PASSWORD',
  database : 'dbName'

//then down in your app

app = express.createServer();
app.get('/login', function(req, res) {
            connection.query('SELECT * FROM `Users`', function (error, results, fields) {
                  res.send('Results: ' + results.length);

Updating SVN and losing permissions on windows machine?

January 8th, 2014

Are you running a project on windows and each time you update your repo locally from SVN losing permissions on files?  I have banged my head around on this one for quite a while and I think I finally have the answer to this problem.

Open your repo on your machine and make sure you have hidden files turned on and look for a directory that is called .svn.  Right click on that folder and choose “Properties”, then choose the “Security” tab and inside that make sure you have the IUSR user in there, especially if you are running IIS as your web server.  If you already have that user in there or once you get that in there, click on the “Advanced” button below and then you will see the same users again in a screen that looks like this adv_sec

Click on the check below to “Replace all child object permission entries with inheritable permission entries from this object”.  Hit Apply and it should go thru and apply that to everything in your svn directory.

Apparently the problem is when you do an svn “Update”, it brings the new files down, sticks them into temp and then copies them over.  That copy somehow loses permissions during that process, maybe it brings the file into that tmp folder and then that file with less permissions comes over to your directory with less permissions.  Not sure but this seems to fix the issue for me.

Downloading files with Javascript with post data without using ajax calls

May 21st, 2013

IF you have been using javascript for a while you will know real quick that you cannot use $.ajax calls to receive a file from your server, which is a real bummer due to the fact that ajax calls just stream down the text data. I searched the web far and wide trying to find a solution to this and if you just simply need to download a file from your server, there is a really simple way to get it accomplished, just simply write this line into your javascript:

location.href = “path/to/api/call”

That will simply go out to your server and execute that on the server and get your file, as long as the response on the other side has headers marked up correctly with the “Content-Disposition” of “attachment: filename=file.whateverext”.

That is fine for simple file download, but you know at some point you are gonna want to pass parameters to your web server so I found a great jQuery plugin here: jQuery Download plugin This will allow you to post your data to the server as a hidden form submit and it works great minus one little issue, it doesn’t handle nested array’s at all, it just wraps them into the post string, so I modified it a little and create a git repo for it enjoy: My Modified jQuery plugin

Backbone collection sorting.

May 14th, 2013

Recently I had a need to sort a list of records in a list by the Date it was created and I wanted to do so using backbone, well it turns out there is a very simple and slick way to get this done, I have included the code snippets below:

The collection:

], function (backbone, model) {
    return backbone.Collection.extend({
        url: '/your_url/',
        model: model,
        sort_key: 'id', // default sort key
        comparator: function (item) {
            return -item.get(this.sort_key);
        sortByField: function (fieldName) {
            this.sort_key = fieldName;

As you can see you just use the comparator: function built into the backbone collections and in my example I am passing a negative so that it will sort descending, the default is ascending so just leave the minus sign off if you want it to work that way. I included the sortByField function here as a convenient way to call it in the code off the collection, it uses the sort_key field in the comparator to organize your collection. Below I have the usage, as you can see, its just a simple call to the string name of the field you want to sort by.

The usage:

new collection().fetch({
                data: { data: "whatever" },
                success: function (r) {
                error: function (c, r) {
                    alert("Error retrieving the data.");

Error trying to run C# SDK for Couchbase

February 20th, 2013

If you are going through the tutorial on this page: Couchbase Tutorial and you get an error right off the bat trying to instantiate the CouchbaseClient with just a simple call like: var client = new CouchbaseClient(); then you probably have your app.config in the wrong order. Contrary to what they are saying on the couchbase site, refer to my config file below to get your stuff up and running correctly.

<?xml version="1.0"?>
    <section name="couchbase" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/>
    <servers bucket="default" bucketPassword="">
      <add uri=""/>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>

The big gotcha is the where I had the runtime line placed, if I had it at the top, it would throw the error, but if you have it as I am showing here, it seems to work fine.

Using Javascript closures in for loops to keep callbacks from overriding the iterator

February 5th, 2013

The problem: You have a for loop in javascript that is executing and you are losing your pointer to the iterator. You can write something like below, wrap your stuff in a closure like so:

var funcs = [];

for (var i = 0; i < 3; i++) {          
    funcs[i] = (function(index) {   
        return function() {          
            console.log("My value: " + index);

Since there is no block scope in JavaScript – only function scope – by wrapping the function creation in a new function, you ensure that the value of “i” remains as you intended. This drove me crazy till I understood how things work in Javascript, now life is good, hope this helps someone.

Nice Javascript function to format numbers to currency

January 29th, 2013

Here is a code snippet I use to take any number in Javascript and format it nicely to a currency, if you just want it to be a regular number, simply leave off the ‘$’ in the return line, voila!! It may look pretty garbled below, if you click on the ‘<>‘ View Source it will show you what its supposed to look like.

Number.prototype.formatMoney = function (c, d, t) {
                var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
                return s + '$' + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(d{3})(?=d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");

BTW, you can use this in any standard JavaScript call, even in Underscore templates like this:

<label><%= YourNumber.formatMoney(2, '.', ',') %></label>