Skip to content

Instantly share code, notes, and snippets.

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 Jun 10, 2021
Vuetify Snippets
View 00-blank.vue
<template>
<span class="text-h3">Just title</span>
</template>
@dulimarta
dulimarta / 10-add-doc-userkey.ts
Last active Mar 22, 2021
Cloud Firestore Snippets
View 10-add-doc-userkey.ts
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 Nov 17, 2021
CS452 Lab10 - hugemem.c
View 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 Oct 22, 2020
CS452 Lab06 - Sample 3
View lab06_b.c
#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 Oct 20, 2020
CSS452 Lab06 - Sample 1
View lab06_a.c
#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 Oct 20, 2020
CS452 Lab06 - POSIX shm
View posix-shm.c
#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 Sep 25, 2020
CS452 ULT swap_conteext
View switch_2threads.c
/*
* 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
Created Sep 23, 2020
CS452 Lab03 - fork() and signal()
View lab03_c.c
#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 Feb 6, 2020
CS452 Lab05 - Sample 1 (Rust)
View main.rs
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 Jan 28, 2020
CS452 Lab04 - Sample 3 (Rust)
View sample3.rs
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'));