Skip to content

Instantly share code, notes, and snippets.

View kaiinui's full-sized avatar

kaiinui kaiinui

View GitHub Profile
#- encode: utf-8
require 'natto'
class Mecab
def self.parse(sentence)
mecab.parse(sentence).split(";").map {|a| a.split(":")}
end
def self.nouns(sentence)
require 'yahoo_parse_api'
class YahooMA
def self.parse(sentence)
client.parse(sentence, param)
end
def self.nouns(sentence)
parse(sentence)["ResultSet"]["ma_result"]["word_list"]["word"].map {|a| a["surface"]}
end
@kaiinui
kaiinui / loader.css
Created May 31, 2014 09:28
Medium/Youtube style simple loader css
#l{
width:100%;
height:2px;
position:fixed;
top:0;
left:0;
z-index:80;
background:red;
animation:lk .95s linear 0 infinite;
-webkit-animation:lk .95s linear 0 infinite;
@kaiinui
kaiinui / tinyquery.js
Last active August 29, 2015 14:02
Experimental. (465bytes when compressed, 247bytes when gzipped.)
var W=window,E=W.Element,P="prototype";
W.$$ = function(s, c){
return (c ? c : document)['querySelectorAll'](s);
};
W.NodeList[P].each = Array[P].forEach;
W.NodeList[P].forEach = Array[P].forEach;
E[P].find=function(q){
@kaiinui
kaiinui / main.vcl
Created June 7, 2014 06:45
add content-type in Varnish/S3. placehold fix since S3 doesn't set Cache-Control and proper Content-type
sub vcl_fetch {
remove beresp.http.Cache-Control;
set beresp.http.Cache-Control = "public, max-age=31600000";
if (req.url ~ ".jpg$") {
set beresp.http.content-type = "image/jpeg";
}
if (req.url ~ ".webp$") {
set beresp.http.content-type = "image/webp";
}
@kaiinui
kaiinui / cloudflow.rb
Last active March 17, 2017 19:03
CloudFlow Specification
#
# Amazon SQS Powered Multi-instance Coding (a.k.a. Workflow) & Docker powered multi-instance deployment. (Cloud Orchestration)
# similar works: Route https://github.com/jmettraux/ruote
#
# Deployment
# Deploy docker containers for each func. define their role with ENV
# TODO: how to define number of containers?
#
# flow use cloudflow.rb # => define which flow to control
@kaiinui
kaiinui / cloudlock.rb
Created June 12, 2014 02:50
[WIP ]CloudLock Specification
#
# Amazon DynamoDB powered distributed Lock system
#
CloudLock.lock("sample_name") do
do_something
end # on the end, lock will be unlocked
# also unlock is available
FROM ubuntu:12.04
RUN apt-get update
RUN apt-get -qy install git vim tmux
RUN apt-get -qy install build-essential libpq-dev libv8-dev
RUN apt-get -qy install curl
RUN apt-get -qy install openssl libreadline-dev curl zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison libcurl4-openssl-dev
RUN adduser --disabled-password --home=/rails --gecos "" rails
RUN apt-get -qy install wget
RUN wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.1.tar.gz
@kaiinui
kaiinui / v.swift
Created June 18, 2014 07:33
Infinite Scroll with UICollectionView in Swift
import UIKit
class ViewController: UICollectionViewController, UICollectionViewDataSource, UICollectionViewDelegate {
override func collectionView(collectionView: UICollectionView!, numberOfItemsInSection section: Int) -> Int {
...
}
override func collectionView(collectionView: UICollectionView!, cellForItemAtIndexPath indexPath: NSIndexPath!) -> UICollectionViewCell! {
...
}
@kaiinui
kaiinui / AppledocSettings.plist
Last active August 29, 2015 14:10
template.podspec
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>--company-id</key>
<string>#{DOMAIN}</string>
<key>--project-company</key>
<string>#{ORGANIZATION}</string>
<key>--project-name</key>
<string>#{PROJECT}</string>