Skip to content

Instantly share code, notes, and snippets.

@hikoz
hikoz / layout.js
Created March 3, 2017 05:22
active tab with preact-router
import { h, Component } from 'preact';
import { Router, Link } from 'preact-router';
function Header({url}) {
const NavItem = ({href, children}, state) => (
<li className={href==url ? 'is-active' : ''}><Link href={href}>{children}</Link></li>
)
return (
<section class="hero is-primary">
<div class="hero-foot">
(let [ws '(進捗 どう です か)
wc (count ws)
l (loop [r [] i 0]
(let [n (rand-int wc)
s (nth ws n)
r (conj r s)]
(if (= n i (dec wc))
r
(recur r (if (= n i) (inc i) 0)))))
s (apply str l)]
(->>
(let [[h & t] (range 1 10)]
(reduce
(fn [l h]
(mapcat (fn [[a b s]]
[[(conj a b) h (str s " + " h)]
[(conj a b) (- h) (str s " - " h)]
[a (bigint (str b h)) (str s h)]])
l))
[[[] h h]]
@hikoz
hikoz / async.clj
Created April 30, 2015 07:56
core.async in top-level-paren-less-clojure
;; Copyright (c) Rich Hickey and contributors. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.
ns clojure.core.async
(:refer-clojure :exclude [reduce into merge map take partition
@hikoz
hikoz / foo.boot
Created February 9, 2015 07:21
boot template
# boot foo.boot usage sleep -t 10
(set-env!
:dependencies '[[org.clojure/core.async "0.1.346.0-17112a-alpha"]
[org.clojure/tools.logging "0.3.1"]
[org.slf4j/slf4j-simple "1.7.10"]])
(doseq [s '(info warn)] (ns-unmap *ns* s))
(require '[clojure.core.async :as async
:refer (go go-loop chan <! >! <!! >!! timeout thread)]
'[clojure.tools.logging :refer (debug info warn error spy)])
@hikoz
hikoz / gist:ddbe7c9f697f82c18362
Created September 9, 2014 04:02
JTwig still having concurrency problem
Caused by: com.lyncode.jtwig.exception.RenderException: com.lyncode.jtwig.exception.CalculateException: com.lyncode.jtwig.resource.WebJtwigResource@31e1a5eb -> Line 7, column 37: Unable to find function with name 'trans'
at com.lyncode.jtwig.content.model.compilable.Output$Compiled.render(Output.java:56)
at com.lyncode.jtwig..model.compilable.Sequence$Compiled.render(Sequence.java:80)
at com.lyncode.jtwig.parser.JtwigParser$CompiledDocument.render(JtwigParser.java:67)
at com.lyncode.jtwig.parser.JtwigParser$CompiledDocument.render(JtwigParser.java:67)
at com.lyncode.jtwig.mvc.JtwigView.renderMergedTemplateModel(JtwigView.java:103)
at org.springframework.web.servlet.view.AbstractTemplateView.renderMergedOutputModel(AbstractTemplateView.java:167)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1228)
at org.springframework.we
#!/usr/bin/env lein exec
(use '[leiningen.exec :only (deps)])
(deps '[[clj-http "0.7.1"]])
(require '[clj-http.client :as client])
(defn api-request [url]
(:body (client/get url {:as :json})))
(let [user (api-request "http://ugomemo.hatena.ne.jp/11F9E990AA34FFBC@DSi.json")
movies (api-request "http://ugomemo.hatena.ne.jp/11F9E990AA34FFBC@DSi/movies.json")]
@hikoz
hikoz / A.java
Created March 19, 2013 07:49
ヒープ領域余らせたままOutOfMemoryだせたよー
public class A {
public static void main(String[] args) {
while (true) {
new Thread(new Runnable() {
public void run() {
try {
Thread.sleep(10000L);
} catch (InterruptedException e) {
}
}
@hikoz
hikoz / responsive.css
Created June 29, 2012 05:35
Responsive Design CSS
a { color: #669; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font: 36px; }
#page { padding: 5px; width: 960px; margin: 20px auto; }
#header { height: 180px; }
#content { width: 630px; float: left; }
#sidebar { width: 300px; float: right; }
#footer { clear: both; }
/* for 980px or less */
@media screen and (max-width: 980px) {
@hikoz
hikoz / ReloadTest.java
Created June 26, 2012 12:46
Reload problem for Rythm
package rythm.test;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import java.io.File;
import java.util.Properties;
import org.junit.Test;