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 / 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;
@dulimarta
dulimarta / posix-shm.c
Last active October 20, 2020 19:33
CS452 Lab06 - POSIX shm
#include <fcntl.h>
#include <unistd.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <time.h>
// New type definitions
@dulimarta
dulimarta / switch_2threads.c
Created September 25, 2020 14:10
CS452 ULT swap_conteext
/*
* Demonstrate a minimal code to implement thread switching in user
* space
**/
#include <ucontext.h>
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <sys/time.h>
@dulimarta
dulimarta / lab03_c.c
Last active February 13, 2023 02:09
CS452 Lab03 - fork() and signal()
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <stdbool.h>
#include <sys/types.h>
#include <sys/wait.h>
bool running = true;
void sigHandler(int number) {
@dulimarta
dulimarta / main.rs
Last active February 6, 2020 03:18
CS452 Lab05 - Sample 1 (Rust)
use core::ffi::c_void; // FFI: Foreign Function Interface
use libc::{c_int, shmid_ds};
use libc::{shmat, shmctl, shmdt, shmget};
use libc::{IPC_PRIVATE, IPC_RMID, S_IRUSR, S_IWUSR};
const FOO: usize = 4096;
fn main() {
println!("Hello, world!");
let shm_ptr: *mut c_void;
@dulimarta
dulimarta / sample3.rs
Created January 28, 2020 21:34
CS452 Lab04 - Sample 3 (Rust)
use nix::unistd::sleep;
use std::thread;
// Global variable
static mut SHARED_DATA: u8 = 5;
fn main() {
// Use lambda when the thread function takes arguments
let thr1 = thread::spawn(|| do_greeting3('a'));
let thr2 = thread::spawn(|| do_greeting3('b'));