Skip to content

Instantly share code, notes, and snippets.

@delphyne
delphyne / auto_create_diagrams.dsl
Created January 30, 2024 14:27
Structurizr scripts
/**
* Auto generate diagrams for anything that wasn't already created manually.
* Be sure to create your manually adjusted diagrams before this script is invoked, or you'll have duplicates.
*/
!script groovy {
import com.structurizr.view.AutomaticLayout; \
def sysctxviews = workspace.views.systemContextViews.collect { \
it.softwareSystem; \
} as Set; \
def containerviews = workspace.views.containerViews.collect { \
@delphyne
delphyne / Ansi.kt
Created November 22, 2022 20:26
Hacky path finder for Gold and Goblins
package util
/**
* adapted from https://gist.github.com/dainkaplan/4651352
*/
class Ansi(private vararg val codes: String) {
fun and(other: Ansi): Ansi {
return Ansi(*codes, *other.codes)
}
[tool.poetry]
name = "multi_source"
version = "0.1.0"
description = ""
authors = ["Delphyne <delphyne@not.a.real.address>"]
packages = [
{include="example", from="src/main/python"},
{include="example/generated", from="src/generated/python"}
]
@delphyne
delphyne / pyproject.toml
Last active February 12, 2019 16:35
invalid toml for differing extras
[tool.poetry]
name = "extras_gist"
version = "0.1.0"
description = ""
authors = ["delphyne <delphyne@not.a.real.address>"]
[tool.poetry.dependencies]
python = "^3.6"
pytest = "*"
pytest = {version = "*", extras = "testing", optional = true}
@delphyne
delphyne / gist:f71b3b56a68a0ef73e92
Created April 23, 2015 17:26
IntelliJ Generate Setters for Guava Optionals
#set ($paramName = $helper.getParamName($field, $project))
#set ($isOptional = $field.typeQualifiedName.startsWith('com.google.common.base.Optional<'))
#if ($isOptional)
#set ($paramType = $field.typeQualifiedName.replaceAll(".*?<(.*)>$", "$1"))
#else
#set ($paramType = $field.typeQualifiedName)
#end
public ##
#if($field.modifierStatic)
static void ##
@delphyne
delphyne / fix-hosts.awk
Created April 10, 2014 19:16
There is an obscure bug in OSX (described here: http://stevegrunwell.com/blog/quick-tip-troubleshooting-etchosts-issues/) that causes IP resolution for hosts in /etc/hosts take up to 2 minutes (!!!!) if there are more than 10 aliases on a single line. For us at Spredfast, this occurs in our Vagrant environment when we co-locate too many services…
/(vagrant-hostmanager-start|vagrant-hostmanager-end)/{f=f?0:1}f && /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]/ {
if (NF>2) {
out=""
for (i=2;i<=NF;i++) {
out=(out $1 "\t" $(i) "\n")
}
$0=out
}
}1
@delphyne
delphyne / Vagrantfile
Created April 9, 2014 17:12
Vagrantfile snippet that allows you to use protected s3 boxes without having to go through the manual download/add shennanigans. Tested with Vagrant 1.4.3. Before using, you'll need to ```vagrant plugin install aws-sdk```.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.require_plugin "aws-sdk"
def get_box_download_url(bucket, key)
s3 = AWS::S3.new
bucket = s3.buckets[bucket]
box = bucket.objects[key]
url = box.url_for(:read, {:expires => (60*30), :secure => true})
url.to_s()