Skip to content

Instantly share code, notes, and snippets.

View woxtu's full-sized avatar

woxtu

View GitHub Profile
@woxtu
woxtu / LICENSE
Last active January 31, 2020 13:31
Time-lapse -ify in Swift
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
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
(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)))
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;
@woxtu
woxtu / gist:c186b173be3a53171533
Last active March 4, 2019 05:37
Face detection in Rust
pub mod cv {
extern crate libc;
use self::libc::{c_char, c_double, c_int, c_schar, c_void};
#[repr(C)]
pub struct HaarClassifierCascade;
#[repr(C)]
pub struct MemStorage;
@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' => ['ク'],
'ク' => ['ァ', 'ア', 'ヮ', 'ワ'],
@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: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: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: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;