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
@webdevwilson
webdevwilson / monitor-directory.groovy
Created January 19, 2011 15:56
Groovy code to monitor a directory and copy modified files to a different directory
String.metaClass.div = { f -> delegate + File.separator + f }
def extensions = ['.jpg','.css','.js','.jsp']
def source = new File( args.length > 0 ? args[0] : '.' ).absolutePath
def dest = new File( args.length > 1 ? args[1] : discoverJBoss() ).absolutePath
println "Monitoring ${source}"
println "Any modified files will be copied to ${dest}"
def files = buildFileList(source, extensions)
@webdevwilson
webdevwilson / State.java
Created March 29, 2013 16:38
Enum containing states with abbreviations
import java.util.HashMap;
import java.util.Map;
public enum State {
ALABAMA("Alabama", "AL"), ALASKA("Alaska", "AK"), AMERICAN_SAMOA("American Samoa", "AS"), ARIZONA("Arizona", "AZ"), ARKANSAS(
"Arkansas", "AR"), CALIFORNIA("California", "CA"), COLORADO("Colorado", "CO"), CONNECTICUT("Connecticut", "CT"), DELAWARE(
"Delaware", "DE"), DISTRICT_OF_COLUMBIA("District of Columbia", "DC"), FEDERATED_STATES_OF_MICRONESIA(
"Federated States of Micronesia", "FM"), FLORIDA("Florida", "FL"), GEORGIA("Georgia", "GA"), GUAM("Guam", "GU"), HAWAII(
"Hawaii", "HI"), IDAHO("Idaho", "ID"), ILLINOIS("Illinois", "IL"), INDIANA("Indiana", "IN"), IOWA("Iowa", "IA"), KANSAS(
#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