Skip to content

Instantly share code, notes, and snippets.

View Yuffster's full-sized avatar
🕳️
ᕕ( ᐛ ) ᕗ

Michelle Steigerwalt Yuffster

🕳️
ᕕ( ᐛ ) ᕗ
View GitHub Profile
@Yuffster
Yuffster / Base.py
Created December 18, 2019 01:13
sqlalchemy base model
class DBModel():
def save(self):
try:
s = get_session()
s.add(self)
s.commit()
except (sa.exc.IntegrityError):
raise x.ValidationError("Invalid data.")
.sprite {
background: url('./zombies.png');
--sprite-width: 32px;
--sprite-height: 48px;
--sprite-x: 0;
--sprite-y: 0;
--sheet-x: 0;
--sheet-y: 0;
--offset-x: calc((var(--sheet-x) * var(--sprite-width) * 3));
--offset-y: calc((var(--sheet-y) * var(--sprite-height) * 4));
Array.prototype.smoosh = (...a) => 'arbitrary extension yay';
Array.prototype.map = (...a) => 'native overload boo';
for (let i in []) console.log(i); // only smoosh
package main
import "fmt"
import "time"
import "syscall"
import "os"
import "os/signal"
type fn func(os.Signal)
func catchSigterm(fun fn) {
class Magic {
constructor(fn, a) {
this.__chain = [[fn, a]];
}
get(t, a) {
if (a == "✨✨MAGIC✨✨") return true;
if (a == "resolve") {
return () => Magic.chain(this.__chain);
}
return (...b) => {
import os.path
import json
import sqlite3
from contextlib import contextmanager
__data_path = None
def get_data_path(file):
return os.path.join(
os.path.dirname(__file__),
@Yuffster
Yuffster / require.js
Created July 10, 2017 03:19
require.js
// Global object to hold modules by their path names.
Modules = {};
Modules.__loaded__ = {};
// Give all the other scripts access to the module hierarchy.
function require(p) {
if (Modules.__loaded__[p]) {
// Only initialize each module once.
return Modules.__loaded__[p];
}
from pydub import AudioSegment
def chunks(l, n):
for i in range(0, len(l), n):
yield l[i:i + n]
def convertAudio(f):
sound = AudioSegment.from_mp3(f)
[[1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,3,3,3,5,18,23,2153,2226,2229,2231,2236,2237,2237,2238,2238,2238,2238,2239,2242,2242,2243,2243,2246,2247,2247,2248,2250,2250,2250,2264,2283,2283,2283,2283,2283,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,22
@Yuffster
Yuffster / kmeans.js
Created February 19, 2017 12:39
kmeans?
function kmeans(k, arr) {
var clusters = [];
var sorted = [...new Set(arr)].sort((a, b) => a - b);
var size = Math.abs(sorted.length/k);
for (var i = 0; sorted.length>0; i += size) {
if (sorted.length < size*2) size = size*2;
clusters.push(sorted.splice(0, size));
}
console.log(clusters.map((a) => JSON.stringify(a.sort((a, b) => a - b))));
var center = (a) => {