Skip to content

Instantly share code, notes, and snippets.

View suewonjp's full-sized avatar

Suewon Bahng suewonjp

View GitHub Profile
@suewonjp
suewonjp / Properly using Primefaces p:poll saving network traffic.java
Last active January 17, 2017 10:17
Properly using Primefaces p:poll saving network traffic
package com.civilizer.web.controller;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import com.civilizer.web.view.*;
@ManagedBean
@ViewScoped
public final class PollController {
@suewonjp
suewonjp / TreeNode.java
Last active October 17, 2022 13:26
Generic Tree Data Structure in Java
// -----------------------------------
// TreeNode interface
// -----------------------------------
import java.util.*;
public interface TreeNode<E> {
public enum TraverseOrder {
PRE,
POST,
#!/usr/bin/env bash
## Preconditions;
## 1: Destination (Github) repository name == Source (local) repository name
## 2: [IMPORTANT!!!] Those two repositories (for GitHub & local) should be created prior to running this script
scriptName=${0##*/}
if [ $# -lt 1 ] ; then
echo "Usage : $scriptName [repo name] [github user name] [remote alias]"
#!/bin/bash
sort_array() {
if [ -n "$1" ]; then
local IFS=$'\n'
eval "local arr=( \${$1[*]} )"
#arr=( $( printf "%s\n" ${arr[@]} | sort ) )
arr=( $( sort <<<"${arr[*]}" ) ) ### <<< is here string notation
eval "$1=( \${arr[*]} )"
fi
@suewonjp
suewonjp / Edit and review github wiki on your local machine.md
Last active February 11, 2023 22:35
Edit and review github wiki on your local machine
First, clone your github wiki to your local machine
  1. Checkout your repository wiki via git.
     - You can find the URL at the lower-right of your wiki page (look for the label "Clone this wiki locally")
  2. Now that you have pulled down a local copy of your github repo wiki, create a new file in the repo called _Sidebar.md  - Note that other names might not work.
  3. Within the newly created _Sidebar.md file, you can add appropriate [[link]] markdown syntax.
  4. Add your new file to the local repository, and push via git push origin master.

With the same procedure, you can add a header(_Header.md) and footer(_Footer.md) file.

@suewonjp
suewonjp / My-bash-aliases.sh
Last active January 23, 2019 07:35
My Bash aliases
if [ "Darwin" == $(uname) ]; then
alias showFiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app'
alias hideFiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app'
alias hibernateMode='sudo pmset -a hibernatemode 25'
alias sleepMode='sudo pmset -a hibernatemode 3'
alias f='open -a Finder '
fi
## Save keystrokes for directory navigation
alias ~='cd ~'
@suewonjp
suewonjp / .tmux.conf
Last active December 17, 2022 19:35
My .tmux.conf ( usable across multi-platforms including OS X | Linux | Cygwin )
set-option -g default-terminal "xterm-256color"
set-window-option -g xterm-keys on
run-shell "tmux setenv -g TMUX_VERSION $(tmux -V | cut -c 6-)"
setw -g mode-keys vi
unbind C-b
# remap prefix to Control + Space
@suewonjp
suewonjp / BlockComment.vim
Created December 25, 2017 06:03
Simple Vim function to block comment multiple lines of code
" Block comment multiple lines of code.
" Intended for Visual mode only
function! BlockComment(tn, bn)
let l:ltop = line("'<")
let l:lbottom = line("'>")
let l:indc = indent(l:ltop)
let l:ind = ''
let l:i = 0
while l:i < l:indc
let l:ind .= ' '
@suewonjp
suewonjp / quicksort.py
Created December 25, 2017 09:15
Quicksort implementation in Python (one line)
f = lambda x: (f([y for y in x if x[0] > y]) + [y for y in x if x[0] == y] + f([y for y in x if x[0] < y]) if x else [])
@suewonjp
suewonjp / mergesort.py
Created December 25, 2017 09:17
Merge sort implementation in Python
def merge(lblock, rblock):
li, ri, llen, rlen = 0, 0, len(lblock), len(rblock)
merged = []
for _ in range(llen + rlen):
if li < llen and (ri >= rlen or lblock[li] < rblock[ri]):
merged.append(lblock[li])
li += 1
else:
merged.append(rblock[ri])
ri += 1