Skip to content

Alex Rusin Blog

  • BlogExpand
    • AWS
    • Javascript Development
    • Remix
    • PHP MySQL Development
    • Laravel
    • System Administration
    • WordPress Development
    • Magento
    • Uncategorized
  • My Projects
Alex Rusin Blog
  • PHP MySQL Development

    Extracting SKUs from Shopify Products

    Byalexrusin September 15, 2018September 15, 2018

    Let’s assume we have a use case. We create products at someotherwebsite.com. In the end of each day we want to sync newly created products to Shopify store using API. Each product that we are creating has a unique code to identify it. This code corresponds to Shopify product’s sku. This is how we link…

    Read More Extracting SKUs from Shopify ProductsContinue

  • Debugging Webhooks
    Laravel | PHP MySQL Development

    Debugging Webhooks

    Byalexrusin August 26, 2018September 22, 2018

    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…

    Read More Debugging WebhooksContinue

  • Mailroom Clerk
    PHP MySQL Development | Uncategorized

    Mailroom Clerk

    Byalexrusin August 21, 2018September 22, 2018

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

    Read More Mailroom ClerkContinue

  • System Administration

    Ubuntu Command Line Search

    Byalexrusin August 20, 2018August 20, 2018

    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

    Read More Ubuntu Command Line SearchContinue

  • System Administration

    Check Available Space on Ubuntu

    Byalexrusin August 19, 2018August 19, 2018

    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…

    Read More Check Available Space on UbuntuContinue

  • PHP MySQL Development

    Replace Funky Characters While Importing CSV

    Byalexrusin August 19, 2018August 19, 2018

    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; }

    Read More Replace Funky Characters While Importing CSVContinue

  • PHP MySQL Development

    Stream Filter

    Byalexrusin August 19, 2018August 19, 2018

    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…

    Read More Stream FilterContinue

  • Laravel | PHP MySQL Development

    Large CSV Export

    Byalexrusin May 19, 2018May 19, 2018

    Sometimes you need to export a large amount of data from your database.  Obviously, if you are going to accumulate all data in an array and then write it to a csv file, you will eventually run out of memory.  A better solution is to use streams.  Here is how you can export data from…

    Read More Large CSV ExportContinue

  • PHP MySQL Development

    Complex Eloquent Query

    Byalexrusin April 30, 2018April 30, 2018

    A query below selects products that need to be updated in a remote application. It takes quantities of products in host application that are connected to source products application. On top of that it looks at all the orders that are in “Pending” status and reserves quantities for those products. SELECT products.quantity_available, connector_products.stock_id, products.id, connector_products.sku,…

    Read More Complex Eloquent QueryContinue

  • PHP MySQL Development

    Upload to FTP with PHP

    Byalexrusin April 29, 2018April 29, 2018

    $fp = fopen(‘https://www.example.com/pdfdoc’, ‘r’); $user = “sammy”; $pass = “password”; $ftp_server = “192.168.10.10”; //should be wrapped in try catch to properly handle errors $ftp_conn = ftp_ssl_connect($ftp_server); $login = ftp_login($ftp_conn, $user, $pass); ftp_chdir($ftp_conn, ‘path/to/folder’); //can also use ftp_pwd ftp_pasv($ftp_conn, true); //passive mode ftp_fput($ftp_conn, “mydocument.pdf”, $fp, FTP_BINARY); fclose($fp); ftp_close($ftp_conn); Above code can be used to upload a…

    Read More Upload to FTP with PHPContinue

Page navigation

Previous PagePrevious 1 … 7 8 9 10 11 … 13 Next PageNext

© 2025 Alex Rusin Blog - WordPress Theme by Kadence WP

  • Blog
    • AWS
    • Javascript Development
    • Remix
    • PHP MySQL Development
    • Laravel
    • System Administration
    • WordPress Development
    • Magento
    • Uncategorized
  • My Projects