Skip to content

Instantly share code, notes, and snippets.

View kakajika's full-sized avatar
🏠
STAY HOME

Keita Kajiwara kakajika

🏠
STAY HOME
View GitHub Profile
@kakajika
kakajika / svn-max.sh
Last active August 29, 2015 14:20
Echo svn working copy's max revision number including external files.
echo $(svn status -v | awk '/^ *[0-9]* *[0-9]* .*$/ {if(REV<$2) REV=$2} END{print REV}')
@kakajika
kakajika / twat.d.ts
Created July 1, 2015 14:26
Type definition file for twat [twitter client for node.js].
// twat.d.ts
declare module "twat" {
var client: Twitter.Client;
export = client;
}
declare module Twitter {
interface AuthParams {
@kakajika
kakajika / kue.d.ts
Created July 1, 2015 16:57
Type definition file for kue [Priority job queue for node.js]
// kue.d.ts
///<reference path='../node/node.d.ts' />
declare module "kue" {
import http = require('http');
export var app: http.Server;
export var createQueue: (opts?: {redis?: any}) => Kue.Queue;
}
@kakajika
kakajika / flatMap.ts
Created July 3, 2015 18:52
Array.prototype.flatMap method in TypeScript.
interface Array<T> {
flatMap<E>(callback: (t: T) => Array<E>): Array<E>
}
Object.defineProperty(Array.prototype, 'flatMap', {
value: function(f: Function) {
return this.reduce((ys: any, x: any) => {
return ys.concat(f.call(this, x))
}, [])
},
//
// Created by kaji on 15/08/17.
//
#ifndef JNIUTIL_JNIPARCEL_H
#define JNIUTIL_JNIPARCEL_H
#include <string>
#include <vector>
#include <memory>
obj/
gdb.setup
gdbserver
@kakajika
kakajika / bridgebot.coffee
Last active September 23, 2015 08:59
Hubot script for bridging channel over two teams in Slack.
# bridgebot.coffee
#
# Description:
# Bot for bridging channel with another Slack team.
qs = require 'querystring'
bridgeMessage = (robot, userid, username, text) ->
return unless text.length > 0
@kakajika
kakajika / CancellableDelayedTask.swift
Created October 26, 2015 08:52
Cancellable delayed task in Swift.
class CancellableDelayedTask {
var cancelled = false
func run(delay: Double, task: () -> Void ) {
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay))
dispatch_after(time, dispatch_get_main_queue()) { [unowned self] () -> Void in
if !self.cancelled {
task()
}
}
}
@kakajika
kakajika / ScopeFuncs.swift
Last active June 21, 2023 13:11
A port of Kotlin's scope functions to Swift.
protocol ScopeFunc {}
extension ScopeFunc {
@inline(__always) func apply(block: (Self) -> ()) -> Self {
block(self)
return self
}
@inline(__always) func letIt<R>(block: (Self) -> R) -> R {
return block(self)
}
}
@kakajika
kakajika / CurveHitTester.java
Last active March 28, 2016 09:51
Android tap hit tester for lines, quadratic bezier curves, cubic bezier curves
import android.graphics.PointF;
public class CurveHitTester {
private static final float FLT_EPSILON = 1.1920928955078125E-7f;
private static final float PI_2 = (float) Math.PI / 2.0f;
public static boolean hitTestLine(PointF point, PointF origin, PointF destination, float lineWidth) {
PointF[] vertices = new PointF[]{ origin, destination };
return hitTestCurve(point, vertices, 1, lineWidth);