Skip to content

Instantly share code, notes, and snippets.

consider multiple solutions, commit on one, and iterate

Yuchen yzhong52

consider multiple solutions, commit on one, and iterate
View GitHub Profile
View colour_themes.conf
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocksConfig version="1">
<![CDATA[modnokai night shift v2]]>
yzhong52 / gist:f81e929e5810271292bd08856e2f4512
Created Apr 23, 2017
Create Spark DataFrame From List[Any]
View gist:f81e929e5810271292bd08856e2f4512
// Spark 2.1
val spark = SparkSession.builder().master("local").getOrCreate()
// Given a list of mixture of strings in integers
val values = List("20030100013280", 1.0)
// Create `Row` from `Seq`
val row = Row.fromSeq(values)
// Create `RDD` from `Row`
yzhong52 /
Created May 18, 2014
Send an email with a gmail account using python 3
# smtplib module send mail
import smtplib
TO = ''
TEXT = 'Here is a message from python.'
# Gmail Sign In
gmail_sender = ''
yzhong52 /
Created Oct 30, 2020
To Kill a Process Using a Port (Mac)

Put this helper funciton in your ~/.zshrc or ~/.bash_profile:

release_port() {
    pid=$(lsof -ti:$1)
    if [ -z $pid ]; then
        echo "Nothing is running on port $1"
        kill $pid
        echo "Killed process on port $1 with pid $pid"
yzhong52 /
Last active Sep 11, 2020


Basic Command

ls - show the current diretory pwd - show the current folder cd - go to folder nano - edit file cat - show the content of a file mv - move a folder to another location

yzhong52 / Dropbox Style Filename
Last active Sep 1, 2020
Rename files based on their created date
View Dropbox Style Filename
Dropbox Style Filename
yzhong52 / gist:4f86787f1a0cdd54ba038e177107bdec
Last active Aug 12, 2020
Check the service using port (mac)
View gist:4f86787f1a0cdd54ba038e177107bdec

Check The Process Using Port

In ~/.zshrc, put the following:

pidportfunction() {
    lsof -n -i4TCP:$1 | grep LISTEN
alias pidport=pidportfunction
View index.ts
// This snippet is a lazy, temporary, inappropriate, not secure fix for error:
// "No 'Access-Control-Allow-Origin' header is present on the requested resource".
// It works as a proxy and add 'Access-Control-Allow-Origin: *' to the response header.
// 1) Init proejct and add dependencies:
// ```
// npm init
yzhong52 / ViewController.swift
Last active Feb 17, 2020
Building a Client App From Scratch (ViewController with Client)
View ViewController.swift
import UIKit
import RxSwift
class ViewController: UIViewController {
private let disposeBag = DisposeBag()
private let client = NewsClient()
override func viewDidLoad() {
client.headlines().subscribe(onSuccess: { (response) in
yzhong52 / NewsTableViewCell.swift
Last active Feb 16, 2020
Building a Client App From Scratch (NewsTableViewCell)
View NewsTableViewCell.swift
import UIKit
class NewsTableViewCell: UITableViewCell {
let titleLabel: UILabel = {
let lable = UILabel()
lable.translatesAutoresizingMaskIntoConstraints = false
lable.numberOfLines = 3
lable.font = UIFont.systemFont(ofSize: 14)
return lable