Skip to content

Merge Excel Sheets with Laravel Excel

Laravel Excel allows you to create and format Excel documents with PHP within the Laravel framework.  I specifically needed to merge Excel sheets, and not just tack on the sheets to one document, but actually merge several files into a single sheet.  It’s pretty straightforward, but the documentation leaves a bit to be desired so it took me a while to narrow down the right way to do this.  The only downside is it will remove any formatting from the sheets.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//first pull all the rows
$rows = [];
Excel::batch(storage_path('FOLDER/CONTAINING/EXCEL/FILES'), function($rows1, $file) use($rows) {
    $rows1->each(function($row) use($rows1) {
        global $rows;
 
        $rows[] = $row->toArray();
    });
 
});
 
//then add them to a new file
Excel::create('new_filename', function ($excel) use ($rows) {
    $excel->sheet('Sheet', function ($sheet) use ($rows) {
        global $rows;
 
        // Sheet manipulation
        foreach($rows as $row) {
            $sheet->appendRow($row);
        }
    });
})->store('xls', storage_path('excel/exports'));

Install a Magento extension from SSH

Magento is a popular open-source eCommerce platform, which has a lot of extensions to add to its basic functionality.  It has a method for installing extensions in its control panel, but in my experience, it hasn’t been very reliable.  So, I usually just install extensions from the shell.  And, this is my quick cheat sheet on how you can install an extension in the shell.

  1. cd into your Magento directory
  2. Get the component name for composer, in the Magento marketplace it will be located under “My Profile > My Purchases”
  3. composer require component/name
  4. run “bin/magento module:status” to get the module’s name, it’ll be under “List of disabled modules:”
  5. bin/magento module:enable ModuleName
  6. bin/magento setup:upgrade
  7. bin/magento setup:di:compile
  8. bin/magento cache:clean
  9. php bin/magento setup:static-content:deploy -f
  10. There’s a known issue with Magento that it often won’t generate a “js-translation.json” file and that will break its back-end, but you can simply create one with empty JSON to fix the issue
  11. nano pub/static/adminhtml/Magento/backend/en_US/js-translation.json
  12. []

And you’re done!  If everything went off without a hitch you should see that extension working in your Magento control panel.

Anime on Netflix with Japanese subtitles

In conjunction with the Language Learning with Netflix chrome app it’s easy to watch shows with Furigana!  However, only so many shows actually have Japanese subtitles on Netflix :(  So here’s a list of anime with Japanese subtitles available on Netflix.  You can also search Netflix by all shows with Japanese subtitles here.

 

Actually Good

Beast Stars

KuroMukuro

 

Not bad

Drifting Dragons

Devilman Crybaby

A.I.C.O.

Cagster of an Insect Cage

 

Total Garbo

Swordgai

 

Haven’t watched

Dorohedoro

Ultramarine Maxwell

Children of the Whales

Carol & Teusday

Forest of Piano

Kengan Ashura

Last Hope

Baki

7 Seeds

Scissor Seven

Ni no Kuni

Kake Guri

Ghost in Shell CG

Levious

Megalobox

Compare CSV files in Bash

I’ve been needing this forever!  I have huge CSV lists and have needed a way to quickly compare them.  For this I just need to make sure that the first field from one CSV does not exist anywhere in the second CSV.  It was actually pretty simple to write this in Bash and it runs really fast!

1
2
3
4
5
6
while IFS=, read -r field1 field2
  do
    if grep --F "$field1" list1.csv; then
      echo "$field1 found"
    fi
done < list2.csv