This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Any, Callable, TypeVar, Tuple, cast | |
F = TypeVar('F', bound=Callable[..., Any]) | |
# A decorator that preserves the signature. | |
def my_decorator(func: F) -> F: | |
def wrapper(*args, **kwds): | |
print("Calling", func) | |
return func(*args, **kwds) | |
return cast(F, wrapper) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default: | |
image: python:3.9 | |
stages: | |
- lint | |
- test | |
- deploy | |
# before_script: | |
# - pip install flake8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@startuml | |
interface Iすごいサービス { | |
Execute : () → string | |
} | |
class Myとてもすごいサービス { | |
Execute : () → string | |
さいこーサービス : Iさいこーサービス | |
感情サービス : I感情サービス |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#nullable enable | |
using System; | |
using System.Linq; | |
using Autofac; | |
using Autofac.Extras.DynamicProxy; | |
using Castle.DynamicProxy; | |
using static System.Console; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
public abstract class Maybe<T> { | |
public Maybe<TResult> Map<TResult>(Func<T, TResult> selector) | |
{ | |
return this.Bind(a => new Just<TResult>(selector(a))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Array | |
import System.Random | |
import Data.Ratio ((%), Ratio) | |
type MatrixIndex = (Int, Int) | |
type MatrixElement = Rational | |
type MatrixValue = Array MatrixIndex MatrixElement | |
newtype MatrixDimension = MatrixDimension Int deriving (Show) | |
data Matrix = Matrix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Eventクラスの作成 | |
# Immutable.jsが必要 | |
class Event | |
constructor: -> | |
@funcs = new Immutable.Set() | |
register: (func) -> | |
@funcs = @funcs.add(func) | |
unregister: (func) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://en.wikipedia.org/wiki/Levenshtein_distance | |
type Length = Int | |
type Distance = Int | |
levenshteinDistance :: String -> String -> Distance | |
levenshteinDistance a b = lev a b i j | |
where i = length a | |
j = length b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Time.LocalTime (LocalTime, ZonedTime) | |
import Data.Time.Clock (UTCTime) | |
import Data.Time.Format ( parseTimeM | |
, defaultTimeLocale | |
, TimeLocale(..) | |
, ParseTime | |
) | |
testTime :: [UTCTime] | |
testTime = parseTimeM True defaultTimeLocale "%Y-%m-%dT%H:%M:%S%z" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Control.Monad.Except | |
type IOE a = IO (Either String a) | |
req1 :: IOE Int | |
req1 = return . Right $ 1 | |
req2 :: Int -> IOE Int |
NewerOlder