Skip to content

Instantly share code, notes, and snippets.

Jeremy Tregunna jeremytregunna

  • 1 AU from Sol
Block or report user

Report or block jeremytregunna

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View daily_volume.ex
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.
View Welcome Email for Mailgun (1).html
<!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>
View exuma.ex
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
View instruction.md
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
View jkff.sby
[tasks]
prove
cover
[options]
prove: mode prove
cover: mode cover
[engines]
smtbmc yices
View gist:6195f6b6a48ca1e47bcb94b5976dcd03
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 Apr 29, 2018
After refactoring...
View authorize.ex
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 Apr 29, 2018
This looks horrible (formatter)
View authorize.ex
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(
View gist:dbc991b43df1a996ee0ad04ad8321b64
[ 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
View gist:d2d213c488455279bf8c065500c99a6e
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
You can’t perform that action at this time.