Skip to content

Instantly share code, notes, and snippets.

View liuderchi's full-sized avatar
🔍
Looking for inspirations

TC Liu liuderchi

🔍
Looking for inspirations
View GitHub Profile

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
@liuderchi
liuderchi / .bashrc
Last active April 18, 2024 21:13
Customize Command Prompt Text with Git Icon and Git Branch (require font-awesome)
# 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/
@liuderchi
liuderchi / rename_author_of_commits.md
Created September 23, 2016 03:03
git rename author info of commit

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 / check_element_visible.js
Created December 1, 2016 01:03
Check if element is visible in DOM
// 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 / DP_stair_factorial.js
Last active March 23, 2017 16:40
Dynamic Programming Basic example
// 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 / happy_git_on_osx.md
Created July 19, 2017 08:58 — forked from trey/happy_git_on_osx.md
Creating a Happy Git Environment on OS X

Creating a Happy Git Environment on OS X

Step 1: Install Git

brew install git bash-completion

Configure things:

git config --global user.name "Your Name"

git config --global user.email "you@example.com"

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
// sample reference https://www.npmjs.com/package/graphql-client
// GitHub API v4 reference https://developer.github.com/v4/explorer/
const graphqlClient = require('graphql-client')
// GET your token https://github.com/settings/tokens
const TOKEN = 'YOUR-TOKEN-HERE'
// choose fields of user info https://developer.github.com/v4/reference/object/user/#fields
const USERFIELDS = [
'login',
@liuderchi
liuderchi / index.js
Last active August 29, 2017 04:09
requirebin sketch
var R = require('ramda')
var DAY = 'DAY'
var fn = R.pipe(
function(x) {
console.log(R.equals(DAY)(x))
return x
},
R.equals(DAY),
function(x) {
@liuderchi
liuderchi / init.js
Last active September 8, 2017 07:10
Insert React Functional Component Snippet for Atom
// steps:
// 1. copy this file to ~/.atom/init.js
// 2. in Atom, dispatch command "Window:Reload", Atom would run this file rather than init.coffee
// 3. create new empty file Foo.js
// 4. focus to new tab, send command "react:insert-functional-component-template"
atom.commands.add('atom-text-editor', 'react:insert-functional-component-template', () => {
editor = atom.workspace.getActiveTextEditor()
if (!editor) { return null }
const fileNameCap = getCamelCaseNameFromPath(editor.getPath())