Skip to content

Instantly share code, notes, and snippets.

View patrickkunka's full-sized avatar

Patrick Kunka patrickkunka

View GitHub Profile
@patrickkunka
patrickkunka / index.js
Created February 28, 2020 15:43
XHR Proxy
((win) => {
const XMLHttpRequest = win.XMLHttpRequest;
class EventTarget {
listeners = {};
addEventListener(type, listener) {
const listenersOfType = this.listeners[type];
if (typeof listenersOfType === 'undefined') {
@patrickkunka
patrickkunka / facades-1.js
Last active January 8, 2019 10:33
Facade Patterns
/**
* Facade #1: Public/Private Members
*
* In this example, a "Facade" is placed between the consumer
* and the implementation in order to cherry-pick which public
* members we wish to expose to the API.
*/
class Implementation {
constructor() {
@patrickkunka
patrickkunka / configuration-1.js
Last active November 17, 2022 02:15
Configuration Patterns
/**
* Configuration #1: Basic Configuration Class
*
* A basic example utilising a sealed instance of a configuration
* class, with user-provided options merged in upon instantation
* of the implementation.
*/
class Config {
constructor() {
@patrickkunka
patrickkunka / factories-1.js
Last active March 6, 2021 21:27
Factory Function Patterns
/**
* Factory #1: Constructor Instantiation
*
* This example shows basic abstraction of constructor/class
* instantation. Additional error checking, validation of arguments
* could be added inside the factory, or just delegated to the constructor.
*/
import Implementation from './Implementation';
@patrickkunka
patrickkunka / .eslintrc
Last active February 7, 2017 17:16
KunkaLabs .eslintrc
{
"env": {
"node": true,
"browser": true
},
"globals": {
"Promise": true,
"Reflect": true,
"Symbol": true,
"describe": true,
@patrickkunka
patrickkunka / retrieve-value-via-stringkey
Created September 8, 2016 20:39
A simple implementation of retrieving the value of an object's property via its stringkey
getProperty = function(obj, stringKey) {
var parts = stringKey.split('.'),
returnCurrent = null,
current = '',
i = 0;
if (!stringKey) {
return obj;
}
# URL
http://<instance-namespace>.eu-west-1.compute.amazonaws.com:8111/
# Create teamcity instance
docker run -d --name teamcity-server-instance -p 8111:8111 -v ~/data/teamcity:/data/teamcity jetbrains/teamcity-server
// change `-d` to `-it` for debug mode
@patrickkunka
patrickkunka / uri-string-manipulations.js
Last active January 19, 2017 10:14
Common string manipulations for URI segments
// dash or snake to camel
String.prototype.toCamel = function() {
return this.replace(/([_-][a-z0-9])/g, function($1) {
return $1.toUpperCase().replace(/[_-]/, '');
});
};
// camel or pascal to snake