Skip to content

Instantly share code, notes, and snippets.

View hypery2k's full-sized avatar
🎯
Focusing

Martin Reinhardt hypery2k

🎯
Focusing
View GitHub Profile
@hypery2k
hypery2k / RxJS.md
Last active October 27, 2021 13:51
Angular Code Review

Subscribing to Multiple Observables in Angular Components

Angular applications heavily rely on RxJS Observables. While building large front end apps with these technologies we quickly will need to learn how to manage subscribing to multiple Observables in our components. In this post we are going to cover five different ways to subscribe to multiple Observables and the pros and cons of each.

Observables

In our component, we will have three Observables. Each Observable has slightly different behavior. The first Observable emits a single value immediately. The second Observable emits a single value after a couple of seconds. The third Observable emits multiple values one value every second. Below are some functions that return the Observables that we will use in our components.

import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs/observable/of';
@hypery2k
hypery2k / jest-setup.ts
Created January 21, 2020 07:49
Jest Web Components Setup
import 'jest-preset-angular';
import 'mutationobserver-shim';
// Mock environment
var mockedRegistry = new Map();
var win = <any>window;
win.alert = () => {};
win.customElements = {
define: (elementName, elementClass) => {},
get: tagName => mockedRegistry.get(tagName)
@hypery2k
hypery2k / Dockerfile
Created July 22, 2019 13:31
Podman & OpenShift
FROM centos/s2i-base-centos7:latest
ENV DESCRIPTION="Podman image runtime for releasing"
ENV TZ="Europe/Berlin"
ENV HOME=/podman
LABEL summary="$SUMMARY" \
description="$DESCRIPTION" \
version="$GIT_TAG" \
build-user="$LAST_BUILD_USER" \
@hypery2k
hypery2k / rhsso-on-openshift.sh
Created February 22, 2018 14:20 — forked from jpkrohling/rhsso-on-openshift.sh
Red Hat SSO on OpenShift
SECRETS_KEYSTORE_PASSWORD=$(openssl rand -base64 512 | tr -dc A-Z-a-z-0-9 | head -c 17)
oc cluster up --version=latest
oc login -u system:admin
oc new-project redhat-sso
oc create serviceaccount sso-service-account
oc policy add-role-to-user view system:serviceaccount:redhat-sso:sso-service-account
oc create -n openshift -f https://raw.githubusercontent.com/jboss-openshift/application-templates/ose-v1.3.7/jboss-image-streams.json
for template in sso71-https.json \
sso71-mysql-persistent.json \
@hypery2k
hypery2k / ansible playbook.yml
Created March 18, 2019 15:06
Ansible Playbook
---
- name: Prepare | Setup Ansible runtime
hosts: all
gather_facts: no
tasks:
- name: Boostrap python
raw: test -e /usr/bin/python || (apt-get -y update && apt-get install -y python-minimal)
- name: Provision
@hypery2k
hypery2k / Packer build.json
Created March 18, 2019 15:04
Packer build
{
"builders": [{
"type": "docker",
"image": "jenkinsci/ssh-slave:latest",
"commit": true,
"changes": [
"VOLUME /data",
"WORKDIR /data",
"EXPOSE 6379",
"ENTRYPOINT [\"docker-entrypoint.sh\"]",
@hypery2k
hypery2k / docker run chain
Last active March 18, 2019 14:52
Docker & Packer
# Install PanDoc
RUN yum -y install epel-release && yum -y install pandoc
# chrome and xvfb
RUN cd /tmp/setup && curl https://intoli.com/install-google-chrome.sh | bash && yum install -y xorg-x11-server-Xvfb
# Install oc and jq
RUN yum -y install epel-release && yum -y install jq
@hypery2k
hypery2k / JenkinsAgentCleaner.groovy
Last active November 29, 2018 07:31 — forked from sirrapa/JenkinsAgentCleaner.groovy
Groovy script for cleaning up ghost workspaces left on slaves after a job has been deleted. Must be run strictly on the master instance.
import hudson.FilePath;
// Initialize dryRun parameter to TRUE if not given as script parameter
dryRun = true;
if( dryRun == true ) {
println "** Execute a dryRun - no files will ever be deleted **";
}
// shortcut to Jenkins instance
=== npm audit security report ===
# Run npm update webpack-dev-server --depth 2 to resolve 1 vulnerability
High Missing Origin Validation
Package webpack-dev-server
Dependency of @angular-devkit/build-angular [dev]
root@57d2d48dd2f5:/# nikto -host www.holisticon.de -C all
- Nikto v2.1.6
---------------------------------------------------------------------------
+ Target IP: 85.214.158.97
+ Target Hostname: www.holisticon.de
+ Target Port: 80
+ Start Time: 2018-05-23 05:36:45 (GMT0)
---------------------------------------------------------------------------
+ Server: nginx
+ The anti-clickjacking X-Frame-Options header is not present.