Skip to content

Instantly share code, notes, and snippets.

View oanhnn's full-sized avatar
🇻🇳

Oanh Nguyen oanhnn

🇻🇳
View GitHub Profile
@oanhnn
oanhnn / strtotime
Created May 11, 2015 03:57
Note for using strtotime function in PHP
<?php
/**
* Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components:
* if the separator is a slash (/), then the American m/d/y is assumed;
* whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed.
*/
strtotime('12/25/2014');
strtotime('25-12-2014');
@oanhnn
oanhnn / VD1.html
Last active August 29, 2015 14:22
CSS center block
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.container-block {
display: block;
position: relative;
background: #ccc; /* For visualization */
width: 500px; /* Changeable */
height: 500px; /* Changeable */
@oanhnn
oanhnn / test_performance_determine_content_type.php
Created November 12, 2015 03:53
Test performance of three determine content type methods
<?php
class A
{
protected $knownTypes = [
'application/json' => true,
'application/xml' => true,
'text/xml' => true,
'text/html' => true,
];
@oanhnn
oanhnn / index.html
Created December 1, 2015 04:05
Launch app from web page snippets
<!DOCTYPE html>
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div style="width:0; height:0; overflow:hidden;">
<iframe id="launch_frame" name="launch_frame"></iframe>
@oanhnn
oanhnn / gource.sh
Created July 29, 2015 02:47
Script mark gource video for git project
# install git and gource
# get a branch of git
# create gource video
$ sudo apt-get install bzr gource
$ git clone git@github.com:oanhnn/slim-skeleton.git project_dir
$ cd project_dir
$ git checkout master
$ gource \
@oanhnn
oanhnn / vagrant.org
Created May 16, 2016 02:19 — forked from akiatoji/vagrant.org
CentOS 6.2 Box for Vagrant

Installing CentOS

Download net install iso: CentOS-6.2-x86_64-netinstall.iso

Create a new VirtualBox machine

  • Name: vagrant-centos
  • Operating System: Linux
  • Version: Red Hat
@oanhnn
oanhnn / install-comodo-ssl-cert-for-nginx.rst
Created May 5, 2017 04:58 — forked from bradmontgomery/install-comodo-ssl-cert-for-nginx.rst
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@oanhnn
oanhnn / README.md
Last active September 23, 2017 10:28
Deploy laravel to shared host

Phương pháp triển khai ứng dụng Laravel trên shared hosting

Hướng dẫn đơn giản để triển khai ứng dụng Laravel và Lumen trên shared hosting.

Yêu cầu

Before trying to deploy a Laravel application on a shared hosting, you need to make sure that the hosting services provide a fit requirement to Laravel. Basically, following items are required for Laravel 5.2: Trước khi thực hiện triển khai ứng dụng Laravel trên shared hosting, bạn cần đảm bảo nhà cung cấp dịch vụ cho bạn môi trường với các yêu cầu cần thiết cho Laravel. Về cơ bản, yêu cầu cho Laravel 5.2 như sau:

  • PHP >= 5.5.9
@oanhnn
oanhnn / install_wkhtmltopdf.sh
Created May 3, 2018 08:30
Install wkhtmltopdf on AMZ Linux
#!/usr/bin/env bash
VERSION=${1:-0.12.4}
yum -y install fontconfig libXrender libXext xorg-x11-fonts-Type1 xorg-x11-fonts-75dpi freetype libpng zlib libjpeg-turbo openssl icu
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/${VERSION}/wkhtmltox-${VERSION}_linux-generic-amd64.tar.xz --dns-timeout=5 --connect-timeout=5
tar -xJf wkhtmltox-${VERSION}_linux-generic-amd64.tar.xz
cp wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
cp wkhtmltox/bin/wkhtmltoimage /usr/local/bin/wkhtmltoimage
@oanhnn
oanhnn / test.php
Created November 4, 2014 08:44
test performance of array_diff on PHP
<?php
function my_array_diff($a, $b)
{
$map = $out = array();
foreach ($a as $val)
$map[$val] = 1;
foreach ($b as $val)
if (isset($map[$val]))
$map[$val] = 0;