Skip to content

Instantly share code, notes, and snippets.

View hirohitokato's full-sized avatar

Hirohito Kato hirohitokato

View GitHub Profile
@kat0h
kat0h / AnalogClockQuine.rb
Last active September 4, 2022 05:44
プログラム
# アナログ時計の形に整形された 自分自身と等しいプログラムを出力するプログラム
eval$s=%w'a=Array;s=
34;b=a.new(s){a.new(s,0)};(0..
.s).each{|x|(0...s).each{|y|xx=x-s/2.1
;yy=y-s/2.1;i=xx**2+yy**2;b[y][x]=(s/2.8)*
*2<i&&i<(s/2)**2?1:((i<(s/20)**2)?1:0)}};l=Math;
t=Time.new;h,m=( t.hour%12+t.min*
0.00872664625) *0.5235,t.min*
0.1047;c=->(p, z,u,d,e){g=d
-z;i=(g>=0)? 1:-1;o=e-u;j
@kat0h
kat0h / vim9script4pythondevelopers.md
Last active March 31, 2021 07:51
Vim9 script for Python Developers

Vim9 script for Python Developers

Vim9 scriptはVim scriptとの互換をなくし変数の型縛りを導入したり、コンパイルをすることなどにより、高速化を実現した新しい処理系です。

defコマンドで定義された関数内、またはVim script内でvim9scriptコマンドを使うことで利用できます(vim9scriptコマンドの後ではfunctionコマンドは利用できません)。

この記事は、 https://gist.github.com/yegappan/16d964a37ead0979b05e655aa036cad0 の内容を元にVim(v8.2.2576)上のVim9 scriptで動作するように改変したものです。

Vim9 scriptで動作を確認できなかったもの、まだ実装されていなものはpassと表記し、省略しています。

@gokselkoksal
gokselkoksal / Channel.swift
Last active September 16, 2022 03:53
Channel implementation
public class Channel<Value> {
private class Subscription {
weak var object: AnyObject?
private let notifyBlock: (Value) -> Void
private let queue: DispatchQueue
var isValid: Bool {
return object != nil
@hirohitokato
hirohitokato / ArrayExtension.swift
Last active March 12, 2024 12:02
Get downsampled array from original data, using vDSP. For only Float array.
extension Array where Element == Float {
// @see: HOW TO CREATE A SOUNDCLOUD LIKE WAVEFORM IN SWIFT 3
// (https://miguelsaldana.me/2017/03/13/how-to-create-a-soundcloud-like-waveform-in-swift-3/)
func downSampled(binSize: Int, multiplier: Float = 1.0) -> [Float] {
let count = self.count
var processingBuffer = [Float](repeating: 0.0,
count: Int(count))
let sampleCount = vDSP_Length(count)
@zwaldowski
zwaldowski / Activity.swift
Last active February 15, 2024 18:49
os_activity_t for Swift 3
//
// Activity.swift
//
// Created by Zachary Waldowski on 8/21/16.
// Copyright © 2016 Zachary Waldowski. Licensed under MIT.
//
import os.activity
private final class LegacyActivityContext {
@nownabe
nownabe / .commit_template
Created July 5, 2016 06:54
Emojiで楽しく綺麗なコミットを手に入れる
# ==== Emojis ====
# 🐛 :bug: バグ修正
# 👍 :+1: 機能改善
# ✨ :sparkles: 部分的な機能追加
# 🎉 :tada: 盛大に祝うべき大きな機能追加
# ♻️ :recycle: リファクタリング
# 🚿 :shower: 不要な機能・使われなくなった機能の削除
# 💚 :green_heart: テストやCIの修正・改善
//
// Collection+movingAverage.swift
//
// inspired by https://gist.github.com/hirohitokato/5bfc5836480d68074135820d73c04794
import Foundation
public protocol ArithmeticType: Comparable, IntegerLiteralConvertible {
func +(lhs: Self, rhs: Self) -> Self
@norio-nomura
norio-nomura / String+StaticString.swift
Last active April 5, 2016 10:40
StringインスタンスをStaticStringとして使う `func withStaticString<T>(@NoEscape f: StaticString -> T)`
import Foundation
extension String {
func withStaticString(@noescape f: StaticString -> Void) {
withCString {
let rawPointer = $0._rawValue
let byteSize = lengthOfBytesUsingEncoding(NSUTF8StringEncoding)._builtinWordValue
let isASCII = true._getBuiltinLogicValue()
let staticString = StaticString(_builtinStringLiteral: rawPointer, byteSize: byteSize, isASCII: isASCII)
f(staticString)
protocol Pokemon {
typealias PokemonType
func attack(move: PokemonType)
}
class Pikachu: Pokemon {
func attack(move: Int) {
print("pika")
}
}
@norio-nomura
norio-nomura / QuickHelpKeywordsOnXcode7.swift
Last active February 26, 2017 00:18
Xcode 7が認識するQuickHelpのキーワード
/// not start with - makes Description slice
/// - Parameter parameterName: is slice label
/// - Throws: is slice label
/// - Returns: is slice label
/// - Attention: is section label
/// - Author: is section label
/// - Authors: is section label
/// - Bug: is section label
/// - Complexity: is section label
/// - Copyright: is section label