Skip to content

Instantly share code, notes, and snippets.

View danieldietrich's full-sized avatar
💭
📡 working from space

Daniel Dietrich danieldietrich

💭
📡 working from space
View GitHub Profile
@danieldietrich
danieldietrich / gh-pages-deploy.md
Created October 6, 2020 21:32 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@danieldietrich
danieldietrich / presidents-us.json
Created September 29, 2020 11:32
Presidents of the United States
[
{
"no":1,
"name":"George Washington",
"desc":"George Washington was an American political leader, military general, statesman, and founding father who served as the first president of the United States from 1789 to 1797. Previously, he led Patriot forces to victory in the nation's War for Independence.",
"life":["1732-02-22","1799-12-14"],
"period":[1789,1797],
"image":"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD84QzQ5OjcBCgoKDQwNGg8PGjclHyU3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3N//AABEIAHgAeAMBIgACEQEDEQH/xAAbAAABBQEBAAAAAAAAAAAAAAAAAQIDBAUGB//EADMQAAIBAwMCBQMDAQkAAAAAAAECAAMEEQUhMRJBBhMiUWEUcYEyQqHwByMzUmKRscHR/8QAGAEAAwEBAAAAAAAAAAAAAAAAAAECAwT/xAAdEQEBAQEAAgMBAAAAAAAAAAAAARECAyESIjFR/9oADAMBAAIRAxEAPwDyEmEDCY1oICEURGIRcwgBzEEN4YMADExFwYYgDcQimECJCLDEYHfMIQjlAMSKYgioLACKBHgSTNCxwEcBHAbwGGdMOntOg8LeHK+vXfSAyW1PepVA/gfM9P0/w1penUlFnZoW/c9T1MT9zI68k5VOdeH4iET3C/0iyuAf
@danieldietrich
danieldietrich / numji.js
Last active September 25, 2020 20:12
Emoji numbers
function numji(i, c = 0) {
let s = "";
if (!Number.isNaN(i) && Number.isFinite(i)) {
i = Math.abs(Math.trunc(i));
do {
c--;
s = String.fromCharCode(0x0030 + i % 10, 0xFE0F, 0x20E3) + s;
i = Math.trunc(i / 10);
} while (i > 0 || c > 0);
}
@danieldietrich
danieldietrich / .gitignore
Created August 8, 2020 11:24 — forked from just-boris/.gitignore
Shadow DOM as a React component: https://dist-bpvbyiobiw.now.sh
.cache
dist
node_modules
@danieldietrich
danieldietrich / module.ts
Last active June 22, 2021 17:54
How to define interoperable TypeScript modules (use Rollup.js to build cjs, mjs and umd modules)
namespace MyName {
export type MyType = string | number;
export const myValue: MyType = createSampleValue();
// internal
function createSampleValue(): string {
return "test";
}
@danieldietrich
danieldietrich / .github∕dependabot.yml
Created July 30, 2020 00:26
GitHub Action: Automerge Dependabot Pull Requests
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
@danieldietrich
danieldietrich / FizzBuzz.java
Last active July 31, 2020 22:14
FizzBuzz with Vavr using Either
import static io.vavr.API.*;
import io.vavr.collection.Iterator;
import io.vavr.control.Either;
public class FizzBuzz {
public static void main(String[] args) {
var fizzBuzz = Iterator.from(1).map(i ->
implicit class StringContextExtensions(private val sc: StringContext) extends AnyVal {
def xs(args: Any*): String = align(sc.s, args)
def xraw(args: Any*): String = align(sc.raw, args)
private def align(interpolator: Seq[Any] => String, args: Any*): String = ""
}
@danieldietrich
danieldietrich / build.gradle
Last active February 18, 2020 17:20
Gradle maven-publish problem as described here: https://twitter.com/danieldietrich/status/1229794465981829123
buildscript {
repositories {
/*
* --> in-house Artifactory server here <--
*/
gradlePluginPortal()
}
dependencies {
classpath "io.spring.gradle:dependency-management-plugin:${versionSpringDependencyManagementPlugin}"
classpath "net.researchgate:gradle-release:${versionGradleReleasePlugin}"
@danieldietrich
danieldietrich / builder.ts
Last active February 2, 2020 09:40
A generic functional object builder. Builders are used in the presence of default values or if objects are created in multiple steps. Otherwise you would create them directly using the object literal {}.
type Builder<T> = {
with: (t: Partial<T>) => Builder<T>,
build: () => T
}
// A generic builder that works for *ALL* object types
function builder<T>(options: { defaultValues: T }): Builder<T> {
return {
with: _with,
build: () => ({...options.defaultValues})