Skip to content

Instantly share code, notes, and snippets.

View bayucandra's full-sized avatar
🙂

Bayu Candra bayucandra

🙂
View GitHub Profile
@jsdevtom
jsdevtom / frontend-ws-connection.ts
Last active July 17, 2024 17:37
kubernetes-ingress websockets with nodejs
export const ws = webSocket<WebsocketMessage>(`wss://${location.hostname}:${location.protocol === 'https:' ? 443 : 80}/ws/`);
export const wsObserver = ws
.pipe(
retryWhen(errors =>
errors.pipe(
delay(1000)
)
)
);
@l13t
l13t / values.yaml
Created January 16, 2019 13:21
alertmanager alerts to slack for prometheus-operator
.......some config.....
alertmanager:
## Deploy alertmanager
##
enabled: true
## Service account for Alertmanager to use.
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
##
@alvarotf
alvarotf / async-api-call-helper.service.ts
Created December 22, 2018 21:07
Angular Universal: Using ZoneMacroTaskWrapper to make renderModuleFactory wait for async api calls.
import { Injectable } from '@angular/core';
import { Observable, Observer, Subscription } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class AsyncApiCallHelperService {
@cecilemuller
cecilemuller / 2019-https-localhost.md
Last active July 20, 2024 14:39
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

@alanxone
alanxone / ngrx-example-auth-guard.ts
Last active May 11, 2021 23:45
NGRX Tutorial - Auth Guard
// NGRX Complete Tutorial Without Pain (Angular6 / RxJS6)
// https://medium.com/@andrew.kao/ngrx-complete-tutorial-without-pain-angular6-rxjs6-5511b8cb8dac
import { Injectable } from '@angular/core';
import { CanActivate } from '@angular/router';
import { Store, select } from '@ngrx/store';
import { Observable } from 'rxjs';
import { map, take } from 'rxjs/operators';
import * as Auth from '(auth actions)';
import * as fromTeam from '(team main reducer)';
@mikesmullin
mikesmullin / trace.js
Created November 24, 2017 23:21
Node.JS print filename and line number prefixed to console log output
const path = require('path');
function trace(s) {
const orig = Error.prepareStackTrace;
Error.prepareStackTrace = (_, stack) => stack;
const err = new Error();
Error.captureStackTrace(err, arguments.callee);
Error.prepareStackTrace = orig;
const callee = err.stack[0];
process.stdout.write(`${path.relative(process.cwd(), callee.getFileName())}:${callee.getLineNumber()}: ${s}\n`);
@mauron85
mauron85 / launchvnc.sh
Last active April 6, 2023 08:12
Launch vino vnc server without configuring it first
#!/bin/bash
# This script should have been runned by user (non root)
# In case of errors like cannot open display:
# 1. Change DISPLAY=:0 for actual working display
# 2. Check (and change) permissions of files and dirs in user home dir
# specialy when you run this script as root by accident
# sometimes dirs like .dconf may be owned as root.
# As result vino server will not run under user privileges
@int128
int128 / README.md
Last active January 21, 2024 14:52
Watching build mode on Create React App

Create React App does not provide watching build mode oficially (#1070).

This script provides watching build mode for an external tool such as Chrome Extensions or Firebase app.

How to Use

Create a React app.

Put the script into scripts/watch.js.

@jwilson8767
jwilson8767 / es6-element-ready.js
Last active July 12, 2024 05:01
Wait for an element to exist. ES6, Promise, MutationObserver
// MIT Licensed
// Author: jwilson8767
/**
* Waits for an element satisfying selector to exist, then resolves promise with the element.
* Useful for resolving race conditions.
*
* @param selector
* @returns {Promise}
*/
@hivefans
hivefans / shell_output.go
Last active May 12, 2024 10:36
get the realtime output for a shell command in golang|-|{"files":{"shell_output.go":{"env":"plain"}},"tag":"bigdata"}
package main
import (
"bufio"
"fmt"
"io"
"os"
"os/exec"
"strings"
)