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
eric@finkomatic:~/go/src/github.com/metacurrency/holochain$ make test | |
gx install --global | |
installation of dep go-semver complete! | |
installation of dep dns complete! | |
installation of dep go-text complete! | |
installation of dep go-net complete! | |
installation of dep mdns complete! | |
installation of dep go-randbuf complete! | |
installation of dep go-msgio complete! | |
installation of dep go-crypto complete! |
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
go get github.com/libp2p/go-libp2p-swarm | |
# github.com/libp2p/go-libp2p-conn | |
../../libp2p/go-libp2p-conn/dial.go:134: cannot use pconn (type transport.Conn) as type conn.Conn in assignment: | |
transport.Conn does not implement conn.Conn (missing ID method) | |
../../libp2p/go-libp2p-conn/listen.go:104: cannot use pc (type transport.Conn) as type conn.Conn in assignment: | |
transport.Conn does not implement conn.Conn (missing ID method) |
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
//run system commands | |
#include <stdio.h> | |
char *doSys(char *cmd) { | |
FILE *pipe = popen(cmd, "r"); | |
if (!pipe) {return "err"; } | |
int sz = 1000; | |
int remaining = sz; | |
char *buffer = malloc(sz); | |
char buf[255]; | |
while (fgets(buf, 255, pipe) != NULL) { |
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
pub trait MutableVector<'self, T> { | |
fn shuffle(self); | |
} | |
impl<'self, T> MutableVector<'self, T> for &'self mut [T] { | |
fn shuffle(self) { | |
let l=self.len(); | |
let mut i=l; | |
let mut rng = rand::rng(); | |
loop { |
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
(defn make-select [elem-id] | |
(let [select (goog.ui.Select. "Heading") | |
select-elem (d/element (keyword (str "div#" elem-id)))] | |
(.addItemAt select (goog.ui.MenuItem. "Item 1") 0) | |
(.addItem select (goog.ui.Option. "Item 2")) | |
(.render select select-elem) | |
select-elem | |
) | |
) |
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
(defn make-http-handler [host _r] | |
(app | |
["api"] {:post (fn [request] | |
(try | |
(let [b (trim (bytes->string (:body request))) | |
{command :cmd params :params} (clojure.contrib.json/read-json b)] | |
(println (str "POST REQUEST: from " (:remote-addr request) " for: " b)) | |
{:status 200 | |
:headers {"content-type" "application/json" | |
"Access-Control-Allow-Origin" "*"} |
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
; This fails: | |
(doseq [hid ["a" "b" "c"]] | |
(goog.dom.appendChild (goog.dom.$ "some-element-id") (goog.dom.createDom "div" (.strobj {"id" hid}) (str "Test-"hid))) | |
(goog.events.listen (goog.dom.$ hid) goog.events.EventType.CLICK, (fn [e] (js/alert hid)))) | |
;This works: | |
(defn hidfn [hid] | |
(fn [e] (js/alert hid)) | |
) | |
(doseq [hid ["a" "b" "c"]] |
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
(ns test.core | |
(:require [clojure.browser.dom :as dom] | |
[goog.ui.Dialog :as Dialog] | |
[goog.events :as events] | |
[goog.ui.LabelInput :as LabelInput] | |
)) | |
(def d (goog.ui.Dialog.)) | |
(def l (goog.ui.LabelInput. "User 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
(ns cmp.core | |
(:use compojure.core, ring.adapter.jetty) | |
(:require [compojure.route :as route] | |
[compojure.handler :as handler]) | |
) | |
(defn view-form [] | |
(str "<html><head></head><body>" | |
"<form method=\"post\">" |
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
(defmacro make-obj [n & args] | |
(let [name (if (instance? clojure.lang.Symbol n) n (eval n))] | |
`{(keyword '~name) [~@args]} )) | |
(make-obj bar :foo) ; => {:bar [:foo]} | |
(make-obj (symbol (str (name :bar))) :foo) ; => {:bar [:foo]} | |
(defmacro make-fn [n & b] `(defn ~n ~@b)) | |
(make-fn keyword-maker [k] (make-obj (symbol (str (name k))) :foo)) ;=> Thrown class java.lang.InstantiationException |