View mutable_default_arg.py
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
#!/usr/bin/env python3 | |
def fn(d={}): | |
return d | |
d=fn() | |
d['a'] = 'b' | |
print(fn()) # {'a': 'b'} |
View lego_triples.py
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
#!/usr/bin/env python3 | |
import math | |
# Poor man's numpy.arange | |
LENGTHS = [] | |
for i in range(1, 32): | |
LENGTHS.extend([i, i+0.5]) | |
# |\ y - from vertex to top | |
# | \ x - from vertex to right |
View matrix_neighbors.py
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
#!/usr/bin/env python3 | |
TEST = [ | |
[0, 0, 0, 1, 0, 0, 0], | |
[0, 1, 0, 1, 1, 1, 0], | |
[0, 0, 1, 1, 0, 1, 0], | |
[0, 1, 1, 0, 0, 1, 0], | |
[0, 1, 0, 0, 1, 1, 1], | |
[0, 1, 1, 0, 0, 1, 1], | |
[0, 1, 0, 0, 1, 1, 1], |
View TestString.java
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
public class TestString { | |
public static void main(String... args) { | |
final String word = "timecomplexityn"; | |
System.out.println(word); | |
final String space = " ".repeat(word.length()-2); | |
for(int i = 1; i < word.length() - 1; i++) { | |
System.out.print(word.charAt(i) + space + word.charAt(word.length() - i) + "\n"); | |
} | |
System.out.println(new StringBuilder(word).reverse()); |
View springboot.Dockerfile
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
# build the application with maven jdk-17 | |
FROM public.ecr.aws/docker/library/maven:3-amazoncorretto-17 AS build | |
WORKDIR /project | |
ADD pom.xml /project | |
RUN mvn verify --fail-never | |
COPY . . | |
RUN mvn package | |
# Add the jar to the final docker image | |
FROM public.ecr.aws/amazoncorretto/amazoncorretto:17 |
View ble_hrm.ino
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 <ArduinoBLE.h> | |
// Heart Rate Monitor | |
#define BLE_MAC "e9:41:07:7b:ac:1d" | |
#define BLE_SVC "180d" | |
#define BLE_CHR "2a37" | |
// Kickr Core | |
//#define BLE_MAC "ec-7d-27-1c-d6-a5" | |
//#define BLE_SVC "1818" |
View getZones.js
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
function getZones(id) { | |
var url = 'https://app.homefitnessbuddy.com/peloton/powerzone/details/' + id; | |
var html = UrlFetchApp.fetch(url).getContentText(); | |
var doc = XmlService.parse(html); | |
var html = doc.getRootElement(); | |
var script = getElementsByClassName(html, 'body script:nth-child(1)')[0].innerText; | |
var s = eval(script); | |
return s.intervals; | |
} |
View test_webserver.go
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
func TestWebServer(t *testing.T) { | |
terraformOptions := &terraform.Options { | |
// The path to where your Terraform code is located | |
TerraformDir: "../web-server", | |
} | |
// At the end of the test, run `terraform destroy` | |
defer terraform.Destroy(t, terraformOptions) | |
// Run `terraform init` and `terraform apply` | |
terraform.InitAndApply(t, terraformOptions) | |
// Run `terraform output` to get the value of an output variable |
View lambda.go
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
func HandleRequest(ctx context.Context, apiGatewayReq events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) { | |
// Create the handler | |
pathPrefix := fmt.Sprintf("/%s", apiGatewayReq.RequestContext.Stage) | |
handler := boundary.NewRequestHandler(pathPrefix) | |
// Create an HTTP request from the event | |
req, err := getRequestFromLambda(apiGatewayReq) | |
if err != nil { |
View server.go
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
func main() { | |
var port string | |
var ok bool | |
if port, ok = os.LookupEnv("PORT"); !ok { | |
port = "8080" | |
} | |
http.Handle("/", boundary.NewRequestHandler("")) | |
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil)) |
NewerOlder