Skip to content

Instantly share code, notes, and snippets.

Avatar

Sten Hougaard netsi1964

View GitHub Profile
View dream-flag.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@netsi1964
netsi1964 / svg-utils.js
Last active Apr 18, 2022
Some SVG utils
View svg-utils.js
export screen2svg = (eleSvg, x, y) => {
const point = eleSvg.createSVGPoint();
point.x = x;
point.y = y;
return point.matrixTransform(eleSvg.getScreenCTM().inverse());
}
@netsi1964
netsi1964 / funheadlines.js
Created Mar 10, 2022
Make news fun again
View funheadlines.js
var tags = Array.from(document.querySelectorAll('*')).filter(ele => !/^(a|script|iframe|title|meta|head|body|style|html|link|svg|path|g|button|img|picture|ol|ul|source|nav)$/ig.exec(ele.tagName));
var temp = tags.reduce((sum, curr) => {
const tag = curr.tagName;
const len = curr.textContent.length;
if (sum[tag]) {
sum[tag].len += len;
sum[tag].count++;
} else {
sum[tag] = { len, count:1};
}
@netsi1964
netsi1964 / make_DR.DK_headlines_funny.js
Last active Jan 24, 2022
Reading (bad) news can be hard...
View make_DR.DK_headlines_funny.js
// Reading (bad) news can be hard.
// This script you should run in the console and then hover over headlines to get a new random headline.
// Simply copy it
// Open developer toolbar (press F12)
// In the "console" paste the script, press ENTER
// Enjoy! Simply hover over a headline to get a new random text :-)
// Try reading it seeing the photo together with the new random text
// THIS VERSION is for https://www.dr.dk
//
var HEADLINE_SELECTOR = '.dre-title-text, .dre-teaser-title__text, #dr-frontpage__top-spot #text'
@netsi1964
netsi1964 / scriptable_are_you_at_work.js
Created Sep 29, 2021
A script for scriptable which will give a notification about if you are at a location (work) or not
View scriptable_are_you_at_work.js
const workLocation = { longitude: 10.21377573, latitude: 56.15343598 }; // DOKK1
const currentLocation = await Location.current();
const distanceToWork = calcCrow(
currentLocation.latitude,
currentLocation.longitude,
workLocation.latitude,
workLocation.longitude
).toFixed(1);
const notification = new Notification();
@netsi1964
netsi1964 / html to svg.js
Created Feb 21, 2021
Takes a website and creates a SVG of it
View html to svg.js
Element.prototype.getDirectDesc = function () {
const descendants = Array.from(this.querySelectorAll("*"));
const directDescendants = descendants.filter(
(ele) =>
ele.parentElement === this &&
!["script", "iframe"].includes(ele.nodeName.toLowerCase())
);
return directDescendants;
};
@netsi1964
netsi1964 / doneTasks.js
Last active Feb 10, 2021
Get done tasks from Jira
View doneTasks.js
var columns = Array.from(document.querySelectorAll('.ghx-column-title')).map(
(title) => `${title.textContent}\n${'*'.repeat(title.textContent.length + 5)}`
);
document.querySelectorAll('.ghx-columns').forEach((col) => {
const cols = col.querySelectorAll('.ghx-column');
cols.forEach((col, i) => {
col.querySelectorAll('.ghx-issue-fields').forEach((ele) => {
const mev = ele.querySelector('.ghx-key').textContent;
const txt = ele.querySelector('.ghx-inner').textContent;
columns[i] += `\n${mev}: ${txt}`;
@netsi1964
netsi1964 / mousse.ts
Last active Jan 18, 2021
A deno script listning on port 8080 allowing to hit it with rest path: /:route/:id/:action
View mousse.ts
// deno run --allow-net mousse.ts
import { Mousse } from 'https://github.com/Tyrenn/mousse/raw/main/mod.ts';
let mousse = new Mousse({ port: 8080 });
async function handleRequest(c: any) {
const _body = {
...c.params,
};
const body = JSON.stringify(_body);
@netsi1964
netsi1964 / caniuse.ts
Last active Dec 12, 2020
Deno script which creates a HTML table (or text) showing browser feature implementations state
View caniuse.ts
/*
Get Browser feature implementation state
- fetches data from caniuse.com
- checks each browser for support of known features
- generates a HTML table as seen here: https://codepen.io/netsi1964/pen/PoGWoWP
RUN: deno run --allow-net caniuse.ts
Created by Sten Hougaard @netsi1964 12/12-2020
*/
interface SupportStatus {
supported: number;
View canIUse.json
This file has been truncated, but you can view the full file.
{
"eras": {
"e-83": "83 versions back",
"e-82": "82 versions back",
"e-81": "81 versions back",
"e-80": "80 versions back",
"e-79": "79 versions back",
"e-78": "78 versions back",
"e-77": "77 versions back",