Skip to content

Instantly share code, notes, and snippets.

View dulimarta's full-sized avatar

Hans Dulimarta dulimarta

  • School of Computing and Information Systems, Grand Valley State University
  • Grand Rapids, Michigan
View GitHub Profile
@dulimarta
dulimarta / idr_starter.py
Created March 10, 2025 17:48
Iterative Domain Resolver Starter code
from dnslib import DNSRecord, DNSHeader, DNSBuffer, DNSQuestion, RR, QTYPE, RCODE
from socket import socket, SOCK_DGRAM, AF_INET
"""
There are 13 root servers defined at https://www.iana.org/domains/root/servers
"""
ROOT_SERVER = "199.7.83.42" # ICANN Root Server
DNS_PORT = 53
def get_dns_record(udp_socket, domain:str, parent_server: str, record_type):
@dulimarta
dulimarta / 00-types.ts
Created February 25, 2025 21:07
Cloud Firestore CRUD operations (Winter 2025)
export type State = {
// abbreviation: string
name: string;
capital: string;
population: number;
nationalParks: Array<string>;
};
export type City = {
name: string;
export type State = {
// abbreviation: string
name: string,
capital: string,
population: number,
nationalParks: Array<string>
}
export type City = {
name: string,
from socket import gethostbyname, getprotobyname, socket, SOCK_RAW, AF_INET, htons, inet_ntoa
from os import getpid
import sys
from struct import pack, unpack_from
from time import time, sleep
from select import select
ICMP_ECHO_REQUEST = 8
def checksum(sdata):
@dulimarta
dulimarta / Main.kt
Created September 10, 2024 20:41
CS357 Coroutine Example
package edu.gvsu.computing.cs357
import kotlinx.coroutines.*
import kotlin.system.measureTimeMillis
fun sample1() {
println ("Begin Sample 1")
runBlocking {
launch {
println("Begin A")
delay(5000)
@dulimarta
dulimarta / lab02_c.rs
Created January 25, 2024 02:00
CS452 Lab02 - Sample 3 (Rust)
use nix::unistd::{fork, ForkResult};
// use nix::sys::wait::wait;
// use nix::sys::wait::WaitStatus;
use std::process;
fn main() {
let pid = fork();
match pid {
Ok(ForkResult::Child) => {
println!("I'm a child with PID {}", process::id());
@dulimarta
dulimarta / lab04_dup.c
Last active February 2, 2023 03:48
CS452 Lab04 dup2()
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
int main() {
char name[50];
int fd = open("myoutput.txt",
O_WRONLY | O_CREAT | O_EXCL,
@dulimarta
dulimarta / lab03_b.c
Created February 1, 2023 19:59
CS452 Lab04 - Pipes - Sample 2
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#define READ 0
#define WRITE 1
#define MAX 1024
int main () {
@dulimarta
dulimarta / eintr.c
Last active October 10, 2022 20:13
CS452 Lab3 - Interrupted Calls
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <errno.h>
#include <stdbool.h>
int number = 0;
bool running = true;
void do_nothing(int s) {
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <errno.h>
#include <stdbool.h>
int number = 0;
bool running = true;
void do_nothing(int s) {