Skip to content

Instantly share code, notes, and snippets.

View fabric_of_reality.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Reality Fabric</title>
</head>
<body>
<div id="root">
<canvas id="myCanvas" width="400" height="400" style="position: absolute; left: 0; top: 0; z-index: 0;"></canvas>
View mock_implementation.js
test("mock implementation", () => {
const mock = jest.fn(() => "bar");
expect(mock("foo")).toBe("bar");
expect(mock).toHaveBeenCalledWith("foo");
});
test("also mock implementation", () => {
const mock = jest.fn().mockImplementation(() => "bar");
View fertilityCalculator.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>1Dokita fertility calculator</title>
<meta name="description" content="Fertility calculator">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fullcalendar/core@4.2.0/main.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fullcalendar/daygrid@4.2.0/main.min.css">
<style>
View domain-driven-design-cheatsheet.txt
tldr;
DDD is primarily about modeling a Ubiquitous (= überall vertreten) Language in an Bounded Context.
It avoids the design of monolithic applications.
Use DDD when the business model complexity is high (higher than the technical aspects of the project).
Bounded Context - semantic contextual boundary
Within the boundary, each component of the software model has a specific meaning and does specific things
The components inside a Bounded Context are context specific and semantically motivated.
In the Beginning of software modeling the Bounded Context is only coceptual and is part of the Problem Space.
View css-units-best-practices.md

CSS units

Recommendations of unit types per media type:

Media Recommended Occasional use Infrequent use Not recommended
Screen em, rem, % px ch, ex, vw, vh, vmin, vmax cm, mm, in, pt, pc
Print em, rem, % cm, mm, in, pt, pc ch, ex px, vw, vh, vmin, vmax

Relative units

Relative units

@dolubajo
dolubajo / readme.md
Created Feb 15, 2018 — forked from coolaj86/how-to-publish-to-npm.md
How to publish packages to NPM
View readme.md

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "you@example.com"
npm set init.author.url "http://yourblog.com"

npm adduser
@dolubajo
dolubajo / app.js
Created Feb 1, 2018 — forked from acdlite/app.js
Quick and dirty code splitting with React Router v4
View app.js
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
@dolubajo
dolubajo / git-pushing-multiple.rst
Created Jan 24, 2018 — forked from rvl/git-pushing-multiple.rst
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.
View git-pushing-multiple.rst

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just

@dolubajo
dolubajo / selectMany.js
Created Apr 4, 2017 — forked from aaronpowell/selectMany.js
LINQ SelectMany in JavaScript
View selectMany.js
Array.prototype.selectMany = function (fn) {
return this.map(fn).reduce(function (x, y) { return x.concat(y); }, []);
};
// usage
console.log([[1,2,3], [4,5,6]].selectMany(function (x) { return x; })); //[1,2,3,4,5,6]
console.log([{ a: [1,2,3] }, { a: [4,5,6] }].selectMany(function (x) { return x.a; }));
View parse_infix.cs
using System;
using System.Collections.Generic;
class Program
{
static void Main(string[] args)
{
string parameter = "gun and (drugs and not rock) and roll";
//parameter = "(sex and (drugs and (not rock)) and roll)";
//parameter = "(boy and girl) or snake";