Skip to content

Instantly share code, notes, and snippets.

View thebapi's full-sized avatar

Sajib Sarkar thebapi

View GitHub Profile
Setting up python environments
python3 -m venv venv
source venv/bin/activate
pip install numpy
pip install pillow
@thebapi
thebapi / gist:002aa9fc35dca0908991b6212e300163
Created October 19, 2023 21:01
Prost message encoding/decoding
Rust
Encoding Prost Message
pl.encode_to_vec()
Decoding Prost message
let new_pl = integration_pb::UplinkEvent
::decode(&mut Cursor::new(buf))
@thebapi
thebapi / gist:a2a9e777b55471a189ca76d909a2d967
Created October 18, 2023 13:03
Optimize rust build file
To reduce the build file size please add the following setting into the cargo.toml
[profile.release]
opt-level = 'z' # Optimize for size
lto = true # Enable link-time optimization
codegen-units = 1 # Reduce number of codegen units to increase optimizations
panic = 'abort' # Abort on panic
strip = true # Strip symbols from binary*
-- Table: public.alarmlog
-- DROP TABLE IF EXISTS public.alarmlog;
CREATE TABLE IF NOT EXISTS public.alarmlog
(
id_alarm_log bigserial NOT NULL,
id_control_device bigint NOT NULL,
asset_name character varying(50) COLLATE pg_catalog."default" NOT NULL,
property_group_name character varying(50) COLLATE pg_catalog."default" NOT NULL,
@thebapi
thebapi / gist:3dc589109f1838ef47e572788bc798e7
Created September 23, 2023 09:35
setup latest version of Ruby
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
This document is intended for upgrading PostgreSQL 12 database to PostgreSQL 14 or timescale/timescaledb:2.9.1-pg14 db
Inside the docker container
1. cd root
2. pg_dumpall -U postgres -v > $HOME/upgrade_backup.sql
with performance_table
as (select name,
asset_uuid,
device_uuid,
group_uuid,
value,
time
from public.messages
where time between 1690653600000 and 1690739999000
and asset_uuid = '1e112e32-a533-48a7-9c1d-ef30c8b4ed6e'
export PATH=$PATH:$(go env GOPATH)/bin
if go get private package does not work then follow these
go env -w GOPRIVATE='github.com/repoURL/private-repo'
or
go env -w GOPRIVATE='github.com/<OrgNameHere>/*'
https://stackoverflow.com/questions/58305567/how-to-set-goprivate-environment-variable
CREATE TABLE IF NOT EXISTS public.alarmlog
(
id_alarm_log bigserial NOT NULL,
id_control_device bigint NOT NULL,
asset_name character varying(50) NOT NULL,
property_group_name character varying(50) NOT NULL,
value double precision NOT NULL,
unit character varying(5) NOT NULL,
is_acknowledged boolean NOT NULL DEFAULT 'false',
acknowledged_at double precision,