Skip to content

Instantly share code, notes, and snippets.

View jforge's full-sized avatar

jforge

  • Germany, Bargteheide
  • 10:05 (UTC +02:00)
View GitHub Profile
@jforge
jforge / Dockerfile
Created January 30, 2021 21:08 — forked from natcl/Dockerfile
Node-RED Docker ENV test
FROM ubuntu:16.04
RUN \
sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \
apt-get update && \
apt-get -y upgrade && \
apt-get install -y build-essential curl && \
apt-get install -y software-properties-common && \
curl -sL https://deb.nodesource.com/setup_8.x | bash - && \
apt-get install -y nodejs
Calculate the rolling standard deviation of a time series
Python + Pandas:
https://stackoverflow.com/questions/27427618/how-can-i-simply-calculate-the-rolling-moving-variance-of-a-time-series-in-pytho
R:
https://campus.datacamp.com/courses/manipulating-time-series-data-with-xts-and-zoo-in-r/apply-and-aggregate-by-time?ex=11
https://cran.r-project.org/web/packages/PerformanceAnalytics/PerformanceAnalytics.pdf
Node.js:
@jforge
jforge / git.migrate
Created December 14, 2020 07:09 — forked from niksumeiko/git.migrate
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@jforge
jforge / Ansible-Vault how-to.md
Created November 20, 2020 11:58 — forked from tristanfisher/Ansible-Vault how-to.md
A short tutorial on how to use Vault in your Ansible workflow. Ansible-vault allows you to more safely store sensitive information in a source code repository or on disk.

Working with ansible-vault


I've been using a lot of Ansible lately and while almost everything has been great, finding a clean way to implement ansible-vault wasn't immediately apparent.

What I decided on was the following: put your secret information into a vars file, reference that vars file from your task, and encrypt the whole vars file using ansible-vault encrypt.

Let's use an example: You're writing an Ansible role and want to encrypt the spoiler for the movie Aliens.

@jforge
jforge / pkijs-decode-pem-node.js
Created September 25, 2020 09:03 — forked from adisbladis/pkijs-decode-pem-node.js
Minimal example of loading a PEM certificate using pkijs (in nodejs)
#!/usr/bin/env node
// Minimal example of loading a PEM certificate using pkijs (in node)
// babel-polyfill needs to be loaded for pkijs
// It uses webcrypto which needs browser shims
require('babel-polyfill')
const Pkijs = require('pkijs')
const Asn1js = require('asn1js')
const FS = require('fs')
@jforge
jforge / git-lambda.js
Created September 22, 2020 13:14 — forked from loopiezlol/git-lambda.js
flow showing off how to clone, update and push to a git repo from an AWS lambda function
const fs = require('fs')
const path = require('path')
const process = require('process')
const { spawnSync } = require('child_process')
const { GITHUB_TOKEN, GITHUB_USERNAME, GITHUB_EMAIL } = process.env
// leaving this without https:// in order to reuse it when adding the remote
const gitRepositoryURL = 'github.com/owner/repo-name.git'
const repositoryName = 'repo-name'
@jforge
jforge / git-pushing-multiple.rst
Created September 14, 2020 07:53 — forked from rvl/git-pushing-multiple.rst
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just

# The upcoming curl release enables MQTT support by default
# It still has several limitations, that might be show stoppers in most MQTT environments, but it basically works.
# Major requirement for me is following the server-side security-first directive: at least simple authentication + basic TLS 1.2+ support.
# My conclusion here is to keep using the mosquitto_pub/sub tools, when doing such stuff in a terminal window.
# (and of course to try to support the respective curl contributions ;-))
# 1.) Building curl master
# - git clone https://github.com/curl/curl.git
# - Follow the guide: https://github.com/curl/curl/blob/master/GIT-INFO
autoreconf -fi
var Thread = Java.type("java.lang.Thread");
var Instant = Java.type("java.time.Instant");
var topic = "cybus/machine/1CY816L0ⓥ3/lastMovement";
function execute(action) {
out("Test Script: " + action.getName());
for (var i = 0; i < 1000; i++) {
randomTimeSeriesPing();
Thread.sleep(2000);
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html#extend-linux-volume-partition
[ec2-user ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 740K 2.0G 1% /run
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/nvme0n1p1 16G 16G 166M 99% /
tmpfs 390M 0 390M 0% /run/user/1000