Skip to content

Instantly share code, notes, and snippets.

import fs from 'fs';
import path from 'path';
import { Plugin } from 'vite';
import packageJson from './package.json' with { type: 'json' };
async function isCommonJS(depName: string) {
try {
const pkg = (await import(`./node_modules/${depName}/package.json`, {
with: {
type: 'json'
diff --git a/node_modules/react-d3-tree/lib/esm/Tree/index.js b/node_modules/react-d3-tree/lib/esm/Tree/index.js
index 650dd9a..a173e23 100644
--- a/node_modules/react-d3-tree/lib/esm/Tree/index.js
+++ b/node_modules/react-d3-tree/lib/esm/Tree/index.js
@@ -301,7 +301,7 @@ class Tree extends React.Component {
const d = Array.isArray(data) ? data : [data];
return d.map(n => {
const nodeDatum = n;
- nodeDatum.__rd3t = { id: null, depth: null, collapsed: false };
+ nodeDatum.__rd3t = Object.assign({ id: null, depth: null, collapsed: false }, nodeDatum.__rd3t ? nodeDatum.__rd3t: {})
export const valueIterator = (thing) => {
const values = []
const normalize = (thing) => Array.isArray(thing) ? thing.entries() : Object.entries(thing)
const process = (thing) => {
for (const [index, item] of normalize(thing)) {
typeof item !== 'string' && typeof item !== 'number' ? process(item) : values.push(thing)
}
}
@danielbeeke
danielbeeke / formToObject
Created April 17, 2020 11:30
formToObject
/**
* Convert form / POST data to object.
* Like: Tenants[0] = 'a' to { Tenants: ['a'] }
*/
let formToObject = function (form) {
let formData = new FormData(form);
let formDataObject = {};
formData.forEach(function(value, key){
let keySplit = key.replace(/\]/g, '').split('[');
if (keySplit.length > 1) {
/**
* Returns a relative time string.
* @param epoch
* @param addPrefixOrSuffix
* @returns {string}
*/
export let relativeTime = (epoch, addPrefixOrSuffix = true) => {
const rtf = new Intl.RelativeTimeFormat('nl', {
localeMatcher: "best fit",
numeric: "auto",
@danielbeeke
danielbeeke / FormHelperApp.js
Created June 24, 2019 17:06
A interface for using the FormHelper custom element.
import {FormHelper} from './form_helper/FormHelper.js';
class App {
constructor () {
this.data = {
name: 'Henk',
surname: 'Jansen',
isSuperman: true,
awesomeness: 32
server {
server_name *.JOUWNAAM;
root /var/www/nginx/$http_host;
error_page 404 /404.html;
location / {
add_header Access-Control-Allow-Origin *;
try_files $uri $uri/index.html @rewrite;
}
<?php
/**
* @file
* Contains \Drupal\rest\Plugin\rest\resource\EntityResource.
*/
namespace Drupal\gap_rest\Plugin\rest\resource;
use Drupal\Core\Entity\EntityInterface;
@mixin grid-block($gutter, $selector, $grids) {
margin: 0 -#{$gutter / 2};
max-width: calc(100% + #{$gutter});
@include clearfix;
#{$selector} {
margin: $gutter #{$gutter / 2};
}
@each $grid in $grids {
@danielbeeke
danielbeeke / gist:31e5a159d2c1b012b6b8
Created January 1, 2016 20:28
trying to render specific pages
module Jekyll
class PagesPageGenerator < Generator
safe true
priority :highest
def generate(site)
pages = site.collections['pages'].docs