Skip to content

Instantly share code, notes, and snippets.

View carolina-vallejo's full-sized avatar

Carolina Vallejo carolina-vallejo

  • ITONICS, GmbH
  • Berlin
View GitHub Profile
private transform(d) {
const x = (((d.x0 + d.x1) / 2) * 180) / Math.PI;
const y = ((d.y0 + d.y1) / 2) * this.radius;
return `rotate(${x - 90}) translate(${y},0) rotate(${x < 180 ? 0 : 180})`;
}
private position(d) {
const x = (((d.x0 + d.x1) / 2) * 180) / Math.PI;
const y = ((d.y0 + d.y1) / 2) * this.radius;
@carolina-vallejo
carolina-vallejo / mouse-events-binded-rxjs.ts
Created July 5, 2019 14:21
mouse events binded rxjs.ts
import { Component, OnInit, ElementRef } from '@angular/core';
import { fromEvent } from 'rxjs';
import { skipUntil, takeUntil } from 'rxjs/operators';
@Component({
selector: 'app-board',
templateUrl: './board.component.html',
styleUrls: ['./board.component.scss']
})
@carolina-vallejo
carolina-vallejo / hcl-interpolation.ts
Created July 1, 2019 20:19
color function hcl inperpolation
private getColor(i) {
const color0 = '#00ca79';
const color2 = '#7a4da8';
const colorScale = d3
.scaleLinear()
.domain([0, categories.length - 1])
.range([color0, color2])
.interpolate(d3.interpolateHcl);
@carolina-vallejo
carolina-vallejo / hsl-to-rgb.js
Last active May 19, 2018 12:05
rgb to hsl in d3
.style('fill',function(d, i){
var c = d3.hsl(d3.rgb(#FF9900));
c.l += ((0.7/2)*i);
return c + "";
})
@carolina-vallejo
carolina-vallejo / midpoint.js
Created April 12, 2018 09:28
midpoint calculation between two coordinates middle point
function midpoint(x1, y1, x2, y2, per) {
return [x1 + (x2 - x1) * per, y1 + (y2 - y1) * per];
}
@carolina-vallejo
carolina-vallejo / is-small.js
Created March 16, 2018 10:53
is small is mobile
var isSmall = function() {
if (window.matchMedia('(max-width: ' + w_mobile + 'px)').matches) {
return true;
} else {
return false;
}
}
@carolina-vallejo
carolina-vallejo / date-picker-afterShow.js
Created March 12, 2018 17:21
date-picker-afterShow.js
$(function() {
$.datepicker._updateDatepicker_original = $.datepicker._updateDatepicker;
$.datepicker._updateDatepicker = function(inst) {
$.datepicker._updateDatepicker_original(inst);
var afterShow = this._get(inst, 'afterShow');
if (afterShow)
afterShow.apply((inst.input ? inst.input[0] : null)); // trigger custom callback
}
$( "#datepicker" ).datepicker({
beforeShow : function(input, inst) {
@carolina-vallejo
carolina-vallejo / safari-issues.txt
Last active April 1, 2018 19:14
Safari Isssues
- position fixed top 0 left 0
- flexbox con flexclean si hay flotantes
- seudo clases :not se comportan raro tiene mucha especificidad
- input type text 0 de ancho no hace trigger focus
- box shadow solo se puede poner poco de ancho
@carolina-vallejo
carolina-vallejo / cleanflex.scss
Created March 12, 2018 14:17
cleanflex clearfix flex
@mixin cleanflex {
&::after,
&::before {
content: "";
display: table;
-ms-flex-preferred-size: 0;
flex-basis: 0;
-webkit-box-ordinal-group: 2;
-ms-flex-order: 1;
order: 1;
@carolina-vallejo
carolina-vallejo / loadSvgSafe.js
Created March 7, 2018 16:45
load svg safe as xml and inject it in html
function loadSvg(selector, url) {
console.log('kshd')
var target = document.getElementById(selector);
// If SVG is supported
if (typeof SVGRect != "undefined") {
// Request the SVG file
var ajax = new XMLHttpRequest();
ajax.open("GET", url + ".svg", true);
ajax.send();