Skip to content

Instantly share code, notes, and snippets.

View nntoan's full-sized avatar
🌀

Toan Nguyen nntoan

🌀
View GitHub Profile
@nntoan
nntoan / bash
Created January 24, 2018 05:14
Bash Advance
$1, $2, $3, ... are the positional parameters.
"$@" is an array-like construct of all positional parameters, {$1, $2, $3 ...}.
"$*" is the IFS expansion of all positional parameters, $1 $2 $3 ....
$# is the number of positional parameters.
$- current options set for the shell.
$$ pid of the current shell (not subshell).
$_ most recent parameter (or the abs path of the command to start the current shell immediately after startup).
$IFS is the (input) field separator.
$? is the most recent foreground pipeline exit status.
$! is the PID of the most recent background command.
@nntoan
nntoan / purge.sh
Created December 21, 2017 06:25 — forked from adrienbrault/purge.sh
Script to reduce VM size before packaging for vagrant
#!/bin/sh
# Credits to:
# - http://vstone.eu/reducing-vagrant-box-size/
# - https://github.com/mitchellh/vagrant/issues/343
aptitude -y purge ri
aptitude -y purge installation-report landscape-common wireless-tools wpasupplicant ubuntu-serverguide
aptitude -y purge python-dbus libnl1 python-smartpm python-twisted-core libiw30
aptitude -y purge python-twisted-bin libdbus-glib-1-2 python-pexpect python-pycurl python-serial python-gobject python-pam python-openssl libffi5
@nntoan
nntoan / algoliasearch.html
Created September 23, 2017 12:30
algoliasearch_template
<div id="algolia-autocomplete-container" style="position: relative;"><span class="aa-dropdown-menu aa-with-1 aa-with-0 aa-with-products" role="listbox" id="algolia-autocomplete-listbox-0" style="position: absolute; top: 50px; left: auto; z-index: 100; display: block; right: 205px;">
<div class="autocomplete-wrapper">
<div class="col9">
<div class="aa-dataset-products" style="min-height: 443px;"><span class="aa-suggestions" style="display: block;"><div class="aa-suggestion" role="option" id="option-33252661">
<a class="algoliasearch-autocomplete-hit" href="http://inessence-local.balancenet.com.au/stress-essential-oil-blend-25ml" style="white-space: normal;">
<div class="thumb"><img src="//heritage-local.balancenet.com.au/pub/static/version1506161882/frontend/Inessence/base/en_AU/Magento_Catalog/images/product/placeholder/.jpg"></div>
<div class="info">
Stress <em>Ess</em>ential Oil Blend 25mL

Keybase proof

I hereby claim:

  • I am nntoan on github.
  • I am nntoan (https://keybase.io/nntoan) on keybase.
  • I have a public key whose fingerprint is 3E63 D8A0 F1E9 6E43 8314 4643 51D1 9BF2 C192 D18F

To claim this, I am signing this object:

@nntoan
nntoan / CarAutomative.php
Created September 23, 2016 03:07
Logger Example
<?php
namespace Vendor\Package\Model;
class CarAutomative extends \Magento\Framework\Model\AbstractModel
{
/**
* @var \Vendor\Package\Logger\Logger
*/
protected $vendorLogger;
@nntoan
nntoan / di.xml
Created September 23, 2016 03:04
Logger - etc\di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Vendor\Package\Logger\Handler">
<arguments>
<argument name="filesystem" xsi:type="object">Magento\Framework\Filesystem\Driver\File</argument>
</arguments>
</type>
<type name="Vendor\Package\Logger\Logger">
<arguments>
<argument name="name" xsi:type="string">vendorLogger</argument>
@nntoan
nntoan / Logger.php
Last active September 23, 2016 03:03
Logger\Logger.php
<?php
namespace Vendor\Package\Logger;
class Logger extends \Monolog\Logger
{
}
@nntoan
nntoan / Handler.php
Last active September 23, 2016 03:02
Logger\Handler.php
<?php
namespace Vendor\Package\Logger;
class Handler extends \Magento\Framework\Logger\Handler\Base
{
/**
* Logging level
* @var int
*/
@nntoan
nntoan / Enigma.php
Created May 31, 2016 07:48
Project Enigma
<?php namespace App\Services;
/**
* A PHP version of the Enigma machine.
* Wikipedia: http://en.wikipedia.org/wiki/Enigma_machine
*
* This might not be an accurate representation. I have never seen, nor used an enigma machine.
* This class was created by reading the article at http://enigma.louisedade.co.uk/howitworks.html.
*
* Usage:
*
@nntoan
nntoan / update_emails.sql
Created March 23, 2016 07:38 — forked from antoinekociuba/update_emails.sql
Update customer/order email addresses in test environment database (prevent to accidentally send test emails to real customers)
## Update order email addresses ##
UPDATE `sales_flat_order`
SET `customer_email` = CONCAT('test__', `customer_email`)
WHERE `customer_email` NOT IN ('email@domain.com', 'email2@domain.com')
AND `customer_email` NOT LIKE 'test__%';
## Update customer email addresses ##
UPDATE `customer_entity`
SET `email` = CONCAT('test__', `email`)
WHERE `email` NOT IN ('email@domain.com', 'email2@domain.com')