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
| 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 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
| package main | |
| import ( | |
| "bufio" | |
| "fmt" | |
| "io/ioutil" | |
| "net/http" | |
| "net/url" | |
| "os" | |
| "strings" |
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
| 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 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
| 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 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
| 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 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
| #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 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
| #!/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" |
NewerOlder