• Linux Commands Cheat Sheet

    This outputs your stuff in a folder called ‘packageName’: tar -xvzf packageName.tar.gz   This can help tell you what version of linux or at least linux kernel you are running: uname -a   Find a process and kill it: Run this ‘ps’ command to find the process, in this case the MySQL Daemon “mysqld”. ps more

  • Delay a Grails controller’s response

    Sometimes, for testing or development, you need to slow down an ajax response from the server. In the Grails framework, to delay a controller’s response, do the following: In the action you want to delay, insert: Thread.sleep(5000) as in: def index() { Thread.sleep(5000) … do some work… render … some response } where 5000 is more

  • Insert HTML after every Nth comment: use the “end-callback” argument

    I did not find any examples of using WordPress’s “end-callback” argument for “wp_list_comments”. It is documented by WordPress here. Here is an example of how to use it in child-theme code to add custom HTML after each top level comment. This example preserves comment hierarchy, ie: nested replies. In your child theme directory, create a more

  • How to use reserved characters in a URI

    If you have to encode a reserved character (such as ‘/’ or ‘@’) so that it can be passed in a URI path, you may need to encode it twice: Example: const ticker = ‘@SMC/2018’, encodedTicker = encodeURIComponent(encodeURIComponent(ticker)), uri = `https://someexample.io/${encodedTicker}/load`; See also: “When to Encode or Decode” if you like to be confused.

  • Recursion Examples

    Recursion in programming can be a mind bender.  Here are two examples of recursive functions coded in JavaScript.  These examples are dependent on lodash methods. Hopefully these code patterns are useful to you. I find them useful as starting points when I have to code some new recursion.   This function, “omitDeep” deletes an object more