Skip to content

Instantly share code, notes, and snippets.

View jeremytregunna's full-sized avatar

Jeremy Tregunna jeremytregunna

View GitHub Profile
defmodule Hodler.Signal.DailyVolume do
@moduledoc """
Produce a list of the top traded (by volume) crypto currencies on an exchange
as a standardized ratio of weighted sums relative to its initial value.
This is accomplished by taking the top `count` of assets by daily volume,
calculate the market share, then truncate it by the `max_percent`. Then we
rescale them, so the weights all add up to 1. Finally calculated the weighted
average.
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<!-- NAME: SIMPLE TEXT -->
<!--[if gte mso 15]>
<xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
<o:PixelsPerInch>96</o:PixelsPerInch>
</o:OfficeDocumentSettings>
defmodule Exuma do
def doing_work(pid) do
IO.puts("Some work, like a DB fetch")
results = [1, 2, 42]
send(pid, {:update_state, results})
end
end
defmodule Exuma.StateHolderThingy do
use GenServer
31 28 27 downto 22 21 downto 16 15 12 11 downto 6 5 downto 0
GID SI SID / SIM DID GID SI SID / SIM DID

2-issue instructions only.

Should the compiler wish to send a no transport instruction (aka noop in other architectures); it is expected that it will choose to encode an instruction (or two instructions) whose guard fails. For instance, you could construct an instruction whose guard checks for source ID or destination ID to be non-zero, comparing SID or DID address 0 while setting the guard to fail if the value at this address is zero (see the below table for information on guards to achieve this behaviour). One such instruction would be: 16'b1000000000000000. This instruction compares the values at SID and DID to ensure they are both non-zero before issuing the instruction.

  • GID - Guard ID (conditional execution of instructions)
  • 3'b000 - Value at sou
[tasks]
prove
cover
[options]
prove: mode prove
cover: mode cover
[engines]
smtbmc yices
def create_changeset(struct, params \\ %{}) do
struct
|> cast(params, ~w(user_id))
|> cast_assoc(:user)
|> validate_required(~w(user_id)a)
end
def grant_changeset(struct) do
struct
|> cast(%{decision: true}, ~w(decision)a)
@jeremytregunna
jeremytregunna / authorize.ex
Last active April 16, 2020 12:10
After refactoring...
defmodule Api.Authorize do
alias Account.Models.User
alias Tracker.OrganizationMembers, as: OM
def board?(board_id, %User{} = user, available_perms, required_perms) do
with(
{:ok, board} <- Tracker.Board.find(board_id),
true <- OM.user_in_organization?(user.id, board.organization_id)
) do
required_perms == common_permissions(required_perms, available_perms)
@jeremytregunna
jeremytregunna / authorize.ex
Created April 29, 2018 09:09
This looks horrible (formatter)
defmodule Api.Authorize do
alias Account.Models.User
def board?(board_id, %User{} = user, available_permissions, required_permissions) do
with {:ok, board} <- Tracker.Board.find(board_id),
true <-
Tracker.OrganizationMembers.user_in_organization?(user.id, board.organization_id),
^required_permissions <-
Enum.to_list(
MapSet.intersection(
[ 0.016937] mce: CPU supports 23 MCE banks
[ 0.313343] mce: [Hardware Error]: Machine check events logged
[ 0.313344] mce: [Hardware Error]: CPU 8: Machine Check: 0 Bank 0: baa0400000070135
[ 0.313348] mce: [Hardware Error]: TSC 0 MISC d012000101000000 SYND 104c180167 IPID b000000000
[ 0.313353] mce: [Hardware Error]: PROCESSOR 2:800f11 TIME 1517570945 SOCKET 0 APIC 8 microcode 8001129
[ 0.340011] mce: [Hardware Error]: Machine check events logged
[ 0.340011] mce: [Hardware Error]: CPU 9: Machine Check: 0 Bank 5: bea0000000000108
[ 0.340016] mce: [Hardware Error]: TSC 0 ADDR 1ffffbb681dd4 MISC d012000101000000 SYND 4d000000 IPID 500b000000000
[ 0.340021] mce: [Hardware Error]: PROCESSOR 2:800f11 TIME 1517570945 SOCKET 0 APIC 9 microcode 8001129
SERVER ID IMAGE ZONE CREATED STATUS PORTS NAME COMMERCIAL TYPE
ea26208b Ubuntu_Xenial_16_04_lates par1 36 hours running 51.15.X.Y proxy0 VC1S
208338ad Ubuntu_Xenial_16_04_lates par1 36 hours running master1 C2S
2c4a87b0 Ubuntu_Xenial_16_04_lates par1 36 hours running master2 C2S
f6af16b4 Ubuntu_Xenial_16_04_lates par1 36 hours running master0 C2S
99b83c2e Ubuntu_Xenial_16_04_lates par1 36 hours running proxy1 VC1S
978d2833 Ubuntu_Xenial_16_04_lates par1 36 hours running