Skip to content

Instantly share code, notes, and snippets.

View MKruschke's full-sized avatar

Mirko Kruschke MKruschke

  • Adevinta
  • Berlin
View GitHub Profile
function useAbortController(deps=[]) {
const abortControllerRef = React.useRef<AbortController>()
React.useEffect(() => {
return () => abortControllerRef.current?.abort()
}, deps)
const getSignal = React.useCallback(() => {
if (!abortControllerRef.current) {
abortControllerRef.current = new AbortController()
@MKruschke
MKruschke / Folder Structure example.md
Last active January 7, 2020 16:07
Shape your Application with Packages
├── 📂 apps                                             
│   ├── 📂 administration                               
│   │   ├── 📦 main
│   │   ├── 📂 shared
│   │   │   └── 📂 contracts
│   │   │       └── 📦 navigation
│   ├── 📂 inventory
│   │   ├── 📂 features
│   │   |   └── 📦 promotions
const setURL = (url) => {
const parser = document.createElement('a');
parser.href = url;
['href', 'protocol', 'host', 'hostname', 'origin', 'port', 'pathname', 'search', 'hash'].forEach(prop => {
Object.defineProperty(window.location, prop, {
value: parser[prop],
writable: true,
});
});
};
@MKruschke
MKruschke / tmux.conf
Created May 15, 2017 13:55 — forked from spicycode/tmux.conf
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'
killall Dock
@MKruschke
MKruschke / in_viewport.js
Created November 9, 2016 22:47 — forked from jjmu15/in_viewport.js
check if element is in viewport - vanilla JS. Use by adding a “scroll” event listener to the window and then calling isInViewport().
// Determine if an element is in the visible viewport
function isInViewport(element) {
var rect = element.getBoundingClientRect();
var html = document.documentElement;
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || html.clientHeight) &&
rect.right <= (window.innerWidth || html.clientWidth)
);
@MKruschke
MKruschke / launch.js
Created October 11, 2016 15:02 — forked from paambaati/launch.js
Debug mocha tests using Visual Studio Code
{
"version": "0.1.0",
// List of configurations. Add new configurations or edit existing ones.
// ONLY "node" and "mono" are supported, change "type" to switch.
"configurations": [
{
// Name of configuration; appears in the launch configuration drop down menu.
"name": "Run app.js",
// Type of configuration. Possible values: "node", "mono".
"type": "node",
const log = (...args) => {
console.log(...args)
return args
}
# Linking of packages
# warning use it not often (dont link a package was has also a link)
# do that in the project that you want to link
npm link
# do that in the project that needs the linking
npm unlink --global @signavio/effektif-commons
# check if a link is active
{
"bootstrapped": true,
"in_process_packages":
[
],
"installed_packages":
[
"Base64 Fold",
"BracketGuard",
"BracketHighlighter",