Skip to content

Instantly share code, notes, and snippets.

View jiewmeng's full-sized avatar

Jiew Meng jiewmeng

  • WatchTowr
  • Singapore
View GitHub Profile
import asyncio
from random import randint
async def apiCallWorker(name, queue):
while True:
apiId = await queue.get()
sleepTimeInSec = randint(0, 3)
print(f"worker {name} apiId {apiId} sleeping for {sleepTimeInSec}")
await asyncio.sleep(sleepTimeInSec)
@jiewmeng
jiewmeng / develop.js
Created March 21, 2016 01:00
NPM Script to run nodemon, browser-sync and watchify
'use strict';
/**
* Starts `nodemon` and `browser-sync`
*/
const path = require('path');
const fs = require('fs');
const nodemon = require('nodemon');
const browserSync = require('browser-sync').create();
@jiewmeng
jiewmeng / CATToolTest.java
Created February 4, 2014 11:15
cat tool test
package sg.edu.nus.comp.cs4218.impl.fileutils;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.junit.Test;
import sg.edu.nus.comp.cs4218.fileutils.ICatTool;
public class CATToolTest {
@jiewmeng
jiewmeng / Request.java
Created February 26, 2013 08:05
A Parallel Computing Module Assignment done in Java. Simulation of a Client - Server booking system using threads. Clients can book a seat if its available but should ensure that a seat cannot be booked more than once. eg. - Client 1 and 2 gets reservation status and finds that seat 10 is available - They proceeds to book the seat - Only one sho…
package reservation;
public class Request {
public int terminalId;
public String function;
public Object args;
public Request(int terminalId, String function, Object args) {
this.terminalId = terminalId;
@jiewmeng
jiewmeng / basketball-match.cpp
Created November 8, 2012 15:50
Parallel Computing Assignment (OpenMPI)
#include <mpi.h>
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
const int NUMPROCS = 12;
const int FIELD0 = 10; // (0,0) -> (64,64)
const int FIELD1 = 11; // (65,0) -> (128,64)
@jiewmeng
jiewmeng / matrix.cpp
Created October 3, 2012 03:49
Matrix Multiplication Optimization
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <assert.h>
#include <algorithm>
typedef struct
{
@jiewmeng
jiewmeng / 1-batch.c
Created September 26, 2012 10:24
Parallel Computing - Assignment 1 - Levels & Size of Caches
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define KB 1024
#define MB 1024 * 1024
int main() {
unsigned int steps = 256 * 1024 * 1024;
static int arr[4 * 1024 * 1024];
@jiewmeng
jiewmeng / HospitalTour.java
Created September 25, 2012 01:29
Data Structures & Algorithms - Lab 3
import java.util.*;
// A0087884H
// Lim Jiew Meng
// Collaborators:
class HospitalTour {
private int V; // number of vertices in the graph (number of rooms in the hospital)
private ArrayList<HashSet<Integer>> AdjList; // the graph (the hospital)
private Vector < Integer > RatingScore; // the weight of each vertex (rating score of each room)
import java.util.*;
// A0087884H
// Lim Jiew Meng
// Collaborators:
class SchedulingDeliveries {
protected ArrayMaxHeap mothersToBeQueue; // when we need to access by priority
protected HashMap<String, MotherToBe> mothersToBe; // when we need to access by mother's name
@jiewmeng
jiewmeng / MathJaxMarkdownEditor.coffee
Created August 31, 2012 13:45
MathJax/Markdown Editor in CoffeeScript
define [
"marked",
"jquery",
"mathjax"
], (marked, $, MathJax) ->
# see: http://cdn.mathjax.org/mathjax/latest/test/sample-dynamic-2.html
class MathJaxMarkdownEditor
inputName: "#editor"