A Southwestern adventurer striking out into the badlands of the Midwest for fun, profit, and for a wife who wouldn't move back to the Southwest :)
Friday, October 04, 2013
Free Online Javascript Book
I just started reading [this] book for free online about Javascript. So far helpful.
5 Free JavaScript Libraries to Add Text Editing to Your Web Application
Tuesday, September 03, 2013
JavaScript Scope and IIFEs
I ran into an issue I've never run into before. I have some JavaScript files included in most pages on a website. These files define objects and populate them with properties like user options, site root URLs, an ajax callback function, etc... Well there were a few pages that end up being pop ups on modals, and in that case one of the JavaScript objects wasn't getting created, so I was getting undefined errors.
Initially I created an immediately invoked function on the offending pages that I would pass the object into to make sure it existed and if not populate it. However you cannot pass a variable or object to an IIF if it isn't defined. The solution to the problem was simple, but I'd never done this before. In any function you have access to the window object, which is where all the globals are kept, so you can actually declare global variables in functions without having to declare them outside a function first like I had been doing for years.
While I will probably circle back at one point an fix the scripts so that this little hack will not be needed, I thought it was cool you could do this and it had never occurred to me to try it. Probably not a best practice, and most likely JavaScript 101 to those who develop JavaScript aps, but to me it was new and interesting. I hope this technique helps someone else as well.
Update
For nested objects, this code snip might be of value as well http://jsfiddle.net/EGZxJ/ which came from http://joonhachu.blogspot.com/ though I haven't tested this yet.
Initially I created an immediately invoked function on the offending pages that I would pass the object into to make sure it existed and if not populate it. However you cannot pass a variable or object to an IIF if it isn't defined. The solution to the problem was simple, but I'd never done this before. In any function you have access to the window object, which is where all the globals are kept, so you can actually declare global variables in functions without having to declare them outside a function first like I had been doing for years.
(function () {
if (typeof window.SomeObj == 'undefined') {
window["SomeObj"] = {};
window["SomeObj"].property1 = 'blah blah';
window["SomeObj"].property2 = 'some option';
}
})();
While I will probably circle back at one point an fix the scripts so that this little hack will not be needed, I thought it was cool you could do this and it had never occurred to me to try it. Probably not a best practice, and most likely JavaScript 101 to those who develop JavaScript aps, but to me it was new and interesting. I hope this technique helps someone else as well.
Update
For nested objects, this code snip might be of value as well http://jsfiddle.net/EGZxJ/ which came from http://joonhachu.blogspot.com/ though I haven't tested this yet.
Wednesday, June 19, 2013
HTML 5 Game Tutorial
Here is a link to a great HTML 5 game creation tutorial. Even if you are not a game creator there are still some Javascript object creating techniques that I think are worth looking at.
http://blog.sklambert.com/html5-canvas-game-html5-audio-and-finishing-touches/
The link is to the final tutorial in the five part series, but I would suggest starting from the first part and walking through the code through till the last part.
http://blog.sklambert.com/html5-canvas-game-html5-audio-and-finishing-touches/
The link is to the final tutorial in the five part series, but I would suggest starting from the first part and walking through the code through till the last part.
Wednesday, May 29, 2013
Mind Mapping Software Review
OK, I'm on a "Gotta get a side business going again. I like to hash out ideas with mind mapping software. I usually use FreeMind but I decided to take a look at what is out there. I was looking for something free or low cost that was still full featured. For reference my main research sites where these-
Wikipedia List of concept- and mind-mapping software
Hive Five: Five Best Mind Mapping Applications
http://mindmappingsoftwareblog.com/
Well, the skinny of it is I'm keeping FreeMind but I might play with TheBrain. Honorable mention is bubble.us for quick and simple mind maps.
Wikipedia List of concept- and mind-mapping software
Hive Five: Five Best Mind Mapping Applications
http://mindmappingsoftwareblog.com/
Well, the skinny of it is I'm keeping FreeMind but I might play with TheBrain. Honorable mention is bubble.us for quick and simple mind maps.
- It looks like for the open source world, the FreeMind file type has become a standard, with multiple mind mapping web and desktop applications exporting and importing the FreeMind file type.
As far as software-
- Google now has entered the fray, with their not so advertised "Coggle" software. I use a lot of Google products, so this looked interesting. But after getting burned with Google's RSS reader going away I think I'll stay away from Google's fringe products for a bit. Coggle is not as nearly as full featured as the alternative I will present here either.
- Mindmeister looked promising. It is web based and looks nice, both pluses, but it didn't seem to have a lot to it yet.
- If you just need to do simple mind maps and would like to make them "in the cloud", the winner would be Bubbl.us hands down. Very simple web interface and has all the basic stuff you need. I might use it in a pinch.
- TheBrain looks really cool. It is a desktop app but there are versions of it for the big three OS's (Linux, Windows, Mac). You can link any kind of files directly into your mind maps which I found interesting. I held off because it is a download the pro version download and then after 30 days TheBrain downgrades itself to the free version. I might test it out later but Idon't want to get sucked into buying stuff when I don't have to, as my budget for my business is very, ah, lean...
- FreeMind reigns supreme right now still. I don't like that it is a desktop application and I don't like that it has a Java dependency. It doesn't look quiet as cool as say Mindmeiser or TheBrain. But it works for my purposes for now I guess. Maybe I'll revisit this in the future.
There are other tools out there, most of them cost $$$ or didn't look as promising as the above. Disagree? Know a better tool? If so let me know in the comments.
Monday, May 06, 2013
Webmatrix 3: Hold Off
I found a bug with Webmatrix 3 that may only happen to specific machine setups, which is this
http://stackoverflow.com/questions/16392844/webmatrix-3-sql-server-ce-4-busted
Not saying this will happen to you, I've read a bit and apparently most people claim everything is working great for them with Webmatrix 3. But to be honest unless you are doing a lot with Azure or non razor development I would HOLD OFF installation of Webmatrix 3 just in case.
More info here http://forums.asp.net/t/1903867.aspx/1?WebMatrix+3+SQL+Server+CE+Database+Read+Only+ID+Column+Cannot+be+Modified
http://stackoverflow.com/questions/16392844/webmatrix-3-sql-server-ce-4-busted
Not saying this will happen to you, I've read a bit and apparently most people claim everything is working great for them with Webmatrix 3. But to be honest unless you are doing a lot with Azure or non razor development I would HOLD OFF installation of Webmatrix 3 just in case.
More info here http://forums.asp.net/t/1903867.aspx/1?WebMatrix+3+SQL+Server+CE+Database+Read+Only+ID+Column+Cannot+be+Modified
Monday, April 08, 2013
SQL Server Join Hints
Here is a link to a great article explaining SQL Server Join hints...the how, the when, and the why to use them.
http://www.mssqltips.com/sqlservertip/2917/sql-server-join-hints/
From the article-
http://www.mssqltips.com/sqlservertip/2917/sql-server-join-hints/
From the article-
"In summary, here's when to use the various types of join:
LOOP JOIN
Query has a small table on the left side of the join
One or both tables are indexed on the JOIN predicate
Query has a small table on the left side of the join
One or both tables are indexed on the JOIN predicate
HASH JOIN
Tables are fairly evenly-sized or are large
Indexes practically irrelevant unless filtering on additional WHERE clauses, good for heaps
Arguably most versatile form of join
Tables are fairly evenly-sized or are large
Indexes practically irrelevant unless filtering on additional WHERE clauses, good for heaps
Arguably most versatile form of join
REMOTE JOIN
Same as hash join, but good where right side is geographically distant
Only suitable for INNER JOINs
Not suitable for local tables, will be ignored.
Same as hash join, but good where right side is geographically distant
Only suitable for INNER JOINs
Not suitable for local tables, will be ignored.
MERGE JOIN
Tables are fairly even in size
Works best when tables are well-indexed or pre-sorted
Uses very efficient sort algorithm for fast results
Unlike hash join, no memory reallocation, good for parallel execution
Tables are fairly even in size
Works best when tables are well-indexed or pre-sorted
Uses very efficient sort algorithm for fast results
Unlike hash join, no memory reallocation, good for parallel execution
And if in doubt - let the optimizer decide!"
Wednesday, March 20, 2013
HTML 5 DataList Key Value Work Around
I like the new HTML 5 datalist element. But most of the time when I deal with autocomplete drop down type stuff it is usually in key value pairs read from a database. The datalist doesn't (too my knowledge) support this out of the box. But you can add an attribute of say id to each option in your datalist, and then use a little jQuery to grab that id value for pushing back up to the server onsubmit. Here is a basic example just to get you going.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<form name="test" method="post" action="">
<input id="datalisttestinput" list="stuff" ></input>
<datalist id="stuff">
<option data-id="3" value="Collin" >
<option data-id="5" value="Carl">
<option data-id="1" value="Amy" >
<option data-id="2" value="Kristal">
</datalist>
<br /><br />
<a href="javascript:GetValue();">test</a>
</form>
<script>
function GetValue() {
var x = $('#datalisttestinput').val();
var z = $('#stuff');
var val = $(z).find('option[value="' + x + '"]');
var endval = val.attr('data-id');
alert(endval);
}
</script>
</body>
</html>
Update: You can also do <option value="3">Collin</option> like you would expect on some browsers, hopefully all soon.
Friday, January 18, 2013
Sharepoint 2013
If you are an old SharePoint hack, the latest release of SharePoint 2013 might be exciting for you. If you are coming into SharePoint as a complete noobie, I'd advise taking a pass. I've been fooling around with it for a few weeks off and on now, and so far I'm very under impressed.
I've run into all sorts of configuration issues that cause needed admin menu links (like to the design manager) to be missing or some features to not even work at all. I'm having a hard time getting simple jQuery plugins to work even though 2013 SharePoint is advertised as being HTML 5 / Javascript friendly. I'm sure I'm doing things wrong, but it shouldn't be as hard as it is. Sometimes if things seem to have a steep learning curve to get hello world working I lose enthusiasm for them quickly. Might be my bad I guess. As I get older I just want things to work as advertised and not have to f**k with them to get basic functionality going.
I've run into all sorts of configuration issues that cause needed admin menu links (like to the design manager) to be missing or some features to not even work at all. I'm having a hard time getting simple jQuery plugins to work even though 2013 SharePoint is advertised as being HTML 5 / Javascript friendly. I'm sure I'm doing things wrong, but it shouldn't be as hard as it is. Sometimes if things seem to have a steep learning curve to get hello world working I lose enthusiasm for them quickly. Might be my bad I guess. As I get older I just want things to work as advertised and not have to f**k with them to get basic functionality going.
Wednesday, January 02, 2013
Tired of Metro
I haven't tried this yet, but I'm not a big fan of the metro interface for desktops and servers. This might help.
http://virtualizationreview.com/blogs/virtual-insider/2012/08/windows-2012-traditional.aspx
http://virtualizationreview.com/blogs/virtual-insider/2012/08/windows-2012-traditional.aspx
Wednesday, November 28, 2012
Digital Signature pfx Blues and Fix
Update: This does the same thing w/o having to use a visual studio extension/plug in. http://www.slickit.ca/2010/09/fix-cannot-import-following-key-file.html
------------------------
Yes, it was machine migration time again. So I downloaded all my projects from team foundation server and went to debug...and...blam. Mycompany.pfx throws build errors. Now I know the password for the digital signature file (which is what the pfx files are) but I don't remember how they were setup. You can right click and install them, but there is a bunch of options that I'm not sure which of is correct. So I google, and I find this nifty little VS2010 extension-
http://visualstudiogallery.msdn.microsoft.com/d491911d-97f3-4cf6-87b0-6a2882120acf?SRC=Featured
I closed Visual Studio, downloaded and installed the extension, then restarted visual studio and opened my project that was giving me the pfx error.
Hit debug, build failed, right clicked the error in the error list window, and now there is an option called "Apply Fix." Right clicked it, a command window opened up asking me what the pfx password was, which I supplied, and got a confirmation that the pfx certificate was now installed. Started up the project in debug, and everything worked!
Note, this utility only works for Visual Studio 2010 Pro version or above. There might be a 2008 version, and the 2010 version might work with Visual Studio 2012, but I haven't tried it yet.
More info on pfx issues here-
http://stackoverflow.com/questions/2815366/cannot-import-the-following-keyfile-blah-pfx-the-keyfile-may-be-password-prote
Note, it turns out this plugin isn't free.
Pro Application Lifecycle Management With Visual Studio By Rossberg, Joachim/ Olausson, Mathias (Google Affiliate Ad)
------------------------
Yes, it was machine migration time again. So I downloaded all my projects from team foundation server and went to debug...and...blam. Mycompany.pfx throws build errors. Now I know the password for the digital signature file (which is what the pfx files are) but I don't remember how they were setup. You can right click and install them, but there is a bunch of options that I'm not sure which of is correct. So I google, and I find this nifty little VS2010 extension-
http://visualstudiogallery.msdn.microsoft.com/d491911d-97f3-4cf6-87b0-6a2882120acf?SRC=Featured
I closed Visual Studio, downloaded and installed the extension, then restarted visual studio and opened my project that was giving me the pfx error.
Hit debug, build failed, right clicked the error in the error list window, and now there is an option called "Apply Fix." Right clicked it, a command window opened up asking me what the pfx password was, which I supplied, and got a confirmation that the pfx certificate was now installed. Started up the project in debug, and everything worked!
Note, this utility only works for Visual Studio 2010 Pro version or above. There might be a 2008 version, and the 2010 version might work with Visual Studio 2012, but I haven't tried it yet.
More info on pfx issues here-
http://stackoverflow.com/questions/2815366/cannot-import-the-following-keyfile-blah-pfx-the-keyfile-may-be-password-prote
Note, it turns out this plugin isn't free.
Pro Application Lifecycle Management With Visual Studio By Rossberg, Joachim/ Olausson, Mathias (Google Affiliate Ad)
Tuesday, October 30, 2012
Localized Month From an Int (1-12)
Demo of getting localized month string from a number (note I'm passing the number in as a string and then TryParsing it this case (modify to suit).
Essential C# 4.0 By Michaelis, Mark (Google Affiliate Ad)
Essential C# 4.0 By Michaelis, Mark (Google Affiliate Ad)
Monday, October 29, 2012
Swaping VS 2012 Default Debug Browser
Need to change the browser that Visual Studio 2010 uses for debugging? There is an extension for that-
[LINK]
[Direct Download from Microsoft]
Illustrated C# 2012 By Solis, Daniel (Google Affiliate Ad)
[LINK]
[Direct Download from Microsoft]
Illustrated C# 2012 By Solis, Daniel (Google Affiliate Ad)
Tuesday, October 23, 2012
Using Bit Flags in SQL
Using bit flags is a great way to store a lot of information in a single place that can be used in a variety of ways, of which the most common I've seen is to use big flagging for permission checks. I could write the following post myself, but I don't think I could add much to the following excellently done reply to a question on StackOverflow about using bit flags in SQL, so here you go-
[Link]
Also if you are a little rusty on using bit flags in .Net, here is a refresher article link-
[Link]
[Link]
Also if you are a little rusty on using bit flags in .Net, here is a refresher article link-
[Link]
Tuesday, July 10, 2012
Cross posted at http://steamunderground.blogspot.com/
At the core of any game application is going to be a random number generator. I found out that using .Net's base random class is fine for a one off or limited set of random numbers needing to generated, but once you start beating on the .Net random class you start seeing some funky results. So for a little game demo I'm working on I put together a static class that generates random numbers based on the System.Security.Cryptography.RNGCryptoServiceProvider which seems work well even if it is a tad slow.
Here is the class. Note the static method GetD6Successes. This is meant to mimic the "exploding" D6 die pool mechanic used in some table top RPG's. I like the concept as in theory a lone peasant has a chance, though a very very very small chance, of slaying a dragon with this mechanic. Let me know what you think.
At the core of any game application is going to be a random number generator. I found out that using .Net's base random class is fine for a one off or limited set of random numbers needing to generated, but once you start beating on the .Net random class you start seeing some funky results. So for a little game demo I'm working on I put together a static class that generates random numbers based on the System.Security.Cryptography.RNGCryptoServiceProvider which seems work well even if it is a tad slow.
Here is the class. Note the static method GetD6Successes. This is meant to mimic the "exploding" D6 die pool mechanic used in some table top RPG's. I like the concept as in theory a lone peasant has a chance, though a very very very small chance, of slaying a dragon with this mechanic. Let me know what you think.
Friday, May 18, 2012
Quick Trick, Splitting on Multiple Characters
This is more of a Junior Varsity post, as I'm sure the .Net gods have figured this technique out a long time ago. But for the rest of us, if you ever wanted to split a string on more than one character, this is how it is done in .Net, or at least one of possibly many ways it can be done. In this example I want to split on new line breaks and space characters.
string mybiglongstringwithlotsofnewlines = "a whole bunch of characters";
List < char > lst = Environment.NewLine.ToList < char > ;
lst.Add(' ');
string[] myarray = mybiglongstringwithlotsofnewlines.Split(lst.ToArray());
Happy coding!
string mybiglongstringwithlotsofnewlines = "a whole bunch of characters";
List < char > lst = Environment.NewLine.ToList < char > ;
lst.Add(' ');
string[] myarray = mybiglongstringwithlotsofnewlines.Split(lst.ToArray());
Happy coding!
Tuesday, April 10, 2012
Following Facebook Pages Through RSS

I love RSS, but it isn't really catching on like I thought it would. But most web applications, including Facebook, have ways of getting at content updates through RSS, you just have to hunt a little bit harder since RSS seems to not be hitting the mainstream. Here is a helpful link on how to follow Facebook updates (pages and users) via RSS, and without even logging into Facebook (which should give you a little pause actually).
http://sem-group.net/
Sunday, January 29, 2012
Fix for Chrome Crashing with Youtube on Closing
Here is a temp fix for the issue when you are watching a youtube video in Chrome and then you try to fix it, Chrome crashes. Unfortunately the fix is to disable the two Flash dll's. Chrome is working on a fix. These two dll's can easily be re-enabled as needed.
* In the chrome URL window type about:plugins
* Click show details
* do a find on gcswf32.dll and NPSWF32.dll, disable them both.
For reference-
http://www.google.com/support/forum/p/Chrome/thread?hl=en&tid=1fe8d66c8677d694
* In the chrome URL window type about:plugins
* Click show details
* do a find on gcswf32.dll and NPSWF32.dll, disable them both.
For reference-
http://www.google.com/support/forum/p/Chrome/thread?hl=en&tid=1fe8d66c8677d694
Thursday, October 27, 2011
Big Bad Malware: One Helpful program.
I know several people now (including my wife) that have had their machines get infected with malware that is very hard to remove. Microsoft recently released a tool that might be helpful.
http://connect.microsoft.com/systemsweeper
Good luck!
http://connect.microsoft.com/systemsweeper
Good luck!
Thursday, October 13, 2011
Free Windows Virtual Desktop Manager
I've been using an ancient virtual desktop manager called Yodem3D. It works OK, but it is beginning to show its age lately.
So the 4SysOps blog had an article on a few to try (see comments too)-
[Link]
I tried Windows Pager http://sourceforge.net/projects/windowspager/ and it works OK. Another mentioned is http://virtuawin.sourceforge.net/ that looks like it might be better. I'll give that one a shot later. If you know of any better ones please let me know in the comments! Thanks.
So the 4SysOps blog had an article on a few to try (see comments too)-
[Link]
I tried Windows Pager http://sourceforge.net/projects/windowspager/ and it works OK. Another mentioned is http://virtuawin.sourceforge.net/ that looks like it might be better. I'll give that one a shot later. If you know of any better ones please let me know in the comments! Thanks.
Subscribe to:
Posts (Atom)
