Skip to content

Instantly share code, notes, and snippets.

Avatar
🍋

Jan R. Biasi janbiasi

🍋
View GitHub Profile
@janbiasi
janbiasi / export.sh
Created Sep 9, 2014
Export GitHub wiki as HTML files
View export.sh
#!/bin/bash
# for each md file in the directory
for file in *.md
do
# convert each file to html and place it in the html directory
# --gfm == use github flavoured markdown
marked -o pages/$file.html $file --gfm
done
@janbiasi
janbiasi / navigation-trigger-handler.js
Created Nov 30, 2020
Simple snippet for creating a mobile navigation with pure vanilla JavaScript
View navigation-trigger-handler.js
// Replace this with your burger icon element ID
var trigger = document.getElementById('mobile-navigation-trigger');
// Replace this with with your navigation element ID
var navigationList = document.getElementById('navigation-list');
// open or close the mobile flyout
function toggleNavigation() {
if (navigationList.classList.contains('is-open')) {
navigationList.classList.remove('is-open');
@janbiasi
janbiasi / git.sh
Last active Oct 28, 2020
Git Merge branch in master as overwrite
View git.sh
#!/bin/sh
TARGET="master"
BRANCH="seotweaks"
git push origin $TARGET && git stash
# Overwrite $TARGET with $BRANCH
git checkout $BRANCH
git merge -s ours $TARGET
@janbiasi
janbiasi / MyComponent.gondel.ts
Last active Jun 26, 2020
[Gondel Angular Component Playground] Example implementation of an Angular Component with Gondel integration in mind. #gondel #angular
View MyComponent.gondel.ts
import { Component, EventListener, GondelBaseComponent } from '@gondel/core';
@Component()
export class UIMyComponent extends GondelBaseComponent {
static componentName = 'MyComponent';
@EventListener('click', '.js-a-my-component__button')
_handleClick(ev: any) {
alert('Button clicked!');
}
@janbiasi
janbiasi / sigterm.js
Last active Jan 15, 2018
Handle node.js process quit by user (Command+Q on MacOS, Control+C on Windows)
View sigterm.js
['SIGINT', 'SIGTERM'].forEach(sig => {
process.on(sig, () => process.exit());
});
View shared-events-ios.md

Events

  • http:error = Server Errors with code 500
  • http:timeout = Requests which exceeded the max. timeout of 10s

Param Signature

window.__REACT_SHARED_EVENTS__.on('http:error', (code, response, config) => { });
window.__REACT_SHARED_EVENTS__.on('http:timeout', (code, response, config) => { });
View server.js
const DATASOURCE = 'data.json';
const fs = require('fs');
const parser = require('body-parser');
const app = require('express')();
app.use(parser.json());
// HTTP GET /api/data
app.get('/api/data', (req, res, next) => {
@janbiasi
janbiasi / cluster.js
Created Feb 16, 2016
Zukunft. Namics. Snippets für das Node.js Clustermodul (Part 2)
View cluster.js
var cluster = require('cluster');
var numCPUs = require('os').cpus().length;
var proxy = require('./proxy');
if (cluster.isMaster) {
for (var i = 0; i < numCPUs; i++) {
// Erstellt pro Kern einen neuen Worker
cluster.fork();
}
} else {
@janbiasi
janbiasi / proxy.js
Last active Feb 16, 2016
Zukunft. Namics. Snippets für das Node.js Clustermodul (Part 1)
View proxy.js
var http = require('http');
var httpProxy = require('http-proxy');
exports.createServer = function(host, proxyPort, httpPort) {
proxyPort = proxyPort || 8000;
httpPort = httpPort || 9000;
host = host || 'localhost';
// Erstellt den Proxy-Server
httpProxy.createServer(httpPort, host).listen(proxyPort);
@janbiasi
janbiasi / microp.js
Created Feb 9, 2016
Micro sized promise library for Node.js and the Browser
View microp.js
(function() {
var root = this;
var giveBackOldPromise = Promise;
var isNode = typeof process === 'object' || window === undefined;
var asap = function(handler) {
if(isNode) {
process.nextTick(handler);
} else {