This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule ManyProcess do | |
def start_link(id) do | |
{:ok,spawn_link(fn -> loop(id,%{}) end)} | |
end | |
def loop(id,map) do | |
receive do | |
{:get,key,caller}-> | |
IO.puts "send id=#{id} key=#{key}" | |
send caller,Map.get(map,key) | |
loop(id,map) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require Logger | |
defmodule KV do | |
def start_link do | |
Task.start_link(fn -> loop(%{}) end) | |
end | |
defp loop(map) do | |
receive do | |
{:get,key,caller} -> | |
send caller,{:get,:ok,Map.get(map,key)} | |
loop(map) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule TestProcess.Mixfile do | |
use Mix.Project | |
def project do | |
[app: :test_process, | |
version: "0.0.1", | |
elixir: "~> 1.0", | |
build_embedded: Mix.env == :prod, | |
start_permanent: Mix.env == :prod, | |
escript: escript, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
STRFTIME_UTC_USEC(date, '%Y-%m') AS dt, | |
count(*) | |
FROM [nicodata_test.comment_data] | |
GROUP BY dt ORDER BY dt DESC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select count(*) from [nicodata_test.comment_data]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule VercheckEx do | |
use Application | |
use GenServer | |
require HTTPoison | |
require Floki | |
require Timex | |
use Timex | |
def fetch_content(params) do | |
{{url,type},i} = params | |
ret = HTTPoison.get!( url ) # urlで指定されるページのデータを取得 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule VercheckEx do | |
use Application | |
require HTTPoison | |
require Floki | |
require Timex | |
use Timex | |
def fetch_content() do | |
IO.puts("fetch_content") | |
receive do | |
{caller,url,type,i} -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule VercheckEx do | |
# requireで使用するライブラリを指定 | |
require HTTPoison | |
require Floki | |
require Timex | |
use Timex | |
def fetch_content() do | |
IO.puts("fetch_content") | |
receive do | |
{caller,url,type,i} -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule VercheckEx do | |
# requireで使用するライブラリを指定 | |
require HTTPoison | |
require Floki | |
require Timex | |
use Timex | |
def fetch_content(url, type) do | |
ret = HTTPoison.get!( url ) # urlで指定されるページのデータを取得 | |
%HTTPoison.Response{status_code: 200, body: body} = ret | |
# HTML bodyを取得する |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding:utf-8 -*- | |
import numpy as np | |
import doctest | |
def gini_coefficient(src): | |
""" | |
>>> gini_coefficient([245,362,826]) | |
0.40544312630844381 |