Skip to content

Instantly share code, notes, and snippets.

@tonyfg
tonyfg / docker-compose.yml
Created November 18, 2020 11:27
Docker compose file for home assistant + domoticz + mosquitto + zigbee2mqtt
version: "3"
services:
domoticz:
image: linuxserver/domoticz:latest
container_name: domoticz
environment:
- PUID=19000
- PGID=19000
- TZ=Europe/Lisbon
volumes:
@drhelius
drhelius / Game Boy Boot ROM Disassembly
Last active November 20, 2023 18:34
Game Boy Boot ROM Disassembly
LD SP,$fffe ; $0000 Setup Stack
XOR A ; $0003 Zero the memory from $8000-$9FFF (VRAM)
LD HL,$9fff ; $0004
Addr_0007:
LD (HL-),A ; $0007
BIT 7,H ; $0008
JR NZ, Addr_0007 ; $000a
LD HL,$ff26 ; $000c Setup Audio
@DSKonstantin
DSKonstantin / Auto start puma via systemctl description
Last active November 16, 2023 16:14
Auto start puma via systemctl
Article: https://github.com/puma/puma/blob/master/docs/systemd.md
#1 nano /etc/systemd/system/puma.service
#2 paste from puma.service
Commands:
# After installing or making changes to puma.service
systemctl daemon-reload
# Enable so it starts on boot
systemctl enable puma.service
@bruth
bruth / README.md
Last active November 23, 2022 21:54
Postgres push notification

Postgres push triggers

Watch a table for changes and push a notification with a payload describing the change.

Example

In the Postgres shell:

-- Create the functions
@derrek
derrek / google_play_receipt_verification.md
Last active August 17, 2022 19:34
Google Play/Android Receipt Validation/Verification/Lookup with Ruby

This document outlines setting up google's ruby gem, google-api-client, to verify payloads(receipts) sent to a server from google play in app purchases made via an android app.
This document was written using version 0.9.13.

First you'll need 'owner' access to the google play developer's console that contains the mobile app you wish to verify receipts from.

  • Go to https://play.google.com/apps/publish
  • Click on the mobile app you'd like to set up
  • Click "Settings" on the left click "API access"
  • Below "LINKED PROJECT" link the google play account

Next setup an api account

@ninoseki
ninoseki / test.rb
Created December 12, 2018 02:37
Playing with wss://certstream.calidog.io in Ruby
require 'faye/websocket'
require 'eventmachine'
require "json"
EM.run {
ws = Faye::WebSocket::Client.new("wss://certstream.calidog.io")
ws.on :message do |event|
message = JSON.parse(event.data)
all_domains = message.dig("data", "leaf_cert", "all_domains")
@u1-liquid
u1-liquid / update-sentry.sh
Last active March 23, 2022 15:01
Update Sentry on Docker
#!/bin/sh
sudo docker stop sentry-worker sentry-cron
sudo docker stop sentry sentry-smtp sentry-postgres sentry-redis
sudo docker rm sentry-worker
sudo docker rm sentry-cron
sudo docker rm sentry
sudo docker rm sentry-smtp
sudo docker rm sentry-postgres
@danneu
danneu / benchmark
Created October 29, 2012 23:04
Ox vs Nokogiri: DOM and SAX parsing comparison
# I'm no benchmark guru. Just did a bunch of:
$ time ruby <filename>
# Note: This is just an 80mb XML file with 38,000 nodes.
ox_dom.rb 4.56s user 0.78s system 93% cpu 5.714 total (550mb)
ox_dom.rb 4.58s user 0.79s system 87% cpu 6.126 total (550mb)
ox_dom.rb 4.60s user 0.80s system 87% cpu 6.140 total (550mb)
nokigiri_dom.rb 11.75s user 1.02s system 94% cpu 13.518 total (895mb)
nokigiri_dom.rb 11.36s user 1.02s system 93% cpu 13.211 total (895mb)
@taf2
taf2 / reconnect-on-disconnect.js
Created July 1, 2011 15:51
mongoose node.js reconnect code
var mongoose = require('mongoose');
var db = mongoose.connect("mongodb://localhost/testdb");
var reconnTimer = null;
function tryReconnect() {
reconnTimer = null;
console.log("try to connect: %d", mongoose.connection.readyState);
db = mongoose.connect("mongodb://localhost/testdb");
}
@Joncom
Joncom / gist:e8e8d18ebe7fe55c3894
Last active September 11, 2021 00:29
Check if two line segments intersect
// Adapted from: http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect/1968345#1968345
function line_intersects(p0_x, p0_y, p1_x, p1_y, p2_x, p2_y, p3_x, p3_y) {
var s1_x, s1_y, s2_x, s2_y;
s1_x = p1_x - p0_x;
s1_y = p1_y - p0_y;
s2_x = p3_x - p2_x;
s2_y = p3_y - p2_y;
var s, t;