Skip to content

Instantly share code, notes, and snippets.

View JesterXL's full-sized avatar
🔊
writing

Jesse Warden JesterXL

🔊
writing
View GitHub Profile
@JesterXL
JesterXL / webpack.config.js
Created February 27, 2017 13:39
Example webpack for ES6 unit testing
'use strict';
// Modules
var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var _ = require('lodash');
app "AoC Day 2 - Rock Paper Scissors"
packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.1.1/zAoiC9xtQPHywYk350_b7ust04BmWLW00sjb9ZPtSQk.tar.br" }
imports [pf.Stdout, pf.Path, pf.File, pf.Task]
provides [main] to pf
# saysYeah = \yup ->
# "\(yup) yeah!"
# expect saysYeah "cactus" == "cactus yeah!"
@JesterXL
JesterXL / promiseall.js
Last active October 31, 2022 16:02
Example of using Array Destructuring for Promise.all.
Promise.all([
someThingThatReturnsAPromise(),
otherThingThatReturnsAPromise(),
lastThingThatReturnsAPromise()
])
.then( results =>
{
// this...
const [first, second, third] = results;
// ... instead of
class Ok {
constructor(data) {
this.data = data
this._type = "Ok"
this.then.bind(this)
this.match.bind(this)
}
then(func) {
const result = func(this.data)
@JesterXL
JesterXL / elm-review-rules-adr.md
Last active February 28, 2022 20:44
Elm Review Rules on Mon, Feb 28th, 2022

Elm Review Rules Architectural Design Record

Status

Proposed

Context

While Elm has an idiomatic way to do things regarding the architecture, there are various ways to use types and code. Much like JavaScript and Python have linting rules, Elm does as well to help enforce best practices that the team deems important.

@JesterXL
JesterXL / index.py
Created June 6, 2017 16:51
Python Logging examples
import logging
logger = logging.getLogger('name of app')
logger.info('whatever')
logging.basicConfig(stream=sys.stderr)
import logging
const binaryBody = await res.buffer()
const body = binaryBody.toString('binary')
debug("first 255 of string body: %s", body.substr(0, 255))
const { isAnError, parsedResult } = verifyNotJSONErrorMessage(body)
debug("isAnError: %o", isAnError)
if(isAnError) {
return failure({ isAnError, parsedResult })
}
const boundaryHeader = res.headers.get('content-type')
debug("boundaryHeader: %s", boundaryHeader)
@JesterXL
JesterXL / default-value-ramda-propOr-lodash-getOr.js
Created March 1, 2021 00:02
People think you don't need Lodash or Ramda, but ... you just have to have patience and love and empathy.
// keep in mind this does NOT do paths
const getOr = (defaultValue, prop, object) =>
(object ?? {})?.[prop] ?? defaultValue
module Main exposing (main)
import Browser
import Html exposing (Html, button, div, text)
import Html.Events exposing (onClick)
import Html.Attributes exposing (style)
import Draggable
type alias Model =
type applicationLoadBalancerEvent = {
path: string,
httpMethod: string,
queryStringParameters: option<string>,
body: option<string>
}
type header = (string, string)