Skip to content

Instantly share code, notes, and snippets.

Avatar
🦉
hi

Kazuaki Matsuo KazuCocoa

🦉
hi
View GitHub Profile
View 20160429_integration_gat.exs
defmodule MyApp.IntegrationCase do
use ExUnit.CaseTemplate
using do
quote do
use Hound.Helpers
import Ecto
import Ecto.Changeset
import Ecto.Query
View 20150420_defps.exs
defmodule Functions do
# switch using `def` or `defp` in compile time
defmacro defpt(func, body \\ nil) do
case test_env? do
true -> quote do: def(unquote(func), unquote(body))
false -> quote do: defp(unquote(func), unquote(body))
end
end
defp test_env? do
View 20160315_zndco_kiyoshi2.exs
defmodule Znd do
@z "ズン"
@d "ドコ"
@k "キ・ヨ・シ"
def kiyoshi, do: [] |> kiy
defp kiy(zd) when zd == [@d, @z, @z, @z, @z], do: [@k|zd] |> Enum.reverse |> Enum.join
defp kiy(zd) when length(zd) > 5 do
{h, t} = zd |> Enum.split(5)
View 20160315_zndco_kiyoshi.exs
defmodule Znd do
@z "ズン"
@d "ドコ"
@k "キ・ヨ・シ"
def kiyoshi, do: [] |> kiy
defp kiy(zd) when zd == [@z, @z, @z, @z, @d], do: [zd|[@k]] |> Enum.join
defp kiy(zd) when length(zd) > 5, do: tl(zd) |> kiy
defp kiy(zd), do: [zd|[Enum.random([@z, @d])]] |> List.flatten |> kiy
View googleAppScriptHipChat.js
/*
* @param authToken [String] HipChat token you are created.
* @param roomId [String] Room id you would like to send notification.
* @param message [String] Message string
*/
function hipchat(authToken, roomId, message) {
var url = 'https://api.hipchat.com/v2/room/' + roomId + '/notification?auth_token=' + authToken;
var payload =