Skip to content

Instantly share code, notes, and snippets.

View Kuniwak's full-sized avatar
💭
I may be slow to respond.

Yuki Kokubun Kuniwak

💭
I may be slow to respond.
View GitHub Profile
@hatsugai
hatsugai / subseq.thy
Created May 7, 2020 06:25
subsequence
theory subseq imports "~~/src/HOL/Hoare/Hoare_Logic" begin
definition is_subseq :: "'a list => 'a list => bool" where
"is_subseq xs ys ==
(\<exists>c.
(\<forall>i. i + 1 < length ys --> c i < c (i + 1))
\<and> (length ys > 0 \<longrightarrow> c (length ys - 1) < length xs)
\<and> (\<forall>i. i < length ys \<longrightarrow> ys ! i = xs ! (c i)))"
fun is_subseq2 :: "'a list => 'a list => bool" where
@norio-nomura
norio-nomura / terminal.sh-session
Last active August 26, 2018 06:38
How to use `thread backtrace -e true` in `lldb`.
$ echo 'import Dispatch; func f() {}; DispatchQueue.global(qos: .default).async { f() }; dispatchMain()'|swiftc -
$ lldb
(lldb) target create main
Current executable set to 'main' (x86_64).
(lldb) b f
Breakpoint 1: 9 locations.
(lldb) process launch -v DYLD_LIBRARY_PATH=/usr/lib/system/introspection -v DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/usr/lib/libBacktraceRecording.dylib
Process 33297 launched: '/Users/norio/github/swift-dev/SourceKitten/main' (x86_64)
Process 33297 stopped
* thread #2, queue = 'com.apple.root.default-qos', stop reason = breakpoint 1.1
func c(_ g: @escaping (Int) -> Void) {}

func a() {
    let f: ((Int) -> Void) -> Void
    
    f = { (g) -> Void in
        c(g)
    }
}
// swift/stdlib/public/runtime/Metadata.cpp をプリプロセッサのみ実行した結果から抜粋
struct ValueWitnessTable;
namespace value_witness_types {
typedef OpaqueValue * (*initializeBufferWithCopyOfBuffer) (ValueBuffer *, ValueBuffer *, const Metadata *);
typedef void (*destroy) (OpaqueValue *, const Metadata *);
typedef OpaqueValue * (*initializeWithCopy) (OpaqueValue *, OpaqueValue *, const Metadata *);
typedef OpaqueValue * (*assignWithCopy) (OpaqueValue *, OpaqueValue *, const Metadata *);
typedef OpaqueValue * (*initializeWithTake) (OpaqueValue *, OpaqueValue *, const Metadata *);
class Number {}
class Zero : Number {}
class Succ<N:Number> : Number {}
typealias One = Succ<Zero>
typealias Two = Succ<Succ<Zero>>
typealias Three = Succ<Succ<Succ<Zero>>>
class Eq<S: Number, T: Number> {}
class Add<S: Number, T:Number> : Number {}
@tk0miya
tk0miya / tk0miya-sponsors-2021.md
Last active September 23, 2021 13:25 — forked from melpon/wandbox-sponsors.md
@tk0miya のスポンサー募集

(For English readers: please read https://github.com/sponsors/tk0miya instead)

@tk0miya の企業・個人スポンサーを募集します

@tkomiya は、日本在住の OSS 開発者です。
趣味として Sphinxpycmarkblockdiag などの OSS の開発やメンテナンスに携わっています。

ここ数年の活動の中心は Sphinx です。 Sphinx は PythonLinux カーネルをはじめとして、数多くの OSS のドキュメントに利用されているドキュメンテーションツールです。 Sphinx プロジェクトはごく少人数のメンテナによって活動しており、(明確な役割として定義はされていないものの) リードメンテナ、メインメンテナとして活動しています。

class Binding
def return_if(name)
eval "return #{name}" if local_variable_get(name)
end
end
def foo(v)
binding.return_if(:v)
'v is nil'
end
@sunaot
sunaot / writing_unit_test.md
Last active February 20, 2022 06:57
テストを書くか書かないかの判断の話

ユニットテストでテストを書くか書かないかの判断の話

お題

メソッドの出力の結果が、true か false のどちらでも返ってくる可能性がある場合、assert 文を書く時は true の場合だけで良いのだろうか

テストとは

まず、基本の考えとしてなぜテストをするのか?というのがあります。

#!/usr/bin/env ruby
if ARGV.size != 3
puts "usage: ack-sed <pattern> <replace-string> <dir>"
end
query, replace, dir = ARGV
system("ack #{query} #{dir} | cut -d':' -f1 | uniq | LANG=C xargs sed -i -e 's/#{query}/#{replace}/g'")