Skip to content

Instantly share code, notes, and snippets.

View gilankpam's full-sized avatar
🏸
Focusing

Gilang gilankpam

🏸
Focusing
View GitHub Profile
@gilankpam
gilankpam / convert.py
Created June 15, 2023 19:03
yolov8 rk3588
from rknn.api import RKNN
ONNX_MODEL = 'yolov8m.onnx'
RKNN_MODEL = 'yolov8m.rknn'
DATASET = './dataset.txt'
QUANTIZE_ON = True
if __name__ == '__main__':
# Create RKNN object
@gilankpam
gilankpam / epever.yaml
Created December 22, 2023 06:31
ESPHome Epever
esphome:
name: solar-monitor
friendly_name: solar-monitor
platformio_options:
## larger stack size required with all registers enable_load_test
## reduce registers or wait for integration of 2.0.0 arduinoespressif32
## not yet working needs 2.0
build_flags:
- -DCONFIG_ARDUINO_LOOP_STACK_SIZE=32768

Xiaomi Smart devices only accept command from the same subnet. This is openwrt configuration I used to fix that.

iot is the smart devices subnet, including xiaomi devices

192.168.10.8 is my Home Assistant IP

192.168.88.232 is xiaomi device IP

uci add firewall nat # =cfg1793c8
@gilankpam
gilankpam / motion_light_switch.yaml
Last active April 29, 2023 16:27
HA motion activated light with switch
blueprint:
name: Motion-activated Light Switch
description: Turn on a light when motion is detected.
domain: automation
source_url: https://gist.github.com/gilankpam/8835ad03329c16066e1046cb9ab4c698
author: Home Assistant
input:
motion_entity:
name: Motion Sensor
selector:
@gilankpam
gilankpam / redux-request-success-failure.js
Last active May 17, 2022 14:04
redux-request-success-failure.js
function reduxHelper (actionName, fn) {
if (typeof actionName !== 'string') {
throw new Error('actionName must be a string')
}
if (typeof fn !== 'function') {
throw new Error('fn must be a function')
}
const actionNameUpper = actionName.toUpperCase()
const actionRequest = actionNameUpper + '_REQUEST'
const actionSuccess = actionNameUpper + '_SUCCESS'
function middleware({dispatch}) {
return next => action => {
if (typeof action === 'function') {
return action(dispatch)
}
return next(action)
}
}
@gilankpam
gilankpam / tail.py
Created October 8, 2018 10:54
Tail implementation in python
import io, sys, itertools
def tail(file, line_count):
BUFFER_SIZE = 1024
pos = -BUFFER_SIZE
offset = 0
result_lines = []
result_line_count = 0
while result_line_count < line_count:
file.seek(pos, io.SEEK_END)
@gilankpam
gilankpam / update_elb.sh
Last active July 11, 2018 09:00
acme.sh hook script for AWS ELB
#!/bin/bash
set -e
# FOR DEBUG
# print all env var
env
ELB_LISTENER_ARN=arn:......
ACME_PATH=~/.acme.sh
@gilankpam
gilankpam / deep-merge.js
Last active August 15, 2017 09:35
Javascript Deep Merge (Recursive)
// Merge multiple objects
function deepMerges(...objs) {
return objs.reduce((a, b) => deepMerge(a,b), {})
}
// Merge two objects
function deepMerge (one, two) {
if (Array.isArray(one) && Array.isArray(two)) {
return one.concat(two)
}
export const { loginAction, loginActionTypes, loginReducer } = reduxHelper('login', function(username, password) {
return api.login('username', 'password')
})