This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ikku.coffee | |
# | |
# Description: | |
# Bot for detecting ikku pattern. | |
# | |
{tokenize} = require 'kuromojin' | |
{nfkc} = require 'unorm' | |
haiku_pattern = [5, 7, 5] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.graphics.Color; | |
import android.support.annotation.ColorInt; | |
import android.support.annotation.NonNull; | |
import android.support.annotation.Size; | |
public class ColorUtil { | |
public static @ColorInt int lighten(@ColorInt int color, float value) { | |
float[] hsl = colorToHSL(color); | |
hsl[2] += value / 100; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mov2gif() { | |
command ffmpeg -i $1 -vf "scale=320:-1" -pix_fmt rgb24 -r 30 -f gif - | gifsicle --delay=3 --optimize=3 > $2 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author kakajika | |
* @since 2016/04/27 | |
*/ | |
public class MaxLinearLayout extends LinearLayout { | |
public MaxLinearLayout(Context context) { | |
super(context); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
enum Zundoko: CustomStringConvertible { | |
case Start | |
indirect case Zun(Zundoko) | |
indirect case Doko(Zundoko) | |
indirect case Kiyoshi(Zundoko) | |
var description: String { | |
switch self { | |
case Start: return "スタート!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PaperSwift | |
let ExampleScript1 = { (paper: PaperView) in | |
var center: CGPoint | |
var width: CGFloat | |
var height: CGFloat | |
var pathHeight: CGFloat | |
let points = 8 | |
let path = paper.Path() | |
path.fillColor = UIColor.darkGrayColor() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
public class CurveHitTester { | |
typealias CurvePointMapper = (t: CGFloat, u: CGFloat) -> (x: CGFloat, y: CGFloat) | |
public static func hitTestLine(point: CGPoint, p1: CGPoint, p2: CGPoint, segments: Int, lineWidth: CGFloat) -> Bool { | |
return hitTestPoints(point, segments: segments, lineWidth: lineWidth) { (t, u) in | |
let x = u * p1.x + t * p2.x | |
let y = u * p1.y + t * p2.y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
} | |
} | |
} |