This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE PackageImports, UnicodeSyntax #-} | |
import "mtl" Control.Monad.State | |
type Stack a b = State [a] b | |
push ∷ a → Stack a () | |
push a = modify (a:) | |
pop ∷ Stack a a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
page1 :: Markup | |
page1 = html $ do | |
head $ do | |
title "Introduction page." | |
link ! rel "stylesheet" ! type_ "text/css" ! href "screen.css" | |
body $ do | |
div ! id "header" $ "Syntax" | |
p "This is an example of BlazeMarkup syntax." | |
ul $ mapM_ (li . toMarkup . show) [1, 2, 3] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html = Arbre::Context.new do | |
h2 "Why Arbre is awesome?" | |
ul do | |
li "The DOM is implemented in ruby" | |
li "You can create object oriented views" | |
li "Templates suck" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var page = (function (cur) { | |
var data = public; | |
for (var i = 0; i < cur.path.length - 1; ++i) { | |
data = data[cur.path[i]]; | |
} | |
data = data.data[cur.path[cur.path.length - 1]]; | |
return data; | |
}) (current); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- var tagsForPosts = function() { | |
- var data = public.posts.data; | |
- var tags = {}; | |
- for (var name in data) { | |
- if (name[0] != '_') { | |
- var ts = data[name].tags; | |
- for (var i in ts) { | |
- tag = ts[i]; | |
- tags[tag] = tags[tag] || [] | |
- tags[tag].push (name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The [python-dbtxn](https://github.com/echaozh/python-dbtxn) is a library I wrote to ease db accessing from Python programs. Directly calling Python DBI leaves a lot of boilerplate code all over the place, and boilerplate code is bad. I googled, and there are no dbtxn like libraries, so I wrote my own. | |
<!-- more --> | |
There are 2 sources of boilerplate code: | |
... |