Skip to content

Instantly share code, notes, and snippets.

💭
🕉 Coding...

Daniel Dietrich danieldietrich

💭
🕉 Coding...
Block or report user

Report or block danieldietrich

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
@danieldietrich
danieldietrich / unicode.ts
Created Sep 5, 2019
Unicode Dictionary for Slugifying / Hyphenating URLs (see https://github.com/danieldietrich/slugify)
View unicode.ts
// A subset of Unicode version 12.0
// https://en.wikipedia.org/wiki/List_of_Unicode_characters
// https://en.wiktionary.org/wiki
// Identity translations a-zA-Z0-9 and most punctuations are suppressed.
// Units and currencies and some are translated.
const unicode = {
"Basic Latin": {
// ASCII Punctuation & Symbols
'$': 'dollar',
'%': 'percent',
View Fetch.java
import io.vavr.control.Try;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
public final class Fetch {
View vavr-logo-history.txt
2014-2015
/ \____ _ ______ _____ / \____ ____ _____
/ \__ \/ \ / \__ \ / __// \__ \ / \/ __ \
_/ // _\ \ \/ / _\ \\_ \/ // _\ \ /\ \__/ /
/___/ \_____/\____/\_____/____/\___\_____/_/ \_/____/
2015-2016
/ \____ _ _ ____ ______ / \ ____ __ _ _____
/ / \/ \ / \/ \ / /\__\/ // \/ \ / / _ \
_/ / /\ \ \/ / /\ \\__\\ \ // /\ \ /\\/ \__/ /
@danieldietrich
danieldietrich / scratchbook.md
Created May 26, 2019
Markdown enumerated list
View scratchbook.md

List

  1. first
  2. second
  3. third
@danieldietrich
danieldietrich / README.md
Last active Jul 16, 2019
Deeply merging JavaScript objects
View README.md

Deeply merging JavaScript objects

This method is like Object.assign except that it recursively merges own enumerable string keyed properties of source objects into the destination object. Source properties that resolve to undefined are skipped if a destination value exists. Arrays are concatenated. Plain object properties are merged recursively. Other objects and value types are overridden by assignment. Source objects are applied from left to right. Subsequent sources overwrite property assignments of previous sources.

Note: This method mutates target.

Motivation

  • The native Object.assign does simply overwrite values on duplicate keys.
  • The Lodash _.merge does not handle arrays the way I would expect it:
View .bash_profile
# -----------------------------------------------------------------------------
# This is a fragment of ~/.bash_profile that adds git status and branch
# information to the terminal prompt. The 'colors' section is optional.
# -----------------------------------------------------------------------------
# prompt
export PS1="\[\e[0;32m\]\u@\h:\[\e[1;36m\]\w\[\e[0;33m\]\$(parse_git_status)\[\e[1;32m\]\$(parse_git_branch)\[\e[1;36m\] $\[\e[0m\] "
# colors
export TERM=xterm-color
@danieldietrich
danieldietrich / README.md
Last active Jan 19, 2019
Howto install a new JDK on a Mac
View README.md

Howto install a new JDK on a Mac

  1. Download JDK: http://jdk.java.net/13/ to ~/Downloads
  2. Unpack downloaded .tar.gz bundle
  3. Goto base dir cd /Library/Java/JavaVirtualMachines
  4. Move unpacked JDK mv ~/Downloads/jdk-13.jdk .
  5. Change owner sudo chown -R root jdk-13.jdk/
  6. Change group sudo chgrp -R wheel jdk-13.jdk/
  7. Remove quarantaine flag sudo xattr -dr com.apple.quarantine jdk-13.jdk
  8. Create symlink sudo ln -s jdk-13.jdk/ jdk13
@danieldietrich
danieldietrich / README.md
Last active Jan 14, 2019
Coursier Artifact Fetching
View README.md

Java

import static io.vavr.API.*;

class Main {
    public static void main(String... args) {
        println("Hello Vavr!");
    }
}
@danieldietrich
danieldietrich / README.md
Created Jan 6, 2019
Hello world (Node.js)
View README.md
  1. Download npm and node
  2. echo "console.log('Hello world');" > index.js
  3. node index.js
View index.js
const f = require('./module.js');
const g = require('./module.js');
console.log("f()", f()); // = f() 0
console.log("g()", g()); // = g() 1
const path = require('path');
delete require.cache[path.resolve(__dirname, 'module.js')];
const h = require('./module.js');
console.log("h()", h()); // = h() 0
You can’t perform that action at this time.