Skip to content

Instantly share code, notes, and snippets.

@adamu
adamu / benchmark.exs
Created June 21, 2021 03:55
Benchmarking functions to count codepoints in strings
#! /usr/bin/env elixir
Mix.install([:benchee])
string = for i <- 0x1F600..0x1F64F, into: "", do: <<i::utf8>>
codepoints = fn -> string |> String.codepoints() |> length end
charlist = fn -> string |> String.to_charlist() |> length end
comprehension = fn -> for <<_::utf8 <- string>>, reduce: 0, do: (count -> count + 1) end
Benchee.run(
@adamu
adamu / docker-compose.yml
Last active January 1, 2021 12:39
Docker compose file for a simple Postgres server that keeps its state in a Docker volume for persistence between runs.
version: '3.8'
services:
db:
image: postgres
restart: always
ports:
- '5432:5432'
environment:
POSTGRES_PASSWORD: postgres
volumes:
@adamu
adamu / line_bot_elixir_howto_ja.md
Last active September 14, 2021 07:13
Elixirを使ってLineのチャットボットを作ろう

これはfukuoka.ex Elixir/Phoenix Advent Calendar 2019の13日の記事です。 ElixirでLineのチャットボットを作る方法を紹介します。 🧪🤖🧪

昨日はsanpo_shihoさんの「Rails経験者に贈るPhoenix入門」でした。

English version.

  1. 先ずはLine Developers ConsoleMessaging API Channelを作成する必要があります。 そして作成されたチャネルIDとチャネルシークレットを後で使用するためメモしておき、ボットと友達になります。
  2. Supervision treeありのElixirのアプリを作ります。
@adamu
adamu / line_bot_elixir_howto_en.md
Last active June 10, 2023 18:02
How to make a Line Chatbot with Elixir

This is my entry for the fukuoka.ex Elixir/Phoenix Advent Calendar 2019 day 13, and it's a guide for how to write a Line bot using Elixir. 🧪🤖🧪

日本語版はこちらです。

  1. First you need to create a Messaging API Channel on the Line Developers Console. You will also need to add your bot as a friend, and know the generated Channel ID and Channel Secret.

  2. Create a new Elixir app with a supervision tree:

    mix new advent --sup

  3. cd advent

  4. If you want to use git, now we can create a repository (optional):

@adamu
adamu / flags.csv
Last active August 24, 2019 10:30
Unicode flag codes
🇦🇦 🇦🇧 🇦🇨 🇦🇩 🇦🇪 🇦🇫 🇦🇬 🇦🇭 🇦🇮 🇦🇯 🇦🇰 🇦🇱 🇦🇲 🇦🇳 🇦🇴 🇦🇵 🇦🇶 🇦🇷 🇦🇸 🇦🇹 🇦🇺 🇦🇻 🇦🇼 🇦🇽 🇦🇾 🇦🇿 🇧🇦 🇧🇧 🇧🇨 🇧🇩 🇧🇪 🇧🇫 🇧🇬 🇧🇭 🇧🇮 🇧🇯 🇧🇰 🇧🇱 🇧🇲 🇧🇳 🇧🇴 🇧🇵 🇧🇶 🇧🇷 🇧🇸 🇧🇹 🇧🇺 🇧🇻 🇧🇼 🇧🇽 🇧🇾 🇧🇿 🇨🇦 🇨🇧 🇨🇨 🇨🇩 🇨🇪 🇨🇫 🇨🇬 🇨🇭 🇨🇮 🇨🇯 🇨🇰 🇨🇱 🇨🇲 🇨🇳 🇨🇴 🇨🇵 🇨🇶 🇨🇷 🇨🇸 🇨🇹 🇨🇺 🇨🇻 🇨🇼 🇨🇽 🇨🇾 🇨🇿 🇩🇦 🇩🇧 🇩🇨 🇩🇩 🇩🇪 🇩🇫 🇩🇬 🇩🇭 🇩🇮 🇩🇯 🇩🇰 🇩🇱 🇩🇲 🇩🇳 🇩🇴 🇩🇵 🇩🇶 🇩🇷 🇩🇸 🇩🇹 🇩🇺 🇩🇻 🇩🇼 🇩🇽 🇩🇾 🇩🇿 🇪🇦 🇪🇧 🇪🇨 🇪🇩 🇪🇪 🇪🇫 🇪🇬 🇪🇭 🇪🇮 🇪🇯 🇪🇰 🇪🇱 🇪🇲 🇪🇳 🇪🇴 🇪🇵 🇪🇶 🇪🇷 🇪🇸 🇪🇹 🇪🇺 🇪🇻 🇪🇼 🇪🇽 🇪🇾 🇪🇿 🇫🇦 🇫🇧 🇫🇨 🇫🇩 🇫🇪 🇫🇫 🇫🇬 🇫🇭 🇫🇮 🇫🇯 🇫🇰 🇫🇱 🇫🇲 🇫🇳 🇫🇴 🇫🇵 🇫🇶 🇫🇷 🇫🇸 🇫🇹 🇫🇺 🇫🇻 🇫🇼 🇫🇽 🇫🇾 🇫🇿 🇬🇦 🇬🇧 🇬🇨 🇬🇩 🇬🇪 🇬🇫 🇬🇬 🇬🇭 🇬🇮 🇬🇯 🇬🇰 🇬🇱 🇬🇲 🇬🇳 🇬🇴 🇬🇵 🇬🇶 🇬🇷 🇬🇸 🇬🇹 🇬🇺 🇬🇻 🇬🇼 🇬🇽 🇬🇾 🇬🇿 🇭🇦 🇭🇧 🇭🇨 🇭🇩 🇭🇪 🇭🇫 🇭🇬 🇭🇭 🇭🇮 🇭🇯 🇭🇰 🇭🇱 🇭🇲 🇭🇳 🇭🇴 🇭🇵 🇭🇶 🇭🇷 🇭🇸 🇭🇹 🇭🇺 🇭🇻 🇭🇼 🇭🇽 🇭🇾 🇭🇿 🇮🇦 🇮🇧 🇮🇨 🇮🇩 🇮🇪 🇮🇫 🇮🇬 🇮🇭 🇮🇮 🇮🇯 🇮🇰 🇮🇱 🇮🇲 🇮🇳 🇮🇴 🇮🇵 🇮🇶 🇮🇷 🇮🇸 🇮🇹 🇮🇺 🇮🇻 🇮🇼 🇮🇽 🇮🇾 🇮🇿 🇯🇦 🇯🇧 🇯🇨 🇯🇩 🇯🇪 🇯🇫 🇯🇬 🇯🇭 🇯🇮 🇯🇯 🇯🇰 🇯🇱 🇯🇲 🇯🇳 🇯🇴 🇯🇵 🇯🇶 🇯🇷 🇯🇸 🇯🇹 🇯🇺 🇯🇻 🇯🇼 🇯🇽 🇯🇾 🇯🇿 🇰🇦 🇰🇧 🇰🇨 🇰🇩 🇰🇪 🇰🇫 🇰🇬 🇰🇭 🇰🇮 🇰🇯 🇰🇰 🇰🇱 🇰🇲 🇰🇳 🇰🇴 🇰🇵 🇰🇶 🇰🇷 🇰🇸 🇰🇹 🇰🇺 🇰🇻 🇰🇼 🇰🇽 🇰🇾 🇰🇿 🇱🇦 🇱🇧 🇱🇨 🇱🇩 🇱🇪 🇱🇫 🇱🇬 🇱🇭 🇱🇮 🇱🇯 🇱🇰 🇱🇱 🇱🇲 🇱🇳 🇱🇴 🇱🇵 🇱🇶 🇱🇷 🇱🇸 🇱🇹 🇱🇺 🇱🇻 🇱🇼 🇱🇽 🇱🇾 🇱🇿 🇲🇦 🇲🇧 🇲🇨 🇲🇩 🇲🇪 🇲🇫 🇲🇬 🇲🇭 🇲🇮 🇲🇯 🇲🇰 🇲🇱 🇲🇲 🇲🇳 🇲🇴 🇲🇵 🇲🇶 🇲🇷 🇲🇸 🇲🇹 🇲🇺 🇲🇻 🇲🇼 🇲🇽 🇲🇾 🇲🇿 🇳🇦 🇳🇧 🇳🇨 🇳
@adamu
adamu / fizzbuzz.markdown
Last active April 28, 2022 11:16 — forked from jarednorman/fizzbuzz.markdown
Fizzbuzz in Elixir

Fizzbuzz in Elixir

Elixir is a beautiful language. Among its strength is its powerful pattern matching system which allows one to write very declarative, elegant code. FizzBuzz is a trivial problem often presented to new programmers or interviewees to determine baseline programming ability. Here is a solution Elixir:

defmodule FizzBuzz do
@adamu
adamu / keybase.md
Last active November 8, 2017 16:26

Keybase proof

I hereby claim:

  • I am adamu on github.
  • I am adamu (https://keybase.io/adamu) on keybase.
  • I have a public key ASCKIyMyzBSZA7bnIWrtEQaV21Fgu91gFppiDEmvK3k6Ewo

To claim this, I am signing this object: