This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Computer Information: | |
Manufacturer: Unknown | |
Model: Unknown | |
Form Factor: Desktop | |
No Touch Input Detected | |
Processor Information: | |
CPU Vendor: GenuineIntel | |
CPU Brand: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz | |
CPU Family: 0x6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Sutro.ServiceMode.Controller do | |
@moduledoc """ | |
A Controller process that waits for various service mode messages to come in. | |
It also includes various helper methods for sending messages to the correct process. | |
""" | |
require Logger | |
require ServiceModeConstants | |
alias Sutro.ServiceMode.{ServiceSession, ServiceSessionManager} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Spiral do | |
def order(matrix) do | |
bounds = %{ | |
xmin: 0, | |
xmax: matrix |> hd() |> length(), | |
ymin: 0, | |
ymax: length(matrix) | |
} | |
matrix |> next({0, 0}, {1, 0}, bounds, []) |> Enum.reverse() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Dag do | |
defstruct edges: %{} | |
def from_list(list) do | |
Enum.reduce(list, %Dag{}, fn [to, from], dag -> insert(dag, from, to) end) | |
end | |
def insert(%Dag{edges: edges}, from, to) do | |
nodes = Map.get(edges, from, []) | |
updated_edges = Map.put(edges, from, [to | nodes]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Dictionary do | |
@moduledoc """ | |
A Trie based approach to the dictionary. | |
https://en.wikipedia.org/wiki/Trie | |
""" | |
defstruct words: %{} | |
@terminatior "." | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule ListNode do | |
@moduledoc """ | |
Define a Node type for our linked list. | |
""" | |
@enforce_keys [:data, :next] | |
defstruct data: 0, | |
next: nil | |
end | |
defimpl String.Chars, for: ListNode do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Digits do | |
@operators ["+", "-", "*"] | |
def calculate(num, target) do | |
# 1) Turn num into a list of characters | |
# 2) Build all possible equations | |
# 3) Filter out the ones that don't evaluate to the target | |
# 4) Clean up results for printing | |
num |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import unittest | |
def zero(matrix): | |
if len(matrix) == 0: | |
return matrix | |
rows = set() | |
cols = set() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module type ApiClient = {let getFile: unit => string;}; | |
module FakeApiClient: ApiClient = { | |
let getFile = () => "cat.jpg"; | |
}; | |
let unwrapUnsafely = data => | |
switch (data) { | |
| Some(v) => v | |
| None => raise(Invalid_argument("unwrapUnsafely called on None")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const money = t => parseFloat(t.trim().replace(/[^0-9\.]+/g,"")); | |
const pending = $('#sortTable tr').toArray().reduce((acc, node) => { | |
const trNode = $(node); | |
if(trNode.find('td.date').text() === 'Pending') { | |
return acc + money(trNode.find('td.amount').text()); | |
} | |
return acc; |
NewerOlder