Skip to content

Instantly share code, notes, and snippets.

@myyellowshoe
myyellowshoe / AutoScalingSvgSolution.md
Last active July 1, 2024 14:05
Auto Scaling Svg Solution

Autoscaling SVG's

Scaling svgs is annoying and most solutions require tradoffs I don't want. I'm suprised the ammount of solutions out there that are pretty subpar or require extra overhead.

What I don't want:

  • use an image tag
  • use wrappers
  • use weird padding
  • pass down props for width/height or viewBox props.
@michaelChein
michaelChein / README.md
Last active January 19, 2019 18:10
Generating a Euclidean matrix using numpy's broadcasting

Generating a Euclidean matrix using numpy's broadcasting

This is an algorithm for calculating a euclidean distance matrix between each point to each other point in a data set, written as part of a agglomerative clustering exercise, using numpy's broadcasting, but could be applied to any other calculation done on multidimensional data sets.

The basic concept is that, when adding or multiplying two vectors of sizes (m,1) and (1,m), numpy will broadcast (duplicate the vector) so that it allows the calculation. For example multiplying a vector [1,2,3,4,...10] with a transposed version of itself, will yield the multiplication table. For Example:

drawing

The same technique can be used for matrices. In this case, I was looking to generate a Euclidean distance matrix for the iris data set.

@kylegach
kylegach / index.js
Last active April 18, 2019 19:13 — forked from vikramrojo/index.js
CSS in JS using styled-components, polished & styled-system
import React from 'react';
import styled, { ThemeProvider, css } from 'styled-components'
import { darken, lighten } from 'polished'
import { space, width, fontSize, color } from 'styled-system'
import { storiesOf } from '@storybook/react';
// import { action } from '@storybook/addon-actions';
// import { linkTo } from '@storybook/addon-links';
//Theme for Layers
@vikramrojo
vikramrojo / index.js
Last active January 20, 2018 15:28
CSS in JS using styled-components, polished & styled-system
import React from 'react';
import styled, { ThemeProvider, css } from 'styled-components'
import { darken, lighten } from 'polished'
import { space, width, fontSize, color } from 'styled-system'
import { storiesOf } from '@storybook/react';
// import { action } from '@storybook/addon-actions';
// import { linkTo } from '@storybook/addon-links';
//Theme for Layers
@pixelbacon
pixelbacon / Logger.js
Created June 13, 2017 20:24
Wrapper for visionmedia/debug
import Debug from 'debug';
Debug.enable('company.*');
function createLogger(prefix){
prefix = 'company.project.' + prefix;
return {
log: Debug(prefix),
error: Debug(prefix + '::ERROR'),
info: Debug(prefix + '::info'),
warning: Debug(prefix + '::warning'),