Monday, November 20, 2017

Getting the index of a table column by TH name

The Table HTML:
<table class="table table-bordered table-hover" id="table">
    <thead>
    <tr>
        <th class="text-center">Name</th>
        <th class="text-center">Phone number</th>
        <th class="text-center">Action</th>
        <th class="text-center">Message</th>
        <th class="text-center">Date</th>
        <th class="text-center">Actions</th>
    </tr>
    </thead>
    <tbody>
    </tbody>
</table>
Here's how to get the index of the "Date" column:
var idx = $('#table th:contains("Date")').index();

Get row data from Datatables

You know how you'll have a action item on every row of your Datatable and need to get that row data when that item is clicked?



Here's how:

//
// create datatable
//
var table = $('#table').DataTable({
    ...
    ...
});

//
// handle clicks of the action selector
//
$('.action-selector').click(function(ev){
    var rowdata = table.row( $(this).parents('tr') ).data();
    //
    // rowdata now has the data from the row that 'action-selector' was clicked on
    //
}

Wednesday, November 8, 2017

Twilio 502 gateway errors when using Valet / ngrok.io

Are you getting 502 gateway errors when using Valet / ngrok.io with Twilio? Update your ngrok.io and it should fix it (press control-u while ngrok.io is running, then restart it).

Friday, September 15, 2017

composer update error: please create GitHub OAuth token to go over the API rate limit

While performing a "composer update" today I ran into an odd error. A lot was dumped to the screen, but this is the important part:

please create a GitHub OAuth token to go over the API rate limit

After Googling around for a bit, I stumbled into the solution.
  1. First, create a "Personal Access Token" in your github account. If you don't have a github account, you'll need one so sign up. Here's how you create that token: How to create a Personal Access Token on GitHub
  2. Make sure you copy this access token down. It is *only* display after creation. Once you leave that page, you will never be able to view it again at GitHub. I keep a copy of mine in my Dashlane Secure Notes section - use whatever tool you prefer.
  3. In your project root, enter this:

    composer config --global github-oauth.github.com <TOKEN>

    where <TOKEN> is the access token you created in step 1 above.

Saturday, September 9, 2017

Setting up a new Laravel 5.5 site

First change the ownership of storage and bootstrap/cache to nobody:

sudo chgrp -R nobody.nobody storage bootstrap/cache

Next, set the permissions:

sudo chmod -R 777 storage bootstrap/cache

Thursday, September 7, 2017

Back in the saddle.

It's been a while. Wife died and this kinda fell off the map. I remarried a few months ago and lets see if I can resurrect this...