VS Code hide open editors pane

If you’d like to hide the open editors tab in VS Code, especially useful if you’re trying to open multiple files in a folder at once and it keeps pushing the list down, you can open up settings Ctrl + , and search for openeditors and set the number of editors shown in the open editors pane to 0.

read more

ColdFusion Removing duplicate values from a list

To get the number unique values from a list you can create a Java set, which does not allow duplicate values

createObject("java", "java.util.HashSet").init(listToArray(valueList(eventsQuery.event_id))).size();

The init values requires a list, so if you already have a list, you can just pass that in to return a Java set object. You will need to convert the set back to a list to make it easy to work with in ColdFusion although you could iterate over it if you’d like. Here’s the easiest version.

listWithDupes = [1,2,3,1,3];
noDupes = createObject("java", "java.util.HashSet").init(listWithDupes);
noDupesArray = createObject("java", "java.util.ArrayList").init(noDupes);
writeDump(noDupesArray); //returns 1,2,3

read more

Detecting a Credit Card number in a field using JavaScript

Given a field such as <input id="notes" type="text" names="notes"> You can detect a Credit Card number using the following in jQuery. This will detect 15 or 16 digit credit card numbers because of the d{3,4}. To only detect 15 or 16 change that to be only d{3} for 15 or d{4} for 16.

$('#notes').on('input', function() {
    const ccDetected = $('#notes').val().match(/\b(?:\d{4}[ -]?){3}(?=\d{3,4}\b)/gm);
    if (ccDetected) {
        alert('don''t use credit cards!');
    }
});

read more

Update LibreELEC to version 9 for Kodi 18

Kodi version 18 has been released as has LibreELEC version 9.

If you’ve checked for updates on your Raspberry Pi and nothing is showing here’s the solution.

  1. Go to the LibreELEC Add-On
  2. Change Automatic Updates from Auto to Manual
  3. Enable Show Custom Channels and then disable it
  4. From the Update Channelmenu chooseLibreELEC-9.0
  5. Go to Available Versions
  6. Install 9.0.0 (or the latest)
  7. Turn Automatic Updates back on
  8. Repeat when LibreELEC version 10 comes out

read more

SurveyMonkey CX API call

SurveyMonkey has a great new API available that allows you to easily send someone an email programmatically. I ran into some hiccups while setting it up and there’s almost zero documentation out there.

Endpoint: This is provided at the end of setting up a survey. Should look like

https://cx.surveymonkey.com/api/v1/surveys/${fromSurvey}/replies

Headers

name="Content-Type" value="application/json"
name="Authorization" value="Token token=#apiToken#"

Body

{
    "person": {
        "email": "emailAddress",
        "first_name": "first name",
        "last_name": "last name",
        "fields": {
            "Custom Field": ["custom field value"]
        }
    },
    "delay": 0
}

The custom fields must match exactly what you put in your admin and you must pass it in as a list. If you don’t pass a list it won’t register. The delay is the number of days to delay sending the survey.

My full postman request is below with sensitive information redacted.

  "info": {
    "_postman_id": "d16018c3-53d9-4ebd-a47f-61a84505a04d",
    "name": "SurveyMonkey",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "Survey Monkey",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Token token=${apiToken}",
            "type": "text"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\r\n  \"person\": {\r\n    \"email\": \"email@gmail.com\",\r\n    \"first_name\": \"First\",\r\n    \"last_name\": \"Last\",\r\n    \"fields\": {\r\n      \"Products\": [\"Acme M500\", \"Acme B7500\"]},\r\n  \"facets\": {\r\n    \"Job ID\": \"1234\"\r\n  },\r\n  \"delay\": 24\r\n}"
        },
        "url": {
          "raw": "https://cx.surveymonkey.com/api/v1/surveys/${fromSurvey}/replies",
          "protocol": "https",
          "host": ["cx", "surveymonkey", "com"],
          "path": ["api", "v1", "surveys", "${fromSurvey}", "replies"]
        }
      },
      "response": []
    }
  ]
}

read more