Skip to content

Instantly share code, notes, and snippets.

View bsstokes's full-sized avatar

Brian Stokes bsstokes

View GitHub Profile
@bsstokes
bsstokes / Response.kt
Last active September 26, 2023 16:23
val SuccessResponse = Unit.success()
val ErrorResponse = Unit.error()
typealias SimpleResponse<T> = Response<T, Unit>
sealed class Response<out VALUE, out ERROR> {
data class Success<VALUE>(val value: VALUE) : Response<VALUE, Nothing>()
data class Error<ERROR>(val error: ERROR) : Response<Nothing, ERROR>()
inline fun <T> fold(ifSuccess: (VALUE) -> T, ifError: (ERROR) -> T): T = when (this) {
val SuccessResponse = Unit.success()
val ErrorResponse = Unit.error()
typealias SimpleResponse<T> = Response<T, Unit>
sealed class Response<out VALUE, out ERROR> {
data class Success<VALUE>(val value: VALUE) : Response<VALUE, Nothing>()
data class Error<ERROR>(val error: ERROR) : Response<Nothing, ERROR>()
inline fun <T> fold(ifSuccess: (VALUE) -> T, ifError: (ERROR) -> T): T = when (this) {
@bsstokes
bsstokes / filter-password.nginx.conf
Created June 10, 2013 13:43
Filter the password from a request in the nginx access log.
log_format filtered_log '$remote_addr - $http_host - $remote_user [$time_local] {$request_time} {$upstream_response_time} $upstream_addr'
'"$filtered_request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
server {
root /home/ubuntu/password_test/www;
index index.html index.htm;
server_name password_test;
location / {
@bsstokes
bsstokes / Employee Guidelines.md
Last active October 13, 2015 18:18
Employee Guidelines

Employee Guidelines

Before you go to work, ask yourself, Did I...

  1. Take a shower with soap?
  2. Put on deodorant?
  3. Put on clean clothes?
  4. Stay away from animal urine and feces?

If you answered no to any of these questions, please stay home.

@bsstokes
bsstokes / build-ruby-1.9.2-p180-gcdata.sh
Created November 27, 2012 19:47
Build ruby-1.9.2-p180 patched with gcdata for rbenv
# Build ruby-1.9.2-p180 patched with gcdata for rbenv
# ===================================================
#
# This script will install a version of ruby-1.9.2-p180 for [rbenv][] that's
# patched with RVM's [gcdata][] patch.
#
# CAVEAT
# ------
#
# Keep in mind that this is for **ruby-1.9.2-p180**. Update the version numbers