Skip to content

Instantly share code, notes, and snippets.

View kcjpop's full-sized avatar
🕳️

An Cao kcjpop

🕳️
View GitHub Profile
@kcjpop
kcjpop / gist:5382140
Last active June 27, 2017 15:49
CHMOD all files to 644 and directories to 755
# Specify -R if recursion is required
chmod u+rwX,go+rX *
# 664, 775
chmod ug+rwX,go+rX *
@kcjpop
kcjpop / gist:5426034
Created April 20, 2013 13:47
Remove "public" in Laravel URL
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
# In case you have to place all files in your root folder
@kcjpop
kcjpop / gist:7310923
Created November 4, 2013 23:11
[vim] Delete all lines in a file
-- Move to the beginning of file
gg
-- Delete everything
dG
@kcjpop
kcjpop / gist:7310943
Last active December 27, 2015 10:28
Virtual Host configuration in Apache 2.4
<VirtualHost *:80>
ServerName cliffly.local
DirectoryIndex index.html index.php
DocumentRoot "/path/to/web"
<Directory "/path/to/web">
Order allow,deny
Allow from all
Require all granted
@kcjpop
kcjpop / gist:7325547
Created November 5, 2013 20:22
Fix found USB disk in Disk Manager but inaccessible
diskpart
listdisk
select disk 3 (or enter the corresponding drive number for external HDD)
clean all
create partition primary
select partition 1
active
format fs=ntfs quick
assign
exit
@kcjpop
kcjpop / gist:8069380
Created December 21, 2013 13:34
Some small JS tests
1. ++Math.PI
2. (0.1 + 0.2) + 0.3 == 0.1 + (0.2 + 0.3)
3. typeof NaN
4. typeof typeof undefined
5. a = {null:null}; typeof a.null;
6. a = "5"; b = "2"; c = a * b;
7. a = "5"; b = 2; c = a+++b;
8. isNaN(1/null)
9. (16).toString(16)
10. 016 * 2
@kcjpop
kcjpop / gist:9267576
Last active December 2, 2016 11:49
My git aliases
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
git config --global alias.dc 'diff --color'
git config --global alias.dca 'diff --color --cached'
git config --global alias.pr 'pull --rebase'
git config --global alias.st 'status'
git config --global alias.aa 'add . -A'
git config --global alias.ca 'commit --amend'
git config --global alias.cm 'commit'
@kcjpop
kcjpop / Vagrantfile
Created March 12, 2014 23:45
Laravel simple Vagrant setup for Windows
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "hashicorp/precise32"
config.vm.synced_folder "./", "/var/www", id: "vagrant-root",
owner: "vagrant",
group: "www-data",
@kcjpop
kcjpop / gist:9982753
Last active August 29, 2015 13:58
Some JavaScript notes
// Check existence of a property
Object.prototype.hasOwnProperty.call(obj, keyToBeChecked);
// Create a new object that inherits from a null prototype
var registry = Object.create(null);
// So this could yield `true`
!registry['hasOwnProperty'];
// Source: http://www.devthought.com/2012/01/18/an-object-is-not-a-hash/
@kcjpop
kcjpop / slugify.js
Last active May 24, 2017 19:55
Vietnamese slugify
const slugify = str => str
.trim()
.toLowerCase()
.replace(/(á|à|ả|ã|ạ|â|ấ|ầ|ẩ|ậ|ă|ằ|ắ|ặ|ẳ|ẵ)/g, 'a')
.replace(/(é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ)/g, 'e')
.replace(/(ó|ò|ỏ|õ|ọ|ơ|ờ|ớ|ở|ợ|ỡ|ô|ố|ồ|ổ|ộ)/g, 'o')
.replace(/(í|ì|ỉ|ĩ|ị)/g, 'i')
.replace(/(ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ự)/g, 'u')
.replace(/(ý|ỳ|ỷ|ỹ|ỵ)/g, 'y')
.replace(/(đ)/g, 'd')