Skip to content

Instantly share code, notes, and snippets.

View jiewmeng's full-sized avatar

Jiew Meng jiewmeng

  • WatchTowr
  • Singapore
View GitHub Profile
@jiewmeng
jiewmeng / rsgen.py
Created March 29, 2012 04:59
For Operating Systems module in University. Project objective is to analyse difference in page replacement algorithms: eg. FIFO, LRU, Random etc.
#!/usr/bin/env python3.2
#################################################################
# Lim Jiew Meng (A0087884H)
# CS2106 OS Proj 2 : Page Replacement Algorithms
#################################################################
import argparse
import random
from math import floor
@jiewmeng
jiewmeng / getdata.py
Created March 31, 2012 04:31
OS Project 2 WIP: Virtual Memory Page Replacement Algorithms Analysis
#!/usr/bin/env python3.2
##################################################################
# Lim Jiew Meng (A0087884H)
# CS2106 OS Project 2 : Page Replacement Algorithms
##################################################################
import argparse
from rsgen import ReferenceStringGenerator
from vm import VirtualMemory, RandomPageReplacement, FifoPageReplacement, LruPageReplacement
@jiewmeng
jiewmeng / gist:2627913
Created May 7, 2012 13:54
Symfony 2 Image Upload
/**
* @ORM\PrePersist
*/
public function uploadIcon() {
// proceed with upload only if isDirty
if (!$this->isDirty)
return;
// delete the old file if any
$oldIcon = APP_ROOT .'/uploads/' . $this->iconUrl;
@jiewmeng
jiewmeng / gist:2650924
Created May 10, 2012 03:48
Arch Linux Install
pacman -Syyu
# for nvidia xf86-video-nouveau, virtualbox: virtualbox-archlinux-additions
pacman -S dbus xorg-server xorg-server-utils alsa-utils mesa xf86-video-ati sudo acpi pm-utils cpufrequtils vbetool xfce4 xfce4-power-manager
# start dbus manually
# /etc/rc.d/dbus
# start dbus automatically
# add to rc.conf > DAEMONS=(..., dbus)
# Virtual box guest: `modprobe -a vboxvideo vboxguest vboxsf vboxnetflt` or in /etc/rc.conf `MODULES=(... vboxvideo ...)`
@jiewmeng
jiewmeng / gist:2983360
Created June 24, 2012 14:12
Backbone Auth Test
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Backbone Auth Test</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/coffee-script/1.3.1/coffee-script.min.js"></script>
<script type="text/coffeescript">
@jiewmeng
jiewmeng / Cakefile
Created August 4, 2012 09:14
Cakefile to start Express app, watch & compile CoffeeScript & Stylus files
{spawn, exec} = require "child_process"
# process the output of a spawned process
# see **[link](http://stackoverflow.com/a/7376108/292291)**
processOutput = (proc) ->
proc.stdout.on "data", (data) ->
console.log data.toString().trim()
task "startdev", "Starts server with nodemon and watch files for changes", ->
# start nodemon server
@jiewmeng
jiewmeng / MongooseNotes.md
Created August 12, 2012 01:44
MongooseJS Notes

Connection to MongoDB

Connect to different MongoDB database depending on enviornment

# server.coffee
mongoose = require "mongoose"
app.configure "development", ->
	mongoose.connect "localhost", "app-dev"
@jiewmeng
jiewmeng / ArchInstall.md
Created August 12, 2012 07:56
Arch Linux Build

Arch Linux Install Notes

Core Packages

dbus xorg-server xorg-server-utils alsa-utils mesa xf86-video-ati sudo xfce4 lxdm

For NVIDIA, use xf86-video-nouveau For VirtualBox guest, virtualbox-archlinux-additions

@jiewmeng
jiewmeng / .gitignore
Created August 15, 2012 03:15
Script to create express app with CoffeeScript etc. and modular folder structure
node_modules/
public/css/app
public/js/app
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
@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"