Skip to content

Instantly share code, notes, and snippets.

View hungtrungthinh's full-sized avatar
🤒
Out sick

Thinh Nguyen hungtrungthinh

🤒
Out sick
View GitHub Profile
@hungtrungthinh
hungtrungthinh / php_export_html_to_excel_via_phpexcel
Created July 8, 2018 17:13 — forked from narainsagar/php_export_html_to_excel_via_phpexcel
Export Html contents to Excel file using PHPExcel
<?php
/*
// save this file to: ExcelService.class.php
Create new folder 'libs' under your project dir, and download PHPExcel-1.8 library .zip from here..
use this clone url: [email protected]:PHPOffice/PHPExcel.git
OR https://github.com/PHPOffice/PHPExcel.
*/
define('TMP_FILES', "../temp/"); // temp folder where it stores the files into.
@hungtrungthinh
hungtrungthinh / url_slug.php
Created June 22, 2018 20:21 — forked from sgmurphy/url_slug.php
URL Slugs in PHP (with UTF-8 and Transliteration Support)
<?php
/**
* Create a web friendly URL slug from a string.
*
* Although supported, transliteration is discouraged because
* 1) most web browsers support UTF-8 characters in URLs
* 2) transliteration causes a loss of information
*
* @author Sean Murphy <[email protected]>
* @copyright Copyright 2012 Sean Murphy. All rights reserved.
# Get Graphics Magick
> cd /
> mkdir /dowload
> cd /download
> wget ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/GraphicsMagick-LATEST.tar.gz
> tar -xzvf GraphicsMagick-LATEST.tar.gz
> cd GraphicsMagick-1.3.21 (or the lastest graphics magick)
# Install Graphics Magick
## Get libs
@hungtrungthinh
hungtrungthinh / m2-installer.sh
Created May 27, 2018 11:25 — forked from MagePsycho/m2-installer.sh
Magento 2 Installer - Bash Script
#!/usr/bin/env bash
#
# Script to install Magento2
#
# @author Raj KB <[email protected]>
# @website http://www.magepsycho.com
# @version 0.1.0
# UnComment it if bash is lower than 4.x version
PATH_TO_MAGENTO='/path/to/magento/installation/folder'
GITHUB_TOKEN='github-token-here'
MAGENTO_USER='your-key-here'
MAGENTO_PASS='your-pass-here'
MAGENTO_ADMIN_URL='http://your-server.com'
MAGENTO_ADMIN_USER='admin'
MAGENTO_ADMIN_PASS='admin123'
# ondrej best php apt-repository for php to be able to
# update and install PHP as needed
<?php
/**
* A simple fix for a shell execution on preg_match('/[0-9]\.[0-9]+\.[0-9]+/', shell_exec('mysql -V'), $version);
* The only edit that was done is that shell_exec('mysql -V') was changed to mysql_get_server_info() because not all
* systems have shell access. XAMPP, WAMP, or any Windows system might not have this type of access. mysql_get_server_info()
* is easier to use because it pulls the MySQL version from phpinfo() and is compatible with all Operating Systems.
* @link http://www.magentocommerce.com/knowledge-base/entry/how-do-i-know-if-my-server-is-compatible-with-magento
* @author Magento Inc.
*/
@hungtrungthinh
hungtrungthinh / wp_custom_title_placeholder_text.php
Created May 21, 2017 17:16 — forked from isGabe/wp_custom_title_placeholder_text.php
WordPress: Custom placeholder text for custom post type title input box #snippet #WordPress
<?php
/*
replacing the default "Enter title here" placeholder text in the title input box
with something more descriptive can be helpful for custom post types
place this code in your theme's functions.php or relevant file
source: http://flashingcursor.com/wordpress/change-the-enter-title-here-text-in-wordpress-963
*/
server {
# see: http://wiki.nginx.org/Pitfalls
# see: http://wiki.nginx.org/IfIsEvil
listen 80;
root /app;
index index.html index.htm index.php;
error_page 404 /index.php;
# Make site accessible from http://set-ip-address.xip.io
@hungtrungthinh
hungtrungthinh / functions.php
Created August 18, 2016 09:20
Store GET variables for UTM-vars in a cookie and replace them in form content.
<?php
// store {utm_campaign}, {utm_source} and {utm_medium} vars in cookies
add_action( 'init', function() {
$keys = array( 'utm_source', 'utm_medium', 'utm_campaign' );
foreach( $keys as $key ) {
if( ! empty( $_GET[ $key ] ) ) {
$value = (string) $_GET[ $key ];
setcookie( $key, $value, time()+3600, '/');
}
@hungtrungthinh
hungtrungthinh / local.xml
Created May 26, 2016 10:27 — forked from Maksold/local.xml
Magento XML - local.xml boilerplate
<?xml version="1.0"?>
<layout>
<default>
<!--Root/Default Layouts-->
<reference name="root">
<!--Appending Block-->
<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>
</reference>
<!--CSS and JS Files-->