Migrating from Orchard to WordPress

I still like the Orchard CMS project, but I’ve found it taking too much maintenance time and having weird issues over the years, so I finally caved and moved this site (and a number more to follow) to (or back to) wordpress.

Even this process was made way more difficult than it should have, the basic process went something like this:

-Over time, my site had become so slow it was hurting indexing and other issues- so I had to look into why. Finally figured out spammers had been comment spamming the site so hard, it had over 45k comments in the database and it was hurting performance. The site had an akismet plugin, which was detecting much of the spam, but it was still staying in the database.

-Run an old version of a BlogML export module so I could move the content to wordpress, but the content it exported messed up categories and tags. Tried upgrading to the latest blogml export module, but it doesnt work with my old 1.2 version of orchard, so it promptly crashed and had to be backed out.

-Orchard site was pretty old version (because it doesn’t do auto updating like wordpress does, so I never have time to go manually update the versions), so I first attempted to update from version 1.2 up to 1.10. After a lot of finagling, I actually got the site to load… at first, it just bombed and wouldn’t let me log in. Digging through log files, finding out what was crashing etc., hours later it finally let me in.

-The blog was not shown in the admin, nor on the live site. Where did all the content go?? Found a way to pull the blog content out, but it’s a mess.

-Tried several more ways to export content from the blog, but either the original slug url’s were missing, or the export content was mangled in some other way. Finally decided to just use the original blogml export, sans tags, and just recreate them by hand. UGH.

Oddly enough, the only blogml import module I found for WordPress also was outdated and no longer worked in current wordpress (actually, php) versions. I had to edit the php to fix this module… I *hate* php code! But at least I got it work. Finally get the import completed, and have been messing around with tags. I wanted to map the old orchard /Tags/tagname to the wordpress /tag/tagname, so I added a url rewrite rule to do this.

Now my site is back in commission, running fast, and will auto update when new versions of wordpress comes out. Oh, I’m still running on a windows server though, so I’m not completely mainstream just yet 😉

Where does that leave my relationship with Orchard? I wish the project much success, and I will be still using it for select projects, but for basic blog-type content, I’ll just use WP for a quick setup and execution going forward.

Starbucks CEO Pay

The CEO of starbucks made about 21.5 million in 2014 (combined salary, options, stocks etc.)

Starbucks made 16.4 Billion in 2014

Starbucks employs nearly 200,000 full time employees and over 20,000 stores. 

I often see Starbucks accused of overpaying their CEO (even though he is getting paid only .1% of the company’s revenue) and that they should pay their employees more instead of him. 

So: What would happen if we gave 100% of the the CEO’s pay to all teh employees instead? How much per hour of a pay raise could we give them? 

          200,000   employees
          x 2,000   hours (40 hours per week for a year is 2000 hours)  
=  400,000,000   paid hours in a year (that’s 400 million)

Let’s split up the CEO pay and give it to all those hours.

      21,500,000     ceo pay
/   400,000,000
=        0.05375, OR 5 cents per employee hour.

This means that giving 100% of the CEO pay to all the starbucks employees would result in a whopping 5 CENTS per hour pay raise.

Put another way: The CEO of starbucks gets paid a full 5 cents per hour for every employee his company employs.

  

OneDrive reducing from 15gb to 5gb for free accounts

This is amazing- Microsoft sent a notice today that the free tier for their onedrive offering (basically cloud storage) will be dropping from 15gb down to 5gb. This is in a world where storage continues to get cheaper and storage offerings are continuing to grow their free tiers larger and drop their prices on non-free. Even though Microsoft claims this was a very “hard decision” for them to make, the only logical explanation for this decision would have to be something like:

-implement onedrive way back in windows 7ish (or was it 8?) and make it confusingly integrated with your local document folders
-get a gazillion people to accidently start using the service
-get a second gazillion to start using it after the forced win10 upgrade. 
-ms noticed 60jillion users with 5.623 gb in use and laments how much storage that adds up
-ms genius says “man, if we dropped the free limit to 5gb, we’d be RIIIICH(er)!”
-publish some contrived reason why the limit must be dropped, attempting deperately to not sound like a big stupid lie.

You can read the announcement here if you care to: https://support.office.com/en-us/article/Microsoft-OneDrive-storage-changes-bf91132d-d0cb-4cbb-96ba-86278c5c1c2f?WT.mc_id=PART_OneDrive-Unknown_OneRM_StorageChanges_FAQ&ui=en-US&rs=en-US&ad=US

basically, tons of users will be scrambling to figure out what to do with their files if they are over the 5gb limit, and a large number will feel it necessary to shell out cash for a big ol upgrade.

(Note: my “RICH” joke above is not some bernie-esque hatred of the rich, in fact I’m quite fond of them. I just hate seeing big companies make stupid decisions… over… and over…. and over…)

Prosper 202 on Windows IIS

I’ve been running more PHP and Mysql apps on windows IIS servers lately… I hope this is not the result of some disorder ;p

Wanted to try out Prosper202 Click tracking software. Downloaded the latest, version 1.9.29 as of writing. 

First issue encountered – the app highly recommends installing memcache for performance. I did some checking and memcache on windows looks like it hasn’t been done in a while… the couple binaries I found that might work are pretty outdated or were just broken links. Decided to skip this for now and revisit later (maybe). 

Second issue was a bit trickier- the app loaded and installed the database, but one I logged in, some things were obviosuly not working correctly. I noticed that many of the ajax widgets on the page just kept showing spinners, never loading. I looked at the source on the page and all the realtive links in the page were prepended with “\” instead of “/” – an obvious goof related to how the windows os uses backslashes instead of forward slashes like linux os’es use. 

I traced this down to a function, in the \202config\functions.php file- Update your get_absolute_url() function with this code: 

function get_absolute_url() {

$tmp = substr(substr(dirname( __FILE__ ), 0,-10),strlen(realpath($_SERVER[‘DOCUMENT_ROOT’])));

$tmp = str_replace(‘\\’, ‘/’, $tmp);

return $tmp; 

}

The first line is pretty much what the original used, but then we add a replace for any backslashes to make them into a fwd slash. I haven’t checked further if maybe we could slice off the first char every time and replace it instead, but this broad replace function seems to work so far https://espanolfarmacia.net/amoxil-generico-precio/

The software seems to work now, but will proceed next to actually try it – and see if any other problems or performance issues arise. 

Converting DirectX to Vulcan API

Vulcan API spec is out there now and is looking to directly compete with the DirectX api for gaming (and others), for Linux and other platforms. 

I’m sure there will be a lot of discussion about porting from DirectX and/or OpenGLcode to the Vulcan API, so I’ll be adding more content here as I discover more about it. 

update: apparently some are calling it vulcun api instead of vulcan. Learn to spell!

AMP Accelerated Mobile Pages for MVC ASP.Net

Google has a new mobile standard for html that strays from the recent common knowledge involving responsive web pages which show the same html for both mobile and desktop traffic, but which reformats itself to the width of the browser Instead, Accelerated Mobile Pages ( or AMP ) actualy adds a lot of resrictions and some new tags and other goodies with the intention of making the mobile experience much faster. This has been the common compliant I’ve had with the mobile web- even with a powerful smartphone on a fast connection, the web experience is often very slow and just bad. I’m not even sure why some pages are so terrible when they even seem to be built to support mobile, but they just are. This must be the resaoning behind the new AMP standard. 

AMP has recently been in the news because google has indicated that sites supporting AMP will soon receive a bit of an SEO boost. So now, many webmasters who depend on search engine traffic are scrambling to deploy AMP-enabled versions of their sites to take advantage of this slight…advantage. 

Since most of my web projects run on ASP.Net MVC, I’m looking to implement AMP using some boilerplate template code. I’ve checked Nuget and haven’t found anything in there yet. Maybe we’ll have to develop this and add it to the nuget repository. 

Have any of you built or found something to help accelerate developing and/or deploying AMP using .Net MVC? Comment below to discuss further. 

Skype chat messages appear in wrong order – how to fix

I use skype for chatting almost all day, and today it started doing a strange behavior – my types messages would jump “up” the chat thread, to appear earlier than other messages I had already received from my chat partner. I figured it would clear itself up, but a day later things were still wrong. I assumed either my system clock or my partner’s was off, so we started comparing notes and I dicovered the clock on my laptop had skewed off just a few seconds- 5 or 6 – from what the time services show as the “correct” time, and so this was causing skype to get confused about when it was receiving new messages – my chat partner messages seemed to be almost in the future a bit, and so my messages sent to him would jump up the page behind his, in their “chronological” order based on the timestamps of each message. 

I’m actually not having this issue any longer, so I’m not sure if it was being caused by issues with connecting with a time server, or it might have been the intensive ftp transfers I had running for almost a week, pulling 10 threads of files constantly- I think this may have been taxing the cpu in a way that caused the time to shift over the course of a day. In any case, it seems to have stopped now. 

Back on topic- If you find this happening on your system, how can you fix it? 

We can force the clock to sync with a time server again to get the clock back on track. Follow these steps: 

– Open Control Panel, and open Date and Time icon
– Click the Internet Time tab (if you are on a domain, this apprently is not available)
– Click the Change Settings button on the page
– If UAC pops up, click Yes
– Check the “Synchornize with Internet time server” check box, pick a time server from the dropdown (or use the default), and click Update Now

Sometimes this will throw an error if the server cannot be reached. You can try hitting Update Now again, or try selecting a different server and do it again.

Now you’re done! Go back to skype and test out your chats, they should show up in the correct order now. 

There is a commandline option as well, but I haven’t had luck making this one work- maybe you will: 

-open an admin-level command prompt
– run: w32tm /resync   OR IF on a domain run: net time /domain

I’ve seen this throw a “time service is not running” error, in which case I tried starting the windows time service and ran it again, but still no luck. Apparently you can keep trying it until it works, but I just used the UI version above instead. 

PS3 Controller with Samsung Gear VR on Galaxy S6

This is a work in progress. 

Now that I have my Samsung Gear VR up and cranking, I’m looking for some games to mess with, and I’ve noticed that some games need a game controller. Samsung apparently sells a bluetooth controller for use with the galaxy s6, but I’ve seen mentioned that many bluetooth controllers will work with it. So, my PS3 SixAxis controller sitting next to my neglected PS3 – seems like it would be a likely candidate? 

Some searches later, I’ve found a few guys who bound their ps3 controller to their android phone and used it inside games. Every instance I’ve seen so far shows the use of an OTG cable to physically connect the controller to the phone for the initial pairing setup… and as luck would have my, my hacker brother has an OTG cable laying around. This cable basically converts the normally “slave” mode port on the phone into a master USB – the phone physically supposrts this mode internally, but you have to use this adapter cable to get it to behave this way. 

I’m still in progress on this and will update more once I’ve been able to try pairing the ps3 controller my to galaxy s6 and see if we can make it all work inside the Gear VR. 

3D 360 degree Spherical Video for VR

I recently acquired a Samsung Gear VR headset to use with my Galaxy S6 phone. As soon as I tried it on, I was able to experience what I’d been looking forward to trying – seeing a virtual world around me which convincingly stays in place when I move my head around. I’ve known that the full version of the Oculus Rift was able to do this, but wasn’t sure how good the Samsung verison would be- well, it’s good. 

I checked out some 360 degree photos and videos, but I realized that even though I can look in all directions, the images and videos were not in 3d. And if you think about it, the normal way to snap a 3d photo or to record a 3d film is to use a pair of cameras set eye width apart. This works fine, until you try to make it work in a Vr world where the viewer could move and look in any direction – how do you have two cameras pointing in “every” direction at the same time, set eye width apart? Seems like an impossible task. Note that this is not a problem in games, because they can re-render the image immediately from any perspective, and create the two stereoscopic images for your eyes on the fly. 

I was wondering if having an array of cameras might gather enough info that software might be able to build a full 360 degree view that is also in 3d- and it appears this is exactly what a few companies are doing (or attempting to do). Even google is in on the action. Here are a few solutions I found: 

360Heros – http://www.360heros.com/2014/01/worlds-first-fully-spherical-3d-360-video-and-photo-gear/  – Uses a big pile of 12 gopro cameras to capture a stereoscopic view of all 6 directions from a viewer’s perspective. 

Panocam 3d – http://www.panocam3d.com/camera.html  – wear it on your body or use a tripod, captures full 3d stereoscopic video using 24 cameras!

Google Jump – https://www.google.com/get/cardboard/jump/  –  an array of 16 gopro’s in a circle, so it appears to be meant for looking around in a cylinder, not so concerned about 3d above and below you (I assume?)Ody

GoPro Odyssey –  http://gopro.com/odyssey – derived from the google project, uses the smaller gopro 4 cameras. Apparently can control all the cameras at once, and can sync the frames to be exact with each other. 

It will be interesting to see what happens next with this technology, perhaps to bring the cost down and make it available to the consumer. I can envisions spherical camera lenses, reflectors, and low cost cameras being combined in such a way to provide this fucntionality cheaply, and perhaps it will be the next big feature to be included with smartphones.

Of course the shortcoming of 3d video like this is, the vr user can look around, but can’t actually move within the environment. Maybe the next iteration will be to set up a grid of 24 of these 24 camera clusters…. Just kidding!

Could not load file or assembly Newtonsoft.Json

I’ve run into this problem a few times, usually when source control is involved. 

-Delete the package from you /packages folder

-open nuget package manager, it will notify that things are out of sync- click the resolve button. 

-if you have version conflicts, edit your dependentAssembly bindingRedirect so that the older version(s) are redirected to the newer. 

-You may also try uninstalling using nuget and reinstalling, but this usually doesn’t fix everything. 

Dynamixel Servos with Arduino

Dynamixel servos are a bit (or a lot!) different from normal servos- instead of a PWM signal beign sent to each servo on it’s own signal wire, dynamixels use a serial communication prootocl which allows the servos to share a single signal line and each servo can be addresses over the line. The serial protocol allows setting all kinds of things on the servo, instead of just simply telling it to “move to this position” – such as adjustable speed and torque settings, full rotation mode, and can even feed back position and torque loads to the controller. 

Arduino boards can very easily support traditional PWM servo control, but these “digital servos” are a bit of a different animal. Can an arduino control a dynamixel? 

update: Since writing the draft of this post, I’ve found an arduino shield that directly addresses this issue – see this page for details: http://www.dfrobot.com/index.php?route=product/product&product_id=958

Are there software-only ways to control the dynamixels? I’m still researching this but there seem to be some, but I haven’t tested them yet and I suspect they’r ekinda kludgy.. here’s a few resources I’ve found:

The Arduino/Dynamixel Resource Page

The “dynamixel_serial.zip” file included with this project: https://code.google.com/archive/p/slide-33/downloads

And a nice collection of resources here: http://www.funnyrobotics.com/2011/04/arduino-with-dynamixel-ax-12-servo-from.html

And even some code on pastebin… weird! http://pastebin.com/U8e3jaAa

More to come…

URL structure

We use URL’s every day, but as a developer we have to know a bit more about their structure and the rules that apply to them. 

This article does a good job of reviewing all these rules: 

http://www.skorks.com/2010/05/what-every-developer-should-know-about-urls/

Some highlights: 

<scheme>://<username>:<password>@<host>:<port>/<path>;<parameters>?<query>#<fragment>

One part I hadn’t realized was the “parameters” portion after the semicolon- this is apparnetly not used very frequently at all.

The article also discusses a lot of encoding and special character ruls for each portion of the url.  

Change brightness of web rgb colors

Recently needed to use an existing web color (like, the #rrggbb color definitions) and produce a “lighter” version of it. I found some javascript code to do this, which changed the “luminance” of a given web color, at this url: http://www.sitepoint.com/javascript-generate-lighter-darker-color/

So this is a .Net translation of this code: 

        public static string ColorLuminance(string hex, float lum)
        {

            // validate hex string
            hex = new Regex(@"[^0-9a-f]", RegexOptions.None).Replace(hex, "");
            //if abc, make aabbcc
            if (hex.Length < 6)
            {
                var hchr = hex.ToCharArray();
                hex = new string(new char[] { hchr[0], hchr[0], hchr[1], hchr[1], hchr[2], hchr[2] });
            }

            // convert to decimal and change luminosity
            string rgb = "#";
            for (int i = 0; i < 3; i++)
            {
                int c = Int32.Parse(hex.Substring(i * 2, 2), NumberStyles.HexNumber);
                string sc = Convert.ToInt32(Math.Round(Math.Min(Math.Max(0, c + (c * lum)), 255))).ToString("X2");
                rgb += sc; // ("00" + sc).Substring(sc.Length);
            }
            return rgb;
        }

Facebook Like button load async

The facebook like button historically was loaded inside a small iframe, but later the recommended approach changes to using a javascript to load the button. Only headache with this script is that it, like any javascript, can slow page loading due to the script blocking rendering of the html until it is finished loading. 

Facebook has updated their sample code to show how to load it asynchronously, but it uses an older trick that is no longer considered optimal- basically by using a small inline script which writes the actual script tag to the document object. This script can then be loaded after the html is finished downloading and procesing. This method is actually considered harmful nowdays (see https://www.igvita.com/2014/05/20/script-injected-async-scripts-considered-harmful/ ). This is the sample code from facebook: 

<script>
        (function (d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) return;
            js = d.createElement(s); js.id = id;
            js.src = "http://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.0";
            fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));
</script>

Notice the “parentNode.insertBefore” portion- this is where the concocted script tag is inserted into the parent document. 

However, the newer and cleaner method (part of html5) is to use a new attribute on the script tag named “async”- by adding this to the <scipt> tag, the browser will load the script asynchronously, automatically. Note that this can’t just be added to any script and have it work, as many scripts have dependencies on other scripts and thus have to be loaded in a particular order. But from what I can see, the facebook script doesnt have these dependencies. 

So, I’m now testing this script as a replacement and it seems to work fine: 

<script id="facebook-jssdk" src="http://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.0" async defer></script>

So far it seems to work great. I’d be curious if anyone sees any issue with this… and why isn’t facebook using it? 

UPDATE: 

A less disruptive method of doing this should also work – just add js.async=true to the old script, like this: 

<script>
        (function (d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) return;
            js = d.createElement(s); js.id = id;
js.async = true; js.src = "http://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.0"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script>

UPDATE 2:

While we're in here, we can make this script compatible with a secure/https version of the page by changing the "http://connect.facebook.net..." link to simply use "//connect.facebook.net...".

UPDATE 3:

I found this script elsewhere on the net, it seems to verify what I've built here:
<div id="fb-root"></div>
<script>
  (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
      '//connect.facebook.net/en_US/all.js#xfbml=1';
    document.getElementById('fb-root').appendChild(e);
  }());
</script>

IE8 not supported in Jquery 2.x

If you’re using jquery 2.0 or newer, it is no longer supported in internet explorer 8 or older. You can use the older jquery lib to make things work again with IE8 though.

Note that the following code has the current at time of posting versions of jquery, you should replace this with whichever version of 2.x you are using, and check if there is a newer ver for 1.9.x as well.

ALSO note- since IE8 will be using an older version of jquery, you’ll likely need to test this separately to make sure your site still works with the 1.9.x version. Big headache? Sure.

<!–[if (!IE)|(gt IE 8)]><!–>

  <script src=”//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js”></script>

<!–<![endif]–>

<!–[if lte IE 8]>

  <script src=”//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js”></script>

<![endif]–>