Skip to content

Instantly share code, notes, and snippets.

View az-iar's full-sized avatar

Azri Ismail az-iar

View GitHub Profile
@az-iar
az-iar / thousand_number_format
Created November 25, 2014 03:19
Shorten number in thousand format
if(!function_exists('thousandsNumberFormat')){
function thousandsNumberFormat($num) {
if(empty($num) || $num < 1000) return $num;
$x = round($num);
$x_number_format = number_format($x);
$x_array = explode(',', $x_number_format);
$x_parts = array('k', 'm', 'b', 't');
$x_count_parts = count($x_array) - 1;
$x_display = $x;
@az-iar
az-iar / after.sh
Created February 5, 2015 05:22
Homestead 2.0 after.sh
#!/bin/sh
# If you would like to do some extra provisioning you may
# add any commands you wish to this file and they will
# be run after the Homestead machine is provisioned.''
sudo apt-get update && sudo apt-get upgrade
# install RVM with latest ruby
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
@az-iar
az-iar / MagentoHasher.php
Created March 19, 2015 09:30
Magento user password hasher for laravel 5
<?php namespace App\Services;
use Illuminate\Contracts\Hashing\Hasher;
class MagentoHasher implements Hasher
{
const CHARS_LOWERS = 'abcdefghijklmnopqrstuvwxyz';
const CHARS_UPPERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const CHARS_DIGITS = '0123456789';
@az-iar
az-iar / assign_product_thumbnails.php
Created August 13, 2015 06:19
Magento - Shell Scripts
<?php
require_once 'abstract.php';
class Mage_Shell_Assign_Product_Thumbnails extends Mage_Shell_Abstract
{
/**
* Run script
*
@az-iar
az-iar / countries.php
Last active October 13, 2015 09:46
List of countries and states of Malaysia
<?php
class Country {
public static $countries = [
"Afghanistan" => "af",
"Albania" => "al",
"Algeria" => "dz",
"American Samoa" => "as",
"Andorra" => "ad",
"Angola" => "ad",
@az-iar
az-iar / .vimrc
Last active February 6, 2016 17:28
vim config
syntax enable
set number " Show line numbers
set showmatch " Highlight matching brace
set visualbell " Use visual bell (no beeping)
set hlsearch " Highlight all search results
set smartcase " Enable smart-case search
set ignorecase " Always case-insensitive
set incsearch " Searches for strings incrementally
@az-iar
az-iar / fix-order-grid.php
Created June 28, 2016 02:54
magento - fix missing order and invoice grid data
<?php
include_once 'abstract.php';
class FixOrderGrid extends Mage_Shell_Abstract
{
/**
* Run script
*
*/
@az-iar
az-iar / helpers.php
Created October 4, 2016 04:52
Split string by max length
<?php
function split_string_by_length($string, $max_length)
{
$array = explode(' ', $string);
$length = 0;
foreach ($array as $word) {
$newLength = $length + strlen($word) + 1;
@az-iar
az-iar / malaysian_states.json
Created February 5, 2017 14:37
List of all Malaysian states
[
{
"code": "JHR",
"name": "Johor"
},
{
"code": "KDH",
"name": "Kedah"
},
{
@az-iar
az-iar / options.php
Last active February 2, 2018 03:01
Form select options helpers
<?php
if (!function_exists('titles')) {
function titles()
{
return [
'Encik' => 'Encik',
'Cik' => 'Cik',
'Tuan' => 'Tuan',
'Puan' => 'Puan',