Skip to content

Instantly share code, notes, and snippets.

👀
Looking for inspirations

TC Liu liuderchi

👀
Looking for inspirations
Block or report user

Report or block liuderchi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@liuderchi
liuderchi / DP_stair_factorial.js
Last active Mar 23, 2017
Dynamic Programming Basic example
View DP_stair_factorial.js
// http://www.csie.ntnu.edu.tw/~u91029/DynamicProgramming.html#2
function stairs(n) {
var res = [];
res[0] = 1; // first stair
res[1] = 1; // second stair
if (n > 0 && n < 2) return res[n-1];
for (var i = 2; i < n; i++){
@liuderchi
liuderchi / check_element_visible.js
Created Dec 1, 2016
Check if element is visible in DOM
View check_element_visible.js
// http://stackoverflow.com/questions/19669786/check-if-element-is-visible-in-dom
//Where el is the DOM element you'd like to test for visibility
function isHidden(el) {
return (el.offsetParent === null);
}
@liuderchi
liuderchi / rename_author_of_commits.md
Created Sep 23, 2016
git rename author info of commit
View rename_author_of_commits.md

setup author info of past commits

  • $ git rebase -i {{base_commit|--root}}
  • edit all 'pick' to 'edit' then save
  • do following for each commit:
    • $ git commit --amend --author="Author-Name <email@address.com>"
    • $ git rebase --continue

setup author info of future commits

@liuderchi
liuderchi / .bashrc
Last active Sep 8, 2016
Customize Command Prompt Text with Git Icon and Git Branch (require font-awesome)
View .bashrc
# README
# 1. append following content to your ~/.bashrc file
# 2. apply your setup by enter shell command $ source ~./bashrc
### Git ###
git_icon() {
# NOTE: printing icon requires install font on http://fontawesome.io/
# Choose one icon you like
#printf ' \uf126 ' # http://fontawesome.io/icon/code-fork/
printf ' \uf09b ' # http://fontawesome.io/icon/github/
View demo_draw_diagram_using_Markdown.md

Draw Diagram using Markdown

  • markdown preview enhanced is a Atom package

    • preview markdown in Atom editor on the fly
    • allow you to draw flow chart using power of mermaid
    • you can export the document in html or pdf
  • mermaid let you draw diagram like writing markdown

    • supporting lots of diagram
View typhoon_dayoff_crawler.py
# coding=utf8
import urllib
import re
from bs4 import BeautifulSoup as BS
url = 'http://www.dgpa.gov.tw/'
html_content = urllib.urlopen(url).read()
soup_obj = BS(html_content, 'html.parser')
@liuderchi
liuderchi / line_sticker_printer.py
Last active Jan 28, 2016
crawl img in line store and download them. using beautifulsoup4
View line_sticker_printer.py
#!/usr/bin/env python3
# Web Crawler for line stickers
# USAGE:
# $ python line_sticker_printer.py <url>
# example url:
# https://store.line.me/stickershop/home/user/zh-Hant
# https://store.line.me/stickershop/home/general/zh-Hant
#
# credit:
# jminh@github and hour of code
@liuderchi
liuderchi / test_thread.py
Created Jan 27, 2016
test thread by Chou
View test_thread.py
#!/usr/bin/env python
from threading import Thread
import time
class Man(object):
def __init__(self):
self.switch = True
def stop(self):
self.switch = False
View wk4-q1.py
mc_menu = [ ["Big Mac" , "beef, cucumber, cheese" , 109 ],
["Filet-O-Fish" , "fish, cheese, mayonnaise" , 99 ],
["McChicken" , "chicken, lettuce, mayonnaise" , 89 ] ]
def print_burger( menu ):
i = 0
while i < len( menu ) :
print ( menu[ i ][ 0 ] ) # print burger
print ( menu[ i ][ 2 ] ) # print price
View wk3-q2.py
menu = [ 25, 105, 38, 55, 110 ]
drink = [ 35, 88, 140 ]
def change_price( price ):
result = []
for e in price:
if e > 100:
e = e - 20
result.append(e)
return result
You can’t perform that action at this time.