Skip to content

Instantly share code, notes, and snippets.

@joyrexus
joyrexus / README.md
Created March 28, 2014 16:59
Nested grouping of arrays

nest.js

A multi-level groupBy for arrays inspired by D3's nest operator.

Nesting allows elements in an array to be grouped into a hierarchical tree structure; think of it like the GROUP BY operator in SQL, except you can have multiple levels of grouping, and the resulting output is a tree rather than a flat table. The levels in the tree are specified by key functions.

See this fiddle for live demo.

<?php
/*
* NOTICE OF LICENSE
*
* Part of the Rinvex Fort Package.
*
* This source file is subject to The MIT License (MIT)
* that is bundled with this package in the LICENSE file.
*
@puredazzle
puredazzle / webpack.mix.js
Last active December 21, 2018 06:25
Advanced Laravel Mix setup for WordPlate - https://github.com/wordplate/wordplate
const mix = require('laravel-mix');
const resources = 'resources/assets';
const themePath = 'public/themes/wordplate';
const assetsPath = `${themePath}/assets`;
mix.setPublicPath(assetsPath);
mix.setResourceRoot('../');
mix.browserSync({
@ehrenfeu
ehrenfeu / html_mail.py
Last active April 24, 2024 22:24
Use Python to send HTML emails with expand/collapse boxes working in TB and Android
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
def send_html_mail(subject, body, to_addr, from_addr):
"""Send an HTML email using the given subject, body, etc."""
# Create message container - the correct MIME type is multipart/alternative here!
message = MIMEMultipart('alternative')
message['subject'] = subject
@icerge
icerge / glidemultiple*_samples.md
Last active April 16, 2021 13:29
Glide Multiple operations (Update, Delete)

GlideMultipleUpdate usage

var x = new GlideMultipleUpdate('sys_user');
x.addQuery('company', "59a8f78c37561304985d8ff1b3990e2f");
x.setValue('company', "d4287b0c37561304985d8ff1b3990e92");
x.setValue('department', null);
x.execute();
@jtomaszewski
jtomaszewski / useFormFieldWarning.ts
Last active November 8, 2023 11:45
Hook for `react-hook-form` that lets you maintain state of a form field's warning (that is: an error that doesn't prohibit the form from being submitted).
import { useCallback, useState, useEffect, useRef } from "react";
import {
LiteralToPrimitive,
UnpackNestedValue,
useFormContext
} from "react-hook-form";
import { useDebouncedCallback } from "use-debounce";
/**
* Returns state of a warning for the given form field.