Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Huy Pham huypn

🏠
Working from home
Block or report user

Report or block huypn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@huypn
huypn / countries.php
Created Oct 31, 2018 — forked from josephilipraja/countries.php
List of Countries with Country code & Telephone (Dial) Code as a PHP Array. Bonus: PHP function to list all Countries as HTML Select Tag Options with their 2 character Country code as values
View countries.php
<?php
$countryArray = array(
'AD'=>array('name'=>'ANDORRA','code'=>'376'),
'AE'=>array('name'=>'UNITED ARAB EMIRATES','code'=>'971'),
'AF'=>array('name'=>'AFGHANISTAN','code'=>'93'),
'AG'=>array('name'=>'ANTIGUA AND BARBUDA','code'=>'1268'),
'AI'=>array('name'=>'ANGUILLA','code'=>'1264'),
'AL'=>array('name'=>'ALBANIA','code'=>'355'),
'AM'=>array('name'=>'ARMENIA','code'=>'374'),
'AN'=>array('name'=>'NETHERLANDS ANTILLES','code'=>'599'),
View README.md

Font Face

A mixin for writing @font-face rules in SASS.

Usage

Create a font face rule. Embedded OpenType, WOFF2, WOFF, TrueType, and SVG files are automatically sourced.

@include font-face(Samplino, fonts/Samplino);
View settings.php
<?php
function ibenic_email_template_settings() {
// Section
add_settings_section(
'email_templates_section',
'Dynamic Email Templates',
'ibenic_email_templates_section',
'email-templates'
);
@huypn
huypn / gist:d86141edf2a5f37344f2deb06747a331
Created Dec 9, 2017 — forked from mikejolley/gist:2974310
WooCommerce - Set default state/country for checkout
View gist:d86141edf2a5f37344f2deb06747a331
/**
* Manipulate default state and countries
*
* As always, code goes in your theme functions.php file
*/
add_filter( 'default_checkout_country', 'change_default_checkout_country' );
add_filter( 'default_checkout_state', 'change_default_checkout_state' );
function change_default_checkout_country() {
return 'XX'; // country code
View Find and replace text in file with Regex
#!/bin/bash
# Find and change text in file with "sed"
# https://unix.stackexchange.com/questions/159367/using-sed-to-find-and-replace
# http://www.thegeekstuff.com/2009/09/unix-sed-tutorial-replace-text-inside-a-file-using-substitute-command/?utm_source=sitekickr&utm_medium=snip_button
DIRS=`ls -l "." | egrep '^d' | awk '{print $9}'`
for DIR in $DIRS
do
FILE=$DIR"/wp-config.php"
sed -i -e "s/define('DB_PASSWORD',.*);/define('DB_PASSWORD', 'root');/g" $FILE
@huypn
huypn / atom-macos-context-menu.md
Created Nov 16, 2017 — forked from idleberg/atom-macos-context-menu.md
“Open in Atom” in macOS context-menu
View atom-macos-context-menu.md

Open in Atom

  • Open Automator
  • Create a new Service
  • Set “Service receives selected” to files or folders in any application
  • Add a Run Shell Script action
  • Set the script action to /usr/local/bin/atom -n $@
  • Set “Pass input” to as arguments
  • Save as Open in Atom
@huypn
huypn / sublime-text-macos-context-menu.md
Created Oct 30, 2017 — forked from idleberg/sublime-text-macos-context-menu.md
“Open in Sublime Text” in macOS context-menu
View sublime-text-macos-context-menu.md

Open in Sublime Text

  • Open Automator
  • Create a new Service
  • Set “Service receives selected” to files or folders in any application
  • Add a Run Shell Script action
  • Set the script action to /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -n $@
  • Set “Pass input” to as arguments
  • Save as Open in Sublime Text
@huypn
huypn / backup.php
Created Oct 28, 2017 — forked from MarvinMenzerath/backup.php
PHP: Recursively Backup Files & Folders to ZIP-File
View backup.php
<?php
/*
* PHP: Recursively Backup Files & Folders to ZIP-File
* MIT-License - Copyright (c) 2012-2017 Marvin Menzerath
*/
// Make sure the script can handle large folders/files
ini_set('max_execution_time', 600);
ini_set('memory_limit','1024M');
@huypn
huypn / sendmail_setup.md
Created Sep 28, 2017 — forked from kany/sendmail_setup.md
Setup SENDMAIL on Mac OSX Yosemite
View sendmail_setup.md
@huypn
huypn / gist:3f1739747f2b848ff485a13cefa861df
Created Aug 17, 2017 — forked from jrmadsen67/gist:bd0f9ad0ef1ed6bb594e
Laravel Quick Tip: Handling CsrfToken Expiration gracefully
View gist:3f1739747f2b848ff485a13cefa861df
Quick tip for handling CSRF Token Expiration - common issue is when you use csrf protection is that if
a form sits there for a while (like a login form, but any the same) the csrf token in the form will
expire & throw a strange error.
Handling it is simple, and is a good lesson for dealing with other types of errors in a custom manner.
In Middleware you will see a file VerifyCsrfToken.php and be tempted to handle things there. DON'T!
Instead, look at your app/Exceptions/Handler.php, at the render($request, Exception $e) function.
All of your exceptions go through here, unless you have excluded them in the $dontReport array at the
You can’t perform that action at this time.