Skip to content

Instantly share code, notes, and snippets.

View meadsteve's full-sized avatar
🌲
stuff

Steve Brazier meadsteve

🌲
stuff
View GitHub Profile
@meadsteve
meadsteve / deserialize_pydantic.py
Last active August 1, 2019 14:15 — forked from henriklindgren/deserialize_pydantic.py
Unpack dict based on pydantic BaseModel into model
#This is free and unencumbered software released into the public domain.
#
#Anyone is free to copy, modify, publish, use, compile, sell, or
#distribute this software, either in source code form or as a compiled
#binary, for any purpose, commercial or non-commercial, and by any
#means.
#
#In jurisdictions that recognize copyright laws, the author or authors
#of this software dedicate any and all copyright interest in the
#software to the public domain. We make this dedication for the benefit
@meadsteve
meadsteve / Dockerfile
Last active April 2, 2019 08:11 — forked from philcross/Dockerfile
docker example
#services/php/Dockerfile
FROM php:7.3-fpm
WORKDIR /var/www/html
ENV COMPOSER_ALLOW_SUPERUSER=1
ENV COMPOSER_NO_INTERACTION=1
ENV COMPOSER_HOME=/usr/local/share/composer
var CheckMessageForKeyword = function(message, keyword, hasParameters) {
if (!message.data || !message.data.text) {
return null;
}
var keywordRegex;
if (hasParameters) {
keywordRegex = new RegExp("^\\s*" + keyword + "\\s*(\\S.+?)\\s*$", "i");
var params = message.data.text.match(keywordRegex);
@meadsteve
meadsteve / clock.ex
Created September 30, 2015 19:31 — forked from CrowdHailer/clock.ex
Creating boundary modules for elixir applications. These have their implementation set during the configuration step. In this example we switch clock between system clock and a dummy clock
# This module represents a behaviour and when used picks from the Application configuration which implementation will be used
defmodule Clock do
@callback now() :: Integer.t
defmacro __using__([]) do
module = Application.get_env(:my_app, :Clock)
quote do
alias unquote(module), as: Clock
end
#!/usr/bin/env elixir
defmodule Committer do
defstruct [:name, :email]
def list(repo) do
repo
|> from_repo
|> Stream.unfold(fn str ->
case String.split(str, "\n", parts: 2, trim: true) do
@meadsteve
meadsteve / gist:4665196
Last active December 11, 2015 21:48 — forked from jazlalli/gist:4663914
var converter = (function () {
'use strict';
var romanNumeralsArray = [
{roman: 'I', number: 1},
{roman: 'V', number: 5},
{roman: 'X', number: 10},
{roman: 'L', number: 50},
{roman: 'C', number: 100},
{roman: 'D', number: 500},