Skip to content

Instantly share code, notes, and snippets.

@dj1020
dj1020 / vhosts.conf
Last active September 18, 2020 04:47
Laravel Virtual Host for Apache Example
<VirtualHost *:80>
DocumentRoot "/Users/myName/Projects/laravel/public"
ServerName myLaravel.dev
<Directory "/Users/myName/Projects/laravel/public">
AllowOverride All
Options FollowSymLinks +Indexes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
@dj1020
dj1020 / getProperty.php
Created July 4, 2016 03:02
分享一個「用 Closure 取得 Class Private Property」的特殊技巧
<?php
// 用 Closure 取得 Class Private Property
//
// ref: https://ocramius.github.io/blog/accessing-private-php-class-members-without-reflection/
// 比用 reflection 快很多
class Example {
private $myName;
public function __construct($name) {
@dj1020
dj1020 / .gitconfig
Created February 23, 2016 09:39
Git Alias Settings
[alias]
adda = add -A
al = add .
bl = branch -a
br = branch
ci = commit
cim = commit -m
cima = commit -a -m
ck = checkout
fa = fetch --all
#!/usr/bin/env bash
# Upgrade Base Packages
sudo apt-get update
sudo apt-get upgrade -y
# Install Web Packages
sudo apt-get install -y build-essential dkms re2c apache2 php5 php5-dev php-pear php5-xdebug php5-apcu php5-json php5-sqlite \
php5-mysql php5-pgsql php5-gd curl php5-curl memcached php5-memcached libmcrypt4 php5-mcrypt postgresql redis-server beanstalkd \
openssh-server git vim python2.7-dev
@dj1020
dj1020 / migrate.sh
Last active February 5, 2019 13:05 — forked from tobi-pb/migrate.sh
Upgrade MAMP to Mysql 5.7 tested by Ken Lin 2015/11/09
#!/bin/sh
wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.9-osx10.10-x86_64.tar.gz
tar xfvz mysql-5.7*
echo "stopping mamp"
sudo /Applications/MAMP/bin/stop.sh
sudo killall httpd mysqld
echo "creating backup"
#!/bin/bash
for pkg in `dpkg --get-selections | egrep -v deinstall | awk '{print $1}' | egrep -v '(dpkg|apt|mysql|mythtv)'` ; do apt-get -y install --reinstall $pkg ; done
@dj1020
dj1020 / .vimrc.after
Last active August 29, 2015 14:27
Janus, Jeffrey way .vimrc.after file
set nocompatible " 關閉 vi 相容模式,不太確定做什麼用。和 u,及 insert mode 的方向鍵移動有關。
set t_Co=256
colorscheme xoria256
set guifont=Menlo:h16
set guioptions-=T " Removes top toolbar
set guioptions-=r " Removes right hand scroll bar
set go-=L " Removes left hand scroll bar
set linespace=15
" set lines=25 加了之後 iTerm 會被設成 25 行 >"<
@dj1020
dj1020 / gulpfile.js
Created July 23, 2015 02:38
Gulp with PHPUnit simplest config file
var gulp = require('gulp'),
exec = require('child_process').exec,
sys = require('sys'),
util = require('util');
gulp.task('phpunit', function() {
exec('clear', function(error, stdout, stderr){
util.puts(stdout);
exec('phpunit', function(error, stdout) {
sys.puts(stdout);
var CompactCommand= function(){
var self = this;
this.start = new Date(); // measure running time
this.exec = function(){
printDbStats(); // before dbstats
execCommand();
printDbStats(); // after dbstats
}
this.calcExecTime = function(){
var end = new Date();
@dj1020
dj1020 / gulpfile.js
Last active August 29, 2015 14:20 — forked from mikeerickson/gulpfile.js
Gulp with Phpspec edited from Mike Erickson
/* Gulpfile
* Mike Erickson
*/
var gulp = require('gulp'),
notify = require('gulp-notify'),
phpspec = require('gulp-phpspec');
gulp.task('phpspec', function() {
var options = {