Skip to content

Instantly share code, notes, and snippets.

View kamontat's full-sized avatar
💭
I may be slow to respond.

Kamontat Chantrachirathumrong kamontat

💭
I may be slow to respond.
View GitHub Profile
# Usually use
# |set|option|#|option-name|->|description|
set -e # errexit -> Exit immediately if non-zero code returned.
set -v # verbose -> Display shell input lines as they are read.
set -x # xtrace -> Display commands and their arguments as they are executed.
set -n # noexec -> Check syntax of the script but don't execute.
# Often use
set -b # notify -> Reported cause the status of terminated bg jobs immediately.
set -h # hashall -> Locate and remember (hash) commands as they are looked up for execution.
set -m # monitor -> Job control is enabled (https://www.gnu.org/software/bash/manual/html_node/Job-Control.html#Job-Control)

RUN

run command with specify sscript and version

Requirement

  1. docker
  2. run script file
  3. test script files (optional)

Usage

run by './run' 'argument', if wrong you might didn't give permission to it.

@kamontat
kamontat / recursive_func.asm
Created November 15, 2017 06:40
example recursive function in MIPS assembly
.data # data section
spacebar: .asciiz " "
.text # text section
.globl main # call main by SPIM
my_recursive_func:
# shift for save return address
@kamontat
kamontat / insertion_sort.asm
Created November 15, 2017 06:41
example MIPS assembly: insertion sort
.data # data section
data: .word 132470, 324545, -4, 73245, 93245, 80324542, 244, 2, 66, 236, 327, -7, 236, 21544
size: .word 14
spacebar: .asciiz " "
.text # text section
.globl main # call main by SPIM
@kamontat
kamontat / SearchRange.java
Created November 15, 2017 06:46
java code, searching (range) in input array
import java.util.*;
public class SearchRange {
public static void main(String[] agrs) {
Scanner input = new Scanner(System.in);
System.out.print("Enter n: ");
int n = Integer.parseInt(input.nextLine());
String[] textNums = input.nextLine().split(" ");
int[] numbers = new int[textNums.length];

Useful-git-command

$ git rev-parse HEAD # git latest commit 
3386d270952e7d8dc614839bfb00de3529d56c77

$ git rev-parse --verify HEAD # git latest commit 
3386d270952e7d8dc614839bfb00de3529d56c77

$ git show-ref # turn references (branches and tags) into SHA-1
function v5(h) {
var percent = Math.ceil(Math.random() * 100)
switch (h) {
case "g":
if (percent > 65)
return 5 // 35%
else if (percent > 40)
return 4 // 25%
else if (percent > 20)
return 3 // 20%
@kamontat
kamontat / sep.sh
Last active April 28, 2018 11:08
separate images raw files and jpg files
#!/usr/bin/env bash
# set -x #DEBUG - Display commands and their arguments as they are executed.
# set -v #VERBOSE - Display shell input lines as they are read.
# set -n #EVALUATE - Check syntax of the script but don't execute.
# -------------------------------------------------
# Create by: Kamontat Chantrachirathumrong
# -------------------------------------------------
# Version: 0.0.1 -- finish
#!/bin/bash
# <bitbar.title>command shortcut</bitbar.title>
# <bitbar.version>v1.1</bitbar.version>
# <bitbar.since>9 Mar 2018</bitbar.since>
# <bitbar.author>kamontat</bitbar.author>
# <bitbar.author.github>kamontat</bitbar.author.github>
# <bitbar.desc>Show setting shortcut keys</bitbar.desc>
# <bitbar.dependencies>bash</bitbar.dependencies>
@kamontat
kamontat / setup.bash
Created August 30, 2018 17:03
Restart Setup, To recreate Admin user in MacOS
# Shutdown your computer (Mac)
# Press `Command+S` and turn computer on.
# Press, until computer open black screen
## Type below to the screen
# Mount root dir
/sbin/mount -uw /
# remove setup entry
rm /var/db/.applesetupdone