This file contains 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
FROM hexpm/elixir:1.13.0-erlang-24.0.3-alpine-3.14.0 | |
RUN mix local.hex --force | |
RUN mix local.rebar --force | |
COPY --from=mkhan45/rustscript /bin/rustscript /bin/rustscript | |
COPY server.exs . | |
# hacky way to get elixir deps | |
RUN sh -c "timeout 30s elixir server.exs" |
This file contains 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
#define MINERAL_LEN (50) | |
#include <assert.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
typedef struct rock { | |
char mineral[MINERAL_LEN]; | |
float mass; |
This file contains 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
macro_rules! function { | |
() => {{ | |
fn f() {} | |
fn type_name_of<T>(_: T) -> &'static str { | |
std::any::type_name::<T>() | |
} | |
let name = type_name_of(f); | |
&name[..name.len() - 3] | |
}} | |
} |
This file contains 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
import Data.List (intercalate) | |
import Prelude hiding (or, and) | |
toBinArray :: Int -> [Bool] | |
toBinArray = reverse . helper | |
where helper :: Int -> [Bool] | |
helper 0 = [False] | |
helper n | |
| n `div` 2 == 0 = [(n `mod` 2) /= 0] | |
| otherwise = ((n `mod` 2) /= 0) : helper (n `div` 2) |
This file contains 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
# Configuration for Alacritty, the GPU enhanced terminal emulator. | |
# Any items in the `env` entry below will be added as | |
# environment variables. Some entries may override variables | |
# set by alacritty itself. | |
#env: | |
# TERM variable | |
# | |
# This value is used to set the `$TERM` environment variable for | |
# each instance of Alacritty. If it is not present, alacritty will |
This file contains 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
⍝ Problem 1 | |
{+/(∨⌿0=(3 5)∘.|⍵)/⍵}⍳999 | |
⍝ ⍳999 is [1..999] | |
⍝ {...} is a function which is applied to [1..999] | |
⍝ a/b where a and b are vectors of the same length replicates | |
⍝ each index of b by the equivalent index of a. Here it acts as a filter since each value in a is either 0 or 1 | |
⍝ (3 5)∘.|⍵ is the dot product of (3 5) with w using | (residue) as the operator. | is like backwards remainder in this case | |
⍝ 0= compares the remainder matrix with 0 |
This file contains 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
#include <stdio.h> | |
#include <stdlib.h> | |
void free_expr(); | |
int eval_expr(); | |
typedef enum expr_ty { | |
Atomic, | |
Binary, | |
} expr_ty; |
This file contains 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
#include <iostream> | |
#include <memory> | |
enum BinOp { | |
Add, | |
Sub, | |
Mul, | |
Div, | |
}; |
This file contains 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
Push 0 | |
Push 0 | |
-- accumulator is 0 | |
-- index is 1 | |
-- adds index to accumulator | |
Get 0 | |
Get 1 | |
Add |
This file contains 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
import Data.Semigroup | |
data Node a -- a Node containing type a is | |
= Val a (Node a) -- either a Value of type a and another Node | |
| End -- or the end of the list | |
-- Makes it possible for REPL to display a linked list | |
-- Val 5 (Val 3 (Val 9 End)) becomes 5->3->9->() | |
instance (Show a) => Show (Node a) where | |
show (Val a next) = (show a) <> "->" <> (show next) |
NewerOlder