Skip to content

Instantly share code, notes, and snippets.

View pointyneedle's full-sized avatar

Needle pointyneedle

View GitHub Profile
@pointyneedle
pointyneedle / main.go
Created January 13, 2023 09:05 — forked from asdvxgxasjab/main.go
Make a genesis block
// Copyright 2019 cruzbit developers
// Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.
package main
import (
"encoding/base64"
"encoding/hex"
"encoding/json"
"flag"
@pointyneedle
pointyneedle / index.html
Created December 5, 2022 08:24 — forked from emeeks/index.html
Visualizing the PageRank Model
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Visualizing PageRank Centrality</title>
<meta charset="utf-8" />
</head>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/colorbrewer.v1.min.js"></script>
<style>
svg {
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");
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.

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

@pointyneedle
pointyneedle / readme.md
Created February 15, 2018 17:10 — forked from coolaj86/how-to-publish-to-npm.md
How to publish packages to NPM

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 "[email protected]"
npm set init.author.url "http://yourblog.com"

npm adduser

@pointyneedle
pointyneedle / app.js
Created February 1, 2018 14:57 — forked from acdlite/app.js
Quick and dirty code splitting with React Router v4
// 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 => {
@pointyneedle
pointyneedle / git-pushing-multiple.rst
Created January 24, 2018 14:39 — forked from rvl/git-pushing-multiple.rst
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

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

@pointyneedle
pointyneedle / selectMany.js
Created April 4, 2017 15:28 — forked from aaronpowell/selectMany.js
LINQ SelectMany in JavaScript
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; }));
//We will create a function to be extended to all String Objects
//This Injects the function into the String Object so any String Object will be able to call count
String.prototype.count = function countV() {
//store Object
var StringObj = this;
//Because countV is a function that will extend the String Object this will refer to the String itself if
//Our Json Object to Hold Data this is more efficient as you can return multiple results in one Object
var letter = { vowel: 0, consonant: 0 };
//Our loop
for (var i = 0; i < StringObj.length; i++) //Remember StringObj holds the String Object