Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Takanori Ishikawa ishikawa

🏠
Working from home
View GitHub Profile
@ishikawa
ishikawa / index.ts
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
@ishikawa
ishikawa / index.ts
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
@ishikawa
ishikawa / map_helpers.ex
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
@ishikawa
ishikawa / gist:3f340f1274b3eb384156355665559ed7
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
@ishikawa
ishikawa / parameterized_test.exs
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",
@ishikawa
ishikawa / function_options.ex
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
"""
@ishikawa
ishikawa / my_module.ex
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
@ishikawa
ishikawa / kebab.sh
Last active Jul 12, 2019
Convert phrase to kebab-case
View kebab.sh
# Type your phrase then ^D
perl -pe 'chop;s/([a-z]+)/lc($1)/ige' | perl -lpe 's/[^a-z0-9]+/-/ig'
@ishikawa
ishikawa / format_json.sh
Created Mar 11, 2019
mi: 選択範囲の JSON を整形
View format_json.sh
#!/bin/bash
#replace_selected
echo -n "$2" | /usr/local/bin/jq .