Skip to content

Instantly share code, notes, and snippets.

View netsi1964's full-sized avatar

Sten Hougaard netsi1964

View GitHub Profile
@netsi1964
netsi1964 / make_DR.DK_headlines_funny.js
Last active January 24, 2022 11:47
Reading (bad) news can be hard...
// 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 / splitStringToItems.xslt
Created May 9, 2012 21:05
XSLT split a string into items
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="xml" indent="no"/>
<xsl:variable name="groups" select="'265, 256'" />
<xsl:template match="root">
<xsl:variable name="items">
<xsl:call-template name="splitStringToItems">
@netsi1964
netsi1964 / umbracoHandySnippets.md
Created August 13, 2013 11:52
My Umbraco handy snippets

My Umbraco handy snippets

Content

  • Masterpage
  • [Website values](#website-values)
    
  •       [Output](#output)
    
  •   [Macroes in Umbraco](#macroes-in-umbraco)
    
  •       [Example: Create a parameter "footer"](#example-create-a-parameter-footer)
    
  •   [Razor](#razor)
    
  • Try-catch snippet
@netsi1964
netsi1964 / scriptable_are_you_at_work.js
Created September 29, 2021 20:37
A script for scriptable which will give a notification about if you are at a location (work) or not
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 February 21, 2021 10:55
Takes a website and creates a SVG of it
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 February 10, 2021 13:40
Get done tasks from Jira
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 January 18, 2021 15:49
A deno script listning on port 8080 allowing to hit it with rest path: /:route/:id/:action
// 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 December 12, 2020 10:11
Deno script which creates a HTML table (or text) showing browser feature implementations state
/*
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;
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",
"e-76": "76 versions back",
@netsi1964
netsi1964 / byCode.js
Last active December 3, 2020 18:16
Get phone country codes from iban.com
const byCode = {
"1": {
"country": "United States Virgin Islands",
"code": "1",
"intPrefix": "011",
"natPrefix": "1",
"natNumber": "(340)+7 digits",
"utsDst": "-4",
"note": " "
},