Skip to content

Instantly share code, notes, and snippets.

Avatar
🍋

Jan R. Biasi janbiasi

🍋
View GitHub Profile
@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 / 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 {
@janbiasi
janbiasi / index.php
Created Jan 13, 2016
Tired of the default XAMPP/MAMP Index? Try this one and get a beautiful directory listing in your server root!
View index.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Index of <?= $_SERVER['SERVER_NAME'] ?></title>
<style type="text/css">
html, body { margin: 0; padding: 0; }
body { font-family: 'Helvetica Neue', Arial, sans-serif; padding: 20px; }
a { text-decoration: none; color: #4BB7DB; }
a:hover { text-decoration: underline; }
@janbiasi
janbiasi / example-properties.js
Last active Jan 6, 2016
Node Type let you easily work with types and its core possibilities such as enumerability, writability and readonly settings. Properties can be declared with a specific type and a livetime validator.
View example-properties.js
var out = function(val) { console.log(val); };
var User = Type.create({
properties: {
name: String,
id: {
type: Number,
enumerable: false
},
class: {
You can’t perform that action at this time.