Skip to content

Instantly share code, notes, and snippets.

View UniDyne's full-sized avatar

D. Oliver Brown UniDyne

View GitHub Profile
"""
# Stable Diffusion Embedding Converter
This is a simple script that converts a `.pt` Textual Inversion embedding file to `.safetensors` format. Nothing more, nothing less.
## To Use
```
$ python convert_embedding.py embeddings/myembed.pt embeddings/myembed.safetensors
@UniDyne
UniDyne / MySuperClass.js
Last active July 20, 2020 12:53
Get the directory of a subclass from the parent class in NodeJS.
const path = require('path');
// this is the key function where all the magic happens
function getSubclassDir() {
// override prepareStackTrace
// error.stack will be <CallSite>[] rather than <string>
const original = Error.prepareStackTrace;
Error.prepareStackTrace = function(err, stack) { return stack; };
// create a new error and use the stack
@UniDyne
UniDyne / CanonicalJSON.js
Last active April 7, 2016 01:23
Create a canonical JSON string - ideal for cyptographic signing and verifying.
function getCanonicalJSON(obj) {
if(typeof obj === 'object') {
var keys = [];
// get keys and sort them
for(var k in obj) keys.push(k);
keys.sort();
// append each kvp to string
return '{' + keys.reduce(function(prev, cur, i) {
return prev + (i>0?',':'') + '"' + cur + '":' + getCanonicalJSON(obj[cur]);
@UniDyne
UniDyne / static_server.js
Last active March 27, 2016 16:41 — forked from ryanflorence/static_server.js
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
// this could be stored in a json file instead
var mimetypes = {
css: "text/css",
gif: "image/gif",
@UniDyne
UniDyne / mergeCSV.js
Created October 26, 2015 14:24
Merge similar CSV files, reorder columns in JScript.
/**********************************************************************
mergeCSV.js - Merge similar CSVs
***********************************************************************
Copyright (C) 2015 D. Oliver Brown <unidyne AT gmail.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to