This file contains hidden or 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> | |
<head><title>Table Template</title></head> | |
<body> | |
<table> | |
<thead> | |
<tr class="main"><th>H1</th><th>H2</th></tr> | |
<tr><th>HH1</th><th>HH2</th></tr> | |
</thead> | |
<tbody> | |
<tr class="odd"><td class="first">A</td><td>B</td><td>C</td> |
This file contains hidden or 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
(def table-template (html-resource "templates/table.html")) | |
(defsnippet header-cell table-template | |
[[:thead] [:tr first-child] [:th first-child]] | |
[value] | |
[:th] (content value)) | |
$ lein repl | |
"REPL started; server listening on localhost:4633." | |
user=> (use 'blog.table :reload-all) |
This file contains hidden or 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
user=> (use 'blog.table :reload-all) | |
nil | |
(header-cell "X") | |
user=> ({:tag :th, :attrs {:class "TH"}, :content ("X")}) |
This file contains hidden or 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
(defsnippet header-row table-template | |
[[:thead]] | |
[primary secondary] | |
[:tr] (content (map #(header-cell %) secondary)) | |
[:tr.main] (content (map #(header-cell %) primary))) | |
user=> (header-row ["A" "B" "C"] ["1" "2" "3"]) | |
({:tag :thead, :attrs nil, :content ("\n\t\t" {:tag :tr, :attrs {:class "main"}, :content ({:tag :th, :attrs {:class "TH"}, :content ("A")} {:tag :th, :attrs {:class "TH"}, :content ("B")} {:tag :th, :attrs {:class "TH"}, :content ("C")})} "\n\t\t" {:tag :tr, :attrs nil, :content ({:tag :th, :attrs {:class "TH"}, :content ("1")} {:tag :th, :attrs {:class "TH"}, :content ("2")} {:tag :th, :attrs {:class "TH"}, :content ("3")})} "\n\t")}) |
This file contains hidden or 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
(ns blog.table | |
(:use [net.cgrand.enlive-html])) | |
(def table-template (html-resource "templates/table.html")) | |
(defn t [selector] | |
(select (html-resource table-template) selector)) | |
(defsnippet header-cell table-template | |
[[:thead] [:tr first-child] [:th first-child]] |
This file contains hidden or 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
user=> (table ["A" "B" "C"] ["1" "2" "3"] [["X" "Y" "Z"]]) | |
({:tag :table, :attrs nil, :content ({:tag :thead, :attrs nil, :content ("\n\t\t" {:tag :tr, :attrs {:class "main"}, :content ({:tag :th, :attrs {:class "TH"}, :content ("A")} {:tag :th, :attrs {:class "TH"}, :content ("B")} {:tag :th, :attrs {:class "TH"}, :content ("C")})} "\n\t\t" {:tag :tr, :attrs nil, :content ({:tag :th, :attrs {:class "TH"}, :content ("1")} {:tag :th, :attrs {:class "TH"}, :content ("2")} {:tag :th, :attrs {:class "TH"}, :content ("3")})} "\n\t")} {:tag :tbody, :attrs nil, :content ({:tag :tr, :attrs {:class "even"}, :content ({:tag :td, :attrs {:class "first"}, :content ("X")} {:tag :td, :attrs nil, :content ("Y")} {:tag :td, :attrs nil, :content ("Z")})})} {:tag :tfoot, :attrs nil, :content ("\n\t\t" {:tag :tr, :attrs {:class "main"}, :content ({:tag :th, :attrs nil, :content ("A")} {:tag :th, :attrs nil, :content ("B")} {:tag :th, :attrs nil, :content ("C")})} "\n\t\t" {:tag :tr, :attrs nil, :content ({:tag :th, :attrs nil, |
This file contains hidden or 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
import com.sun.jna.Library; | |
import com.sun.jna.NativeLong; | |
import com.sun.jna.Pointer; | |
import com.sun.jna.ptr.LongByReference; | |
public interface ZmqLibrary extends Library { | |
void zmq_version(int[] major, int[] minor, int[] patch); | |
} |
This file contains hidden or 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
public void testVersion() { | |
assertNotNull(zmqLibrary); | |
int[] major = new int[1]; | |
int[] minor = new int[1]; | |
int[] patch = new int[1]; | |
zmqLibrary.zmq_version(major, minor, patch); | |
assertEquals(2, major[0]); | |
assertEquals(0, minor[0]); | |
assertEquals(8, patch[0]); | |
} |
This file contains hidden or 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
package blog.zeromq; | |
import com.sun.jna.Library; | |
import com.sun.jna.NativeLong; | |
import com.sun.jna.Pointer; | |
import com.sun.jna.ptr.LongByReference; | |
public interface ZmqLibrary extends Library { | |
void zmq_version(int[] major, int[] minor, int[] patch); |
This file contains hidden or 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
module Zipper | |
type 'a Tree = Item of 'a | Section of 'a Tree list | |
type 'a Path = Top | Node of 'a Tree list * 'a Path * 'a Tree list | |
type 'a Location = Loc of 'a Tree * 'a Path | |
let left (Loc(t, p)) = | |
match p with |
OlderNewer