Skip to content

Instantly share code, notes, and snippets.

View huypn's full-sized avatar
🏠
Working from home

Huy Pham huypn

🏠
Working from home
View GitHub Profile
@huypn
huypn / com.edb.launchd.postgresql-9.1.plist
Created April 14, 2016 14:17 — forked from abhishekdev/com.edb.launchd.postgresql-9.1.plist
Disable/Enable PostgreSQL Autostart on Mac OS X Lion
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>com.edb.launchd.postgresql-9.1</string>
<key>ProgramArguments</key>
@huypn
huypn / PushNotifications.php
Created February 23, 2017 18:50 — forked from joashp/PushNotifications.php
Simple PHP script to send Android Push Notification, iOS Push Notification and Windows Phone 8 Push Notification
<?php
// Server file
class PushNotifications {
// (Android)API access key from Google API's Console.
private static $API_ACCESS_KEY = 'AIzaSyDG3fYAj1uW7VB-wejaMJyJXiO5JagAsYI';
// (iOS) Private key's passphrase.
private static $passphrase = 'joashp';
// (Windows Phone 8) The name of our push channel.
private static $channelName = "joashp";
@huypn
huypn / youtubeID.js
Created August 15, 2017 17:36 — forked from takien/youtubeID.js
Get YouTube ID from various YouTube URL using JavaScript
/**
* Get YouTube ID from various YouTube URL
* @author: takien
* @url: http://takien.com
* For PHP YouTube parser, go here http://takien.com/864
*/
function YouTubeGetID(url){
var ID = '';
url = url.replace(/(>|<)/gi,'').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);
@huypn
huypn / gist:3f1739747f2b848ff485a13cefa861df
Created August 17, 2017 08:14 — forked from jrmadsen67/gist:bd0f9ad0ef1ed6bb594e
Laravel Quick Tip: Handling CsrfToken Expiration gracefully
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
@huypn
huypn / sendmail_setup.md
Created September 28, 2017 20:37 — forked from kany/sendmail_setup.md
Setup SENDMAIL on Mac OSX Yosemite
@huypn
huypn / backup.php
Created October 28, 2017 07:51 — forked from menzerath/backup.php
PHP: Recursively Backup Files & Folders to ZIP-File
<?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 / sublime-text-macos-context-menu.md
Created October 30, 2017 20:28 — forked from idleberg/sublime-text-macos-context-menu.md
“Open in Sublime Text” in macOS context-menu

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 / atom-macos-context-menu.md
Created November 16, 2017 21:56 — forked from idleberg/atom-macos-context-menu.md
“Open in Atom” in macOS context-menu

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 / gist:d86141edf2a5f37344f2deb06747a331
Created December 9, 2017 23:33 — forked from mikejolley/gist:2974310
WooCommerce - Set default state/country for checkout
/**
* 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
@huypn
huypn / settings.php
Created December 12, 2017 19:46 — forked from igorbenic/settings.php
How to Create Dynamic WordPress Email Templates | http://www.ibenic.com/create-dynamic-wordpress-email-templates/
<?php
function ibenic_email_template_settings() {
// Section
add_settings_section(
'email_templates_section',
'Dynamic Email Templates',
'ibenic_email_templates_section',
'email-templates'
);