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 / 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 / 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 / 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

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.

# 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)
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=
@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 ->
@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)
#!/bin/bash
# make sure that you give permission to this file
# run chmod 755 atom-plugin.sh
# or chmod +x atom-plugin.sh
# -----------------------------------------
# command setting
if ! command -v apm >/dev/null 2>&1 && ! command -v apm-beta >/dev/null 2>&1; then
echo "you don't have commandline interface, install it!"
@kamontat
kamontat / base64.bash
Last active May 12, 2017 11:33
encode and decode str with base64
#!/bin/bash
INPUT=false
ACTION=""
CODE=""
while getopts 'iD:E:h' flag; do
case "${flag}" in
i) INPUT=true ;;
D) ACTION="D" && CODE="$OPTARG" ;;