Skip to content

Instantly share code, notes, and snippets.

View woxtu's full-sized avatar

woxtu

View GitHub Profile
@woxtu
woxtu / gist:11217616
Created April 23, 2014 14:33
A bunch of grapes
;; http://www2.oninet.ne.jp/mazra/math104.htm
(ns grape
(:refer-clojure :exclude [record? ==])
(:require [clojure.core.logic.fd :as fd])
(:use [clojure.core.logic]))
(clojure.pprint/pprint
(run* [q]
(fresh [a0 a1 a2 a3 a4 b0 b1 b2 b3 c0 c1 c2 d0 d1 e0 xs]
@woxtu
woxtu / gist:ce68ceb6750a3a610906
Created June 11, 2014 14:34
Find all Shikwasa!
# http://ja.wikipedia.org/wiki/%E3%82%B7%E3%83%BC%E3%82%AF%E3%83%AE%E3%83%BC%E3%82%B5%E3%83%BC#.E8.A1.A8.E8.A8.98
require 'pp'
shikwasa = {
'シ' => ['ィ', 'イ', 'ー1'],
'ィ' => ['ー1', 'ク'],
'イ' => ['ー1', 'ク'],
'ー1' => ['ク'],
'ク' => ['ァ', 'ア', 'ヮ', 'ワ'],
extern crate time;
fn main() {
let now = time::now();
let year = now.tm_year as uint + 1900;
let month = now.tm_mon as uint + 1;
let first_wday = {
let mut t = now.clone();
t.tm_mday = 1;
(ns markov
(:require [cljs.nodejs :as nodejs]
[clojure.string :refer [join replace]]))
(def kuromoji (nodejs/require "kuromoji"))
(defn wakachi [tokenizer sentence]
(->> (js->clj (.tokenize tokenizer sentence) :keywordize-keys true)
(map :surface_form)))
import math
import os
import sequtils
import strutils
const libmecab = "libmecab.2.dylib"
type mecab_node_t = object
prev: ptr mecab_node_t
next: ptr mecab_node_t
@woxtu
woxtu / gist:6963724
Created October 13, 2013 15:46
Tweet in Rouge.
;; Rouge 0.0.14
(require "oauth")
(def *consumer-key* "YOUR CONSUMER KEY")
(def *consumer-secret* "YOUR CONSUMER SECRET")
(let [consumer-token (OAuth.Consumer. *consumer-key* *consumer-secret*
{:site "https://api.twitter.com/"})
request-token (.get_request_token consumer-token)]
@woxtu
woxtu / gist:7045816
Created October 18, 2013 18:19
Convert image to Data URI in Rouge.
;; Rouge 0.0.14
(require "base64")
(require "mime/types")
(let [filename (nth ARGV 0)]
(let [data-type (-> filename MIME.Types/of first)
data-str (-> filename Kernel/open .read Base64/encode64)]
(.write (Kernel/open (str (File/basename filename) ".html") "wb")
(str "<!DOCTYPE html>\n" "<img src=\"data:" data-type ";base64," data-str "\" />"))))
@woxtu
woxtu / gist:7237411
Created October 30, 2013 18:18
Do something when the animation of the navigation bar is complete
// in the view controller
UIWindow* window = [[UIApplication sharedApplication] keyWindow];
UINavigationController* navigationController = (UINavigationController *)[window rootViewController];
[UIView transitionWithView:self.view
duration:UINavigationControllerHideShowBarDuration
options:UIViewAnimationOptionCurveLinear
animations:^{
[navigationController setNavigationBarHidden:YES animated:NO];
@woxtu
woxtu / gist:7543972
Created November 19, 2013 11:24
Read the whole file into std::string in C++.
#include <fstream>
#include <string>
#include <iostream>
int main() {
std::ifstream stream{"fujiyama.txt"};
std::string buffer{std::istreambuf_iterator<char>(stream), std::istreambuf_iterator<char>()};
std::cout << buffer << std::endl;
@woxtu
woxtu / gist:7156835
Last active February 10, 2016 22:17
Draw a triangle using GLSL and VBO in Rouge
;; Rouge 0.0.15
(require "glut")
(require "opengl")
(def vertex-shader "
attribute vec3 position;
attribute vec4 color;
varying vec4 vertex_color;