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
#!/bin/sh | |
# Usage: sc [DELAY] [OUTPUT] | |
# Image is copied to clipboard and saved to output | |
if [ -z "$2" ] | |
then | |
file="$(mktemp)" | |
else | |
file="/home/$USER/$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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <string.h> | |
#define PROGRESSLEN 25 | |
// I'm not sure if I'm following best practices at all here but it works | |
int main(int argc, char *argv[]) { |
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
enum Game { | |
BlinkGame | |
}; | |
static Game game; | |
const int button1 = 3; | |
const int button2 = 4; | |
const int button3 = 5; | |
const int greenled = 6; | |
const int redled = 7; |
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 yourgrad as yg | |
a = yg.Tensor(list(range(15))) | |
b = yg.Tensor(list(range(15))) | |
f = a + b | |
f.backward() | |
print(a.grad) |
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 typing import List, Dict, Tuple, Set | |
import math | |
g = lambda x: 1 / (1 + math.e**(-x)) | |
def solve_net(node_vals: List[int], edges: Dict[Tuple[int, int], int], activated_nodes: Set[int]): | |
unsolved_nodes = [i for (i, v) in enumerate(node_vals) if v == None] | |
for node in unsolved_nodes: | |
val = sum(node_vals[i1 - 1] * w for ((i1, i2), w) in edges.items() if i2 == node + 1) |
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
package main | |
import ( | |
"bufio" | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
"net/url" | |
"os" | |
"strings" |
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
package main | |
import ( | |
"net/http" | |
) | |
func httpRedirect(w http.ResponseWriter, req *http.Request) { | |
target := "https://" + req.Host + req.URL.Path | |
if len(req.URL.RawQuery) > 0 { | |
target += "?" + req.URL.RawQuery | |
} |
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) |
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
#include <iostream> | |
#include <memory> | |
enum BinOp { | |
Add, | |
Sub, | |
Mul, | |
Div, | |
}; |
OlderNewer