Skip to content

Instantly share code, notes, and snippets.

@limitusus
limitusus / zero_division.md
Last active June 21, 2024 19:35
Zabbix: handle calculated item with zero division

Problem

Want to create a calculated item with last("X") / last("Y"). When Y = 0, the result should be 0.

Answer

last("X") * (1 - count("Y",#1,0)) / (last("Y") + count("Y",#1,0))
@ageis
ageis / bitcoin-monitor.md
Last active June 5, 2024 01:36
Prometheus exporter for monitoring statistics of Bitcoin daemon

bitcoind-monitor.py

This is a script written in Python intended to run alongside a Bitcoin node and export statistics for monitoring purposes. It assumes the existence of bitcoin-cli in the PATH and access to the RPC interface over localhost.

It tracks stuff like: block height, difficulty, number of peers, network hash rate, errors, uptime in seconds, mempool size, size of recent blocks, number of transactions within blocks, chaintips, total bytes received and sent, and transaction inputs and outputs. These Bitcoin metrics are refreshed once every 5 minutes.

How it works

Prometheus is a monitoring system and time-series database.

@dbkbali
dbkbali / AXH_Vector_Sum.sql
Created January 15, 2018 05:12 — forked from andrewxhill/AXH_Vector_Sum.sql
Sum PostgreSQL arrays in place [1,2,3] + [2,3,4] = [3,5,7]
CREATE AGGREGATE vector_sum (
sfunc = AXH_Vector_Sum,
basetype = int[],
stype = int[],
initcond = '{0}'
);
DROP FUNCTION IF EXISTS AXH_Vector_Sum(int[], int[]);
CREATE OR REPLACE FUNCTION AXH_Vector_Sum(int[], int[])
RETURNS int[] AS $$
@maxivak
maxivak / 00.md
Last active May 23, 2024 13:24
Sending emails with ActionMailer and Sidekiq

Sending emails with ActionMailer and Sidekiq

Send email asynchroniously using Sidekiq.

ActionMailer

Create your mailer us usual:

@hallahan
hallahan / installation.md
Last active February 14, 2017 13:00
SpatialServer Installation Instructions

Preliminary Packages

Make sure you have done sudo apt-get update and sudo apt-get upgrade on your fresh install. This guide is geared toward Ubuntu 14.04 LTS (Trusty Tahr). Most of the guide will work for earlier versions of Ubuntu with some slight changes, but 14.04 is advised.

Enable the root user

sudo cp /home/ubuntu/.ssh/authorized_keys /root/.ssh/
@dommmel
dommmel / Vagrantfile
Last active March 6, 2023 04:19
Vagrantfile for Ruby on Rails application development (rbenv, postgres, node.js)
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<SCRIPT
set -e
set -x
cd
sudo apt-get update -y
sudo apt-get install \
@gertig
gertig / gist:6038283
Last active December 19, 2015 23:59 — forked from arkan/gist:5662905
class MyCustomCell < UITableViewCell
# This method is used by ProMotion to instantiate cells.
def initWithStyle(style_name, reuseIdentifier: reuseIdentifier)
super
stylish
self
end
# A delegate method when the user clicks the Row(it's blue by default)
@scottatron
scottatron / nginx_unicorn.erb
Created September 16, 2012 05:20
Rails / Dragonfly / nginx X-Sendfile (aka X-Accel-Redirect)
upstream unicorn {
server unix:/tmp/unicorn.<%= application %>.sock fail_timeout=0;
}
server {
listen 80 default deferred;
# server_name example.com;
root <%= current_path %>/public;
if (-f $document_root/system/maintenance.html) {
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@lagartoflojo
lagartoflojo / nesting.coffee
Created February 13, 2012 23:12 — forked from geddski/nesting.js
Helper function for nesting Backbone collections (CoffeeScript version)
Backbone.Model::nestCollection = (attributeName, nestedCollection) ->
#setup nested references
for item, i in nestedCollection
@attributes[attributeName][i] = nestedCollection.at(i).attributes
#create empty arrays if none
nestedCollection.bind 'add', (initiative) =>
if !@get(attributeName)
@attributes[attributeName] = []
@get(attributeName).push(initiative.attributes)