Skip to content

Instantly share code, notes, and snippets.

Avatar
⌨️
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">
<editor>
<colour_sets>
<ACTIVE_COLOUR_SET>
<str>
<![CDATA[modnokai night shift v2]]>
</str>
</ACTIVE_COLOUR_SET>
<ACTIVE_LANG>
@yzhong52
yzhong52 / readme.md
Created Oct 30, 2020
To Kill a Process Using a Port (Mac)
View readme.md

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"
    else
        kill $pid
        echo "Killed process on port $1 with pid $pid"
@yzhong52
yzhong52 / readme.md
Last active Sep 11, 2020
在Ubuntu操作系统下运行shiny服务器
View readme.md

在Ubuntu操作系统下运行shiny服务器

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
yzhong52 / Dropbox Style Filename
Last active Sep 1, 2020
Rename files based on their created date
View Dropbox Style Filename
Dropbox Style Filename
@yzhong52
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
yzhong52 / send_an_email.py
Created May 18, 2014
Send an email with a gmail account using python 3
View send_an_email.py
# smtplib module send mail
import smtplib
TO = 'recipient@mailservice.com'
SUBJECT = 'TEST MAIL'
TEXT = 'Here is a message from python.'
# Gmail Sign In
gmail_sender = 'sender@gmail.com'
@yzhong52
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() {
super.viewDidLoad()
client.headlines().subscribe(onSuccess: { (response) in
@yzhong52
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
@yzhong52
yzhong52 / ViewController.swift
Created Feb 16, 2020
Building a Client App From Scratch - ViewController NewsManager
View ViewController.swift
class ViewController: UIViewController {
private let manager = NewsManager()
private let disposeBag = DisposeBag()
private var articles: [Article] = []
private let titleLabel: UILabel = {
let label = UILabel()
label.text = NSLocalizedString("News", comment: "")
You can’t perform that action at this time.