Skip to content

Instantly share code, notes, and snippets.

View Thomascountz's full-sized avatar
💃
LGTM!

Thomas Countz Thomascountz

💃
LGTM!
View GitHub Profile
@Thomascountz
Thomascountz / laser_cut_test_card.svg
Created December 5, 2023 19:06
Laser Cut Test Card
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Thomascountz
Thomascountz / async_http_client.py
Last active October 25, 2023 13:43
AsyncHttpClient is an asyncio-based MicroPython library, designed for asynchronous, concurrent HTTP/HTTPS requests to avoid blocking the execution of other coroutines.
# v0.1
import usocket as socket
import ussl
import uasyncio as asyncio
import ujson as json
from utime import ticks_ms, ticks_diff
class AsyncHttpClient:
"""
@Thomascountz
Thomascountz / closures.md
Created August 7, 2023 01:23
Closures in Ruby

🚀 Let's explore Closures in #Ruby with a space-themed example! 🌌 #ThomasTip

Closures are functions/methods that can be invoked from other functions or methods, while retaining access to variables from their original scope.

def launch_sequence(seconds)
  start = Time.now
  -> do
    elapsed = Time.now - start
 remaining = seconds - elapsed.round
@Thomascountz
Thomascountz / hash_struct_data_class_benchmark.rb
Created August 4, 2023 18:45
Ruby Hash v. Struct v. Data v. Class
require 'benchmark/ips'
PointStruct = Struct.new(:x, :y, :grayscale)
PointData = Data.define(:x, :y, :grayscale)
class PointClass
attr_accessor :x, :y, :grayscale
def initialize(x, y, grayscale)
73d3a42b29e14f6ddeb56cee824957ee6cfaa5f95a3c3a205f102147288c3661a4ea95b6025dc788deb1f79b09552e75cab662ee432fcf0041a290f80a6f45cd0ad26fc0ab8fc49fa062e1ac81f4c5cfd99e4f695e7b349c008c2744e0637d79a1f25b1ef4b580655a7559617a4e1c104a98deefa265d5cee5471043bba9f57d8b46f3d166d98077b70bf729598b9d8fe063002befc47aa49cd14757ec80e4e93d3b934d2ad3ae80ea0ecd4d91e4f0d73374f6277f2776ca1e9560cc5111a6ef1dd363944c9430d2c894a6a4c09bedf4a59dcc91d00c9c96a122252bd127655e18e494d19b397b5030f9ca603788dbeb3cd1f1fefc5e4f7f1d178d7c714cd90623f0ac3eef0bf6a32dca69c20787e1576f1e7fa9bc7ae0249c4cc16624e594c5c05f1785ba3afe2fa9fee6f2b05b2300ceb59c35d91018bb924f0b430c3e843a0d9023503edc5adb335f71311841faa772c721dc4111ae045330ba53bdf4036a09c8273551b27ef7df82c29f899facbc7722d86c9479fa5e5b7dca0600512fc6f89b7885f2a63e0af36ccdc433576c868ff6792e6bbcfd2eb606c356c3be1e26876196f5b73349c5088686b4731f05fb1dd76069d04a92f1c5968614fafa71efa4bb6863db3e2bbd08945a776aa15f0861afacca64842077546c7c979d9e4620b34ea2fdbd20c2fec4c5658ba7663f1e5c673413e75c4f267f003c7f5261c04a
@Thomascountz
Thomascountz / rails_new_dev.sh
Last active April 21, 2023 11:53
Creating a new Rails app using locally checked-out code.
# Fork rails/rails on Github
> git clone gem https://github.com/thomascountz/rails.git
Cloning into 'rails'...
> cd rails
# Checkout SHA prior to the merge commit and create a new branch
> git checkout -b practice-pr-46683 59fe981^
Switched to a new branch 'practice-pr-46683'
@Thomascountz
Thomascountz / why_null_sql_text.md
Created September 14, 2022 12:50
Why is SQL_TEXT NULL?

This is an example of selecting * that will need to execute for more than the set timeout of 1ms.

mysql> select * /*+ MAX_EXECUTION_TIME(1) */ from test_table;
ERROR 3024 (HY000): Query execution was interrupted, maximum statement execution time exceeded

mysql> select thread_id,event_name,sql_text,digest_text,current_schema,mysql_errno,returned_sqlstate,message_text,errors from performance_schema.events_statements_history where mysql_errno = 3024 limit 1\G
*************************** 1. row ***************************
        thread_id: 345
       event_name: statement/sql/select
@Thomascountz
Thomascountz / output_graph.md
Last active August 22, 2022 08:23
Addition operation on a Value object
graph LR
    A["A | data: 1.0"]
    APlus(("+"))
    B["B | data: 2.0"]
    C["C | data: 3.0"]
    A --> APlus
    B --> APlus
    APlus --> C
@Thomascountz
Thomascountz / sixth_export.rb
Created June 28, 2022 08:00
Lo-fi inspired piece written programmatically with Sonic Pi
use_bpm 68
kicks = "/Users/thomas.countz/Sync/Lunar/Drum Shots/Kicks"
snares = "/Users/thomas.countz/Sync/Lunar/Drum Shots/Snares"
live_loop :click do
sleep 1
end
live_loop :hiss, sync: :click do
sample :vinyl_hiss, amp: 0.3, beat_stretch: 5, rpitch: -8
@Thomascountz
Thomascountz / third_export.rb
Created June 27, 2022 21:59
Lo-fi Piece written programmatically with Sonic Pi
# Listen here: https://soundcloud.com/thomas-countz/third-export
use_bpm 68
kicks = "/Users/thomas.countz/Sync/Lunar/Drum Shots/Kicks"
snares = "/Users/thomas.countz/Sync/Lunar/Drum Shots/Snares"
live_loop :click do
sleep 1
end