Skip to content

Instantly share code, notes, and snippets.

View mikz's full-sized avatar

Michal Cichra mikz

View GitHub Profile
@stalniy
stalniy / 1. Intro.md
Last active March 28, 2024 09:10
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 April 8, 2024 03:00
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.

@KonnorRogers
KonnorRogers / environment.js
Last active October 3, 2022 17:25
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 / dropzone_controller.js
Last active March 9, 2024 05:14
Dropzone.js + Stimulus + Active Storage
import { Controller } from "stimulus"
import { DirectUpload } from "@rails/activestorage"
import Dropzone from "dropzone"
import { getMetaValue, findElement, removeElement, insertAfter } from "helpers"
Dropzone.autoDiscover = false
export default class extends Controller {
static targets = [ "input" ]
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
Last active July 15, 2020 14:51
pack.lua | The Lua module bundler
#!/usr/bin/env lua
--[[
The MIT License
Copyright (C) 2017 Saravjeet 'Aman' Singh
<saravjeetamansingh@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

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 April 1, 2024 11: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
@jdneo
jdneo / timerInterrupt.ino
Created December 8, 2016 02:21
Timer Interrupt example for Adafruit Feather M0. Callback function can be written in TC3_Handler().
#define LED_PIN 13
#define CPU_HZ 48000000
#define TIMER_PRESCALER_DIV 1024
void startTimer(int frequencyHz);
void setTimerFrequency(int frequencyHz);
void TC3_Handler();
bool isLEDOn = false;