Skip to content

Instantly share code, notes, and snippets.

@robschmuecker
robschmuecker / README.md
Last active July 22, 2024 12:38
D3.js Drag and Drop, Zoomable, Panning, Collapsible Tree with auto-sizing.

This example pulls together various examples of work with trees in D3.js.

The panning functionality can certainly be improved in my opinion and I would be thrilled to see better solutions contributed.

One can do all manner of housekeeping or server related calls on the drop event to manage a remote tree dataset for example.

Dragging can be performed on any node other than root (flare). Dropping can be done on any node.

Panning can either be done by dragging an empty part of the SVG around or dragging a node towards an edge.

@tkon99
tkon99 / name.js
Last active April 19, 2024 14:38
Random Name Generator for Javascript
/*
(c) by Thomas Konings
Random Name Generator for Javascript
*/
function capFirst(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function getRandomInt(min, max) {
.sticky {
position: absolute;
right: 0;
z-index: 150;
transform: rotate(5deg);
width: 200px;
min-height: 150px;
margin: -10px 10px 10px;
padding: 10px;
font-family: "Comic Sans MS", "Comic Sans", "Chalkboard SE", "Comic Neue", cursive;
@sposmen
sposmen / ColombiaHolidaysExample.js
Created November 23, 2016 15:29
Holidays Helper
// This example populate the 2016,2017 and 2018 holidays in Colombia
[2016, 2017, 2018].forEach(function(year){
var holidaysHelper = new HolidaysHelper(year);
// Fixed
[
{month: HolidaysHelper.Months.January, day: 1, description: "Año Nuevo"},
{month: HolidaysHelper.Months.May, day: 1, description: "Día del Trabajo"},
{month: HolidaysHelper.Months.July, day: 20, description: "Grito de Independencia"},
{month: HolidaysHelper.Months.August, day: 7, description: "Batalla de Boyacá"},
@istepanov
istepanov / Configuration.h
Last active July 26, 2023 16:45
Marlin Anet A8 config
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@lucas-lm
lucas-lm / useCanvas.js
Created March 7, 2020 01:18
React custom hook for using canvas
import { useRef, useEffect } from 'react'
const useCanvas = (draw) => {
const canvasRef = useRef(null)
useEffect(() => {
const canvas = canvasRef.current
const context = canvas.getContext('2d')
@lucas-lm
lucas-lm / Canvas.js
Created March 7, 2020 01:19
Canvas component
import React from 'react'
import useCanvas from '../hooks/useCanvas'
const Canvas = props => {
const { draw, ...rest } = props
const canvasRef = useCanvas(draw)
return (
<canvas ref={canvasRef} {...rest} />
)
@neurobug
neurobug / Canvas.js
Created April 15, 2021 16:55 — forked from lucas-lm/Canvas.js
Canvas component
import React from 'react'
import useCanvas from '../hooks/useCanvas'
const Canvas = props => {
const { draw, ...rest } = props
const canvasRef = useCanvas(draw)
return (
<canvas ref={canvasRef} {...rest} />
)