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
@kamontat
kamontat / Annotation.kt
Last active July 10, 2017 10:20
medium source code
// file name unnecessary to match with annotation name
// Target must matching (if not you will cannot get from annotations)
@Target(AnnotationTarget.VALUE_PARAMETER)
annotation class JsonKey(val key: String)
@kamontat
kamontat / GHObjectBuilder.kt
Last active July 10, 2017 10:37
medium source code
object GHObjectBuilder {
// build function
fun <T : Any> build(tClass: KClass<T>, json: JsonObject): T? {
// check primary constructor
if (tClass.primaryConstructor == null) return null
// create parameter mapping
val map: HashMap<KParameter, Any?> = HashMap<KParameter, Any?>()
// for each paramete in constructor
tClass.primaryConstructor!!.parameters.forEach {
param ->
filter.lfs.required=true
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
user.name=kamontat
user.email=kamontat_c@hotmail.com
core.excludesfile=/Users/kamontat/.gitignore_global
core.autocrlf=input
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE"
difftool.sourcetree.path=
# 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 / array_sum.asm
Created November 15, 2017 06:28
summation array on MIPS assembly
.data # data section
array_a: .word 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
array_b: .word 0x7fffffff, 0x7ffffffe, 0x7ffffffd, 0x7ffffffc, 0x7ffffffb, 0x7ffffffa, 0x7ffffff9, 0x7ffffff8, 0x7ffffff7, 0x7ffffff6
output_a: .asciiz "Sum a = "
output_b: .asciiz "Sum b = "
new_line: .asciiz "\n"
.text # text section
@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];
@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