Skip to content

Instantly share code, notes, and snippets.

package hello
import arrow.core.*
import arrow.typeclasses.*
import arrow.instances.*
import java.util.Collections.list
fun main(args: Array<String>) {
val a = ForOption extensions {
binding {
@kkismd
kkismd / signature.rb
Created June 3, 2018 10:04
imitate sorbet typecheker
#! env ruby
class CodeSignature
def initialize(args)
@args = args
end
def returns(klass)
@ret = klass
puts "CodeSignature: @args = #{@args.inspect}"
puts "CodeSignature: @ret = #{@ret.inspect}"
@kkismd
kkismd / dog.py
Created May 12, 2018 09:36
mypy why
class Dog():
def __init__(self, name: str) -> None:
self.name: str = name
def bark(self) -> str:
return "Bow-wow (" + self.name + ")"
def test():
# No mypy error, but causes Rutime error at next line!!!
dog = Dog(123)
@kkismd
kkismd / temperature.rb
Created May 11, 2018 08:05
steep example
class Temperature
# @implements Temperature
private_class_method :new
def self.celsius(num)
new(num)
end
def self.fahrenheit(num)
@kkismd
kkismd / gi.sh
Created March 8, 2018 07:06
bash / zsh function `gi tlog` -> `git log`
# `git log` TYPO to `gi tlog`
function gi() {
a1=${1#t}
shift
git $a1 $*
}
@kkismd
kkismd / optional.rb
Created December 19, 2017 02:30
Optional class in Ruby
class Optional
private_class_method :new
class << self
def some(value)
new(value, false)
end
def none
new(nil, true)
@kkismd
kkismd / google-ime_azik.tsv
Created November 20, 2017 01:43 — forked from junkw/google-ime_azik.tsv
Google 日本語入力用 AZIK ローマ字テーブル (for macOS + US キーボード)
-
~
:
;
a
ba
bd べん
be
bh ぶう
bi
@kkismd
kkismd / Main.scala
Last active May 18, 2017 07:30
コンソールでつぶやくコマンド
import twitter4j._
object Main {
def main(args: Array[String]): Unit = {
val tweet = args.mkString(" ")
val status = TwitterFactory.getSingleton().updateStatus(tweet)
println("status id = " + status.getId.toString())
}
}
@kkismd
kkismd / remove.sh
Created March 15, 2017 03:04
Railsログのエスケープシーケンスを削除
ruby -p -e "gsub /\e\[\d{1,3}[mK]/, ''" < INPUT > OUTPUT
@kkismd
kkismd / memory_mesureable.rb
Last active March 2, 2017 03:25
ActiveRecordのメモリ使用量を見積もりたい
require 'objspace'
module MemoryMesureable
extend ActiveSupport::Concern
included do
delegate :memsize_of, to: ObjectSpace
end
def memsize