Sunday, February 26, 2023

The Joy of Lighter Tech

So I am a huge proponent of gaming laptops over "engineering laptops" or "developer centric" laptops.  In my experience when a company say like Dell sells an engineering laptop to corporations (not to pick on Dell, swap out any other "enterprise" corporate brand) they are selling them an over priced dog that will tend to overheat.  I would rather have a gaming laptop any day of the week.

With that in mind for my personal laptops I've always had HP or more recently Asus gaming laptops as my dev machines.  I usually had them with at least 15'6 screens (I still do) and they tended to be bulky with short battery lives, both tradeoffs I could live with.

This last time around though I got an ASUS G15.  It isn't perfect, but I upgraded the ram to 40 gigs (8 built in, 32 added...so only the first 16 gigs is paired, kind of a bummer but I haven't noticed a big slow down.  I also added an extra 1 Terabyte mk 2 SSD.  I've been running it for a little over a year and so far so good.

One of the advantages of the G15 is that it is light.  I would have never bought the G15 for it being thin and light because that usually means gimped performance.  Not so with the G15.  But more to the point what I'm finding is that once you go thin and light it is going to be really hard to go back.  

I packed up my older Asus laptop the other day, one that I previously thought was fairly light, and it was like holding a lead brick.  That pound or two of weight (1/2 kg ish) actually makes a pretty big difference.  And although the extra battery life for me isn't critical there have been a few times where it has come in handy.

So the point of this blog post, is that if you are like how I was, where you scoff at thin and light laptops, unless you need that extra 5% of speed you are missing out.  With modern chips that tend to handle heat better, that gap in performance between a brick and a thin and light is closing too.  

Just something to ponder when you are in the market for a new box.

Friday, June 25, 2021

The Next Push

OK, so I took about six months off from the working world.  It was a disaster...but I wish it was longer :)  Since then I've been working for about 5 months now.  But I haven't been doing any side projects as I've been too busy trying to keep my head above water.

But starting next week that changes.    This weekend I will pull a bunch of data off my old laptop so it will become my son's.  After that I add a new secondary drive to my new laptop and start installing software.  Hopefully two weekends out I will be ready to go.  My targets will be R&D for work, working on my game, photoshop, and video editing...in reverse order :)  

Content creation is fun for me, so that will be my emphasis with the new laptop and most of my spare time.  We will see how it goes.

 

Monday, May 24, 2021

Scripting Tables with Indexes in SQL Server Management Studio

 OK, so you got some tables you want to script out for whatever reason.

You notice when you do, some of your indexes are missing.

What the heck?

No biggie...just need to set some default from false to True.

SSMS->Tools->Options->SQL Server Object Explorer->Scripting->Table and view options (on right)

Toggle Script Indexes to True.
If you use triggers or other options there, I would toggle them to true as well.



Reference...

https://stackoverflow.com/questions/3067599/script-table-as-create-via-ssms-doesnt-show-unique-index


Saturday, September 05, 2020

What's Up?

 Yo.  I'm still here for anyone who cares.  But, when Corona broke out and the schools closed either my wife or I needed to stay home and watch my special needs son full time.  I did while trying to work full time. For a variety of reasons, it didn't work out.  So I quit my job and have paused my IT career.  22 years with 20 of those being coding.  

Next week my son will be going to day care three days a week.  My cash reserves are being blown through much faster than budgeted (but I'm not surprised) so I am going to have to start coding again or doing something. I think what I'm going to shoot for is getting a part time job and then trying to do my own thing code wise at night.  I've got a few ideas that might generate a few bucks.  We get to see.  In about six months if that doesn't work out I'll try to pursue a job in cubeville again :)  Wish me luck and pray I find a niche before that!  

Anyways, I'll be sporadically posting again here.

Tuesday, October 22, 2019

The Demoralized Coder

OK, another useless non-coding rant.  Here is the skinny of it.  I've got a core 2 project, a fairly larger web application, that I migrated to 2.1 and fixed a few problems.  Then core 3 came out and I was told to migrate to 3.  Well the 2.1 to 3, especially with the entity framework changes, is turning out to be a real pain.  Add in Telerik, which is a great control set, but I'm not sure the latest build is really core 3 ready for prime time.  So I'm getting all these issues and it is kind of a mission impossible.  At one point core 3.1 is coming out (December?) which will fix a bunch of things. But all my work arounds to get this app working in 3.0 will probably break then or be unnecessary by then too.

In essence I've got a working app, and just to keep the code base current while Microsoft finds itself is causing me a lot of grief.  I've got some health issues, and I don't expect to live till I'm 90.  I think I'll be lucky to him the mid 70ies point.  I've already been in IT for over 20 years.  I gotta admit I'm feeling a little burnt.  The money is good.  But it seems like I'm back on the coda obscura track rather than the creativity/problem solving track.  I want to solve the customers problems for getting an app that does what they need, not debug MS code each time they tweak something.  It is kinda getting old.  And the complexity of web development at this point, it is nothing I can't do but just the joy of doing it lately is a little lacking. 

So I ponder...there is the machismo factor of being on the bleeding edge...but I gotta say as of late I'm tired of bleeding all the time.  I'd like a lighter stack to work on, or maybe switch from web development to something else for awhile.  Not sure what or if that is practical.  I've got a great job with a great company, just the tools I've been given to do the job are starting to suck IMHO. 

I know waaaaa....I'll suck it up and make things happen like usual.  It just feels like ever iteration of doing this gets a little harder to pull off, and little longer to do, and more of a pain.  I like it when I'm not developing against moving targets so much and can get proficient without having to do a bunch of hacks to make things come together and focus on creating rather than hacking out esoteric problems. 

It doesn't help that this year has been really hard on the sick front.  I think I've been under the weather 4 out of 5 days on average this last 3 months.  Trying to think when you feel like a roasted turd isn't helping.

So, when this iteration is done, I will figure it out and make things come together, I hope to get a little bit of time to really think on what I want to do in life.  Do I want to reup for another 20 years doing the same thing I've been doing, do I just need a break, do I need to change focus?  Change tools?  All this I'm going to have to pray through.  Fear of taking a big money hit in changing careers is present, but my family unit if tightening the belt a little bit is possible we could get by with me making less money.  But, I don't want to screw them either.  All stuff to think about.


Tuesday, September 18, 2018

Securing MVC Applications

This is a great 10 point article on how to secure your MVC applications by Saineshwar Bageri.  Worth a read.

https://www.codeproject.com/Articles/1259066/10-Points-to-Secure-Your-ASP-NET-Core-MVC-Applic-2

Monday, September 17, 2018

What is Microsoft Doing?

Maybe I'm just old.
Maybe I'm just cranky.
Maybe I'm not that good.

Dealing with Microsoft, to me though, is getting old.  I love C# and many aspects of their web development stack, but I'm tired of all the false starts from Microsoft...


  • Webmatrix->Now kinda "Web Pages" in .net Core
  • MVC vanilla or Core...will vanilla be supported?
  • Web Forms...complicated and code bloat for sure, but instead of abandoning, now when the browsers are finally getting to the point where standard HTML5 is pretty much supported, Microsoft should have enhanced and slimmed down web forms and did them right.
  • Continual configuration nightmares.  Once you figure out a config setting, no big deal, but if you aren't into the art of writing / modifying config files all the time, needing an obscure setting can be pain.
  • Powershell and Unix envy.  Having it is fine, but abandoning GUI tools for it is lame.  I can just use Linux at that point and I would have a more stable OS...
  • IIS...This whole push for Core...is Microsoft going to fix IIS or just get c# to run everywhere?  To me this will translate into MS devs abandoning IIS and using open sourced C#...without attracting to much of the cross stream from the Linux dev crowd to adopt the other direction.  Dumb.  Plus again, if I want to program on Linux, I can already do that.  
  • Visual Studio seems to me to be collapsing on it's own weight.  Creating a simple web project now produces like 500 files with 10 folders and all sorts of again config bull sh*t.  Just to say hello world.  I get tired of the seemingly .5-1.5 gig bi-weekly updates to Visual Studio as well.  Come on guys, get your stuff straight.
  • Entity framework...ambitious idea, I got it to work, but not without it's quirks.  Slow as balls though for high scale apps unless you get in and start tweaking the frack out of things. 
  • Azure...I actually use Azure for home projects, but for professional development I, at least right now, could care little about it.  No way the enterprise stuff I work on is ever going into "the cloud".  So I get worried when I see the latest round of Microsoft Certs all seeming to contain Azure test questions.  I have no problem with Microsoft having a set of Microsoft Azure certs, I mean by all means of course.  But to FORCE Azure knowledge everywhere in order to remain certified pisses me off.
I don't know.  Programming to me seems like a lot of fads for smart people.  Web development is taking data from a user and / or displaying data in a meaningful way with security.  You can make that as complicated or as simple as you want.  It seems like just when web development was becoming fun again (HTML5 stabilizing, not having to write as much separate client code for browser exceptions, lot's of client side frameworks to do animations and such with) my dev stack, Microsoft, exploded.  

Kind of a bummer.  Especially with so many things C# / .Net do right.  Again maybe I'm just getting old and suck, but it seems like with the Microsoft stack lately I struggle with my tools rather than providing solutions.  That bugs me.  I'm looking for something lighter.  I'm not 18 any more where I enjoy jumping over hoop after hoop to get something to work, especially when in the past it seems things were much simpler and easier to get things done.  

I know Waaa right?

I really liked the MVC / SQLite in wal mode on IIS stack.  Though I only used it a few times it worked for me and I was productive in writing quick little web apps.  .Net Core MVC less so. I guess I will explore Core web pages and see if they are light.  I'm also looking at doing somethings in the ancient LAMP stack,maybe just to give me some perspective and possibly provide some backup skills in case Microsoft goes off the deep end.  I'll probably pick up Node again as well.  Ruby?  Naah...Python?  Maybe.




Tuesday, March 06, 2018

Coda Obsura: Getting the selected items of a Telerik Kendo ListBox.

Maybe I'm missing something.  But I don't see any javascript API for getting the SELECTED items in a kendo listbox.  I'm just binding to a string list that I pull with a read.  I ended up having to get the items using jquery hunting them down by the selected style.


  $('#mylistboxname').prev("div").find('ul').find('.k-state-selected').each(function () {
    myarray.push($(this).text());
  });

Tuesday, January 30, 2018

Adding to, and Accessing, Properties on the ApplicationUser Class in ASP.Net Core 2.0 MVC

Ok, this is actually really simple to do, but frack me if it didn't take me awhile to figure things out.  Note for this example we will use a code first approach just to show the concept.

Step 0: Create a new core MVC project, select the option for authentication called something like "store credentials in application" (I'm updating VS Studio right now so going on memory).

Step 1: Add whatever properties you want to the ApplicationUser class, stuff like

public string SomeField {get; set;}
public string SomeOtherField {get;set}

Save

Step 2: from the nuget console, run add-migration , give it a name.

Step 3: from the nuget console, run update-database

When done you can use whatever to see the table with the new fields (In VS sql server object explorer).

Optional: You can tweak all the view and manage models to support your new fields.  I didn't for now.  I just went in and gave one of my new fields a value.

Step 4: Tweak you controller and inject the usermanager into your controller.
 
a) include using Microsoft.AspNetCore.Identity; and maybe the namespace of where you models reside.

b) Add a private usermanager variable to your controller like so-

    private readonly UserManager _userManager;

c) Then on your initialization method, inject the usermanager.  If your controller is names HomeController it would look like this-

public HomeController ( UserManager userManager )
    {
      _userManager = userManager;
    }

Step 5: In your controller you can now access the added properties to your user like so (in this example I added PersWeboptionsText to the field  ApplicationUser class.

  // test for a given value...
      var weboption = _userManager.GetUserAsync( User ).Result?.PersWeboptionsText;


YAY!  Now you can use and abuse that value to do whatever.


But what about in a view?  Are we stuck always passing that value in as ViewData or something?  No, you can use a similar approach.  You must inject the user manager into your view (or into your _layout.cshtml file at the top like of the view like so-

@inject UserManager UserManager


Ok, now in your page to access customer ApplicationUser properties/fields, again using PersWeboptionsText as an example field added to ApplicationUser, you can do so like this-

@UserManager.GetUserAsync( User ).Result?.PersWeboptionsText


That should get you going.  Next up is adding collections to the ApplicationUser and making sure they populate right.

I should come back and reformat this post and make it pretty...ain't nobody got time for that.

Happy Coding.

Friday, December 01, 2017

Using Thor's Hammer to Crush a Tac into Cardboard

All right, not so much of a techie article, more of a choice / philosophy article.  Here goes.

Back in the late 90ies, when this thing called the interwebs was just getting going, there were all sorts of smaller software packages you could buy to do little things.  Ulead GIF animator, 3DFX suite, Bryce 3D, gosh I forget most of them at this point which makes me sad.  I didn't have a lot of money back then (still don't but relatively I'm more able to purchase things).  I loved saving my pennies and buying these little 50 dollar software packages that would allow you to do photo editing and basic 3D stuff.

But the big stuff, like Photoshop, was always out of reach to me.  So I went on this thing called usenet (ancient I know) and there was a adobe.support.whatever group.  I didn't have much money, but I worked at a winery at the time, and I could get wine dirt cheap, so I figured maybe I could reach out to Adobe and make a deal.  And it worked.  Pretty soon I exchanged emails with someone at Adobe and traded a box of various wines for a brand new version of Photoshop 4.

Now I was professional.  I loved that program and played with it a lot.  But over the years I went more of the programming route, and had less and less time to play with Photoshop.  Somewhere around version CC whatever the interface changed quite a bit.  I find sometimes with the new interface doing simple stuff takes me a bit to figure out.  If I still used Photoshop often it would be no big deal, but the truth is I just don't anymore.  And what I do use it for is often really simple, stuff free software could like Paint.Net could do really easily.

So it leaves me with a conundrum.  I've been fiercely loyal to Adobe ever since I traded with that one guy online for a case of wine for Photoshop.  I love Adobe products.  I pay for the full creative cloud (about 55 to 60 bucks a month) which gives me everything.  After Effects, Premier, the works.  And for all you get that price point in my humble opinion is an absolute bargain...if you use the tools a lot.

And there is the rub.  I don't.  I want to.  I keep setting little goals for myself to learn After Effects or Indesign.  If I don't I will give up the subscription.  The goals come and go but yet over 600 bucks a year goes out of my wallet to Adobe.

Two issues.  Expense and learning curve.  GIMP, Paint.Net, Paintshop Pro, etc... are all fairly capable programs for what I would ever use them for.  These low end "consumer grade" or freeware stuff has come a long, long way from where they were ten years ago.  Paintshop Pro is fairly compatible with Photoshop, I think it can even export PSD's and such.  Premier is awesome, but I haven't really used it since like CS1, and when I try to use it now I can figure stuff out, but it takes awhile.

There is a sale going on right now where I can get Corel's Paintshop Pro and whatever the Video Editor is called for like 80 bucks.  I've used Vegas (competing video editor to Premier and another tempting but more expensive option) before and I like it, but that Corel bundle is tempting.  About a month and a half of what I pay for Adobe's stuff.  Hell I could even buy the latest versions every year and still come out way ahead.

 I think I'm going to give up my subscription, and because of my history with Adobe it sucks.  I hesitate a bit because in a sense it is admitting defeat for me.  By giving up on the professional grade Adobe tools I am admitting to myself that I most likely will never become a professional graphic designer.  When I initially got into web development, twenty years ago, the graphic side of things is what I liked.  But I realized quickly that my talent there was limited, and focused more on coding.  That little bit of that young man getting into tech still lives and still really wants to be a "real" graphic designer, but...the reality of things is I just won't get, or make, the time to do it, nor encounter projects both at work and at home that really push me on the graphic design level.  I sadly am coming to grips with this, and thus I'm more willing to give up my Adobe subscription for the "consumer" grade stuff.  It bums me out.

But at the same time, using newer, less clunky software might actually be a key to jump starting my graphic design skills again.  With limited time, using easy to (re)learn stuff to get content out the door quickly when I do have time to play with things just might be the spark I need.  Instead of using a giant hammer to tackle a simple task, which makes the task less fun, maybe using a simple, quick, light tool to do it will get me past those simple task into more complex ones, where I actually do hit a wall and need more advanced tools to get a job done.  And if I can convince my wife to let me keep that 600 dollar yearly budget, but spend it on other things, I can purchase some 3D software I've been eyeing again.

Lastly, Adobe has changed a bit from when I first had a relationship with them.  It seems Adobe, even though their tools are still absolutely the best, is a different company now then when the were in the 90ies.  As a company they have blown a few opportunities as well.  Director could be eating Unity's lunch, but Adobe let the ball fall there.  Not sure Flash was handled like it could have been as well, heck I would have rather have seen Director pushed more than Flash.  And then when Adobe did redo Directory they just outsourced to a team of programmers and did a refresh.  Not sure how much in house talent they keep around in house.  I'm sure some, but they are doing the global outsourcing thing like everyone else.  No longer the slightly bigger Mom and Pop company that I encountered long ago.  Maybe my out for a little disloyalty :)

Well, if I ever am able to get into the swing of things, I can resubscribe I guess.  Just worry I never will as time and tide take me down other paths with software.  But the option is there.

Adobe, I love you.  Your software is still king.  But I must acknowledge that a full on graphic designer I am not, and I can make do with a lot less.  Makes me sad.  It is me not you.

Friday, November 10, 2017

Waaa

A former boss of mine, a great guy, made a comment about some code I wrote a long time ago and how the follow on developer said it was crap.  Oh I betcha it probably was...some of the stuff I still right today is crap.  I just wrote some crap a minute ago.

Crap code sometimes is a value add.  Craftsmen like to do everything perfectly.  But sometimes when someone needs a hammer you don't need to always build Thor's Hammer for them.  Sometimes if someone brings in something broken fixing it with duct tape works fine.  Not always, but sometimes. I know even thinking this way is heresy in the current world of code blogging.  But writing code is only a single domain.  Problems often are multi domain problems, where time, effort, and other priorities play a roll.  Sometimes you just have to do what you can and move on though I agree that this shouldn't be done just for laziness sake (though I'm guilty of this a time or two).  People following after you may not know the variables at play.  All they see is a crappy hammer and some duct tape.

A prime example of this.  I'm working on a big project, but I get pulled off to do a minor upgrade on an older project.  I look at it.  To do this upgrade the proper way would have required re-writing code that affected a whole lot more than just the minor update I needed to accomplish.  Plus, I'm having a feeling that this project within a few years will be rewritten from the bottom up.  So, I decide to just "hack" it for now so I can get back to other priorities, so I don't have to rework something that goes deep into the code base that could have unintended consequences, and I won't have to spend time to do more testing than either the project manager who pulled me off another bigger priority or myself originally thought.  The "hack" took about a half an hour and 15 minutes of testing.  Done.  Moving on.  In a few years I might come back and look at what I did and say "what the frack?"  But EVEN if I did do the deep fix, I guarantee  when I rewrite the application (or whoever else does) this code section will be completely rewritten from the bottom up as requirements over time have changed and will change.  So it would have been pure vanity as a craftsman to "do it right" this time around.  I left a few notes and called it good.

And I've inherited lot's of code over the years that I would have written differently if I wrote it.  I would have written it "better" or at least more understandable.  But I don't remember ever calling code that worked crap.  But then that is how I judge things...does it work?  Do the users like it?  Is it responsive?  Are there at least a few things I'm wowed a little by?  If yes then I call what I wrote or anyone else wrote a success.

In the instance I was critiqued on,  I know my code worked, just some anal type didn't like how I wrote it.  I also know that an auditor for the fortune 500 company I wrote it for called it one of the most intuitive tools he ever used.  And he didn't say this to flatter me as I was already gone from the company, he said this after.  So suck it anal type!

Now the kicker.  As a developer I'd say I'm mediocre. I've met many developers who can program rings around me.  I've also met many who cannot (some may know this, many may not, but proof is in the pudding).   I'm not the best craftsman nor, to be totally honest, do I want to be.  The problems I'm solving are often more interesting to me then the tools being used to solve them I guess.  But I get the job done.  The average burn out rate for a developer is five years...I know many great developers who have lasted longer than that, but that is the average.

So I wonder, I'm still here.  I've been writing code, some good, some bad, most mediocre, a small percentage brilliant, for almost 20 years now.  Many craftsmen would hate me.  I betcha I'm sill here after they have burned themselves out and are gone...

I guess that comment just stung more than it should have.  And I also have to keep in mind that much of my success has been due to grace...unmerited favor by the creator Jesus.  I've gotten opportunities that I didn't merit and advanced in my career beyond what others more talented then myself have been able to.  I don't want to get a big head.

But to distractors,  although it might aggravate you, I'm still here...while most of you are gone gone gone!

Tuesday, May 16, 2017

Microsoft is Losing Me

Firstly, Microsoft has been good to me.  My semi-mastery of Microsoft tools for web development has spawned nearly a 20 year career.  So I am by far not a Microsoft hater.  Yet some recent things that Microsoft is doing has me scratching my head.

  • ASP.Net Core - The idea of having one framework that will run nearly anywhere is a noble one.  But is this really a problem that your average enterprise development team was asking to be solved?  Most (I'm guessing) that use Microsoft Visual Studio for development are solidly in the Microsoft ecosystem.  The idea of running MVC on non-Microsoft servers appeals to what...one percent of the Microsoft ecosystem users?  Plus if I can use free tools to develop open source MVC say, why would I be paying 1000's per year per developer seat for Visual Studio? So I can tweak JSON config files and run things from the command line out of penis envy for Linux users?  Dude I like GUI's.  Seems I'm one of the few.  Maybe that makes me a weak programmer but I grow tired of coda obscura for config files and other command line crap.  Give me a limited set of options in a GUI window that is well documented so I can pick what I need and move on to solving problems not pulling my hair out with being gifted with additional ones from Microsoft.
  • Along similar lines, what is up with XAML?  I knew Silverlight would fail just like few are picking up XAML.  Again, why the GUI hatred all of a sudden?  Weird.
  • Constantly changing things.  We have been jumping through hoops from Microsoft for years.  First ASP.  Then ASP.Net Webforms.  Then MVC.  Now MVC core with helper tags quasi bringing back webform like functionality  (but without the GUI support...sigh).  As we jump through the hoops we leave a scattering of legacy applications behind us.  The bleeding edge buzz word flinging developers build and move on leaving their head aches to others while they pursue fame and glory.  Us rank and file dudes have all these apps to support.  It is starting to get old.  If you wrote a PHP app 20 years ago it would (with minimal tweaking) work fine now.  LAMP stack is still widely used.  Can we say that for Classic ASP aps? Not really, though some decent sites are still powered by it.  What about .net 1 apps?  1.1, 2.0?  MVC 1?  .ASMX web services? Now core?  What happens when Microsoft jukes in a new direction?  Should we constantly be upgrading our apps to feed the beast?
I really like MVC and Sqlite.  For me it is a sweet spot for development.  But I think I'm going to become a real programmer and start branching out to Ubuntu running Node.js.  I bet I can build and app and not touch it for 10 years and it will run fine on the latest version of Node and Ubuntu just fine (though would be ugly as HTML / JS / CSS evolves, but it would still work!).  

Microsoft, you are losing me.

Tuesday, March 28, 2017

xmldatasource

For those of us still stuck supporting and enhancing web forms apps, sometimes it is useful to use an xmldatasource to as fake data until the underlying structure can be worked out.  Pasting a sample of an xmldatasource here to remind me of it's format in the future.  This is what you need for combo boxes



<asp:XmlDataSource ID="MyDataSet" runat="server" XPath="/items/item">
      <Data>
       <items>
        <item desc="field_one" val="some value" />
        <item desc="field_two" val="escape invalid chars" />
        <item desc="field_three" val="vals can by any type just put them line like a string" />
        <item desc="field_four" val="And so on, and so on, and so on" />
       </items>
      </Data>
    </asp:XmlDataSource>

To databind xmlsources to grids, you want the data to be laid out more like this

<asp:XmlDataSource ID="MyDataSet" runat="server" XPath="/items/item">
      <Data>
       <items>
        <item field_one="some value" field_two="escape invalid chars" field_three="vals can by any type just put them lin like a string" field_four="And so on, and so on, and so on" />
        <item field_one="some other value" field_two="escape invalid chars" field_three="vals can by any type just put them lin like a string" field_four="And so on, and so on, and so on" />
      </items>
      </Data>
    </asp:XmlDataSource>

Monday, February 27, 2017

Using the tinyMCE CDN

As you know there are all sorts of text editors out there.  For my purposes tinyMCE works fine.  It has a CDN so with the inclusion of a little javascript, you have a capable wysiwyg text editor without having to install any bits into your code (as long as the CDN is up...).  Here is how I use it.



<script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
        <script>
            tinymce.init({
                browser_spellcheck: true,
                contextmenu: false,
                selector: 'textarea',
                height: 500,
                theme: 'modern',
                plugins: [
                  'advlist autolink lists link image charmap print preview hr anchor pagebreak',
                  'searchreplace wordcount visualblocks visualchars code fullscreen',
                  'insertdatetime media nonbreaking save table directionality',
                  'emoticons template paste textcolor colorpicker textpattern imagetools'
                ],
                toolbar1: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
                toolbar2: 'print preview media | forecolor backcolor emoticons',
                image_advtab: true,
            });
          </script>

This works pretty well as a blog editor.  I have to hand put in some HTML for embedded images and videos, but so far that hasn't been a big issue.  I get the raw HTML from the tinyMCE editor for saving like so-

var ct = tinyMCE.activeEditor.getContent({ format: 'raw' });

Quick and easy.  Happy coding.

Friday, January 20, 2017

An Old Programmers Tale of Caution and Encouragement.


This was originally posted [HERE].  The post is so old I worry it will vanish, and I think it is an important read, not just for gaming, but for any project.  So I re-post it here.  God bless rogerborg.
----------------------------

Why I can't write games anymore - a novella
Postby rogerborg » Wed Jan 16, 2008 1:07 pm

Pull up a chair and I'll tell ye a tale. A tale of back in the olden days, when men were real men, women were real women, and small fluffy compilers from Alpha Delorie were real small fluffy compilers from Alpha Delorie.

Back in the Day - about 1994 or so - I found myself with some free time on my hands. So I 'downloadorzed' (hey, it was a novel concept back then) Allegro and djgpp for my supa-phat new 486DX2-66 DOS/Win3.1 PC and decided that I'd write me a game.

Because I'm a sad Trekkie (please, nobody ever tell my daughter why she's named Miranda) I figured that I'd write a computronic version of Star Fleet Battles, easily the most complex board game ever devised by Man or Nerd God. I mean, that thing ships with Errata, Addenda, and Errata in the Addenda.

Bear in mind that at this point, I really had no idea what I was doing. Sure, I had a degree in Computer Science, but being from the Old Skoolz it hadn't taught anything as tawdry as how to actually, you know... write software. I'd hacked the bejeesus out of Netrek, but only to the extent of pwoning it with a 'borg client.

So I went in with an abundance of overconfidence, and no real knowledge of what I was doing, or how to achieve it.

And in about 8 weeks of finger-bleeding coding, I had a playable 2D game written in pure structastic C and debugged with printfs(), much as the Pilgrims must have done. It had no config to speak of: you created ship descriptions in human readable text files, using a 'unit X is based on unit Y' hierarchy, and likewise with scenarios. When you started it up, it presented a simple list of available scenarios. You selected one, and away it went.

But you know what? That primitive pile of junk implemented a significant subset of Star Fleet Battles. Cloaks, shields, damage control, phasers, photons, disruptors, plasma torps, drones, anti-drones, hellbores, fusion beams, expanding sphere generators, tractors, transporters, boarding parties, shuttles/fighters, tugs, pods, star bases, planets and ground bases, all 'modelled' in Windows 3.1 Paint then rendered in glorious spinny 2d-o-rama, replete with asplosions and Star Trek sound effects ripped from the bleeding belly of the burgeoning intartubes. It had AI that provided a moderate if predictable challenge, it had fleets and fleet commands, and it implemented all of my original requirements and a few more besides.

That was in 1994, when I knew nothing and had tools little better than sticks and rocks. In 2008, when I know vastly more about how to design, write and test software, and have tools that would make the 1994 me mess my pants... I honestly believe that I couldn't write that game again.

Want to know why not?

I know too much, and have too much.

I'd second guess myself on design, and design patterns. I'd agonise for weeks over the exact hierarchy of objects, interfaces and responsibility for implementing features, and then I'd change my mind and start over. I'd spend an age carefully abstracting away the presentation from the data so that I could change engines, then I'd spend another age using that flexibility to dither over whether to use engine X for its bells, or engine Y for its whistles. I'd agonise over whether a networked version should be architected as a multiplayer game with AIs, or a single player game with a coop/competitive mode. I'd type a line of code, then Google for an hour to convince myself that it was optimal.

I'd make posts like this rather than actually knuckling down and just writing code that implements the clear goals that I've set myself, because it's more rewarding to talk about it than to worry that I've picked the wrong way of doing it.

In 1994, I was Aquaman. Sure, all I could do was talk to fish, but dammit, when there was a problem to be solved that smelled even remotely piscine, I talked their little fishy fins off. Now I'm El Dorado. I have loads of powers, and can make up new ones as I go, but that just makes it harder to choose one and go with it. A marauding octopus! Should I read its mind? Shoot it with my eye lasers? Create an illusion of a sexy lady octopus? Should I grab it and teleport it to a sashimi restaurant? What to do... what do... oh, never mind, it's eaten Kairo.

So, as we grind and bump towards the conclusion of this senile shaggy dog story, do I have a point to make? A nugget of wisdom to impart?

I do.

First, don't listen to the 2008 Rogerborg. Now I only know what can't be done. I've forgotten what can be achieved though ignorance and determination.

Second, listen to the 2008 Rogerborg when he says to do as he says, and not as he does. If you have a game that you want to write, then write it. Just knuckle down and write it. Don't worry about how optimal your data encapsulation is, just bung everything into a structure and call functions on it. Write naive code, and don't give a stuff about optimisation or resource management. Get stuff on screen, and make it spin.

When you are happy, then you're done.

And here endeth the lesson.

Thursday, January 12, 2017

Three SQLite Gotchas

If you are using SQLite coming from say a Microsoft SQL Server background, here are a few differences that might throw you.
  1. There is no TOP as in "select top 50 from....".  
    Instead you use LIMIT, and you put it at the end of your query like "Select blah from blah order by blah limit 50".
  2. Paging because of the above is actually made easy.  You can use OFFSET with LIMIT for easy paging like so. "Select blah from blah order by and wheres blah limit 20 offset 50..." if you pass in a paging variable like say @page you can times your offset to get you what page you want, like "offset * @page".   There is even a shorthand for it, but with a gotcha...the offset and limit are swapped.  Like "select .... order by blah limit 40,10" actually means offset 40 limit 10, which is counter intuitive but there for backwards compatibility.
  3. CASE.  Case is kind of a bummer for comparisons in SQLite.  you can set in on your indexes or on your connection strings to ignore case on your where @mystring = 'blah' type queries like so

    - programa collate nocase in your connections string
    - collate nocase on the end of your queries
    - or add collate nocase on your index when creating a column

    But alas, not that simple.  this only works for UTF-8, if you are using UTF-16 you have to use more exotic solutions with collate binary (I'll leave a link).

    Out of the box you can fake insensitivity using the like operator,  select blah where x like @xxx +'%'... though note here you are better off adding that % operator on your sql param then having it in your query string, for some reason the later doesn't work for me but maybe I'm missing something.

    Also instr, the equivalent to charindex in SQL, insn't case insensitive.  Bummer.

Some useful links-

Monday, October 10, 2016

CSS Responsive Videos

Again, these are old tricks but new to me as I get back into developing new sites rather than supporting Telerk based ones.  In the previous post I shared a CSS snippet on how to make images responsive.  Now onto video.  A lot of sites offer ways for you to copy some code that allows you to paste their videos into your various web sites.  Many use iframes to do this which can be a little problematic.

The following CSS snippet works for youtube videos at least.  I just take whatever copy/paste code form a given site that allows me to embed things and wrap it in a div with the class "vid".  Here is the CSS.


 .vid {  
   position: relative;  
   padding-bottom: 56.25%;  
   padding-top: 30px;  
   height: 0;  
   overflow: hidden;  
 }  
   .vid iframe, .video-container object, .video-container embed {  
     position: absolute;  
     top: 0;  
     left: 0;  
     width: 100%;  
     height: 100%;  

This seemed to work.  More information [HERE].

Getting the Strong Name PublicKeyTolken from an Assembly

[Update, if this doesn't work check the bottom]


Ok, this is .net 101, but I don't update assemblies that often so here is a recap of it so I remember in the future more for me than for you.

1) First, go the the assembly, right click it, get the details, write down the version number, that is probably old too.

2) Since you have the file open, copy it's path, then open up a Visual Studio command prompt.  Type in

sn -T (paste your path)\yourassemblydll

And it should output a new/correct PublicKeyTolken.

Copy and paste the new version and the new PublicKeyTolken text into your config file.  That should do it.

More info on this [HERE].

---------------------------------------

Well, this used to work all fine and good, but didn't work on a new machine that I have that just had visual Studio 2015 on it.  Here is what I had to do.


1) Navigate with file explorer to where the sn.exe file is located, for me it was here-
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools.  Copy that that path then open the Visual Studio developer prompt.

2) type cd then past the path in, hit enter.

3) Next, get the path to your dll that you want to get a strong name for.  Also write down the detail information like in step 1 in the old way above.

4) In the command prompt type sn.exe -T and hit enter.

That worked for me.

Thursday, October 06, 2016

CSS Responsive Images

This is an old trick but I didn't know it.  Here is how to make your images auto scale-

 img {  
      max-width:100%;  
      height:auto;  
 }  

More [HERE].

Also check out the new picture HTML 5 element [HERE].

Friday, September 30, 2016

Celebrating Some Depreciated Tech

Early this year I purchased an ASUS gaming laptop for development and I love it.  16 Gigs of RAM, I popped in a mk2 SSD, and the thing smokes.  But this post isn't about that.  This post is about my stall worth HP Pavilion dv6-6c35dx laptop that served me well for about three years.


I loved this laptop.  I probably had it up and running for 14 hours a day most of the time and it didn't give me any problems.  It had some gaming capability with the built in Radeon graphics card that did fine at low and sometimes medium settings playing all but the most latest games.  After about a year I put in a Samsung 840 EVO SSD and the thing really hummed.  Zero noise and fast boot times.  The six gigs of memory was just enough so I could comfortably develop on it, running virtual machines with 4 gigs of memory out of the six allocated to a particular VM.

I know HP laptops are hit and miss.  I supported HP laptops at a huge corporate cube farm early in my career and some of the models HP put out where just horrible.  I probably wouldn't have bought this one at all but dumped a cup of coffee on my Toshiba laptop and it fried. I needed a laptop for work now and at the time I liked the specs and the price of this HP so I took a risk and that little A8 Pavilion ended up being a great work horse.

Spec wise it was nothing that great, but for what I wanted to do with it it seemed perfect.  Light to medium gaming, opened applications and booted up lighting fast due to the later added SSD, quiet, never over-heated.  I miss it.

With Windows 10 coming out and Visual Studio 2015 on the way I had been debating getting a new laptop for a long time but this Pavilion just seemed to keep handling everything I could throw at it so I held off for awhile.  One of my dogs helped me take the plunge though, as it got it's tale caught in the power cord and yanked my poor Pavilion (which I had dropped and punished numerous times before without every having any problems) onto the floor and munched the monitor or the graphics card.  That was enough to in my mind justify buying a new machine.

I always felt kind of guilt though, like I had cheated.  I could still plug in my Pavilion into my TV and use it to watch internet moves through (graphics worked ok for external monitors so it probably was the display).  But tonight I decided to gut for parts my little Pavilion so it will be no more.

Work gave me a hand me down laptop and told me to use it last year so I have been.  Compared to my Pavilion and my ASUS the thing was a dog (incidentally it is a high-end HP work station laptop).  Today I couldn't stand how slow my work laptop was running so I yanked the Samsung SSD out of my Pavilion, cloned my work hard drive to it, and popped the SSD into my work computer.  Now my work computer is tolerable.  It felt like I was ripping out the soul of my little Pavilion though.

So there it is.  I was really blessed at purchasing that laptop at the time for under 600 and having it serve me so well.  I didn't research the purchase and bought it at Best Buy, usually two ingredients for a recipe for disaster, but I lucked out. I see you can buy these for under 200 bucks now, and most coming with an SSD.  For that price this laptop is still a good value, but my ASUS with all it's great specs is more of what I need now.

So I raise a glass and toast a great piece of technology that served me well: The HP Pavilion dv6-6c35dx.  I will probably yank the memory out of it tomorrow and toss it into the garbage as it isn't cost effective to try to fix the monitor.  You will be missed.