Skip to content

Instantly share code, notes, and snippets.

View mikebuss's full-sized avatar

Mike Buss mikebuss

View GitHub Profile
@mikebuss
mikebuss / floyd-steinberg.py
Created February 8, 2024 01:03
Floyd Steinberg Dithering
import sys
import io
import os
import traceback
from wand.image import Image as WandImage
from wand.color import Color
from PIL import Image
IMAGE_WIDTH = 800
IMAGE_HEIGHT = 480
@mikebuss
mikebuss / s3_uploader.rb
Last active March 16, 2020 20:16
Partial script for uploading to S3 in Ruby
require "aws-sdk"
require_relative "errors"
class S3Uploader
AWS_ACCESS_KEY = ENV["AWS_ACCESS_KEY"]
AWS_SECRET_KEY = ENV["AWS_SECRET_KEY"]
AWS_BUCKET_NAME = ENV["AWS_BUCKET_NAME"]
AWS_REGION = ENV["AWS_REGION"] || "us-east-1"
AWS_FILE_PREFIX = ENV["AWS_FILE_PREFIX"] || "bm"
@mikebuss
mikebuss / simple-device-query.swift
Created January 28, 2020 00:02
Query Devices in Swift
func queryForDevices() {
let rPi = URL(string: "http://10.3.141.1:8080/devices")!
let task = URLSession.shared.dataTask(with: rPi) {(data, response, error) in
guard let data = data else { return }
print(String(data: data, encoding: .utf8)!)
}
task.resume()
}
@mikebuss
mikebuss / router.go
Created January 27, 2020 23:54
Simple Go Server
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
http.HandleFunc("/devices", HandleDeviceRequest)
@mikebuss
mikebuss / PhraseRecognitionExample.cs
Created January 25, 2020 19:29
PhraseRecognitionExample
using System.Collections.Generic;
using UnityEngine.Windows.Speech;
using System.Linq;
public class PhraseRecognitionExample : MonoBehaviour
{
// Holds all of the keywords and their actions
Dictionary<string, System.Action> keywords = new Dictionary<string, System.Action>();
// Called before the first frame update
@mikebuss
mikebuss / cbot.sh
Last active January 29, 2019 00:51
certbot-renewal
echo "Updating certbot..."
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository universe
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot python-certbot-apache
echo "Printing version..."
certbot --version
@mikebuss
mikebuss / decode-json-swift.swift
Created January 25, 2019 21:46
Decode [Any] and [String: Any] Swift 4
//
//
// Adapted from:
//
// Original: https://gist.github.com/loudmouth/332e8d89d8de2c1eaf81875cfcd22e24
// Adds encoding: https://github.com/3D4Medical/glTFSceneKit/blob/master/Sources/glTFSceneKit/GLTF/JSONCodingKeys.swift
// Adds fix for null inside arrays causing infinite loop: https://gist.github.com/loudmouth/332e8d89d8de2c1eaf81875cfcd22e24#gistcomment-2807855
//
struct JSONCodingKeys: CodingKey {
var stringValue: String
@mikebuss
mikebuss / math-helper.swift
Created November 4, 2018 01:01
math-helper.swift
class MathHelper {
lazy var pi: Double = {
// Calculate pi to a crazy number of digits
return resultOfCalculation
}()
}
@mikebuss
mikebuss / lazy-person.swift
Created November 4, 2018 01:01
lazy-person.swift
class Person {
var name: String
lazy var personalizedGreeting: String = {
return "Hello, \(self.name)!"
}()
init(name: String) {
self.name = name
}
@mikebuss
mikebuss / lazy-var-class-function.swift
Created November 4, 2018 01:00
lazy-var-class-function.swift
class TestClass {
lazy var players = TestClass.initialPlayers()
class func initialPlayers() -> [String] {
var players = ["John Doe"]
return players
}
}