Skip to content

Instantly share code, notes, and snippets.

View bouzuya's full-sized avatar

bouzuya bouzuya

View GitHub Profile
$ echo hello,gpg > samle.txt
$ cat sample.txt
hello,gpg
$ gpg --sign sample.txt
gpg: no default secret key: secret key not available
gpg: signing failed: secret key not available
$ man gpg
(ns google-reader.xml-test
(:require [clojure.xml :as xml]
[clojure.zip :as zip]
[clojure.data.zip.xml :as dzx])
(:use clojure.test))
(def xml-str-1
(str "<root id='1'>"
" <parent id='2'>"
" <child id='3'/>"
package com.github.bouzuya;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ServletExample extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String title = "ServletExample";
function! s:insert_tmux_buffer()
let buffers = split(system('tmux list-buffers'), '\n')
if empty(buffers)
return
endif
let buffers_origin1 = map(buffers,
\ 'substitute(v:val, ''\V\^\d\+'', ''\=submatch(0) + 1'', '''')')
call insert(buffers_origin1, 'tmux list-buffers', 0)
let selected_index = inputlist(buffers_origin1) - 1
if selected_index >= 0
(use 'clojure.test)
(with-test
(defn remove-x [x v]
(vec (map #(set (remove #{x} %)) v)))
(are
[x v expected]
(= (remove-x x v) expected)
nil [] []
2 [#{1 2 3}] [#{1 3}]
package info.bouzuya.http_client;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
import org.apache.commons.httpclient.HttpClient;
(reduce (fn [m [k v]] (assoc m k v)) {} (doto (java.util.HashMap.) (.put "a" 1) (.put "b" 2)))
; => {"a" 1, "b" 2}
(reduce-kv (fn [m k v] (assoc m k v)) {} (doto (java.util.HashMap.) (.put "a" 1) (.put "b" 2)))
; #<IllegalArgumentException java.lang.IllegalArgumentException: No implementation of method: :kv-reduce of protocol: #'clojure.core.protocols/IKVReduce found for class: java.util.HashMap>
(into {} (doto (java.util.HashMap.) (.put "a" 1) (.put "b" 2)))
; => {"b" 2, "a" 1}
package info.bouzuya.http_client;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethodBase;
@bouzuya
bouzuya / build.xml
Created April 4, 2013 16:19
Apache Ivy を自動でインストールして ivy:retrieve する。
<property name="ivy.version" value="2.3.0" />
<property name="ivy.jar" value="ivy-${ivy.version}.jar" />
<available file="${ant.library.dir}/${ivy.jar}" property="ivy.installed" />
<target name="install-ivy" unless="ivy.installed">
<get dest="${ant.library.dir}" src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/${ivy.jar}" />
</target>
<target name="retrieve" depends="install-ivy">
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpath="${ant.library.dir}/${ivy.jar}" />
<ivy:retrieve />
</target>
@bouzuya
bouzuya / HatenaBookmark.java
Created May 3, 2013 13:04
はてなブックマークからブックマーク数をスクレイピング
package info.bouzuya.hateb;
import java.io.IOException;
import java.util.List;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.nodes.TextNode;
import org.jsoup.select.Elements;