Skip to content

Instantly share code, notes, and snippets.

@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"
#!/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 / .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
@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 / 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 / AbstractFoo.php
Created February 9, 2017 07:08 — forked from pjdietz/cloudSettings
Testing Protected Method of Abstract Class with PHPUnit
<?php
namespace Minitest;
abstract class AbstractFoo
{
protected function bar()
{
return $this->baz();
}
@dj1020
dj1020 / openGitRepo
Created January 10, 2018 06:46
Quick open gitlab/git repo page
getRepoUrl() {
local name='origin'
local gitUrl
local repoUrl
if [ ! -z "$1" ]; then
name="$1"
fi
gitUrl=`git remote get-url $name`
@dj1020
dj1020 / info.mamp.start.apache.plist
Last active June 13, 2018 09:00
Automatically start MAMP without password confirm - Apache
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>info.mamp.start.apache</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/MAMP/Library/bin/apachectl</string>
@dj1020
dj1020 / info.mamp.start.mysql.plist
Last active June 13, 2018 09:08
Automatically start MAMP without password confirm - MySQL
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>info.mamp.start.mysql</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/MAMP/Library/bin/mysqld_safe</string>
@dj1020
dj1020 / tm.sh
Created July 14, 2021 00:10 — forked from jyurek/tm.sh
Create and switch sessions in tmux quickly
#!/bin/sh
tm() {
if [ -z $1 ]; then
tmux switch-client -l
else
if [ -z "$TMUX" ]; then
tmux new-session -As $1
else
if ! tmux has-session -t $1 2>/dev/null; then
TMUX= tmux new-session -ds $1