$ iex -S mix
iex(1)> B.new_hoge
:fuga
This file contains hidden or 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
| defmodule Trie do | |
| def build(binaries) when is_list(binaries) do | |
| binaries | |
| |> Enum.reduce(%{}, &_insert(&2, &1)) | |
| end | |
| defp _insert(trie, binary) when is_binary(binary) do | |
| _insert(trie, String.codepoints(binary)) | |
| end |
This file contains hidden or 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
| package jp.co.monocrea.monolib4iac.domain.eks; | |
| import com.google.common.io.Files; | |
| import io.kubernetes.client.openapi.ApiClient; | |
| import io.kubernetes.client.openapi.ApiException; | |
| import io.kubernetes.client.openapi.apis.AppsV1Api; | |
| import io.kubernetes.client.openapi.models.V1Deployment; | |
| import io.kubernetes.client.openapi.models.V1DeploymentBuilder; | |
| import io.kubernetes.client.openapi.models.V1LabelSelectorBuilder; | |
| import io.kubernetes.client.openapi.models.V1PodTemplateSpec; |
This file contains hidden or 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
| defmodule PowerfulDiscountTickets.Main do | |
| def read_array() do | |
| IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1) | |
| end | |
| def main() do | |
| [_, m] = read_array() | |
| as = read_array() |> Enum.sort(:desc) | |
| solve(as, m) |
This file contains hidden or 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
| defmodule SieveOfEratosthenes do | |
| def run(n) do | |
| sqrt = :math.sqrt(n) |> floor() | |
| {time, d} = :timer.tc(SieveOfEratosthenes, :init_d, [n]) | |
| IO.inspect(time, label: "init d time") | |
| # 偶数を飛ばす | |
| Stream.iterate(13, &(&1 + 2)) |
This file contains hidden or 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
| defmodule State do | |
| defstruct id: 0, next: %{}, failure: 0, outputs: [] | |
| def update_failure(%State{} = state, new_id) do | |
| Map.update!(state, :failure, fn _ -> new_id end) | |
| end | |
| def add_next(%State{} = state, character, id) do | |
| Map.update!(state, :next, &Map.put(&1, character, id)) | |
| end |
This file contains hidden or 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.io.{ByteArrayOutputStream, Closeable, IOException, InputStream} | |
| import javax.inject._ | |
| import play.Logger | |
| import play.api.Environment | |
| import play.api.db.evolutions._ | |
| import play.api.inject._ | |
| import play.api.libs.Collections | |
| import scala.io.Codec |
This file contains hidden or 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
| $ sudo yum install -y yum-utils \ | |
| device-mapper-persistent-data \ | |
| lvm2 |
This file contains hidden or 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
| defmodule Zundoko do | |
| @zun "ズン" | |
| @doko "ドコ" | |
| @kiyoshi "キ ・ ヨ ・ シ!" | |
| def run() do | |
| gen_zundoko() | |
| |> show_list | |
| |> call |
This file contains hidden or 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
| const puppeteer = require('puppeteer'); | |
| (async () => { | |
| const browser = await puppeteer.launch({headless: true}); | |
| const page = await browser.newPage(); | |
| const targetElementSelector = '#tw-container' | |
| await page.goto('https://google.co.jp') | |
| await page.type('pupperteer 翻訳') |
NewerOlder