Dev Notes There is no spoon Fri, 13 Apr 2018 19:34:38 +0000 en-US hourly 1 45967196 BigCommerce – Creating a WebHook Fri, 13 Apr 2018 19:34:38 +0000 I couldn’t find any reliable C# examples on how to create a webhook using BigCommerce’s API so I thought I’d share my solution. The example code below will create a webhook when an order is created in your BigCommerce store.

//BigCommerce Authorization
string clientID = "<your_client_id>";              
string token = "<your_token>";
string storeHash = "<your_store_hash>";
string resourcePath = "hooks";

string baseURL = "" + storeHash + "/v2/" + resourcePath;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(baseURL);
req.AllowAutoRedirect = true;
req.ContentType = "application/json";
req.Accept = "application/json";
req.Method = "POST";

req.Headers.Add("X-Auth-Client", clientID);
req.Headers.Add("X-Auth-Token", token);             
//send scope and destination as json
using (var streamWriter = new StreamWriter(req.GetRequestStream()))
    string json = "{\"scope\":\"store/order/created\"," +


string jsonResponse = null;
using (WebResponse resp = req.GetResponse())
    if (req.HaveResponse && resp != null)
        using (var reader = new StreamReader(resp.GetResponseStream()))
            jsonResponse = reader.ReadToEnd();

]]> 0 11255
Salesforce Formula For Calculating Case Age In Hours Excluding Weekends Sun, 24 Sep 2017 22:52:30 +0000 This is a modification of the Salesforce formula for finding the number of business hours between two dates. Here is the Salesforce formula:

ROUND( 8 * (
   ( 5 * FLOOR( ( DATEVALUE( date/time_1 ) - DATE( 1900, 1, 8) ) / 7) +
     MOD( DATEVALUE( date/time_1 ) - DATE( 1900, 1, 8), 7) +
     MIN( 1, 24 / 8 * ( MOD( date/time_1 - DATETIMEVALUE( '1900-01-08 16:00:00' ), 1 ) ) )
   ( 5 * FLOOR( ( DATEVALUE( date/time_2 ) - DATE( 1900, 1, 8) ) / 7) +
     MIN( 5,
      MOD( DATEVALUE( date/time_2 ) - DATE( 1996, 1, 1), 7 ) +
      MIN( 1, 24 / 8 * ( MOD( date/time_2 - DATETIMEVALUE( '1900-01-08 16:00:00' ), 1) ) )
0 )

We need to make a few modifications in order to calculate case or lead age for Monday-Friday (no business hours). The Salesforce formula above calculates for business hours between 9am-5pm. We need the same formula for 24 hour days. First, as posted in the Salesforce article we can simply change all the eights to whatever number we want to calculate so change the first 8 to 24 and we can get rid of 24 / 8 since 24 / 24 = 1 it is not needed. The next modification is we need to choose a reference date/time so for a 24 hour period we change ‘1900-01-08 16:00:00’ to ‘1900-01-08 00:00:00’. The end result is:

(5*FLOOR((TODAY()-DATE(1996,01,01))/7) + 
MOD(TODAY()-DATE(1996,01,01), 7) + 
MIN(1, (MOD(NOW()-DATETIMEVALUE('1996-01-01 00:00:00'), 1))) 
(5*FLOOR((DATEVALUE(CreatedDate)-DATE(1996,01,01))/7) + 
MOD(DATEVALUE(CreatedDate)-DATE(1996,01,01), 7) + 
MIN(1, (MOD(CreatedDate-DATETIMEVALUE('1996-01-01 00:00:00'), 1))) 
), 0)
]]> 0 11229
Adding Custom Color Flag Fields in Salesforce Tue, 15 Aug 2017 03:14:46 +0000 Salesforce no longer allows you to create custom fields with custom background colors. However, you can add images to custom fields. Let’s say you wanted to create a custom field to identify case age in business hours. For this example, we’ll identify a case opened within 24 hours with a green flag, a case opened within 48 hours with a yellow flag and a case opened longer than 48 hours with a red flag.
You’ll need to create a customer formula field with a Text return type. The code below will add the flag icons along with the number of hours the case has been opened.

IF(FLOOR((NOW() - CreatedDate)*24) < 24,
IMAGE("/img/samples/flag_green.gif", TEXT(FLOOR((NOW() - CreatedDate))*24)) & " " & TEXT(FLOOR((NOW() - CreatedDate)*24)),
IF(FLOOR((NOW() - CreatedDate)*24) < 48,
IMAGE("/img/samples/flag_yellow.gif", TEXT(FLOOR((NOW() - CreatedDate)*24))) & " " & TEXT(FLOOR((NOW() - CreatedDate)*24)),
IMAGE("/img/samples/flag_red.gif", TEXT(FLOOR((NOW() - CreatedDate)*24))) & " " & TEXT(FLOOR((NOW() - CreatedDate)*24))))

Once you’ve created your custom formula field, add it to a view and you should have a view similar to the image below:


Color Flags in Salesforce

]]> 0 11218
FIX: iOS Apple TV Remote App doesn’t connect to Apple TV Sun, 30 Apr 2017 23:26:49 +0000 If you recently purchased a new router, switched internet service providers or were never able to pair your app with your Apple TV then your router settings may be the issue. Ubee router default settings or any router’s default settings might not be ideal for the Apple TV remote app to connect to your Apple TV. Follow these steps below:

  • Log in to your router. You can find your routers IP address in your manual or sometimes its listed on back or side of your router. Here’s list of login IP Address for different routers.
  • Once logged in Enable Multicast. Depending on your router this may be called IGMP or IGMP snooping.
  • Disable WPS which is sometimes called Automatic Security Configuration.
  • Restart both your router and Apple TV.
  • With those settings set you should be able to connect to your Apple TV with your iOS Remote app.

    ]]> 1 11208
    CashMeOusside.js – An Easter Egg Plugin Tue, 07 Feb 2017 02:26:28 +0000 First off, I’d like to apologize for polluting the world of jQuery plugins. I had nothing to do so I conjured up this plugin to add “Cash Me Ousside, How Bow Dah” to your website. Installation instructions can be found on Github.


    cash me ousside

    cash me ousside

    ]]> 0 11194
    W3 Total Cache broke my WordPress site Wed, 18 Jan 2017 03:39:54 +0000 W3 Total Cache broke my website rendering nothing but gibberish. I know that the Minify JS setting can cause issues since W3 Total Cache attempts to minify javascript files that are already minified. This in turn causes CSS files not to render properly. I’ve had this issue in the past and fixed it by manually specifying which javascript files to minify. More info on fixing that can be found here.
    This time around it wasn’t the minify JS settings that were causing my problem. After scratching my head for about an hour I decided to Restore Default Settings which can be found at the bottom of the General Settings section. This fixed the issue temporarily. Once I started adding my settings back, gibberish again! I restored again and changed my settings one by one until I found the culprit, Page Cache. Yes, turning on Page Cache under General Settings was causing the gibberish to be rendered. I’m not sure if that was specific to the Catch Box theme I was using but it was a real pain in the ass and caused me an hour of downtime. Anyone have any caching alternatives they’d liked to recommend?

    Update: I re-enabled Page Cache and turned off Enable HTTP (gzip) compression which can be found under Browser Cache. This also fixed the issue while decreasing page load times. This issue seems to only be affecting servers using PHP 5.3xx. Patiently waiting for an update from W3TC.

    Update #2: Here’s the fix from the W3TC community.
    1. Open PgCache_ContentGrabber.php (found in the w3-total-cache directory)
    2. Jump down to line 1244 which should show:

    if ( isset( $value0['n'] ) ) {

    3. Replace that line with:

    if ( is_array($value0) && isset( $value0['n'] ) ) {

    This fix will be included in the next update.

    ]]> 0 11186
    My First Amazon Alexa Skill: Reading RSS using Node.js Sun, 15 Jan 2017 00:15:37 +0000 I recently had my first Amazon Alexa skill published and am eagerly awaiting my Alexa Dev hoodie! Developing and publishing an Alexa skill is a lot easier than you might think especially with all the tutorials and resources Amazon provides. I decided to develop a skill that’ll read the WOD (Workout of the day) from the crossfit gym I go to. The only problem is that my gym’s website didn’t have a public API even though it was running on WordPress. Fortunately it did have an unpublished RSS feed that I was able to find the URL to.
    I chose to create my skill using Node.js without having to use any node modules. This was a challenge since I couldn’t read in the RSS feed directly without running into any cross-domain issues. To overcome this I used Yahoo’s YQL to read the RSS feed and return the results via JSON. YQL can read any RSS feed using it’s SQL-like syntax.

    select * from rss where url = 'RSS URL'

    It even provides you with a REST url. Once I had that, the rest was easy.

    var https = require('https');
    var optionsget = {
        host : '', 
        port : 443,
        path : '/v1/public/yql?q=rssurl&format=json&diagnostics=true&callback=', // the rest of the url with parameters if needed
        method : 'GET' 
    function getWod(eventCallback) {
        var reqGet = https.request(optionsget, function(res) {
            var finalData = "";
            res.on('data', function(d) {
                finalData += d.toString();
            res.on("end", function() {     
                var obj = JSON.parse(finalData);
        reqGet.on('error', function(e) {
            console.log("Got error: ", e);
    ]]> 8 11169
    Apple will make ATS mandatory by Jan 1st 2017. What about my Admob ads? Thu, 16 Jun 2016 19:21:14 +0000 During Apples WWDC, the company revealed the deadline for all apps in its App Store to switch to App Transport Security (ATS) by January 1st, 2017. Like a lot of indie developers trying to earn revenue from iOS apps, I decided to implement Google’s Admob ads into my app to generate revenue. Google encouraged developers to disable ATS to prevent third party ads from being blocked. You can read about that here. When the news about Apple’s mandate hit, I quickly began searching for a solution for display Admob’s ads in my apps with ATS enabled. It turns out that Admob already supports ads being served over HTTPS. It simply has to be enabled in your ad settings. Disaster averted.

    ]]> 0 11139
    Backdoor in Joomla Core Files Sun, 22 May 2016 22:16:54 +0000 When a friend asked if I could make some changes to his website, I agreed thinking I’ll be modifying some PHP or Javascript files. Turns out he was using Joomla. I normally wouldn’t attempt to modify files from a CMS like Joomla especially since I have no experience doing so.
    I decided to do some research and found this great post from Fioravante Souza at Sucuri Security.

    He found malware embedded in the core files of Joomla. I suggest you read the post and check your own Joomla files for any anomalies.

    ]]> 0 11125
    Debugging Sigabrt error on Main Sun, 03 Apr 2016 20:35:40 +0000 The dreaded Sigabrt error in Xcode is as useless as censored. To help debug it, wrap it in a Try/Catch. That should give you a more meaningful error. Happy debugging!!

    int main(int argc, char *argv[])
        int retVal = 0;
        @autoreleasepool {
            @try {
                retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
            @catch (NSException *exception) {
                NSLog(@"Exception - %@",[exception description]);
        return retVal;
    ]]> 0 11095