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 / 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) {
@dulimarta
dulimarta / 00-blank.vue
Last active June 10, 2021 19:11
Vuetify Snippets
<template>
<span class="text-h3">Just title</span>
</template>
@dulimarta
dulimarta / 10-add-doc-userkey.ts
Last active March 22, 2021 17:54
Cloud Firestore Snippets
import {
FirebaseFirestore,
DocumentReference,
CollectionReference,
GeoPoint,
} from "@firebase/firestore-types";
const stateData = [
{ name: "Alaska", abbrev: "AK", capital: "Juneau", population: 735_720 },
{
@dulimarta
dulimarta / hugemem.c
Last active November 17, 2021 21:29
CS452 Lab10 - hugemem.c
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
const size_t GIGA = 1024*1024*1024;
int main() {
for (int k = 1; k <= 128; k++) {
char *p = malloc(k * GIGA);
if (p == NULL || errno != 0) {
@dulimarta
dulimarta / lab06_b.c
Last active October 22, 2020 00:43
CS452 Lab06 - Sample 3
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <sys/mman.h>
typedef struct {
int arr[2];
} shared_info;
@dulimarta
dulimarta / lab06_a.c
Last active October 20, 2020 23:23
CSS452 Lab06 - Sample 1
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
void* swapper(void*);
int arr[2];
int main(int argc, char* argv[]) {
pthread_t who;