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
# typed: ignore | |
# Ruby 2.7 (Pattern Matching) | |
require 'sorbet-runtime' | |
class FizzBuzz | |
extend T::Sig | |
sig {params(n: Integer).void} | |
def self.check_number(n) |
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
# typed: true | |
require 'sorbet-runtime' | |
class FizzBuzz | |
extend T::Sig | |
sig {params(n: Integer).void} | |
def self.check_number(n) | |
if n <= 0 then raise ArgumentError end | |
end |
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
# typed: ignore | |
require_relative '../fizzbuzz' | |
describe 'FizzBuzz' do | |
it 'check_number' do | |
f = ->(n) { FizzBuzz.check_number(n) } | |
expect{f.(-1)}.to raise_error ArgumentError | |
expect{f.(0)}.to raise_error ArgumentError | |
expect{f.(1)}.to_not raise_error | |
end |
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
# typed: true | |
# Ruby 2.6 (Function Composition, filter) | |
require 'sorbet-runtime' | |
class MailHeader | |
extend T::Sig | |
TEST_FILE_PATH = '/tmp/__mail_header_test_file__' |
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
# typed: ignore | |
require_relative '../mail_header' | |
describe 'MailHeader' do | |
it 'split_header_body' do | |
f = ->(text) { MailHeader.split_header_body(text) } | |
expect{f.("abcdefghi")}.to raise_error ArgumentError | |
expect(f.("abc\r\n\r\ndef\r\n\r\nghi")).to eq ["abc", "def\r\n\r\nghi"] | |
end |
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
#!/usr/bin/env julia | |
using HTTP | |
function print_usage() | |
println("Usage: send_chatwork token room_id body") | |
end | |
function make_chatwork_url(room_id::String)::String | |
"https://api.chatwork.com/v2/rooms/$room_id/messages" |
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
/* | |
[dependencies] | |
widestring = "0.4.0" | |
lazy_static = "1.3.0" | |
[dependencies.winapi] | |
version = "0.3.7" | |
features = ["winuser", "winbase", "libloaderapi", "hidusage"] | |
*/ |
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
/* | |
javac --release 12 --enable-preview -Xlint:unchecked TestSwitchExp.java | |
java --enable-preview TestSwitchExp | |
*/ | |
import java.util.stream.IntStream; | |
public class TestSwitchExp { | |
static class Tuple<X, Y> { | |
public final X x; |
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
open System | |
open System.IO | |
open System.Text.RegularExpressions | |
let read_file (path:string): string option = | |
if (File.Exists path) then Some(File.ReadAllText path) else None | |
let split_header_body (text:string): (string*string) option = | |
match text.Split([|"\r\n\r\n"|], 2, StringSplitOptions.None) with | |
| [| header; body|] -> Some(header, body) |
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 java.nio.file._ | |
object mail_header { | |
def read_file(path: String): Option[String] = { | |
val p = Paths.get(path) | |
if (Files.exists(p)) Some(new String(Files.readAllBytes(p))) else None | |
} | |
def split_header_body(text: String): Option[(String, String)] = { | |
text.split("\r\n\r\n", 2) match { |
NewerOlder