Skip to content

Instantly share code, notes, and snippets.

@tamanugi
tamanugi / K8sService.java
Created Aug 10, 2021
kubernetes-client/java Trial code. create yaml & create deployment via API.
View K8sService.java
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;
View d_powerful_discount_tickets.ex
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)
@tamanugi
tamanugi / sieve_of_eratosthenes.exs
Last active Nov 19, 2020
エラトステネスの篩 for 素因数分解
View sieve_of_eratosthenes.exs
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))
@tamanugi
tamanugi / ex_ahocora.ex
Last active Sep 28, 2020
ex_ahocora.ex
View ex_ahocora.ex
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
@tamanugi
tamanugi / EvolutiosModule.scala
Created Feb 27, 2020
Playframework Custom Evolutions
View EvolutiosModule.scala
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
@tamanugi
tamanugi / file0.txt
Last active Jan 29, 2018
[メモ]CentOS7にGitlab-runnerとDockerを構築 ref: https://qiita.com/tamanugi/items/fedbd60f8b1b907727b4
View file0.txt
$ sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
@tamanugi
tamanugi / zundoko.exs
Last active Nov 28, 2017
ズンドコきよし with Elixir
View zundoko.exs
defmodule Zundoko do
@zun "ズン"
@doko "ドコ"
@kiyoshi "キ ・ ヨ ・ シ!"
def run() do
gen_zundoko()
|> show_list
|> call
@tamanugi
tamanugi / app.js
Last active Dec 24, 2018
Puppeteerを使って指定したDOMのみのスクリーンショットを取得する ref: https://qiita.com/tamanugi/items/8cc1266265457f13b9ea
View app.js
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 翻訳')
@tamanugi
tamanugi / file0.txt
Last active Aug 1, 2017
org-modeでclock-inしているタスクをMacのメニューバーに表示する ref: http://qiita.com/tamanugi/items/ef43056d5c9709e4f7ab
View file0.txt
$ brew cask install bitbar
View file0.txt
module Main exposing (..)
import Html exposing (Html, button, div, text, program)
import Html.Events exposing (onClick)
-- モデル