Skip to content

Instantly share code, notes, and snippets.

View Krewn's full-sized avatar

Kevin Nelson Krewn

View GitHub Profile
class buckets:
def __init__(self,durp=[]):
self.counts = {}
self.maxCount = 0
self.totalCount = 0
for x in durp:
self.count(x)
def count(self,x):
self.totalCount += 1
try:
@Krewn
Krewn / Bingo.py
Last active March 27, 2025 02:28
A questionably stable implementation of random selection by urandom demonstrated with some bingo pulls.
from os import urandom
from math import *
import hashlib
import time
class ___:
pass
_dir = dir(___)
def printSelf(x):
@Krewn
Krewn / clipToSvg.py
Created February 3, 2025 11:12
Pretty much just doodling
class pointXY:
def __init__(self,x,y):
self.x = x
self.y = y
def svgStr(self):
return f"{self.x},{self.y}"
class lines:
@Krewn
Krewn / pages.py
Created January 28, 2025 12:02
Make a long svg for printing from the browser.
import svgwrite
def vecadd(*args):
return [sum(a) for a in zip(*args)]
vadd = vecadd
class pen:
def __init__(self,dwg=None,x=None,y=None):
self.stroke=svgwrite.rgb(10, 10, 16, '%')
self.location = (0 if x == None else x,0 if y == None else y)
@Krewn
Krewn / yieldData.js
Created January 19, 2025 06:43
This was usful in demonstration for extracting json data from html. Data as JSON from html document values with element's names as the keys. TODO: Handle name collisions
let print = function(s){
console.log(s);
}
let hasValue = function(x){
return x!==null && x!==undefined ;
}
let attemptListToObject = function(a){
if(a.every(x => x instanceof Object && Object.keys(x).length == 1)){
@Krewn
Krewn / openAiDalleInterface.py
Created January 4, 2023 18:44
You will need to set your OPENAI_API_KEY system environmental variable for this to work for you.
#importing needed libraries
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
from pyramid.view import view_config
import openai
import json
#creating a data structure for our application
responses = []
@Krewn
Krewn / pyramidWebDemo.py
Last active November 11, 2022 20:39
A basic pyramid webserver for submitting querys to methods.
import os
from urllib import parse
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
from pyramid.view import view_config
class boilerPlate:
@Krewn
Krewn / cap.go
Last active November 17, 2022 18:08
This is a webserver for generating query strings with low hashes, and redirect to http://aHashPlace.herokuapp.com. goCap.py takes an x y image and scale and makes requests to cap.go. runner.py spins up 2 instances of cap.go and 2 instances of goCap.py the second instance will proceed backwards through the pixels in reverse.
package main
import(
"bytes"
"fmt"
"crypto/sha256"
"math/rand"
"time"
"net/http"
@Krewn
Krewn / aHashPlaceImgDrawer.py
Last active October 25, 2022 23:49
Sorry for the default image download. Feel free to make modifications before use... Obviously.
from urllib import parse
import requests
from bs4 import BeautifulSoup
import hashlib
import sys
from PIL import Image
import shutil
def findFlavor(attrs):
@Krewn
Krewn / cap.py
Last active October 25, 2022 21:04
A bot for mining pixels on aHashPlace
import hashlib
from urllib import parse
import webcolors
from PIL import Image
import os
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
from pyramid.view import view_config