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 / sample1a.rs
Last active January 27, 2020 02:21
CS452 Lab04 - Sample 1 (Rust)
use nix::unistd::sleep;
use std::process;
use std::thread;
fn main() {
println!(
"From PID {} thread id {:?}",
process::id(),
thread::current().id()
);
@dulimarta
dulimarta / sample1.rs
Last active September 23, 2020 20:12
CS452 Lab03 - Sample1 (Rust)
extern crate signal_hook;
use std::error::Error;
use std::time::Duration;
use nix::unistd::{pause, sleep};
use signal_hook::{register, SIGINT};
static mut I_CAN_RUN: bool = true;
fn main() -> Result<(), Box<dyn Error>> {
@dulimarta
dulimarta / sample2.rs
Last active September 24, 2020 03:17
CS452 Lab03 - sample 3 (Rust)
use nix::unistd::{close, dup2, fork, pipe, ForkResult};
use std::io::{self, Read, Write};
use std::process::{exit, id};
use std::str;
use std::error::Error;
const MAX: usize = 1024;
fn main() -> Result<(),Box<dyn Error>> {
@dulimarta
dulimarta / sqrt-error.c
Created January 16, 2020 02:17
CS452 Sample - Error checking
// Be sure to link this program with the math library (-lm)
#include <stdio.h>
#include <math.h>
#include <errno.h>
int main() {
double x, z;
printf ("Enter a number: ");
scanf ("%lf", &x);
@dulimarta
dulimarta / lab02_a.rs
Last active January 25, 2024 01:28
CS452 Lab02 - Sample 1 (Rust)
use nix::unistd::fork;
fn main() {
println!("Before fork()");
fork();
println!("After fork()");
}
@dulimarta
dulimarta / lab02_b.rs
Last active January 25, 2024 01:47
CS452 Lab02 - Sample 2 (Rust)
use std::env;
use nix::unistd::fork;
use std::process;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
eprintln!("Not enough argument");
return;
}
@dulimarta
dulimarta / FractionFactory.kt
Created November 25, 2019 17:01
CS343 FractionFactory.kt
package gvfraction
import java.lang.IllegalStateException
import java.lang.reflect.InvocationTargetException
import kotlin.reflect.KClass
object FractionFactory {
var creator: KClass<FractionOperator>?
// var instance: FractionFactory
@dulimarta
dulimarta / CMakeLists.txt
Last active November 7, 2019 18:52
CIS343 C++ Fraction
cmake_minimum_required(VERSION 3.14)
project(Fraction)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "-g -Wall")
include_directories(.)
@dulimarta
dulimarta / bbassign.py
Last active December 9, 2019 20:33
Unzip Bb assignment files by userid
#!/usr/local/bin/python3
"""
This program parses a zipped assignment downloaded from Bb,
creates a new subdirectory for the assignment, and unzip
all the files into subdirectories named after the student userids
"""
import zipfile
import sys
@dulimarta
dulimarta / layout.css
Last active May 14, 2019 00:37
CS371 Flexbox and Grid
#container {
background: lightblue;
}
section {
border: solid 2px black;
border-radius: 8px;
margin: 4px;
padding: 8px;
}