Skip to content

Instantly share code, notes, and snippets.

@warhammerkid
warhammerkid / server.rb
Created October 3, 2022 15:49
Bluetti Prometheus Montior
require 'bigdecimal'
require 'json'
require 'mqtt'
require 'prometheus_exporter'
require 'prometheus_exporter/server'
class MetricsServer
def initialize(broker)
@broker = broker
@hartleybrody
hartleybrody / upgrading-postgresql-database.md
Last active December 1, 2021 13:30
upgrading postgres

Postgres is usually run automatically on my laptop. I also have a weekly cronjob that does brew update and brew upgrade which sometimes bumps the version of portgres that I'm running. Newer versions of the postgres server software aren't necessarily compatible with the older version's data directory structure, and so you need to "upgrade" your database to see all of your old data in the upgraded postgres server.

Trying to start the database manually with

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

Which gives an error message and tells me where to look (note that I passed in the log directory when I ran the command)

waiting for server to start.... stopped waiting

pg_ctl: could not start server

@JoshKaufman
JoshKaufman / digitalocean console paste.js
Created January 7, 2016 00:17
enables sending string to digitalocean web console stdin
var sendString = (function(rfb, force, sendDelay) {
sendDelay = sendDelay || 25;
var _q = [];
var _qStart = function() {
var chr = _q.shift();
if (chr) {
rfb.sendKey(chr);
setTimeout(_qStart, sendDelay);
}
};
@magicznyleszek
magicznyleszek / jekyll-and-liquid.md
Last active September 16, 2024 18:47
Jekyll & Liquid Cheatsheet

Jekyll & Liquid Cheatsheet

A list of the most common functionalities in Jekyll (Liquid). You can use Jekyll with GitHub Pages, just make sure you are using the proper version.

Running

Running a local server for testing purposes:

@adamlj
adamlj / send_mailgun_attachments.py
Created January 23, 2014 10:53
MailGun API Python Requests multiple Attachments Send mail with multiple files/attachments with custom file names
requests.post("https://api.mailgun.net/v2/DOMAIN/messages",
auth=("api", "key-SECRET"),
files={
"attachment[0]": ("FileName1.ext", open(FILE_PATH_1, 'rb')),
"attachment[1]": ("FileName2.ext", open(FILE_PATH_2, 'rb'))
},
data={"from": "FROM_EMAIL",
"to": [TO_EMAIL],
"subject": SUBJECT,
"html": HTML_CONTENT
@willurd
willurd / web-servers.md
Last active November 13, 2024 13:44
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active November 14, 2024 09:13
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@mshafrir
mshafrir / states_hash.json
Created May 9, 2012 17:05
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",