Skip to content

Instantly share code, notes, and snippets.

View dukenmarga's full-sized avatar

Duken Marga dukenmarga

View GitHub Profile
@dukenmarga
dukenmarga / reason_to_use_fortran.txt
Created January 24, 2023 14:34
Valid Reason to Start Structural Analysis Software Project Using Fortran
Valid Reason to Start Structural Analysis Software Project Using Fortran
1. Trivial
- It has nice printing formatting by default
- Less keywords to memorize
- Long life since 1966 and will be keep alive by using modern standard
- Compiled and fast
2. Numerical Reason
- Supports matrix operation in simple terms compared to C/C++
@dukenmarga
dukenmarga / command.md
Last active November 18, 2025 03:28
List of Useful Linux Commands

Generate Random String

Source

# Method 1: md5 Hash
echo $RANDOM | md5sum | head -c 20; echo;
996e405cb0cdd2e10299

# Method 2: UUID
cat /proc/sys/kernel/random/uuid | sed 's/[-]//g' | head -c 20; echo;
c23174ce6fa149498fc7
@dukenmarga
dukenmarga / GitCheatSheet.md
Last active January 19, 2024 14:49
Git Cheat Sheet

Initialise a repository

git init

Basic

# Add
git add somefile.py
@dukenmarga
dukenmarga / svelte-common-errors.md
Last active October 24, 2022 04:40
Svelte Common Errors

Runtime Error

Runtime error is when you see the error in the browser development (web) console.

TypeError: Cannot read properties of undefined

Cannot read properties of undefined (reading 'length')

TypeError: Cannot read properties of undefined (reading 'length')
at Module.each (/node_modules/svelte/internal/index.mjs:1735:31)
@dukenmarga
dukenmarga / bmgtest.py
Created June 20, 2022 08:00
BMG Test (Logic Test)
# Code untuk soal BMG
# Tes Logika
# By Duken Marga
LIMIT = 50
for i in range(LIMIT+1):
# Ignore 0
if i == 0:
continue
@dukenmarga
dukenmarga / docker_command.txt
Last active March 13, 2024 03:15
Docker Cheat Sheet
Create network
$ docker network create redis
Run a docker and connect to specific network exposed in Port 16379
$ docker run --name redis-docker --network redis --detach --publish 16379:6379 redis:latest redis-server
Run interactive
$ docker run -it --network redis --rm redis:latest redis-cli -h redis-docker
Build an image
@dukenmarga
dukenmarga / pi.py
Created April 13, 2021 06:39
In search of pi
# in search of pi=3.14...
# by using random of total dots generated outside or inside a circle
import numpy as np
import math
# number of iteration
n = 10000000
inside = 0
@dukenmarga
dukenmarga / char2int.c
Last active April 2, 2020 11:39 — forked from duken-blog/char2int.c
Convert Character to Integer (C Language)
#include <stdio.h>
int main(){
char c[5] = "23452";
char d[5] = "23452";
int result=0, factor=3;
int numeric;
// take and convert 1 character from an array
numeric = c[2] - '0'; // --> 4
$ git commit ... (1)
$ git reset --soft HEAD~1 (2)
$ edit (3)
$ git add .... (4)
$ git commit -c ORIG_HEAD (5)
Undoing a commit is a little scary if you don't know how it works. But it's actually amazingly easy if you do understand.
Say you have this, where C is your HEAD and (F) is the state of your files.
@dukenmarga
dukenmarga / cherrypy_static_image.py
Last active April 24, 2020 23:23
Serve dynamic image from Matplotlib using base64 encode string, from web framework CherryPy
# modified from https://gist.github.com/tebeka/5426211
# updated to work with Python 3
import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot
import numpy
import cherrypy
from io import BytesIO
import base64