Skip to content

Instantly share code, notes, and snippets.

defmodule AcmeUdpLogger.MessageReceiver do
use GenServer
def start_link(opts \\ []) do
GenServer.start_link(__MODULE__, :ok, opts)
end
def init (:ok) do
{:ok, _socket} = :gen_udp.open(21337)
end
defmodule AcmeUdpLogger.MessageReceiver do
use GenServer
require Logger
def start_link(opts \\ []) do
GenServer.start_link(__MODULE__, :ok, opts)
end
def init (:ok) do
{:ok, _socket} = :gen_udp.open(21337)
defmodule AcmeUdpLoggerTest.MessageReceiver do
use ExUnit.Case
@header <<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2>>
@priority_code <<81>>
@agent_number <<7, 0, 0, 0>>
@message <<116, 104, 101, 32, 104, 101, 110, 32, 104, 97, 115, 32, 102, 108, 111, 119, 110, 32, 116, 104, 101, 32, 99, 111, 111, 112, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32>>
test "it should extract relevant data from UDP packet" do
packet = @header <> @priority_code <> @agent_number <> @message
def application do
[mod: {AcmeUdpLogger, []},
applications: [:logger]]
end
defmodule AcmeUdpLogger do
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
# We will add our children here later
]
### Keybase proof
I hereby claim:
* I am civilframe on github.
* I am alexsolo (https://keybase.io/alexsolo) on keybase.
* I have a public key ASAnUU5xjdh_Hx5hqv5XdqWhF3FlWUfHoO-0V9h7OIQkFAo
To claim this, I am signing this object:
@alexnsolo
alexnsolo / insider_ownership_AAPL.json
Last active May 7, 2020 19:43
Intrinio API for Insider Ownership of AAPL
# https://api.intrinio.com/companies/insider_ownership?identifier=AAPL&api_key={YOUR_API_KEY}
{
"data": [
{
"owner_cik": "0001214128",
"owner_name": "LEVINSON ARTHUR D",
"last_reported_date": "2020-02-04",
"value": 345749000,
"amount": 1150083
@alexnsolo
alexnsolo / insider_transactions_aapl.json
Created May 7, 2020 19:51
Intrinio API Insider Transactions
# https://api.intrinio.com/companies/insider_transactions?identifier=AAPL&api_key={YOUR_API_KEY}
{
"data": [
{
"owner_cik": "0001051401",
"owner_name": "JUNG ANDREA",
"filing_date": "2020-04-30",
"filing_url": "https://www.sec.gov/Archives/edgar/data/320193/000032019320000054/xslF345X03/wf-form4_158829658358801.xml",
"director": true,
@alexnsolo
alexnsolo / historical_insider_ownership
Last active May 14, 2020 20:48
Intrinio API Ruby Script for Historical Insider Ownership
###########################################################################
# Get Historical Insider Ownership for a Company on a Given Date
###########################################################################
require 'net/http'
require 'json'
require 'date'
#--------------------------------------------------------------------------
# Variables
{
"fundamentals": [
{
"id": "fun_z541aN",
"statement_code": "cash_flow_statement",
"fiscal_year": 2017,
"fiscal_period": "FY",
"type": "restated",
"start_date": "2016-09-25",
"end_date": "2017-09-30",