Skip to content

Instantly share code, notes, and snippets.

View lanzhiheng's full-sized avatar
😺
Fine

Lan lanzhiheng

😺
Fine
View GitHub Profile
@lanzhiheng
lanzhiheng / ruby-lambda-expression.rb
Last active September 3, 2017 13:13
用Ruby的Lambda实现基本数值运算
ZERO = -> p { -> x { x } }
ONE = -> p { -> x { p[x] } }
TWO = -> p { -> x { p[p[x]] } }
THREE = -> p { -> x { p[p[p[x]]] } }
FOUR = -> p { -> x { p[p[p[p[x]]]] } }
FIVE = -> p { -> x { p[p[p[p[p[x]]]]] } }
def to_integer(n)
n[-> x {x + 1}][0]
end
@lanzhiheng
lanzhiheng / gist:3c158762b6cae124625ad69b6608464d
Created May 19, 2017 02:53 — forked from joubertnel/gist:870190
HTML5 Canvas - Rendering of Text on high-DPI screens
<html>
<head>
<script src='http://code.jquery.com/jquery-1.5.1.min.js'></script>
</head>
<body>
<h2>Naive canvas</h2>
<canvas id="naive" width="400" height="50"></canvas>
<h2>High-def Canvas</h2>