Skip to content

Instantly share code, notes, and snippets.

@bistaumanga
bistaumanga / kMeans.py
Last active December 7, 2020 10:16
KMeans Clustering Implemented in python with numpy
'''Implementation and of K Means Clustering
Requires : python 2.7.x, Numpy 1.7.1+'''
import numpy as np
def kMeans(X, K, maxIters = 10, plot_progress = None):
centroids = X[np.random.choice(np.arange(len(X)), K), :]
for i in range(maxIters):
# Cluster Assignment step
C = np.array([np.argmin([np.dot(x_i-y_k, x_i-y_k) for y_k in centroids]) for x_i in X])
@samidhtalsania
samidhtalsania / bintree.py
Last active October 28, 2022 14:28
Binary tree in Python
class Node():
def __init__(self,key):
self.key = key
self.left = None
self.right = None
self.parent = None
class Tree():
{
"presets": [
{
"Name": "Major",
"Value": "1;3;5;6;8;10;12",
"Group": "Common"
},
{
"Name": "Minor",
"Value": "1;3;4;6;8;9;11",
@fabtho
fabtho / save_screenshot.py
Last active December 12, 2022 08:07
make full screenshot with selenium in python
#!/usr/bin/python
from selenium import webdriver
from PIL import Image
from cStringIO import StringIO
verbose = 1
browser = webdriver.Firefox()
browser.get('http://stackoverflow.com/questions/37906704/taking-a-whole-page-screenshot-with-selenium-marionette-in-python')
@muink
muink / 3.5lo2balance.md
Last active November 7, 2024 03:48
关于3.5单端和2.5 3.5 4.4 平衡间互相转换的几条定理

关于3.5单端和2.5 3.5 4.4 平衡间互相转换的几条定理

3.5立体声与典型平衡口定义

ddt pht

互转定理

  1. 平衡设备之间可以完全地互相转换,只要接口线序一一对应不出错
@woyin
woyin / autosign.php
Created August 10, 2021 03:22
Auto Sign for Discuz DSU
<?php
header("Content-type:text/html;charset=utf-8");
// 设定cookie和网址
// 通过Chrome 或者Edge 找到对应的Cookie值,找到以saltkey和auth 结尾的Cookie 名称和值,填在这里
$cookie = 'xxxxxxx_saltkey=XXXXXXXX;xxxxxxxx_auth=XXXXXX';
// 获取formhash
$URL = "http://bbs.abc.com/forum.php"; //论坛地址
$str = loadcode($cookie,$URL);
@Miraculix200
Miraculix200 / gist:e0fc7c02e7911d840f3abe3c7cdae6f9
Created October 31, 2022 18:52
Dreambooth on SageMaker Studio Lab (save as .ipynb notebook)
This file has been truncated, but you can view the full file.
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"cellView": "form",
"colab": {
"base_uri": "https://localhost:8080/"
},
@crosstyan
crosstyan / swap_attn.py
Last active July 29, 2023 19:42
swap attn layer for stable diffusion model
# some code is from https://github.com/CCRcmcpe/scal-sdt
from typing import Any, Literal, Optional
from pathlib import Path
import warnings
import torch
import click
DType = Literal["fp16", "fp32", "bf16"]
LayerName = Literal["attn", "ff"]
StateDict = dict[str, Any]
@MrSedan
MrSedan / README.md
Last active August 25, 2024 15:36
NAI (NovelAI) prompt to WebUI prompt converter

NAI to WebUI prompt converter

Running

You just need to have python installed on your system and run:

python3 nai_to_webui.py '{{some word}} some prompt...'

Or (not on Windows):

chmod +x nai_to_webui.py
./nai_to_webui.py '{{some word}} some prompt...'