Skip to content

Instantly share code, notes, and snippets.

Avatar

Jerry Peng jerrypnz

  • Auckland, New Zealand
View GitHub Profile
@jerrypnz
jerrypnz / traverse.rs
Created Aug 1, 2019
Future traverse in rust
View traverse.rs
use futures::future::{lazy, try_join_all, Future, RemoteHandle};
use futures::task::SpawnExt;
pub trait SpawnFuture {
fn spawn_future<T, E, F>(&mut self, f: F) -> RemoteHandle<Result<T, E>>
where
T: Send + 'static,
E: Send + 'static,
F: FnOnce() -> Result<T, E> + Send + 'static;
}
@jerrypnz
jerrypnz / Test.hs
Last active Nov 13, 2015
FP101x Practice: JSON Parser
View Test.hs
Main> parse json "\"hello world!\n\""
[(JsString "hello world!\n","")]
Main> parse json "true"
[(JsBoolean True,"")]
Main> parse json "false"
[(JsBoolean False,"")]
@jerrypnz
jerrypnz / evalMonadWithRead.hs
Last active Aug 29, 2015
Expr Evaluator with Read
View evalMonadWithRead.hs
--- Using a monad to implement the evaluation example but this time using "do"
import Control.Applicative
import Control.Monad
data Expr = C Float |
Expr :+ Expr|
V String |
Let String Expr Expr |
Read
@jerrypnz
jerrypnz / LICENSE
Last active Aug 29, 2015
Ganglia Multidisk Extension Module
View LICENSE
#/*******************************************************************************
#* Portions Copyright (C) 2007 Novell, Inc. All rights reserved.
#*
#* Redistribution and use in source and binary forms, with or without
#* modification, are permitted provided that the following conditions are met:
#*
#* - Redistributions of source code must retain the above copyright notice,
#* this list of conditions and the following disclaimer.
#*
#* - Redistributions in binary form must reproduce the above copyright notice,
@jerrypnz
jerrypnz / ab -n 1000 -c 100
Created Jul 15, 2013
breeze test_http_server ab测试结果,单线程,服务器返回一段127 bytes的HTML。好慢啊,摔!
View ab -n 1000 -c 100
[~]$ /usr/sbin/ab -n 1000 -c 100 http://127.0.0.1:8000/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Server Software: breeze/0.1.0
Server Hostname: 127.0.0.1
Server Port: 8000
Document Path: /
@jerrypnz
jerrypnz / poll.rkt
Last active Nov 20, 2018
Play with Racket stateful servlet. This demo is a polling program.
View poll.rkt
#lang racket
(require web-server/http
web-server/managers/none
web-server/servlet
web-server/servlet-env)
(provide interface-version manager star-polling-app)
(define interface-version 'v2)
@jerrypnz
jerrypnz / test_watchers.clj
Created Nov 6, 2012
Clojure wrapper for Java 7 WatchService (java.nio.files)
View test_watchers.clj
(load-file "./watch_service.clj")
(refer 'watch-service)
(defn print-ev
[ev ctx]
(println "[foo]" ev " --> " ctx)
(println "Parent Dir:" (.getParent ctx)))
(defn print-ev-2
[ev ctx]
@jerrypnz
jerrypnz / jstack.txt
Created Oct 26, 2012
JVM stuck in DestroyJavaVM thread
View jstack.txt
2012-10-26 17:12:28
Full thread dump Java HotSpot(TM) 64-Bit Server VM (20.8-b03 mixed mode):
"Attach Listener" daemon prio=10 tid=0x00007fa790001000 nid=0x428e waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
================================= Suspicious DestroyJavaVM thread ================================
"DestroyJavaVM" prio=10 tid=0x00007fa7b8007800 nid=0x425c waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
=================================================================================================
View gist:3957225
public class PrintAB {
// The code below would print overlapped A and B sequences like:
// ...
// A
// A
// B
// B
// ...
//