Skip to content

Instantly share code, notes, and snippets.

dj1020 / .aliases
Created July 22, 2021 14:35
Copy JSON string and parse to PHP Array
View .aliases
// Under Mac system, if you have pbcopy, pbpaste
// 如果你用 Mac, 有 pbcopy, pbpaste。就可以直接複製 json 後到 shell 下指令,會直接變成 PHP array 後直接在剪貼簿可以貼上。
alias jsontoarray='pbpaste | jsonToPhpArray | pbcopy'
dj1020 / DownloadSearchEngineJson.js
Last active September 11, 2022 05:13
Export Chrome Search Engine to a Json File, and Import into Brave
View DownloadSearchEngineJson.js
* Source:
* 2021/07/22 Tested successfully on Chrome Version 91.0.4472.164 (Official Build) (x86_64) on Mac
* Usage:
* 1. Open `chrome://settings/searchEngines` on Chrome
* 2. Open Developer Tools (Cmd+Opt+i)
* 3. Choose `Console` tab
* 4. Paste code below and save as a json file
(function exportSEs() {

How to download your Udemy course videos using youtube-dl

$ youtube-dl --list-extractors | grep udemy


  1. Get link to the course to download. e.g.
  2. Login into udemy website, save the cookie from chrome using Chrome (Cookie.txt)[1] export extension. Save it to file udemy-cookies.txt
  3. Get the link of the video that you want to download. usually in format. Use the command provided below where you have to replace the {course_link} and {path_to_cookies_file} with respective paths.
$ youtube-dl {course_link} --cookies {path_to_cookies_file}
dj1020 /
Created July 14, 2021 00:10 — forked from jyurek/
Create and switch sessions in tmux quickly
tm() {
if [ -z $1 ]; then
tmux switch-client -l
if [ -z "$TMUX" ]; then
tmux new-session -As $1
if ! tmux has-session -t $1 2>/dev/null; then
TMUX= tmux new-session -ds $1
dj1020 / info.mamp.start.mysql.plist
Last active June 13, 2018 09:08
Automatically start MAMP without password confirm - MySQL
View info.mamp.start.mysql.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
<plist version="1.0">
dj1020 / info.mamp.start.apache.plist
Last active June 13, 2018 09:00
Automatically start MAMP without password confirm - Apache
View info.mamp.start.apache.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
<plist version="1.0">
dj1020 / openGitRepo
Created January 10, 2018 06:46
Quick open gitlab/git repo page
View openGitRepo
getRepoUrl() {
local name='origin'
local gitUrl
local repoUrl
if [ ! -z "$1" ]; then
gitUrl=`git remote get-url $name`
dj1020 / AbstractFoo.php
Created February 9, 2017 07:08 — forked from pjdietz/cloudSettings
Testing Protected Method of Abstract Class with PHPUnit
View AbstractFoo.php
namespace Minitest;
abstract class AbstractFoo
protected function bar()
return $this->baz();
dj1020 / vhosts.conf
Last active September 18, 2020 04:47
Laravel Virtual Host for Apache Example
View vhosts.conf
<VirtualHost *:80>
DocumentRoot "/Users/myName/Projects/laravel/public"
<Directory "/Users/myName/Projects/laravel/public">
AllowOverride All
Options FollowSymLinks +Indexes
Order allow,deny
Allow from all
dj1020 / getProperty.php
Created July 4, 2016 03:02
分享一個「用 Closure 取得 Class Private Property」的特殊技巧
View getProperty.php
// 用 Closure 取得 Class Private Property
// ref:
// 比用 reflection 快很多
class Example {
private $myName;
public function __construct($name) {