Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

M. Peter mpneuried

🏠
Working from home
Block or report user

Report or block mpneuried

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mpneuried
mpneuried / publish_docs.sh
Created Jun 13, 2019
Script to generate and "publish/copy" a local doc folder to another folder taht could be synced via dropbox/onedrive/google-drive ... it write keep the latest folder and keep archived versions as zip
View publish_docs.sh
#!/bin/sh
#colors
COFF='\033[0m'
CRED='\033[1;31m'
CGREEN='\033[1;32m'
CYELLOW='\033[0;33m'
CCYAN='\033[1;36m'
CBLUE='\033[1;34m'
@mpneuried
mpneuried / pow.yaml
Created May 11, 2019 — forked from frenck/pow.yaml
Sonoff POW R2 Washing Machine Sensor Example
View pow.yaml
esphomeyaml:
name: pow
platform: ESP8266
board: esp01_1m
board_flash_mode: dout
wifi:
ssid: 'Demo'
password: 'Livestream'
@mpneuried
mpneuried / update_ec2_security_ip.sh
Created Dec 20, 2018
AWS EC2 Security Groups: Revoke old and add new current ip to a list of rules based ob the description
View update_ec2_security_ip.sh
#!/bin/sh
# This script will update your ec2 security group with the current ip of your connection.
# To find the "old" rules the description is used
# Requirements:
# - aws-cli with configured profile: https://aws.amazon.com/de/cli/
# - jq: https://stedolan.github.io/jq/
# - curl
####################
View pg-vs-mapd.md
@mpneuried
mpneuried / filtermacs.js
Created Jan 17, 2018
Filter Refurb Macs by GB and SSD: Small function to remove all refurbished macs that does not match the defined GB and SSD size
View filtermacs.js
// paste and execute it into the browser console. You can define ( GB, SSD [, index-of-box-content-class ] )
// https://www.apple.com/de/shop/browse/home/specialdeals/mac/macbook_pro
// eventually there is a header then you can test the param index-of-box-content-class = 1
((_gb, _ssd, content_idx) => { const _wrp = document.getElementsByClassName("box-content")[ content_idx || 0];Array.from(document.getElementsByClassName("specs")).forEach((el) =>{if (!(el.innerHTML.indexOf(_gb.toString() + " GB") > 0 && el.innerHTML.indexOf(_ssd.toString() + " GB") > 0)) {_wrp.removeChild(el.parentNode.parentNode.parentNode)}})})(16,512)
@mpneuried
mpneuried / birthday.coffee
Created Sep 4, 2017
Try to find birthdays by last/next n-days
View birthday.coffee
DAYMS = 1000 * 60 * 60 * 24
checkBirthday = ( now, bd, diff )->
# differ between next and last days (look back or forward)
if diff > 0
start = new Date( now + " 00:00:00 +0000" )
end = new Date( start.valueOf() + ( DAYMS * diff ) )
year = new Date( end ).getFullYear()
else
end = new Date( now + " 00:00:00 +0000" )
@mpneuried
mpneuried / README.md
Last active Mar 8, 2018
AWS SQS Message pump
View README.md

AWS SQS Message pump

This script will pump AWS SQS Messages from one queue into another queue.

Usage

./pump_sqs.sh {profile} {source-sqs-url} {target-sqs-url} [{iterations}]
@mpneuried
mpneuried / postgres_add_json_sub_array_unique.sql
Last active Jul 27, 2019
Add and remove elements unique to a Postgres jsonb sub key: Short a Set implemetation
View postgres_add_json_sub_array_unique.sql
UPDATE public.mytable SET
jsonfieldname = jsonb_set( jsonfieldname, '{json_obj_key}', array_to_json(
ARRAY(
SELECT DISTINCT( UNNEST( ARRAY(
SELECT json_array_elements_text( COALESCE( jsonfieldname::json->'json_obj_key', '[]' ) )
) || ARRAY['Element to add'] ) )
)
)::jsonb )
WHERE id = 23
RETURNING *;
@mpneuried
mpneuried / get_current_redis_client.coffee
Created Feb 10, 2017
parse and filter redis clients
View get_current_redis_client.coffee
querystring = require('querystring')
crypto = require('crypto')
parseRedisClients = ( raw, filter={} )->
clients = []
for line in raw.split( "\n" ) when line.length > 1
cl = querystring.parse( line, " ", "=" )
if Object.keys( filter ).length
_match = true
for _k, _v of filter when cl[ _k ] isnt _v
@mpneuried
mpneuried / Makefile
Last active Aug 13, 2019
Simple Makefile to build, run, tag and publish a docker containier to AWS-ECR
View Makefile
# import config.
# You can change the default config with `make cnf="config_special.env" build`
cnf ?= config.env
include $(cnf)
export $(shell sed 's/=.*//' $(cnf))
# import deploy config
# You can change the default deploy config with `make cnf="deploy_special.env" release`
dpl ?= deploy.env
include $(dpl)
You can’t perform that action at this time.