Skip to content

Instantly share code, notes, and snippets.

Rocket Science

Christian Engel Paratron

Rocket Science
Block or report user

Report or block Paratron

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
Paratron / color-log.js
Created May 21, 2019
This tiny wrapper around chalk enables easy coloring of log messages.
View color-log.js
* Chalk powered color log
* =======================
* This module is a wrapper around the chalk package to provide
* simpler log message formatting.
* To switch a color inside your log message, simply use ´X where
* X is one of the color names in the chalkMap below.
* Example:
Paratron / storageHooks.js
Created Feb 14, 2019
Enables you to use hooks for localStorage and sessionStorage that even redraw all components when their respective values change.
View storageHooks.js
import React from "react";
let lsBus = {};
let ssBus = {};
* Redraw all components that have a hook to localStorage with the given key.
* @param {string} key
* @param {*} newValue
Paratron /
Created Feb 5, 2019
Open a shell into a running docker container
docker exec -ti container_id bash
Paratron / docker-compose.yml
Last active Feb 5, 2019
Quick Apache only server for a project
View docker-compose.yml
# This will start a apache server and maps it to the local port 80
# It will assume your hosted content in the folder ./src
version: '2'
image: webdevops/apache:latest
- ./src:/app
- 80:80
Paratron /
Last active Jan 18, 2019
Use SCSS to CSS converter for your project

Use SCSS to CSS converter for your project

  • npm install --save-dev node-sass
  • Add script to package.json: node-sass --watch INPUTFOLDER -o OUTPUTFOLDER
  • Run script, enjoy
Paratron / promisifyModule.js
Last active Dec 12, 2018
This node module will consume another module and promisify all of its functions.
View promisifyModule.js
const {promisify} = require('util');
const promisifyModuleFunctions = (inModule) => Object
.reduce((outModule, [key, property]) => {
outModule[key] = (typeof property === 'function')
? promisify(property)
: property;
return outModule;
Paratron / async-nodeJS.js
Created Dec 12, 2018
Simple async functionality for native style nodeJS functions
View async-nodeJS.js
// The normal async programming flow in nodeJS can get hairy, quickly:
function readAndParse(filename, callback){
fs.readFile(filename, 'utf8', (err, data) => {
callback(err, null);
myParser.doParsing(data, (err, result) => {
View array-to-object.js
const myObject = ['a', 'b', 'c'].reduce((obj, key) => (obj[key] = key, obj), {});
Paratron / shared_value_component.js
Last active Sep 22, 2017
React shared values component
View shared_value_component.js
* Sometimes you need to create a component of which all instances should rely on the same data pool.
* Lets for example consider a country selector dropdown. No matter how much of them you use inside your
* application - the all should share the same list of countries. But passing that list down to each and
* every component instance via props is very tiresome and bloats your app.
* Behold: the shared value component pattern!
import React from 'react';
import PropTypes from 'prop-types';
Paratron / dynamic_changehandlers.jsx
Last active Sep 18, 2017
React dynamic change handlers pattern
View dynamic_changehandlers.jsx
import React from 'react';
import PropTypes from 'prop-types';
const propTypes = {
firstName: PropTypes.string,
lastName: PropTypes.string,
birthDay: PropTypes.number,
gender: PropTypes.number,
You can’t perform that action at this time.