Skip to content

Instantly share code, notes, and snippets.

View beanieboi's full-sized avatar

Ben Fritsch beanieboi

View GitHub Profile
@beanieboi
beanieboi / gist:ad526faf063181f336a2
Last active May 11, 2023 15:59
Codeship Nginx Config for Heroku
daemon off;
# Heroku dynos have at least 4 cores.
worker_processes <%= ENV['NGINX_WORKERS'] || 4 %>;
events {
use epoll;
accept_mutex on;
worker_connections 1024;
}
@beanieboi
beanieboi / Airrohr.yaml
Created November 25, 2022 18:16
Running Airrohr/Luftdaten Sensor (luftdaten.info) with ESPHome
esphome:
name: airrohr
platform: ESP8266
board: nodemcuv2
# Enable logging
logger:
level: WARN
# Enable Home Assistant API
var file = fs.createReadStream(path);
var sha1_for_file = crypto.createHash('sha1');
file.addListener('error', function(err) {
throw err;
});
file.addListener('data', function(data) {
sha1_for_file.update(data);
});
file.addListener('close', function() {
@beanieboi
beanieboi / home assistant.yml
Last active June 6, 2022 03:09
HomeAssistant Luftdaten REST API - Air Quality, PM2.5, PM10, Temp and Humidity (SDS011 and DHT22)
sensor:
- platform: rest
name: luftdaten
resource: http://192.168.1.149/data.json
scan_interval: 100
json_attributes:
- sensordatavalues
value_template: '{{ value_json.age }}'
- platform: template
sensors:
@beanieboi
beanieboi / ecotrend.rb
Created May 26, 2022 11:58
ISTA Ecotrend
require "bundler"
Bundler.setup
require 'json'
require 'excon'
# get token
login_response = Excon.post('https://api.prod.eed.ista.com/login',
body: '{"email":"email", "password":"password","fromMobileApp":true}',
headers: { "Content-Type" => "application/json" }
)
@beanieboi
beanieboi / cortex.sh
Last active December 26, 2021 09:02
Cortex Metrics FreeBSD rc.d script
#!/bin/sh
# PROVIDE: cortex
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable cortex:
#
# cortex_enable (bool): Set to "NO" by default.
@beanieboi
beanieboi / gist:2702092
Created May 15, 2012 14:15
Upgrade to Postgres 9.2 beta 1 on Ubuntu 12.04
# Install Postgres 9.2 from https://launchpad.net/~pitti/+archive/postgresql
# drop the cluster which gets created during the setup
pg_dropcluster --stop 9.2 main
# create a backup of your current cluster
rsync -a /var/lib/postgresql/9.1 /var/lib/postgresql/9.1.backup
# upgrade the the old 9.1 cluster
pg_upgradecluster 9.1 main /var/lib/postgresql/9.2
@beanieboi
beanieboi / batch-updates.sql
Last active March 11, 2019 12:25
My Postgres Cheatsheet
DO LANGUAGE plpgsql $$
DECLARE counter INTEGER = 1;
DECLARE tick INTEGER = 1;
BEGIN
WHILE counter > 0 LOOP
UPDATE table
SET field = NULL
WHERE id IN (
SELECT id
FROM table
mkdir /tmp/zroot
zpool import -fR /tmp/zroot zroot
mkdir /tmp/root
mount -t zfs zroot/ROOT/default /tmp/root
#!/home/rof/.rvm/rubies/ruby-2.2.0/bin/ruby
require 'json'
require 'net/http'
class CodeshipRestartBuild
def self.restart_build
self.new.restart_build
end