Skip to content

Instantly share code, notes, and snippets.

View gilankpam's full-sized avatar
🏸
Focusing

Gilang gilankpam

🏸
Focusing
View GitHub Profile
@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 / 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 / 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 / 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 / clojure.md
Last active July 13, 2017 09:35
LEARNING CLOJURE
  1. Clojure is homophonic language, it means the program structure is similar to its syntax

  2. Every statement evaluate to one value ex (+ 1 2) => 3

  3. ( ) is a list

  4. Lists are call, first element is operator the rest is arguments

  5. No call expression use infix or postfix position

@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)
}
import { createStore, applyMiddleware } from 'redux'
import reducers from './reducers'
import myMiddleware from './middleware'
const store = createStore(reducers, applyMiddleware(myMiddleware))
import loginReducer from './login'
import registerReducer from './register'
import productReducer from './product'
import { combineReducers } from 'redux'
export default combineReducers ({
login: loginReducer,
register: registerReducer,
product: productReducer