This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DBModel(): | |
def save(self): | |
try: | |
s = get_session() | |
s.add(self) | |
s.commit() | |
except (sa.exc.IntegrityError): | |
raise x.ValidationError("Invalid data.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.smoosh = (...a) => 'arbitrary extension yay'; | |
Array.prototype.map = (...a) => 'native overload boo'; | |
for (let i in []) console.log(i); // only smoosh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
import "time" | |
import "syscall" | |
import "os" | |
import "os/signal" | |
type fn func(os.Signal) | |
func catchSigterm(fun fn) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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__), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) => { |
NewerOlder