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
@jeremytregunna
jeremytregunna / linked-list.ll
Created August 14, 2011 00:18
Linked List in LLVM IR
;; Linked list implementation
;; I compile it like this on Mac OS X:
;
; llvm-as linked-list.ll
; llc linked-list.bc
; as linked-list.s -o linked-list.o
; ld /usr/lib/crt1.o linked-list.o -o linked-list -lSystem -macosx_version_min 10.6
;; Type aliases
%free_func = type void (i8*)*
@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)
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
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
[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)