Skip to content

Instantly share code, notes, and snippets.

View oanhnn's full-sized avatar
🇻🇳

Oanh Nguyen oanhnn

🇻🇳
View GitHub Profile
Regex for matching ALL Japanese common & uncommon Kanji (4e00 – 9fcf) ~ The Big Kahuna!
([一-龯])
Regex for matching Hirgana or Katakana (*)
([ぁ-んァ-ン])
Regex for matching Non-Hirgana or Non-Katakana
([^ぁ-んァ-ン])
Regex for matching Hirgana or Katakana or basic punctuation (、。’)
@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;
@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 / 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 / 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 / using-multiple-github-accounts-with-ssh-keys.md
Last active April 24, 2024 22:56
Using multiple github accounts with ssh keys

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@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