Skip to content

Instantly share code, notes, and snippets.

View kcchien's full-sized avatar

Kuang-Cheng Chien kcchien

  • King Steel Machinery Co., Ltd.
  • Taichung, Taiwan
View GitHub Profile
@kcchien
kcchien / 0_reuse_code.js
Created February 21, 2017 13:05
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@kcchien
kcchien / iterm2-solarized.md
Created June 2, 2017 12:01 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k

@kcchien
kcchien / config.fish
Last active June 4, 2017 06:55
Install fish shell
# Copy this file to ~/.config/fish/
function fish_prompt
~/powerline-shell/powerline-shell.py $status --shell bare ^/dev/null
end
@kcchien
kcchien / npm-exec.bat
Created June 5, 2017 08:43 — forked from joeyespo/npm-exec.bat
Execute a node_modules/.bin script on Windows.
@ECHO OFF
SETLOCAL
REM Speed up by checking for bin directory directly
IF NOT EXIST node_modules\.bin GOTO FINDBIN
SET BIN=.\node_modules\.bin
GOTO RUN
:FINDBIN
REM Find the current bin directory from npm, storing the result in 'BIN'
@kcchien
kcchien / ExportOffice365user.ps1
Created December 8, 2017 08:25
Powershell commands for export Azure AD and import into local AD
#import office 365 session
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
#connect Azure AD
Connect-MsolService -Credential $UserCredential
#Random password generator
Function random-password ($length = 8)
@kcchien
kcchien / README.md
Last active November 7, 2023 12:49
Visual Studio Code command for Fish shell

Save code.fish in ~/.config/fish/functions

@kcchien
kcchien / difference.js
Created June 28, 2018 07:28 — forked from Yimiprod/difference.js
Deep diff between two object, using lodash
/**
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {
return _.transform(object, function(result, value, key) {
if (!_.isEqual(value, base[key])) {
@kcchien
kcchien / cpm.js
Created August 4, 2018 06:17 — forked from perico/cpm.js
Critical Path Method Implementation Javascript
/**
* Implementation of the Critical Path Method (CPM) with variation
* @see http://en.wikipedia.org/wiki/Critical_path_method
*
* Shows all the critical Paths, returns a subset of the graph
* containing the critical activities
*/
/**
* Activity Class
@kcchien
kcchien / parseMustache.coffee
Created August 10, 2018 07:52 — forked from lucasmotta/parseMustache.coffee
A simple function to parse strings with {{mustache}} tags and replace its dot notation string to a given object path.
parseMustache = (str, obj) ->
str.replace /{{\s*([\w\.]+)\s*}}/g, (tag, match) ->
nodes = match.split(".")
current = obj
for node in nodes
try
current = current[node]
catch
return ""
current
// Config file
import * as firebase from "firebase";
const config = {...};
export default !firebase.apps.length ? firebase.initializeApp(config) : firebase.app();
// Other file
import firebase from '../firebase';
...