Skip to content

Instantly share code, notes, and snippets.

@x7c1
x7c1 / karabiner.json
Last active September 2, 2024 04:02
(left_shift, right_shift) -> (eisuu, kana)
{
"description": "シフトキーを単体で押したときに、英数・かなキーを送信する。(左シフトキーは英数、右シフトキーはかな)",
"manipulators": [
{
"from": {
"key_code": "left_shift",
"modifiers": {
"optional": [
"any"
]
@x7c1
x7c1 / sample.ts
Last active May 31, 2018 13:05
example of nominal typing by TypeScript
const showHtml = (html: Html) => console.log(`${html}`);
const html = Html("tagged html sample");
showHtml(html); // tagged html sample
const css = Css("tagged css sample");
showHtml(css);
/*
error TS2345: Argument of type 'TaggedString<"css">' is not assignable to parameter of type 'TaggedString<"html">'.
Types of property 'type' are incompatible.
# http://scalameta.org/scalafmt/#Configuration
align {
openParenCallSite = false
openParenDefnSite = false
}
align = false
assumeStandardLibraryStripMargin = true
@x7c1
x7c1 / CustomController.scala
Created April 10, 2018 16:25
Controller to handle a custom request on Play Framework
package controllers
import play.api.mvc.{ActionBuilder, AnyContent, BaseController, BodyParser, Request, Result}
import scala.concurrent.{ExecutionContext, Future}
case class CustomRequest[A](underlying: Request[A]) {
def body: A = underlying.body
}
"gitlens.blame.line.enabled": false,
"gitlens.codeLens.enabled": false
@x7c1
x7c1 / SamplePage.js
Created December 10, 2017 16:50
redux-seal middleware
import React from 'react';
import { connect } from 'react-redux';
import { counterButton } from './counterButton';
const SamplePageView = props => {
const button = props.counterButton();
return (
<div className='react-sample-area'>
<button type='button' onClick={button.onClick}>
{button.label}
export class Animator {
constructor() {
this._current = 0;
this._running = false;
this._interval = 200;// [msec]
}
run({ from, to, onTick, onFinish }) {
if (this._running) {
this._cancelAnimation();
}
@x7c1
x7c1 / Close.scala
Last active April 29, 2017 17:49
improve Close module
package continuation
import close.Closer
object Close {
def apply0[A: Closer](res: => A): Continuation0[A] =
Continuation0 { f =>
val target = res
try f(target)
const onUnknown = key => new Proxy({}, {
get(target, name) {
switch (name) {
case 'or':
Console.debug(`unknown key [${key}]`);
return initial => initial;
default:
return onUnknown(key);
}
},
object Sample {
def main(args: Array[String]): Unit = {
val x = Seq(
Seq("F", "F", "M", "M", "M") map ("SEX" -> _),
Seq(158, 162, 177, 173, 166) map ("HEIGHT" -> _),
Seq(51D, 55D, 72D, 57D, 64D) map ("WEIGHT" -> _)
).transpose