Skip to content

Instantly share code, notes, and snippets.

View takayoshiotake's full-sized avatar

Takayoshi Otake takayoshiotake

View GitHub Profile
@takayoshiotake
takayoshiotake / saikyou_japanese_modification.json
Last active May 5, 2023 03:25
My the saikyou Karabiner Complex Modification for using Japanese macOS with ANSI keyboard.
{
"title": "Saikyou Japanese Modification v1.4.0",
"rules": [
{
"description": "Kana One Way",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "spacebar",
/******************************************************************************
* Half Duplex Software UART on the LaunchPad
*
* Description: This code provides a simple Bi-Directional Half Duplex
* Software UART. The timing is dependant on SMCLK, which
* is set to 1MHz. The transmit function is based off of
* the example code provided by TI with the LaunchPad.
* This code was originally created for "NJC's MSP430
* LaunchPad Blog".
*
#pragma once
#include <functional>
namespace scopefunction {
template <typename T> T apply(T&& value, std::function<void(T&)> block) {
block(value);
return value;
}
@takayoshiotake
takayoshiotake / ScopeFunctionExtension.cs
Created November 2, 2018 07:46
Scope function for C# like Kotlin
using System;
namespace ScopeFunctionExtension
{
static class Extensions
{
public static T Apply<T>(this T obj, Action<T> block)
{
block(obj);
return obj;
@takayoshiotake
takayoshiotake / ScopeFunction.swift
Last active October 31, 2018 07:52
Scope function for Swift like Kotlin
import Foundation
infix operator =>: ScopeFunctionPrecedence
precedencegroup ScopeFunctionPrecedence {
higherThan: AssignmentPrecedence
associativity: left
}
@discardableResult
@takayoshiotake
takayoshiotake / ColorType.swift
Last active December 22, 2016 15:06
Color blending with Swift
#if os (macOS)
import AppKit
typealias ColorType = NSColor
#elseif os (iOS)
import UIKit
typealias ColorType = UIColor
#endif
extension ColorType {
var r: CGFloat {
@takayoshiotake
takayoshiotake / profile.swift
Created December 20, 2016 12:33
My profile with Swift Color Literal (needs Xcode)
/*
#colorLiteral(red: 0.9411764706, green: 0.9411764706, blue: 0.9411764706, alpha: 1)#colorLiteral(red: 0.9411764706, green: 0.9411764706, blue: 0.9411764706, alpha: 1)#colorLiteral(red: 0.9411764706, green: 0.9411764706, blue: 0.9411764706, alpha: 1)#colorLiteral(red: 0.9411764706, green: 0.9411764706, blue: 0.9411764706, alpha: 1)#colorLiteral(red: 0.9411764706, green: 0.9411764706, blue: 0.9411764706, alpha: 1)#colorLiteral(red: 0.9411764706, green: 0.9411764706, blue: 0.9411764706, alpha: 1)#colorLiteral(red: 0.9411764706, green: 0.9411764706, blue: 0.9411764706, alpha: 1)#colorLiteral(red: 0.9411764706, green: 0.9411764706, blue: 0.9411764706, alpha: 1)#colorLiteral(red: 0.9411764706, green: 0.9411764706, blue: 0.9411764706, alpha: 1)#colorLiteral(red: 0.9411764706, green: 0.9411764706, blue: 0.9411764706, alpha: 1)#colorLiteral(red: 0.9411764706, green: 0.9411764706, blue: 0.9411764706, alpha: 1)#colorLiteral(red: 0.9411764706, green: 0.9411764706, blue: 0.9411764706, alpha: 1)
#colorLiteral(red: 0.941
@takayoshiotake
takayoshiotake / xdump.swift
Created November 24, 2016 15:08
custom dump function with Swift
//
// xdump.swift
//
// Created by OTAKE Takayoshi on 2016/11/24.
// Copyright © 2016 OTAKE Takayoshi. All rights reserved.
//
import Foundation
fileprivate func xdump0<T>(_ value: T, indent: String = "", label: String = "") {
@takayoshiotake
takayoshiotake / UIColor+hex.swift
Created October 29, 2016 12:44
Provides UIColor convenience init with 24 or 32 bits hex value: e.g. 0xffffff(white 100%), 0x00000080(black 50%), and so on.
//
// UIColor+hex.swift
//
// Created by OTAKE Takayoshi on 2016/10/29.
// Copyright © 2016 OTAKE Takayoshi. All rights reserved.
//
import UIKit
extension UIColor {
@takayoshiotake
takayoshiotake / Setup Electron Dev on macOS.md
Last active September 30, 2016 15:03
Setup Electron Dev on macOS

Setup Electron Dev on macOS

Requirements

  • MacPorts

Environment

$ sw_vers
ProductName:	Mac OS X