Skip to content

Instantly share code, notes, and snippets.

View maedaunderscore's full-sized avatar

Yasuyuki Maeda maedaunderscore

View GitHub Profile
@maedaunderscore
maedaunderscore / future_and_dispatch.swift
Created October 29, 2020 09:27
swift + CombineフレームワークのFuture + DispatchQueueを組み合わせる
import Combine
import SwiftUI
func run1() -> Future<String, Never>{
return Future{ promise in
promise(.success("OK1: \(Thread.isMainThread)"))
}
}
func run2() -> Future<String, Never>{
@maedaunderscore
maedaunderscore / IEのアドレスバーとかメニューを強制的に表示
Created January 19, 2012 13:57
IEのアドレスバーとかメニューを強制的に表示
Option Explicit
Dim OBJ_FSO
Dim OBJ_Browser
Dim STR_ProgramName
Set OBJ_FSO = CreateObject("Scripting.FileSystemObject")
For Each OBJ_Browser In CreateObject("Shell.Application").Windows
STR_ProgramName = OBJ_FSO.GetFileName(OBJ_Browser.FullName)
If LCase(STR_ProgramName) = "iexplore.exe" Then
<table>
<tbody>
<tr>
<td>13:10</td>
<td colspan="4"><b>挨拶</b></td>
</tr>
<tr>
<td>13:12〜13:30</td>
<td colspan="4"><b>忍者発表会</b></td>
</tr>
@maedaunderscore
maedaunderscore / memo.st
Last active December 22, 2015 16:00
ScratchをSmalltalkで操作してジングルベルを演奏する(https://www.youtube.com/watch?v=BJ9-j91ZUXU) でコピペしているコード
* 音のブロックを作る + ユーティリティクラス定義
[| last soundColor controlColor |
Smalltalk garbageCollect.
stage _ ScratchStageMorph allInstances first.
soundColor _ (stage class blockColorFor: 'sound').
controlColor _ (stage class blockColorFor: 'control').
last _ nil.
#(
(1.0
Theorem XtimesYinZ_spec : forall st a b st',
st X = a ->
st Y = b ->
XtimesYinZ / st || st' ->
st' Z = a * b.
Proof.
@maedaunderscore
maedaunderscore / arith.scala
Last active December 17, 2015 11:39
TAPL 3.5.17の演習問題
Arith extends App {
type Info = String
sealed trait Term
case class TmTrue(s: Info) extends Term
case class TmFalse(s: Info) extends Term
case class TmIf(s: Info, cond: Term, t: Term, f: Term) extends Term
case class TmZero(s: Info) extends Term
case class TmSucc(s: Info, t: Term) extends Term
case class TmPred(s: Info, t: Term) extends Term
(* **** Exercise: 3 stars (optimize_0plus_b) *)
(** **** 練習問題: ★★★ (optimize_0plus_b) *)
Fixpoint optimize_bexp_0plus (e: bexp) : bexp :=
match e with
| BTrue => BTrue
| BFalse => BFalse
| BEq a1 a2 => BEq (optimize_0plus a1) (optimize_0plus a2)
| BLe a1 a2 => BLe (optimize_0plus a1) (optimize_0plus a2)
| BNot b => BNot (optimize_bexp_0plus b)
| BAnd b1 b2 => BAnd (optimize_bexp_0plus b1) (optimize_bexp_0plus b2)
import scala.util.continuations._
object Main extends App{
abstract sealed class Computation[+A]
case class Yielded[A](k: Unit => Computation[A], v: A) extends Computation[A]
case object Done extends Computation[Nothing]
type yieldable[A] = cps[Computation[A]]
def make[A] (body: (A => Unit @yieldable[A]) => Unit @yieldable[A]): Iterator[A] =
@maedaunderscore
maedaunderscore / gist:1080369
Created July 13, 2011 14:19
sbtからnunitを実行するシェルをたたいて結果を通知
import sbt._
import Keys._
import Process._
import java.io.File
import java.awt.event._
import java.awt.TrayIcon._
object MyBuild extends Build {
override lazy val projects = Seq(root)
lazy val root = Project("root", file(".")) settings(
@maedaunderscore
maedaunderscore / Chap5.v
Created March 27, 2011 06:24
CPDT Chap5 のプログラムの非停止性のサンプルの実装と証明を分けてみた。
Definition reg := nat.
Definition label := nat.
Inductive instr : Set :=
| Imm :reg -> nat -> instr
| Copy : reg -> reg -> instr
| Jmp : label -> instr
| Jnz : reg -> label -> instr.
Definition regs := reg -> nat.