Month: August 2018

  • Debugging Webhooks

    Debugging Webhooks

    A webhook is an HTTP callback, that occurs when something happens (a resource changes its state). Webhooks provide a way to build event-driven apps, because you can be notified about changes. Since webhooks require a publicly accessible URL to function they can be hard to test from your local machine.  There are three main problems…

  • Mailroom Clerk

    Mailroom Clerk

    Download for Windows: mailroom-clerk-win32-ia32 Download for Mac: mailroom-clerk-darwin-x64

  • Ubuntu Command Line Search

    Sometimes I have to go through log files searching for a certain error message. The command below will show you log file names and lines where the message was recorded. grep -rnw ‘logs/’ -e ‘Hello World’ To learn more about “grep” command use the following link https://help.ubuntu.com/community/grep

  • Check Available Space on Ubuntu

    Recently I got into a situation where I ran out of free space on my Ubuntu instance. The first thing you need to do is to check how much available space you have. The command below will give you the general idea. df -h To list the files/directories that take up most of the space…

  • Replace Funky Characters While Importing CSV

    Sometimes uploaded text/csv file may have non-utf8 or other funky characters using the function below. public static function processUploadedBundles($request) { $content = file_get_contents($request->file(‘uploadedFile’)->getRealPath()); $lines = explode(PHP_EOL, $content); $array = []; foreach ($lines as $line) { $arrayCsv = str_getcsv($line, “,”); $arrayCsv = array_map(function($value){ return preg_replace(‘/[\x00-\x1F\x7F-\xFF]/’, ”, $value); }, $arrayCsv); $array[] = $arrayCsv; } return $array; }

  • Stream Filter

    In php one can use filters with streams.  Sometimes it can become handy.  Let’s say you open a .csv file as a stream, but this file is tab separated.  Your program can can process coma separated csvs, but not tab separated.  This is a good use case for a stream filter, because it can make replacements…