Skip to content

Instantly share code, notes, and snippets.

View zhzhxtrrk's full-sized avatar

Steven Zhang zhzhxtrrk

  • Palo Alto, CA, US
View GitHub Profile
class MonadTest {
@Test
fun testMaybeMonad() {
val result = Maybe.unit(1) flatMap {
if (it > 0) Maybe.unit("Hello") else Maybe.None
} map {
"Hi, $it"
} map {
"$it ..."
} map {
@zhzhxtrrk
zhzhxtrrk / md2wiki.lua
Created April 2, 2015 10:15
markdown 到 Confluence WIKI 的 Pandoc 脚本
-- that is very similar to that of pandoc's HTML writer.
-- There is one new feature: code blocks marked with class 'dot'
-- are piped through graphviz and images are included in the HTML
-- output using 'data:' URLs.
--
-- Invoke with: pandoc -t sample.lua
--
-- Note: you need not have lua installed on your system to use this
-- custom writer. However, if you do have lua installed, you can
-- use it to test changes to the script. 'lua sample.lua' will
@zhzhxtrrk
zhzhxtrrk / wiki.lua
Last active April 19, 2020 18:31
pandoc confluence markup writer
-- that is very similar to that of pandoc's HTML writer.
-- There is one new feature: code blocks marked with class 'dot'
-- are piped through graphviz and images are included in the HTML
-- output using 'data:' URLs.
--
-- Invoke with: pandoc -t sample.lua
--
-- Note: you need not have lua installed on your system to use this
-- custom writer. However, if you do have lua installed, you can
-- use it to test changes to the script. 'lua sample.lua' will
@zhzhxtrrk
zhzhxtrrk / view_util.clj
Created August 22, 2013 05:42
hiccup template/partial util
(ns beta-shop.view-util
(:use hiccup.core))
(defmacro defpartial
[fname doc-or-args & body]
(if (string? doc-or-args)
(let [args# (first body)
fbody# (rest body)]
`(defn ~fname ~doc-or-args ~args# ~@fbody#))
@zhzhxtrrk
zhzhxtrrk / uv.c
Created August 6, 2013 03:30
libuv example
#include <stdio.h>
#include <stdlib.h>
#include <uv.h>
static uv_buf_t
alloc_buffer(uv_handle_t *handle, size_t size)
{
return uv_buf_init(malloc(size), size);
}
@zhzhxtrrk
zhzhxtrrk / lua.c
Created June 16, 2013 04:35
简单的嵌入lua,留作模板吧……
#include <stdio.h>
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#define TOY_MODULE_NAME "toy"
require 'pathname'
require 'fileutils'
if ARGV.size < 3
puts "Usage: ruby sign.rb App DeveloperId Provision"
exit
end
puts "Working"