Category: Engineering

Scrape LinkedIn Profiles to CSV with Node.js

I recently wrote this node script to read LinkedIn profiles from a CSV and scrap the data from each into a new CSV. If you’re interesting in analyzing employee or market data, this is a great way to source the data.

Read more →

Sourcing Utah Startup Data From AngelList using Node.js and R

Whenever I want to learn something new, it helps to think of a project or use case that I can work on rather than just learning snippets here and there. For a while now I’ve been tinkering with node.js and R. I’ve really begin to adore these two, especially when it comes to data. Sourcing data with node.js is a glorious thing and analyzing that data with R is even better. At Equation, we’re engulfed with data day in and day out so ramping up on these two has been great.

I’ve been looking forward to the upcoming StartFEST, Utah’s very own startup festival. Since I’m focused on data, I wondered if I could get some context on the current startup ecosystem in Utah. I decided to take some time and use this opportunity to use node.js and R to pull together some data. Below are the steps I took to gather and display the data using node.js and R.

Read more →

PHP Execution of Transact-SQL Stored Procedures on MS SQL Server

There is an interesting nuance when executing Transact-SQL stored procedures from PHP that I’ve run into. It seems that if your stored procedure has multiple Transact-SQL statements, PHP will only execute the first statement. This doesn’t mean that you can’t return multiple result sets, they just need to be in one Transact-SQL block or have one block and other queries that do use any variables ran normally prior or after the Transact-SQL block.

Read more →

Bootstrap Popover Option Menu

I needed a way to provide several views through a small flow, one being a form similar to:

I was already using a Bootstrap popover for another option so I started there. Here is something quick I put together if you ever need to do the same:

See the Pen NPyPap by George (@grgaortiz) on CodePen.

Sorting Date Keys in PHP Object Arrays

I had a interesting problem today where I needed to sort an API response that included a list of dates for keys and integers for values. The trick was that the response was an array object, which I couldn’t sort on.

I ended up having to change the array object to a standard array, cycle through the key/value pairs, put them into a new array, and finally sort on that new array.

// Change object to array
$sortedArray = (array) $arrayObject;
// Create a new array to store the new key values
$array = array();
// Cycle through the array and push
// the new keys into the new array
foreach($sortedArray AS $key => $value){
    $key = date('Y-m-d',strtotime($key));
    $array[$key] = $value;
}
// sort the new array on keys in reverse
ksort($array);

Here is the code in action: http://www.tehplayground.com/#g6pelg6ft

Catching Server Errors in jQuery Ajax Requests

When running jQuery Ajax requests, you can catch server related code errors by using the statusCode object:

$.ajax({
  url: 'script.php',
  type: 'GET',
  dataType: 'json',
  statusCode: {
    404: function() {
      $("#response").html('Could not contact server.');
    },
    500: function() {
      $("#response").html('A server-side error has occurred.');
    }
  },
  error: function() {
    $("#response").html('A problem has occurred.');
  },
  success: function() {
    $("#response").html('Success!');
  },
});

Retrieve Selected Checkboxes with jQuery

When you have multiple HMTL checkboxes with the same name, you can cycle through each of them to get the selected values into an array with jQuery.

var selectedArray = [];

$("input[name='checkboxName[]']:checked").each( function () {
    selectedArray.push($(this).val());
});