Skip to content

Instantly share code, notes, and snippets.

View suewonjp's full-sized avatar

Suewon Bahng suewonjp

View GitHub Profile
#!/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
#!/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]"
@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,
@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 / Converting .bat to .exe using AutoIt.md
Created January 10, 2017 03:51
Converting .bat to .exe using AutoIt

There are many ways to convert Windows batch script files to .exe files;

Unfortunately, most of hit methods when searching with https://www.google.co.kr/?gws_rd=ssl#newwindow=1&q=bat+to+exe
may not work or may not satisfy your quality demand;

Many of these naive implementations may let most of antivirus apps consider your result .exe file as a malware;

I tested several tools but until now, AutoIt is the best tool to convert .bat to .exe

Workflow:

@suewonjp
suewonjp / check-version.sh
Last active January 7, 2017 09:28
compare two version notation strings in Bash
#!/bin/bash
versionAccepted() {
### $1 is the minimum required version, $2 is the version in question;
### If $1 < $2, return 0 (the input version is accepted)
### otherwise, return 1 (not accepted)
versions=( "$1" "$2" )
#printf "${versions[*]}\n"
for (( i=0; i<${#versions[@]}; ++i )); do
@suewonjp
suewonjp / colorful-echo.sh
Last active January 6, 2017 11:29
Bash - Simple echo function to print colorful text
### Font colors
red=1 green=2 yellow=3 blue=4 magenta=5 cyan=6
### Font attributes
bold=1 underline=4 reverse=7
preecholor() {
printf '\e[%s;3%dm' "$1" "$2"
}
@suewonjp
suewonjp / Building Primefaces from source.md
Last active January 18, 2017 10:31
Building Primefaces from source

https://github.com/primefaces/primefaces/wiki/Building-From-Source

  1. git-clone the packages:

     git clone https://github.com/primefaces/maven-jsf-plugin.git
     git clone https://github.com/primefaces/primefaces.git
    
  2. Find out maven-jsf-plugin version before trying to build Primefaces

  • Especially when you want to build older snapshots of Primefaces, you need to build maven-jsf-plugin that matches them
@suewonjp
suewonjp / toggle-qf-win.vim
Created June 7, 2016 08:51
[vim tip] Toggle Quickfix Window
function! ToggleQuickfix()
let l:nr = winnr("$")
if l:nr == 1
copen
else
cclose
endif
endfunction
@suewonjp
suewonjp / rmrf.sh
Last active June 7, 2016 08:32
[Bash tip] Safer 'rm -rf' command
#!/bin/sh
scriptName=${0##*/}
if [ $# = 0 ] ; then
echo "Wrapper script for the dangerous 'rm -rf'"
echo "Usage : $scriptName [folder to delete]"
exit 0
fi