Skip to content

Instantly share code, notes, and snippets.

@tonyhschu
tonyhschu / .block
Last active February 16, 2024 22:44
Small Scroll-linked Animation Demo
scrolling: yes
license: MIT
@rauchg
rauchg / README.md
Last active April 13, 2025 04:29
require-from-twitter
import Foundation
public func getASTString() -> String {
// get the file path for the file "test.json" in the playground bundle
// let filePath = NSBundle.mainBundle().pathForResource("FirstTtest", ofType: "ast")
// get the contentData
let contentData = NSFileManager.defaultManager().contentsAtPath("a.txt")
@armollica
armollica / .block
Last active January 6, 2018 13:19
NBA Attendance
height: 400
@armollica
armollica / .block
Last active May 31, 2016 02:06
Bubbly Jobs Chart
height: 2500
@sxywu
sxywu / README.md
Last active April 18, 2019 03:35
Animate SVG path on scroll

Make sure to pop out to a new window, and then scroll.

An experiment to see if I can get svg paths to animate only to a certain horizontal line while a user scrolls. Used in my unreleased wongfu side project.

Built with blockbuilder.org

@emeeks
emeeks / README.md
Last active August 15, 2016 04:40
Particle Edges Dendrogram

Particle edges from d3_glyphEdges are the most difficult edge type to implement. Here's an example using a dendrogram and the connecting paths from the dendrogram. Remember that d3_glyphEdge.mutate.particle mutates the edge data object, spawning new particles, updating the position of existing particles and deleting particles that have reached the end of the path, and it's this array that you use to represent the particles (either with SVG as in this example or, if you're dealing with a lot of particles, probably canvas). As such, an edge object needs to have, along with .source and .target, .frequency (a positive number) to indicate the number of particles created per tick and .particles (an array) to hold the created particles.

d3_glyphEdge.mutate.particle does not include its own tick function so you need to create your own. This example uses d3.timer whereas this network example uses the built-in ti

"use strict";
var mori = require("mori");
var get = mori.get;
var assoc = mori.assoc;
var hashMap = mori.hashMap;
var vector = mori.vector;
var map = mori.map;
var reduce = mori.reduce;
@plumhead
plumhead / StringSize.swift
Created September 15, 2015 13:34
String extension to find the layout size of a String with specified attributes.
extension String {
func size(withAttributes attrs: [String:AnyObject], constrainedTo box: NSSize) -> NSRect {
let storage = NSTextStorage(string: self)
let container = NSTextContainer(containerSize: NSSize(width: box.width, height: box.height))
let layout = NSLayoutManager()
layout.addTextContainer(container)
storage.addLayoutManager(layout)
storage.addAttributes(attrs, range: NSMakeRange(0, storage.length))
container.lineFragmentPadding = 0.0
let _ = layout.glyphRangeForTextContainer(container)
@curran
curran / .block
Last active January 24, 2017 17:00
Density-based Ticks
license: mit