Skip to content

Instantly share code, notes, and snippets.

View fractos's full-sized avatar
🌑
we are wolves we are not loved

Adam Christie fractos

🌑
we are wolves we are not loved
View GitHub Profile
@fractos
fractos / json-array-to-yaml-list.py
Created September 28, 2020 10:36
JSON array to YAML list
import sys
import json
originalString = sys.argv[1]
jsonPropertyName = sys.argv[2]
targetPropertyName = sys.argv[3]
indentLevel = int(sys.argv[4])
content = json.loads(originalString)
using System;
using Inversion.Process;
namespace Application.Configuration
{
public static class Conditions
{
public static IConfigurationElement EventMatch(string name, string value)
{
return new Inversion.Process.Configuration.Element(
@fractos
fractos / sample.cs
Created March 18, 2017 22:12
Example with some extended prototype configuration
// only fire "process-admin" message if:
// - there is a "user" object in the control state
// - it has an "email" property with value "admin@admin.com"
// - the context parameter "my-number" exists
// - it is safe to convert it to a 32-bit integer
new ParameterisedSequenceBehaviour("do-stuff",
new Configuration.Builder {
{"control-state", "has", "user"},
{"control-state", "equals", "user.email", "admin@admin.com" },
@fractos
fractos / sample.cs
Created March 18, 2017 21:29
Naiad service container example
Inversion.Naiad.ServiceContainer.Instance.RegisterNonSingleton("event-behaviours",
container => new List<IProcessBehaviour>
{
new ParameterisedSequenceBehaviour("my-message",
new Configuration.Builder {
{"context", "flagged", "enable-next-message", "true"},
{"control-state", "has", "user"},
{"fire", "next-message"}
})
});
@fractos
fractos / create-thumbnail-from-event.js
Last active December 13, 2016 14:04
AWS Lambda code for transforming a JPEG2000 source image from an S3 bucket event to multiple JPG thumbnails with a IIIF-compatible info.json blob that are all recorded to S3. This should be packaged as a zip file which contains a node_modules folder that has the "tmp", "async" and "gm" libraries installed.
// dependencies
var async = require('async');
var AWS = require('aws-sdk');
var gm = require('gm')
.subClass({ imageMagick: true }); // Enable ImageMagick integration.
var util = require('util');
var fs = require('fs');
// constants for bounding boxes
var widths = [1000, 800, 400, 200];
@fractos
fractos / gist:f5fa892eb7e927818d7655fe1d4c24e9
Created December 12, 2016 20:37
notes from hydra meetup
two possible URL schemes to pass arguments to a distance function:
/distance_between/mercury/earth
/mercury/distance_to/earth
alternative way of passing arguments to a function that accepts Hydra collection of things
POST to /distance_between
{
"@type": "Collection",
/*
We have a URL scheme where we are expecting these kinds of paths in a non-MVC system:
customers/{customer}
customers/{customer}/queue
customers/{customer}/queue/batches
customers/{customer}/queue/batches/{batch}
customers/{customer}/queue/batches/{batch}/completedImages
customers/{customer}/queue/batches/{batch}/errorImages
customers/{customer}/allImages
@fractos
fractos / create-thumbnail-800x600.js
Created July 29, 2015 22:35
Working version of AWS Lambda thumbnail code.
// dependencies
var async = require('async');
var AWS = require('aws-sdk');
var gm = require('gm')
.subClass({ imageMagick: true }); // Enable ImageMagick integration.
var util = require('util');
var fs = require('fs');
// constants
var MAX_WIDTH = 800;
@fractos
fractos / create-thumbnail-800x600.js
Created July 29, 2015 16:41
AWS Lambda function - modifying original walkthrough example
// dependencies
var async = require('async');
var AWS = require('aws-sdk');
var gm = require('gm')
.subClass({ imageMagick: true }); // Enable ImageMagick integration.
var util = require('util');
// constants
var MAX_WIDTH = 800;
var MAX_HEIGHT = 600;
@fractos
fractos / MongoDBUserStore.cs
Created April 30, 2015 21:22
MongoDBUserStore - Delete
public void Delete(User user)
{
AssertIsStarted();
Task.Run(async () =>
await _collection.DeleteOneAsync(
new BsonDocument("_id", user.ID)))
.Wait();
}