Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import paho.mqtt.client as mqtt
import json
import ssl
import time
# --- PRINTER CREDENTIALS ---
PRINTER_IP = "192.168.x.x"
SERIAL_NUMBER = "0309F....."
ACCESS_CODE = "3081..."
USERNAME = "bblp"
include <BOSL2/std.scad>
difference(){
color("white")
cyl(h=3, d=40, $fn=100, chamfer=0.5); // Increased $fn for a smooth circle
engraved_text(); // Renamed to avoid recursion
up(1.5-0.2)
curved_text(0.05, 0.2);
from collections import defaultdict, Counter
import csv
def loadnums(filename):
nums = []
with open(filename) as csvfile:
reader = csv.reader(csvfile, delimiter=':')
for r in reader:
nums.extend([int(i) for i in r])
return nums
@cashlo
cashlo / sketch.ino
Created November 7, 2024 16:04
Couleur Clarity LED sign
#include "M5Atom.h"
#include <FastLED.h>
#define NUM_LEDS 140 // Number of LEDs in your strip
#define DATA_PIN 25 // Data pin connected to your LED strip
#define BUTTON_PIN G39
#define STAR_START 57 // Start index of the "star" effect
#define STAR_END 134 // End index of the "star" effect
@cashlo
cashlo / gist:da518b185f577641b969af075ae7a21c
Last active July 31, 2022 17:24
Floyd-Steinberg Dithering for Kotlin Android
fun dithering(bitmap: Bitmap) {
val height: Int = bitmap.getHeight()
val width: Int = bitmap.getWidth()
val colors = 3
val threshold = 255/colors
for (x in 0 until width) {
for (y in 0 until height) {
val pixel = bitmap.getPixel(x, y)
var alpha = Color.alpha(pixel)
@cashlo
cashlo / balance_bug.ino
Created October 5, 2020 20:56
M5Stack BugC self-balance bot
#include <M5StickC.h>
#include "bugC.h"
#define sampleTime 0.005
float pitch = 0.0F;
float roll = 0.0F;
float yaw = 0.0F;
float roll_offset = 0.0F;
@cashlo
cashlo / dwarf_fortress_height_map.scad
Created June 21, 2020 20:52
Generate model from Dwarf Fortress elevation map
difference(){
scale([1,1,0.3]){
surface("YOUR FILE NAME GOES HERE", center=true);
}
cube([200,200,14], center=true);
}
@cashlo
cashlo / gomoku_board.py
Created June 3, 2020 16:45
Gomoku Board
class GomokuBoard:
def __init__(self, size=9):
self.size = size
self.board = [0]*(size*size)
self.last_move = None
self.total_moves = 0
def clone_board(self):
new_board = GomokuBoard(self.size)
@cashlo
cashlo / gomoku_mcst.py
Created June 3, 2020 16:30
Gomoku MCST implementation
class GomokuSearchTree(Node):
def __init__(self, parent, board, from_move, next_player, simulation_limit=1, exploration_constant=1):
Node.__init__(self, parent=parent, simulation_limit=simulation_limit, exploration_constant=exploration_constant)
self.board = board
self.from_move = from_move
self.next_player = next_player
def create_from_move(self, move):
new_board = self.board.clone_board()
new_board.place_move(move, self.next_player)