Skip to content

Instantly share code, notes, and snippets.

View carlhannes's full-sized avatar

Hannes W carlhannes

View GitHub Profile
Add-WindowsCapability -Online -Name OpenSSH.Server*
Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'
let versions = [];
(await (await fetch('https://unpkg.com/browse/picasso.js/')).text()).replace(/<option[^>]*value="([^"]*)"[^>]*>/gm, (match, version) => versions.push(version) );
function JSON2Matrix(jsonArray) {
let matrixHeader = [];
let matrixData = [];
for (let idx = 0; idx < jsonArray.length; idx++) {
const cur = jsonArray[idx];
const keys = Object.keys(cur);
let matrixLine = [];
for (let idk = 0; idk < keys.length; idk++) {
@carlhannes
carlhannes / Creating picassojs extensions - Links.md
Last active May 25, 2019 18:39
Creating picassojs extensions
Region Type Count
Stockholm Petrol 1288
Stockholm Diesel 1962
Stockholm Hybrids & Flexifuels 688
Malmo Petrol 495
Malmo Diesel 458
Malmo Hybrids & Flexifuels 116
Gothenburg Petrol 635
Gothenburg Diesel 439
Gothenburg Hybrids & Flexifuels 250
@carlhannes
carlhannes / simpe-parallax.js
Last active October 21, 2017 21:59
Very simple ES6 JavaScript background-position parallax function using requestAnimationFrame
export default function attachParallax(elm) {
document.addEventListener('mousemove', (e) => {
window.requestAnimationFrame(() => {
const left = (e.clientX / window.innerWidth) * 5;
const top = (e.clientY / (window.innerHeight)) * 5;
elm.style.backgroundPosition = `${47.5 + left}% ${47.5 + top}%`;
});
}, false);
}
debounce: function(func, wait, immediate) {
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
// taken from https://github.com/jashkenas/underscore/blob/master/underscore.js
var timeout, args, context, timestamp, result;
var later = function() {
var last = new Date().getTime() - timestamp;