Skip to content

Instantly share code, notes, and snippets.

View webdevwilson's full-sized avatar

Kerry Wilson webdevwilson

View GitHub Profile
#!/usr/bin/env python3
def fn(d={}):
return d
d=fn()
d['a'] = 'b'
print(fn()) # {'a': 'b'}
#!/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
#!/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],
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());
# 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
#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"
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;
}
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
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 {
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))