Skip to content

Instantly share code, notes, and snippets.

View flozano's full-sized avatar

Francisco A. Lozano flozano

  • Kii corporation
  • Valencia, Spain
View GitHub Profile
@ak4zh
ak4zh / migration.sql
Created September 22, 2022 08:48
Double Entry Book Keeping with Journals and Voucher
CREATE TABLE public.vouchers (
id serial PRIMARY KEY,
name text NOT NULL
);
INSERT INTO vouchers
(name)
VALUES
('Sales'),
('Purchase'),
@jolivares
jolivares / gist:87e68c048e4ed5d78b0c081b97eb1d1f
Created September 12, 2022 13:24
Get ID token thru OpenID Connect
package main
import (
"crypto/rand"
"encoding/base64"
"io"
"log"
"net/http"
"time"
@porsager
porsager / housekeeping.sql
Last active November 8, 2021 14:55
Remove all but the latest n rows with group by
-- Simply set the offset to the amount of rows you want to keep. An index of (id, date desc) will make this fast.
delete from some_table st
using (
select distinct
x.id,
x.date
from some_table st1
join lateral (
@chrismaes87
chrismaes87 / create-relative-virtualenv
Created September 25, 2019 06:57
bash script to create a relative virtualenv that can be packaged in an rpm
#!/bin/bash
me=$(basename $0)
set -e # exit on error
function print_help {
echo
echo $me - create a virtualenv with relative paths in a certain buildroot and fix the relative path to make it work after install
echo
echo OPTIONS
echo " -h / --help"
@rbreaves
rbreaves / macOS keyboard layout for Linux
Last active March 31, 2024 10:35
Universal macOS keyboard layout for Linux - Applies to All Windows and Apple Keyboards
# permanent apple keyboard keyswap
echo "options hid_apple swap_opt_cmd=1" | sudo tee -a /etc/modprobe.d/hid_apple.conf
update-initramfs -u -k all
# Temporary & instant apple keyboard keyswap
echo '1' | sudo tee -a /sys/module/hid_apple/parameters/swap_opt_cmd
# Windows and Mac keyboards - GUI (Physical Alt is Ctrl, Physical Super is Alt, Physical Ctrl is Super)
setxkbmap -option;setxkbmap -option altwin:ctrl_alt_win
@Aetherus
Aetherus / scale-out-phoenix-with-websocket.md
Last active February 23, 2024 14:31
How to scale out a Phoenix application with websocket

How to scale out a Phoenix application with websocket

Foreword

It's relatively easy to scale out stateless web applications. You often only need a reverse proxy. But for those stateful web applications, especially those applications that embeds websocket services in them, it's always a pain to distribute them in a cluster. The traditional way is introducing some external services like Redis to handle pubsub, however, in such way, you often need to change your code. Can Erlang/Elixir, the "concurrency oriented programming languages", best other languages in this use case? Has Phoenix framework already integrated the solution of horizontally scaling websocket? I'll do an experiment to prove (or disprove) that.

Resources

@marwei
marwei / how_to_reset_kafka_consumer_group_offset.md
Created November 9, 2017 23:39
How to Reset Kafka Consumer Group Offset

Kafka 0.11.0.0 (Confluent 3.3.0) added support to manipulate offsets for a consumer group via cli kafka-consumer-groups command.

  1. List the topics to which the group is subscribed
kafka-consumer-groups --bootstrap-server <kafkahost:port> --group <group_id> --describe

Note the values under "CURRENT-OFFSET" and "LOG-END-OFFSET". "CURRENT-OFFSET" is the offset where this consumer group is currently at in each of the partitions.

  1. Reset the consumer offset for a topic (preview)
@ismyrnow
ismyrnow / mac-clear-icon-cache.sh
Created May 5, 2017 19:28
Clear the icon cache on a Mac when you start seeing generic icons in Finder or the Dock
sudo rm -rfv /Library/Caches/com.apple.iconservices.store; sudo find /private/var/folders/ \( -name com.apple.dock.iconcache -or -name com.apple.iconservices \) -exec rm -rfv {} \; ; sleep 3;sudo touch /Applications/* ; killall Dock; killall Finder
@Kovrinic
Kovrinic / .gitconfig
Last active July 5, 2024 09:25
git global url insteadOf setup
# one or the other, NOT both
[url "https://github"]
insteadOf = git://github
# or
[url "git@github.com:"]
insteadOf = git://github
@jimblom
jimblom / certs.sh
Last active May 23, 2022 16:27
Update Java cacerts
#!/bin/sh
# certs.sh
# use this for Yocto/Edison:
LIB=lib
# use this for WRLinux/Gateway
# LIB=lib64
if [ -f /usr/$LIB/jvm/java-8-openjdk/jre/lib/security/cacerts ]; then
mv /usr/$LIB/jvm/java-8-openjdk/jre/lib/security/cacerts \