Skip to content

Instantly share code, notes, and snippets.

View steverhoades's full-sized avatar

Steve Rhoades steverhoades

View GitHub Profile
@eavae
eavae / convert_diffusers_lora_to_sd_webui.py
Created August 23, 2023 07:45
A script help you convert diffusers lora to sd webui format
from pathlib import Path
from diffusers import StableDiffusionXLPipeline
import torch
from safetensors.torch import save_file
# text_encoder.text_model.encoder.layers.0.self_attn.k_proj.lora_linear_layer.down.weight
# lora_te_text_model_encoder_layers_0_self_attn_k_proj.lora_down.weight
# 1. text_encoder -> lora_te, text_encoder_2 -> lora_te2
# 2. map
# 3. .weight -> 2 .alpha -> 1 and replace . -> _
@andremsantos
andremsantos / knex-pagination.js
Last active March 4, 2022 12:36
Adding pagination to knex.js
module.exports = function(dbConfig) {
var knex = require('knex')(dbConfig);
var KnexQueryBuilder = require('knex/lib/query/builder');
KnexQueryBuilder.prototype.paginate = function (per_page, current_page) {
var pagination = {};
var per_page = per_page || 10;
var page = current_page || 1;
if (page < 1) page = 1;
@kevin-smets
kevin-smets / 1_kubernetes_on_macOS.md
Last active May 5, 2024 10:12
Local Kubernetes setup on macOS with minikube on VirtualBox and local Docker registry

Requirements

Minikube requires that VT-x/AMD-v virtualization is enabled in BIOS. To check that this is enabled on OSX / macOS run:

sysctl -a | grep machdep.cpu.features | grep VMX

If there's output, you're good!

Prerequisites

@dgraham
dgraham / fetch.js
Last active March 24, 2023 15:44
Simple window.fetch wrapper.
(function() {
function status(response) {
if (response.ok) {
return response
} else {
var error = new Error(response.statusText || response.status)
error.response = response
throw error
}
}
@kristopherjohnson
kristopherjohnson / install_wine_homebrew_osx.sh
Last active February 27, 2019 14:19
Commands to set up OS X to run Enterprise Architect (assumes Homebrew is installed)
# Install Wine and other necessary components using Homebrew
brew install wine
brew install winetricks
brew install cabextract
# Instructions from http://www.sparxsystems.com/support/faq/enterprise-architect-WINE.html
winetricks allfonts
winetricks msxml
winetricks msxml3
winetricks msxml4
@nikic
nikic / objects_arrays.md
Last active April 12, 2024 17:05
Post explaining why objects often use less memory than arrays (in PHP)

Why objects (usually) use less memory than arrays in PHP

This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)

The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array part of it away. So how does that work?

The key here is that objects usually have a predefined set of keys, whereas arrays don't: