{{ message }}

Instantly share code, notes, and snippets.

🏠
Working from home

Takanori Ishikawa ishikawa

🏠
Working from home
Created Jul 17, 2021
"The Art and Craft of Problem Solving" 1.1.3
View solve.py
 combinations = set() for x in range(1, 37): for y in range(1, 37): for z in range(1, 37): if x * y * z == 36: sisters = [x, y, z] sisters.sort(reverse=True) sisters = tuple(sisters) if sisters not in combinations:
Created Jul 17, 2021
Rust: Converting between Enums and Strings
View enum_str.rs
 pub enum Foo { A, B, } impl Foo { pub fn variants() -> impl Iterator { array::IntoIter::new([Self::A, Self::B]) } }
Created Jan 29, 2021
The node implementation for expo-crypto
View index.ts
 /* MIT License Copyright (c) 2021 Takanori Ishikawa Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Created Jan 29, 2021
The node implementation for expo-random
View index.ts
 /* MIT License Copyright (c) 2021 Takanori Ishikawa Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Created Jan 22, 2021
View hello.py
 print('Hello, World!')
Last active Jul 27, 2020
submap?/3 for Elixir's map. It's useful for testing API response (see submap_usage_test.exs).
View map_helpers.ex
 defmodule MapHelpers do @doc """ Checks if `map1`'s entries are all contained in `map2`. ## Options - `:recursive` - Recursively checks if a value is map (Default: `false`) ## Examples
Created Jun 25, 2020
Login with the shell into the first matching pod returned from kubectl get pod
View gist:3f340f1274b3eb384156355665559ed7
 kubectl get pod | awk '{ print \$1 }' | grep '^gateway-' | head -1 | xargs -o -I {} kubectl exec -it {} -- /bin/bash
Last active Dec 10, 2019
My preferred way to write parameterized tests in Elixir.
View parameterized_test.exs
 # The helper functions for the test module. To make it possible to import # this helper module in the test module, define this module outside the context that uses it. defmodule MyTest.Helpers do @spec fake_params(Enumrable.t()) :: map def fake_params(override \\ %{}) do %{ country: "jp", phone_number: Faker.phone_number(), locale: "ja", company: "My Company",
Last active Oct 3, 2019
Passing in options: Maps vs. Keyword lists
View function_options.ex
 # https://elixirforum.com/t/passing-in-options-maps-vs-keyword-lists/1963 @doc """ do foo operation ## Options - `:option1` - option 1 - `:option2` - option 2 """
Last active Sep 22, 2019
Compile different function on Mix env and test
View my_module.ex
 defmodule MyModule do @moduledoc false if Mix.env() == :prod do @foo Application.fetch_env!(:myapp, :foo) def foo, do: @foo else def foo, do: Application.fetch_env!(:myapp, :foo) end end