Skip to content

Instantly share code, notes, and snippets.

View janbiasi's full-sized avatar
🌐
Just building

Jan R. Biasi janbiasi

🌐
Just building
View GitHub Profile
#!/bin/bash
echo "Installing Express ..."
npm install -g express-generator
read -p "Choose the name for your app: " appName
if [[ -z "$appName" ]]; then
echo "Installation failed: no name supplied!"
exit 1
fi
#!/bin/bash
if [ ! -d "./data" ]; then
mkdir -f data
fi
C:\mongodb\bin\mongod.exe --dbpath ./data/
@janbiasi
janbiasi / git.sh
Last active October 28, 2020 09:54
Git Merge branch in master as overwrite
#!/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 / example-properties.js
Last active January 6, 2016 10:49
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.
var out = function(val) { console.log(val); };
var User = Type.create({
properties: {
name: String,
id: {
type: Number,
enumerable: false
},
class: {
@janbiasi
janbiasi / index.php
Created January 13, 2016 08:49
Tired of the default XAMPP/MAMP Index? Try this one and get a beautiful directory listing in your server root!
<!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 / microp.js
Created February 9, 2016 10:31
Micro sized promise library for Node.js and the Browser
(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 / proxy.js
Last active February 16, 2016 07:48
Zukunft. Namics. Snippets für das Node.js Clustermodul (Part 1)
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 / cluster.js
Created February 16, 2016 07:48
Zukunft. Namics. Snippets für das Node.js Clustermodul (Part 2)
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 {
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) => {

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) => { });