Skip to content

Instantly share code, notes, and snippets.

View wemgl's full-sized avatar

Wembley Leach wemgl

View GitHub Profile
@wemgl
wemgl / createSimpleFileServer.go
Created March 10, 2019 14:49
Example of serving static content in Go simple server
// public serves static assets such as CSS and JavaScript to clients.
func public() http.Handler {
return http.StripPrefix("/public/", http.FileServer(http.Dir("./public")))
}
@wemgl
wemgl / createSimpleServerIndexHandlerTest.go
Created March 10, 2019 14:59
Example of testing the index handler for simple server
func TestIndex(t *testing.T) {
req, err := http.NewRequest(http.MethodGet, "/", nil)
if err != nil {
t.Fatalf("TestIndex: couldn't create HTTP GET request: %v", err)
}
rec := httptest.NewRecorder()
index().ServeHTTP(rec, req)
@wemgl
wemgl / Dockerfile
Created November 25, 2020 12:31
Elixir Umbrella App Dockerfile
FROM elixir:1.11.1-alpine AS build
# install build dependencies
RUN apk add --no-cache build-base npm git
# prepare build dir
WORKDIR /app
# install hex + rebar
RUN mix local.hex --force && \
@wemgl
wemgl / main.dart
Last active April 14, 2022 00:42
Hangman Game
String updateGuessState(String correctWord, String guessState, String guess) {
// Update the guess state to account for the latest guessed letter.
var newGuessState = '';
for (var i = 0; i < correctWord.length; i++) {
if (correctWord[i] == guess) {
newGuessState += guess;
} else {
newGuessState += guessState[i];
}
}
@wemgl
wemgl / main.dart
Last active January 11, 2025 14:36
stackoverflow_question_solution_74152502
import 'dart:math';
import 'package:flutter/material.dart';
void main() {
runApp(const MainApp());
}
class MainApp extends StatelessWidget {
const MainApp({super.key});