Skip to content

Instantly share code, notes, and snippets.

🍋
make juice out of lemons!

Jan R. Biasi janbiasi

🍋
make juice out of lemons!
Block or report user

Report or block janbiasi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@janbiasi
janbiasi / MyComponent.gondel.ts
Last active Jun 12, 2018
Example implementation of an Angular Component with Gondel integration in mind.
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: {
@janbiasi
janbiasi / git.sh
Last active Dec 4, 2015
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
You can’t perform that action at this time.