Skip to content

Instantly share code, notes, and snippets.

View katopz's full-sized avatar
🦀
Rust me if you can

Todsaporn Banjerdkit katopz

🦀
Rust me if you can
View GitHub Profile
@vizsumit
vizsumit / LoraConfig.json
Last active August 16, 2024 06:59
settings for Kohya_ss LoRA Training
{
"LoRA_type": "Standard",
"adaptive_noise_scale": 0,
"additional_parameters": "",
"block_alphas": "",
"block_dims": "",
"block_lr_zero_threshold": "",
"bucket_no_upscale": true,
"bucket_reso_steps": 64,
"cache_latents": true,
@ahoho
ahoho / convert-hf-to-pth.py
Created April 2, 2023 19:35
Convert huggingface model to pytorch checkpoint (modified from alpaca-lora)
# Convert a huggingface LLaMA checkpoint to an (unsharded) pytorch checkpoint
# comes from https://github.com/tloen/alpaca-lora/blob/main/export_state_dict_checkpoint.py
import argparse
import json
from pathlib import Path
import torch
import transformers
from transformers import LlamaForCausalLM, LlamaTokenizer # noqa: E402
@domnikl
domnikl / build.yml
Last active November 4, 2024 03:55
GitHub Action Workflow to build a Rust project with tests and clippy
name: main
on:
push:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
jobs:
@fisherdarling
fisherdarling / inserter.rs
Created November 15, 2022 08:31
DO Inserter Implementation with Usage
use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use worker::*;
use workers_do_proxy::{
durable_object_proxy,
error::Error,
proxy::{ProxiedObject, ProxiedRequest},
Ctx,
};
use workers_traits::{env::Env, state::State, storage::Storage};

preact-root-fragment: partial root rendering for Preact

This is a standalone Preact 10+ implementation of the deprecated replaceNode parameter from Preact 10.

It provides a way to render or hydrate a Preact tree using a subset of the children within the parent element passed to render():

<body>
  <div id="root">  ⬅ we pass this to render() as the parent DOM element...
@prologic
prologic / LearnGoIn5mins.md
Last active November 5, 2024 02:14
Learn Go in ~5mins
@wschwab
wschwab / eventFilter.js
Last active September 13, 2024 06:17
a handmade Ethereum event filter that you should never really use
const eventFilter = (contractAddress, contractAbi, eventName, _provider) => {
const provider = _provider
// this will return an array with an object for each event
const events = contractAbi.abi.filter(obj => obj.type ? obj.type === "event" : false);
// getting the Transfer event and pulling it out of its array
const event = events.filter(event => event.name === eventName)[0];
// getting the types for the event signature
const types = event.inputs.map(input => input.type)
// knowing which types are indexed will be useful later
let indexedInputs = [];
@kyontan
kyontan / merge.sql
Last active July 26, 2020 15:20
BigQuery MERGE DML to merge {source} into {destination} with having same primary keys also having newer updated_at
MERGE {destination} T
USING (
SELECT * EXCEPT(rn)
FROM (
SELECT
*,
row_number() over (PARTITION BY {primary_keys} ORDER BY updated_at DESC) AS rn
FROM {source})
WHERE rn = 1
) S
@mistic100
mistic100 / vimeo-downloader.js
Created September 15, 2018 09:01
Download video from Vimeo (chopped m4s files)
// 1. Open the browser developper console on the network tab
// 2. Start the video
// 3. In the dev tab, locate the load of the "master.json" file, copy its full URL
// 4. Run: node vimeo-downloader.js "<URL>"
// 5. Combine the m4v and m4a files with mkvmerge
const fs = require('fs');
const url = require('url');
const https = require('https');
@tomconte
tomconte / truffle-config.js
Last active July 14, 2019 03:38
Example Truffle 3.0 configuration file to allow deploying contracts to an Azure "Bletchley" Ethereum consortium network. Based on the Truffle docs for Infura (http://truffleframework.com/tutorials/using-infura-custom-provider).
var bip39 = require("bip39");
var ethwallet = require('ethereumjs-wallet');
var ProviderEngine = require("web3-provider-engine");
var WalletSubprovider = require('web3-provider-engine/subproviders/wallet.js');
var Web3Subprovider = require("web3-provider-engine/subproviders/web3.js");
var Web3 = require("web3");
// Insert raw hex private key here, e.g. using MyEtherWallet
var wallet = ethwallet.fromPrivateKey(Buffer.from('abcdef', 'hex'));