Skip to content

Instantly share code, notes, and snippets.

View chichunchen's full-sized avatar

Chi-Chun, Chen chichunchen

  • HPE/Cray
  • Minnesota
View GitHub Profile
@chichunchen
chichunchen / specific delete
Created January 26, 2015 19:50
Recursively delete all files of a specific extension in the current directory
You don't even need to use rm in this case if you are afraid. Use find:
find . -name "*.bak" -type f -delete
But use it with precaution. Run first:
find . -name "*.bak" -type f
http://askubuntu.com/questions/377438/how-can-i-recursively-delete-all-files-of-a-specific-extension-in-the-current-di

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

sudo apt-get install virtualbox-guest-utils virtualbox-guest-x11 virtualbox-guest-dkms
@chichunchen
chichunchen / function.c
Created September 25, 2015 16:14
Pass function in c
#include <stdio.h>
void func ( void (*f) (int) );
void print ( int x ) {
printf("%d", x);
}
int main(int argc, const char *argv[]) {
func(print);
@chichunchen
chichunchen / gdb on mac
Created October 4, 2015 19:05
install gdb on mac
http://www.patosai.com/blog/post/installing-gdb-on-mac-os-x-yosemite
@chichunchen
chichunchen / ubuntu nodejs
Created October 16, 2015 08:40
ubuntu nodejs
sudo tar -C /usr/local --strip-components 1 -xzf ~/Desktop/node-v4.2.1-linux-x64.tar.gz
@chichunchen
chichunchen / gist:480140c60ed99586dd41
Created January 17, 2016 12:03
elementary os easy manual
1.
2. Chinese input
3. terminal font size tweak
@chichunchen
chichunchen / .tmux.conf
Created June 10, 2017 13:59 — forked from gblmarquez/.tmux.conf
.tmux.conf with fish as default shell
# Default termtype. If the rcfile sets $TERM, that overrides this value.
set -g default-terminal screen-256color
# support logging out and back in
set -g update-environment "SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION"
# pbcopy support
set-option -g default-command "reattach-to-user-namespace -l bash"
# vi mode
# Mac have python installed, just make sure
brew install python
# install pip
sudo easy_install pip
# if no use, then
curl https://bootstrap.pypa.io/ez_setup.py -o - | sudo python
sudo easy_install pip
# install powerline
@chichunchen
chichunchen / dfa.ml
Created October 9, 2017 19:34
dfa in ocaml
type state = int;;
type 'a dfa = {
current_state : state;
transition_function : (state * 'a * state) list;
final_states : state list;
};;
type decision = Accept | Reject;;
let a_b_even_dfa : char dfa = (* input symbols are characters *)
{ current_state = 0;