Skip to content

Instantly share code, notes, and snippets.

View GrzegorzDrozd's full-sized avatar

Grzegorz Drozd GrzegorzDrozd

View GitHub Profile
@pozs
pozs / json_object_agg.sql
Last active May 18, 2020 10:58
Multiple functions to modify json objects in PostgreSQL
-- Aggregate function to aggregate key-value pairs to json object (opposite of json_each())
-- requires PostgreSQL 9.3+ (but < 9.4!)
-- requires function "json_object_set_key"
DROP AGGREGATE IF EXISTS "json_object_agg" (TEXT, anyelement);
CREATE AGGREGATE "json_object_agg" (TEXT, anyelement)
(
STYPE = json,
SFUNC = "json_object_set_key",
@sticilface
sticilface / PROGMEM.md
Last active July 23, 2023 11:38
PROGMEM

Guide to PROGMEM on ESP8266 and Arduino IDE

Intro

On low memory devices like the arduino and esp8266 you do not want strings to be stored in RAM. This occurs by default on these systems. Declare a string const char * xyz = "this is a string" and it will use up RAM.

The solution on these devices is to allow strings to be stored in read only memory, in Arduino this is the PROGMEM macro. Most of my experience is with the ESP8266 which is a 32bit micros controller. This device stores PROGMEM data in flash. The macro PROGMEM on ESP8266 is simply

#define PROGMEM   ICACHE_RODATA_ATTR
@beginor
beginor / snowflake-id.sql
Last active May 11, 2024 18:48
Twitter Snowflake ID for PostgreSQL
CREATE SEQUENCE public.global_id_seq;
ALTER SEQUENCE public.global_id_seq OWNER TO postgres;
CREATE OR REPLACE FUNCTION public.id_generator()
RETURNS bigint
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
our_epoch bigint := 1314220021721;
seq_id bigint;
@Juul
Juul / lte_mbim_from_scratch.md
Last active June 19, 2024 21:50
How to use 4G LTE modems like the MC7455 on both Debian/Ubuntu and OpenWRT using MBIM

The purpose of this document is to get you familiar with the concepts and command line tools involved with connecting to the internet using modern 4G LTE modems on both Debian/Ubuntu and OpenWRT.

This writeup is based on my experiences with the Sierra Wireless AirPrime MC7455 modem and a Calyx (Sprint) SIM card, but it should apply to most modern 4G LTE modems.

High level overview

These are the steps required:

  • Physically connect antennas