Skip to content

Instantly share code, notes, and snippets.

View mikz's full-sized avatar

Michal Cichra mikz

  • Prague, Czech Republic
View GitHub Profile
@stalniy
stalniy / 1. Intro.md
Last active March 19, 2025 20:55
Ebusd Vaillant Eloblock

Прошивка Wemos D1 mini для ebusd адаптера

Зазначені нижче кроки будуть актуальні для linux (ubuntu) та macos, вінда на "відпочинку" не мав змоги перевірити це там. Для прошивки будемо використовувати esptool.py

Вимоги: ubuntu : встановлений пайтон 3.8.10, або вище (має бути доступний за замовчанням, перевіряємо: python3 -V) macos : встановлений brew, за допомогою якого доставимо все необхідне

Установка esptool: MacOS:

@equivalent
equivalent / README.md
Last active February 18, 2025 03:12
Rails 7 importmaps dropzone.js direct upload ActiveStorage

This is simple implementation of technologies in hobby project of mine built in Rails7 where I need direct upload to S3.

@farmio
farmio / knx-relative-dimming-for-lights.yaml
Last active December 16, 2024 13:56
KNX - relative dimming for lights blueprint
blueprint:
name: KNX - relative dimming for lights
description: Control Home Assistant light entities from KNX switching and relative dimming (DPT 3.007) telegrams.
homeassistant:
# `knx.telegram` trigger and `enabled` templates require Home Assistant 2024.6.0
min_version: "2024.6.0"
domain: automation
input:
target_lights:
name: Light
@KonnorRogers
KonnorRogers / environment.js
Last active July 12, 2024 22:42
ESBuild with Webpacker < 6 in Rails. Bye Babel <3
// DONT FORGET TO `yarn add esbuild-loader` !!!
// config/webpacker/environment.js
const { environment } = require('@rails/webpacker')
const { ESBuildPlugin } = require('esbuild-loader')
const esBuildUse = [
{
loader: require.resolve('esbuild-loader'),
// What you want to compile to, in this case, ES7
@lazaronixon
lazaronixon / _form.html.erb
Last active March 28, 2025 10:19
Dropzone.js + Stimulus + Active Storage + CSS Zero (2025)
<%= form_with(model: billboard) do |form| %>
<%= tag.div class: "dropzone", data: { controller: "dropzone", dropzone_param_name_value: "billboard[images][]", dropzone_url_value: rails_direct_uploads_url, dropzone_accepted_files_value: "image/*", dropzone_max_files_value: 3, dropzone_max_filesize_value: 0.300 } do %>
<div class="dz-default dz-message flex flex-col items-center">
<%= image_tag "upload.svg", size: 28, class: "colorize-black", aria: { hidden: true } %>
<h5 class="font-semibold mbs-4">Drop files here or click to upload.</h5>
<p class="text-sm text-subtle">Upload up to 10 files.</p>
</div>
<% end %>
<div class="inline-flex items-center mbs-2 mie-1">
javascript:for(let%20a%20of%20document.querySelectorAll("tr:not(.days_off):not(.leave_date):not(.full_day_holiday)%20input[name^=\"timesheet[timesheetRow]\"][name$=\"[inTime]\"]"))a.value="09:00";for(let%20a%20of%20document.querySelectorAll("tr:not(.days_off):not(.leave_date):not(.full_day_holiday)%20input[name^=\"timesheet[timesheetRow]\"][name$=\"[breakDuration]\"]"))a.value="01:00";for(let%20a%20of%20document.querySelectorAll("tr:not(.days_off):not(.leave_date):not(.full_day_holiday)%20input[name^=\"timesheet[timesheetRow]\"][name$=\"[outTime]\"]"))a.value="18:00",a.dispatchEvent(new%20FocusEvent("blur"));
@turtleDev
turtleDev / pack.lua.md
Last active December 5, 2024 19:04
pack.lua | The Lua module bundler

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.

@nonsintetic
nonsintetic / ArduinoZeroTimer.ino
Last active January 11, 2025 06:52
SAMD21 Arduino Timer Example
/*
* This sketch illustrates how to set a timer on an SAMD21 based board in Arduino (Feather M0, Arduino Zero should work)
* It should generate a 1Hz square wave as it is (thanks richdrich for the suggestion)
* Some more info about Timer Counter works can be found in this article:
* http://www.lucadavidian.com/2017/08/08/arduino-m0-pro-il-sistema-di-clock/
* and in the datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/SAM_D21_DA1_Family_DataSheet_DS40001882F.pdf
*/
uint32_t sampleRate = 1000; //sample rate in milliseconds, determines how often TC5_Handler is called
# Cleans up branches like:
# if Shopify.rails_next?
# # Rails 5 login
# else
# # Rails 4 login
# end
module RuboCop
module Cop
module ShopifyRails
class RailsNextUnless < Cop