Skip to content

Instantly share code, notes, and snippets.

View medaved's full-sized avatar

Dmitry medaved

View GitHub Profile
@medaved
medaved / esphome_ble_esp32c6.yaml
Created February 11, 2026 07:49 — forked from kabakaev/esphome_ble_esp32c6.yaml
ESPHome BLE proxy on ESP32-C6 board
# # This is an esphome configuration file.
# # It is tested on debian-12 and [nanoESP32-C6](https://github.com/wuxx/nanoESP32-C6/blob/master/README_en.md).
# # This configuration should work on any Linux distribution and any ESP32-C6 board though.
#
# # Create and activate python venv, install esphome:
# test -d ./venv || python3 -m venv venv
# source ./venv/bin/activate
# pip install esphome --upgrade
#
# # Connect ESP32-C6 to USB, press and hold "Boot" button, press and release "Reset", release "Boot".

TLP 1.4 Test: Battery Care for Lenovo Laptops (non-ThinkPad series)

Read the overview document first.

Supported Features

Lenovo laptop series using the ideapad_laptop driver have a feature called 'battery conservation mode', basically a fixed stop charge threshold at 60%. The hardware behaviour is:

  1. Connected to the charger, charging stops when the charge level reaches the stop threshold
@medaved
medaved / README.md
Created October 15, 2023 16:15 — forked from levihuayuzhang/fix-DSD-thinkBook-16p-g4-IRH-linux-6.7.0-rc2.patch
Workaround for Lenovo Thinkbook 16p Gen4 IRH sound issue (by adding a quirk that hasn't been officially verified)
# libs for jp2
sudo apt install libopenjp2-7-dev
# libs for webp
sudo apt-get install libwebp-dev libde265-dev
# clone image magick
git clone https://github.com/ImageMagick/ImageMagick.git ImageMagick
select(<<-SQL)
accounts.*, ((acc_transaction_deposit.amount + acc_transfer_deposit.amount) - (acc_transfer_withdrawal.amount + acc_transaction_withdrawal.amount)) AS account_balance
SQL
.join(<<-SQL)
LEFT JOIN LATERAL (SELECT COALESCE(SUM(account_transactions.amount), 0) AS amount FROM account_transactions WHERE accounts.id = account_transactions.account_id AND account_transactions.kind = 'deposit') acc_transaction_deposit ON true
LEFT JOIN LATERAL (SELECT COALESCE(SUM(account_transactions.amount), 0) AS amount FROM account_transactions WHERE accounts.id = account_transactions.account_id AND account_transactions.kind = 'withdrawal') acc_transaction_withdrawal ON true
LEFT JOIN LATERAL (SELECT COALESCE(SUM(account_transactions.amount), 0) AS amount FROM account_transactions WHERE accounts.id = account_transactions.account_id AND account_transactions.kind = 'transfer') acc_transfer_withdrawal ON true
LEFT JOIN LATERAL (SELECT COALESCE(SUM(account_transactions.transfer_amount), 0) AS amount FROM accoun
@medaved
medaved / Spree: Filter by brand.md
Created February 16, 2019 21:31 — forked from maxivak/Spree: Filter by brand.md
Spree: Filter Products by properties

Fix 'scoped' error for Rails 4

error: undefined method 'scoped' solution:

# config/initializers/scoped.rb
class ActiveRecord::Base
  # do things the modern way and silence Rails 4 deprecation warnings
 def self.scoped(options=nil)

options ? where(nil).apply_finder_options(options, true) : where(nil)

ls *.jpg *.JPG | cat -n | while read n f; do mv "$f" "$n.jpg"; done
@medaved
medaved / routes.rb
Created December 14, 2018 23:23 — forked from shilovk/routes.rb
Интеграция Яндекс.Кассы с Rails
# config/routes.rb
YandexKassaIntegration::Application.routes.draw do
# ...
scope '/yandex_kassa' do
controller 'yandex_kassa', constraints: { subdomain: 'ssl' } do
post :check
post :aviso
get :success
get :fail
rb(main):036:0> Benchmark.bmbm do |x|
irb(main):037:1* x.report('rand 10_000') { 10_000.times { rand}}
irb(main):038:1> x.report('Time rand 10_000') { 10_000.times {(Time.now.to_i.to_s * 2).size}}
irb(main):039:1> end
Rehearsal ----------------------------------------------------
rand 10_000 0.020000 0.000000 0.020000 ( 0.011231)
Time rand 10_000 0.080000 0.000000 0.080000 ( 0.089679)
------------------------------------------- total: 0.100000sec
user system total real
Spree::HomeController.class_eval do
before_action :check_locale, only: :index
private
def check_locale
if params[:locale] == 'en'
current_order.update_attributes!(currency: "USD") if current_order
session[:currency] = 'USD'
else
current_order.update_attributes!(currency: "RUB") if current_order
session[:currency] = 'RUB'