Skip to content

Instantly share code, notes, and snippets.

View jeremytregunna's full-sized avatar

Jeremy Tregunna jeremytregunna

View GitHub Profile
import csv
def generate_referral_code(first_name, last_name):
first = first_name.lower().encode('ascii', errors='ignore').decode().replace(' ', '-')
last = last_name.lower().encode('ascii', errors='ignore').decode().replace(' ', '-')
return f"{first}-{last}".encode('ascii', errors='ignore').decode().replace('(', '').replace(')', '').replace('--', '-')
data = []
with open('file.csv', newline='', encoding='utf-8') as csvfile:
#include "../../config.h"
#define UNICODE_SELECTED_MODES UC_LNX, UC_WINC
#define QMK_KEYS_PER_SCAN 12
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(