Skip to content

Instantly share code, notes, and snippets.

View stevenhao's full-sized avatar

Steven Hao stevenhao

View GitHub Profile
<html>
<head>
<script src="jquery.min.js"></script>
<link rel="stylesheet" href="bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<script>
var xmlns = "http://www.w3.org/2000/svg";
window.$$ = function(tag) {
var el = document.createElementNS(xmlns, tag);
@stevenhao
stevenhao / gmp.jl
Created April 14, 2016 18:53
Attempt #1: replace malloc with new_struct_uninit
# This file is a part of Julia. License is MIT: http://julialang.org/license
module GMP
export BigInt
type Hi
end
import Base: *, +, -, /, <, <<, >>, >>>, <=, ==, >, >=, ^, (~), (&), (|), ($),
#!/usr/bin/python
def cut(lst):
return lst[:5]
with open("words") as f:
all_words = f.read().split("\n")
common = filter(lambda word: all(c.islower() for c in word), all_words)
fours = filter(lambda s: len(s)==4, common)
print = console.log.bind(console);
err = console.error.bind(console);
function Dispatcher(name) {
function evtname(evt) {
return name + '.' + evt;
}
this.fire = function() {
evt = arguments[0];
args = Array.prototype.slice.call(arguments, 1);
initTrap() {
TRAPCMD="initTrap"
}
pushTrap() {
if [ -z "$TRAPCMD" ]; then
initTrap
fi
TRAPCMD="$TRAPCMD;$1"
trap "$TRAPCMD" SIGINT # overrides previous trap
PS1='\[\e[1;33m\][\u@\h \W \t]\$\[\e[0m\] '
PATH=~/bin:/usr/local/bin:$PATH
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
if [ -f ~/.bashrc_local ]; then
. ~/.bashrc_local
fi
#!/bin/bash
CMD_STR=""
for I in $@; do
CMD_STR="$CMD_STR $I"
done
TMP_FILE=/tmp/note-$$
touch $TMP_FILE || echo "meed write permissions to $TMP_FILE"
@stevenhao
stevenhao / mdriver_patch.diff
Last active October 29, 2016 02:21
mdriver patch for peak util
diff --git a/mymalloc/mdriver.c b/mymalloc/mdriver.c
index edbd17d..6bea5f8 100644
--- a/mymalloc/mdriver.c
+++ b/mymalloc/mdriver.c
@@ -502,6 +502,9 @@ static double eval_mm_util(const malloc_impl_t *impl, trace_t *trace, int tracen
char *p;
char *newp, *oldp;
+ double U_numerator, U_denominator, U;
+ double peak_U = 1; // peak util: min U_numerator/U_denominator over time
/*ID: ohs.han1
TASK: contact
LANG: C++
*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
var rpc = require('node-json-rpc');
var colors = require('colors');
var serv = new rpc.Server({ port: 7000, strict: false });
var logger = (function() {
var logger = {};
logger.red = function() {
console.log(Array.from(arguments).join(' ').red);
};
logger.blue = function() {