Skip to content

Instantly share code, notes, and snippets.

View patrickgalbraith's full-sized avatar
🏠
Working from home

Patrick Galbraith patrickgalbraith

🏠
Working from home
View GitHub Profile
from PIL import Image
import stable_inference
import torch
from einops import repeat
def image_grid(imgs, rows, cols):
assert len(imgs) == rows*cols
w, h = imgs[0].size
grid = Image.new('RGB', size=(cols*w, rows*h))
@moodysalem
moodysalem / promise-cancellable.js
Last active April 9, 2024 18:06
ES6 Cancellable Promise Wrapper
/**
* Returns a promise that has a cancelled method that will cause the callbacks not to fire when it resolves or rejects
* @param promise to wrap
* @returns new promise that will only resolve or reject if cancel is not called
*/
export default function cancellable(promise) {
var cancelled = false;
const toReturn = new Promise((resolve, reject) => {
promise.then(() => {
@markzyu
markzyu / mpromise.ts
Last active February 17, 2017 11:29
StateMonad for js Promise
// vim: expandtab ts=4 sw=4:
// Please compile using 'gulp', and 'gulp-typescript'
// This is the core of this library.
/*************************
Copyright (c) 2016 Zhongzhi Yu
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 permit persons to whom the Software is furnished to do so, subject to the following conditions:
@radiosilence
radiosilence / gist:3946121
Created October 24, 2012 13:43
Outputs some files that WMs can import and colourify everything with.
import sys
import colorsys
from colorz import colorz
WALLPAPER = '/home/james/.wallpaper'
COLORS = '/home/james/.colors'
XRESOURCES = '/home/james/.Xresources'
cols = ''
xres = """