Getting started:
Add the following file to ./lib/db.ex
# needed to get defdatabase and other macros
use Amnesia
# defines a database called Database, it's basically a defmodule with
iex(foo@ip-10-40-65-192)78> is_list(res) | |
true | |
iex(foo@ip-10-40-65-192)79> b = list_to_binary(res) | |
** (ArgumentError) argument error | |
:erlang.list_to_binary([4,16,36,64,100,144,196,256,324,400,484,576,676,784,900,1024,1156,1296,1444,1600,1764,1936,2116,2304,2500,2704,2916,3136,3364,3600,3844,4096,4356,4624,4900,5184,5476,5776,6084,6400,6724,7056,7396,7744,8100,8464,8836,9216,9604,10000,10404,10816,11236,11664,12100,12544,12996,13456,13924,14400,14884,15376,15876,16384,16900,17424,17956,18496,19044,19600,20164,20736,21316,21904,22500,23104,23716,24336,24964,25600,26244,26896,27556,28224,28900,29584,30276,30976,31684,32400,33124,33856,34596,35344,36100,36864,37636,38416,39204,40000]) | |
erl_eval.erl:569: :erl_eval.do_apply/6 | |
erl_eval.erl:364: :erl_eval.expr/5 | |
src/elixir.erl:143: :elixir.eval_forms/3 | |
/Volumes/Work/github/elixir/lib/iex/lib/iex/server.ex:81: IEx.Server.eval/4 | |
/Volumes/Work/github/elixir/lib/iex/lib/iex/server.ex:37: IEx.Server.do_loop/1 |
def patterns do | |
{status,list} = :application.get_env(:elgrok, :patterns) | |
if status == :ok do | |
list | |
else | |
[] | |
end | |
end |
defmodule HtmlParsing.Mixfile do | |
use Mix.Project | |
def project do | |
[ app: :html_parsing, | |
version: "0.0.1", | |
deps: deps ] | |
end | |
# Configuration for the OTP application |
defmodule Tst123 do | |
def run(path) do | |
html = """ | |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | |
"http://www.w3.org/TR/html4/strict.dtd"> | |
<HTML> | |
<HEAD> | |
<TITLE>My first HTML document</TITLE> | |
</HEAD> |
defmodule TF do | |
use GenServer.Behaviour | |
def start_link do | |
:gen_server.start_link({:local,:tf},__MODULE__,nil,[]) | |
end | |
def throttle do | |
IO.puts "Starting at #{inspect :erlang.time}" | |
:gen_server.call :tf, :throttle | |
IO.puts "ending at #{inspect :erlang.time}" | |
end |
def fetch(path) do | |
try do | |
case HTTPotion.get(path, @user_agent) do | |
Response[body: body, status_code: status, headers: _headers ] | |
when status in 200..299 -> | |
{ :ok, body } | |
{:error,:req_timedout} -> | |
Lager.info "fetch: timeout detected, sleeping 30 seconds" | |
:timer.sleep(30000) | |
fetch(path) |
[ec2-user@ip-10-132-34-190 ~]$ curl -s http://169.254.169.254/latest/meta-data/public-hostname | |
ec2-54-227-36-44.compute-1.amaziex --sname foo@`curl -s http://169.254.169.253/latest/meta-data/public-hostname` --cookie foo | |
{error_logger,{{2013,7,5},{18,52,26}},"Can't set short node name!\nPlease check your configuration\n",[]} | |
{error_logger,{{2013,7,5},{18,52,26}},crash_report,[[{initial_call,{net_kernel,init,['Argument__1']}},{pid,<0.21.0>},{registered_name,[]},{error_info,{exit,{error,badarg},[{gen_server,init_it,6,[{file,"gen_server.erl"},{line,320}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}]}]}},{ancestors,[net_sup,kernel_sup,<0.10.0>]},{messages,[]},{links,[<0.18.0>]},{dictionary,[{longnames,false}]},{trap_exit,true},{status,running},{heap_size,610},{stack_size,27},{reductions,183}],[]]} | |
{error_logger,{{2013,7,5},{18,52,26}},supervisor_report,[{supervisor,{local,net_sup}},{errorContext,start_error},{reason,{'EXIT',nodistribution}},{offender,[{pid,undefined},{name,net_kernel},{mfargs, |
iex(1)> dbo = [ | |
...(1)> {:adapter, :mysql}, | |
...(1)> {:db_host, 'demo-db.foo.com'}, | |
...(1)> {:db_port, 3306}, | |
...(1)> {:db_username, 'root'}, | |
...(1)> {:db_password, '1234'}, | |
...(1)> {:cache_enable, :false}, | |
...(1)> {:cache_exp_time, 1} | |
...(1)> ] |
# needed to get defdatabase and other macros | |
use Amnesia | |
# defines a database called Database, it's basically a defmodule with | |
# some additional magic | |
defdatabase Database do | |
# this is just a forward declaration of the table, otherwise you'd have | |
# to fully scope User.read in Message functions | |
deftable User |
Getting started:
Add the following file to ./lib/db.ex
# needed to get defdatabase and other macros
use Amnesia
# defines a database called Database, it's basically a defmodule with