Skip to content

Instantly share code, notes, and snippets.

View vectorsize's full-sized avatar

Victor Saiz vectorsize

View GitHub Profile
@vectorsize
vectorsize / linearScale.js
Last active December 20, 2022 14:30
Quick linear scale inspired by d3.js scales, based on the processing.org map() function.takes in an object with a domain array and a rage array, gives you back a function that receives a value and returns the scaled value.
// based on https://github.com/processing/processing/blob/a6e0e227a948e7e2dc042c04504d6f5b8cf0c1a6/core/src/processing/core/PApplet.java#L5093
var scale = function(opts){
var istart = opts.domain[0],
istop = opts.domain[1],
ostart = opts.range[0],
ostop = opts.range[1];
return function scale(value) {
return ostart + (ostop - ostart) * ((value - istart) / (istop - istart));
@vectorsize
vectorsize / gun.py
Created December 17, 2020 22:53
one file git based package manager
#!/usr/bin/env python3
import os
import sys
import subprocess
import json
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
@vectorsize
vectorsize / fixed_kernal_task_high_cpu_on_macos.md
Created July 1, 2020 18:15 — forked from ntamvl/fixed_kernal_task_high_cpu_on_macos.md
Fixed the fan running high, kernel task taking up 500% cpu (high cpu) on macOS

Fixed the fan running high, kernel task taking up 500% cpu (high cpu)

Step 1: Disable SIP

Enter recovery mode

  • Shutdown your macbook
  • Press keys: Command + R
  • Press power button
  • Release keys Command + R when see Apple logo appear
  • Open Terminal app on recovery screen, then run below command:
@vectorsize
vectorsize / domino.js
Last active June 13, 2019 04:18
D3 in a virtual DOM proof of concept.
!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.domino=e():"undefined"!=typeof global?global.domino=e():"undefined"!=typeof self&&(self.domino=e())}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var parserlib = require('./cssparser');
module.exports = CSSStyleDeclaration;
function CSSStyleDeclaration(elt) {
this._element = elt;
}
// Utility function for parsing style declarations
[{"page":1,"pages":16,"per_page":"20","total":304},[{"id":"ABW","iso2Code":"AW","name":"Aruba","region":{"id":"LCN","iso2code":"ZJ","value":"Latin America & Caribbean "},"adminregion":{"id":"","iso2code":"","value":""},"incomeLevel":{"id":"HIC","iso2code":"XD","value":"High income"},"lendingType":{"id":"LNX","iso2code":"XX","value":"Not classified"},"capitalCity":"Oranjestad","longitude":"-70.0167","latitude":"12.5167"},{"id":"AFG","iso2Code":"AF","name":"Afghanistan","region":{"id":"SAS","iso2code":"8S","value":"South Asia"},"adminregion":{"id":"SAS","iso2code":"8S","value":"South Asia"},"incomeLevel":{"id":"LIC","iso2code":"XM","value":"Low income"},"lendingType":{"id":"IDX","iso2code":"XI","value":"IDA"},"capitalCity":"Kabul","longitude":"69.1761","latitude":"34.5228"},{"id":"AFR","iso2Code":"A9","name":"Africa","region":{"id":"NA","iso2code":"NA","value":"Aggregates"},"adminregion":{"id":"","iso2code":"","value":""},"incomeLevel":{"id":"NA","iso2code":"NA","value":"Aggregates"},"lendingType":{"id":"","iso
pepper="~/Library/Application Support/Google/Chrome/PepperFlash"
version=$(ls -t ~/Library/Application\ Support/Google/Chrome/PepperFlash)
open -n -a "Chromium" --args --ppapi-flash-path="$pepper/$version/PepperFlashPlayer.plugin" --ppapi-flash-version=$version
@vectorsize
vectorsize / README.md
Last active December 31, 2015 18:22 — forked from mbostock/.block
DOM-to-Canvas using D3

Mouseover to draw circles!

This is a quick proof-of-concept example demonstrating how to create a canvas scenegraph in the DOM using document fragments. The scenegraph in this example consists of a simple container svg element and a number of child circle elements.

The content positions and sizes are calculated offline and the actual DOM tree doesn't even need to be aware of out svg. To render them, we use a timer that iterates over the child elements and draws them to a canvas element.

This is a modification of the original DOM-to-Canvas using D3 proof of conncept.

{
"caption": "Terminal",
"id": "side-bar-files-open-with-terminal",
"command": "side_bar_files_open_with",
"args": {
"paths": [],
"application": "Terminal.app"
}
}
/* url sets the path */
font-url(file)
return '/public/stylesheets/fonts/' + file
/* abstracts all the specifics*/
webfont(family, file, style, weight)
@font-face
font-family family
font-weight weight
font-style style
vendor(prop, args)
-webkit-{prop} args
-moz-{prop} args
-ms-{prop} args
-o-{prop} args
{prop} args
border-radius()
vendor('border-radius', arguments)