Skip to content

Instantly share code, notes, and snippets.

@dj1020
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
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: https://superuser.com/a/1626575
* 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() {
View udemy-courses-download-using-cookies.md

How to download your Udemy course videos using youtube-dl

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

Steps

  1. Get link to the course to download. e.g. https://www.udemy.com/course-name/
  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
dj1020 / tm.sh
Created July 14, 2021 00:10 — forked from jyurek/tm.sh
Create and switch sessions in tmux quickly
View tm.sh
#!/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
@dj1020
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"
"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 / 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"
"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 / 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
name="$1"
fi
gitUrl=`git remote get-url $name`
@dj1020
dj1020 / AbstractFoo.php
Created February 9, 2017 07:08 — forked from pjdietz/cloudSettings
Testing Protected Method of Abstract Class with PHPUnit
View AbstractFoo.php
<?php
namespace Minitest;
abstract class AbstractFoo
{
protected function bar()
{
return $this->baz();
}
@dj1020
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"
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」的特殊技巧
View getProperty.php
<?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) {