Skip to content

Instantly share code, notes, and snippets.

View Danny-Engelman's full-sized avatar
💭
working on HexedLand

Danny Engelman Danny-Engelman

💭
working on HexedLand
View GitHub Profile
@Danny-Engelman
Danny-Engelman / SharePoint DIVmanager.js
Last active February 18, 2018 09:34
SharePoint DIV manager manages show/hide/style for [selector] DIVs
console.clear();
function DIVManager( selector , numbers){
var manager=this;
function DIV(element){
var div=this;
div.state=element.style.display!=='none';
div.style=function(key,value){
console.log(key,value);
element.style[key]=value;
@Danny-Engelman
Danny-Engelman / json2html.js
Last active February 14, 2019 10:44
Read JSON endpoint, create TABLE HTML
//ES5 version
fetch(uri)
.then(response => response.json())
.then(json => {
// Create HTML TABLE, for a challenge refactor this to one .reduceRight call
let headers = [], maxid = 0;// maximum Primary Key value read in this DB response
// process rows first because the headers info is needed in the THEAD
let TBODY = json.map(function (row) {
headers = Object.keys(row);
let TRdata = '';// stuff all data values as data-attributes on the TR tag
@Danny-Engelman
Danny-Engelman / nearbyGateways.js
Created May 9, 2018 13:48
TTN Gateways near my lat/lon location (and distance)
console.clear();
nearbyGateways(52.4, 4.87); // latitude, longitude
function nearbyGateways(lat, lon, meters = 15000) {
fetch(`https://www.thethingsnetwork.org/gateway-data/location?latitude=${lat}&longitude=${lon}&distance=${meters}`)
.then(response => response.json())
.then(json => {
let $_Distance = (lat1, lon1, lat2, lon2, accuracy = 1e3) => { // Haversine distance
let M = Math, C = M.cos, P = M.PI / 180,
@Danny-Engelman
Danny-Engelman / ClearChromeSearchEngines.js
Created March 6, 2019 11:40
Clear Chrome Custom Search Engines
// Delete all search-engines not starting with _ or named Google
// Open Settings -> Search Engines
// Open F12 Developer tools
// Run scipt as snippet
settings.SearchEnginesBrowserProxyImpl.prototype.getSearchEnginesList()
.then(function(val) {
val.others.sort(function(a, b) { return b.modelIndex - a.modelIndex; });// sort just for clarity
val.others.forEach(function(engine) {
@Danny-Engelman
Danny-Engelman / TransalpClubForumUnread.css
Last active March 15, 2019 11:33
Style Kunena Forum Unread list
/*
CSS changes for: https://transalpclub.nl/forum/unread
apply with Stylus Browser extension (or anyway you want to add CSS)
*/
body {
/* minder witruimte rondom tekstregels */
line-height: 1em;
@Danny-Engelman
Danny-Engelman / SharePoint_Cisar_OpenMonocaEditor.js
Created March 15, 2019 13:51
Open SharePoint document with Monaco editor (CiSaR script)
//add script with Cisar Chrome Browser extension!
SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function () {
function init() {
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
Templates: {
Fields: {
"MonacoEdit": { //add internal fieldname in Document Library!!
View: function (ctx, b, item) {
var fileref = item.FileRef;
var filepath = fileref.split('/');
@Danny-Engelman
Danny-Engelman / 8x8 Display
Last active October 24, 2019 09:54
Character on 8x8 (LED) Display
display(letter) {
let char2bitarray = (char) => {
const font8x8 = [
[0, 0, 0, 0, 0, 0, 0, 0], // U+0020 (space)
[24, 60, 60, 24, 24, 0, 24, 0], // U+0021 (!)
[54, 54, 0, 0, 0, 0, 0, 0], // U+0022 (")
[54, 54, 127, 54, 127, 54, 54, 0], // U+0023 (#)
[12, 62, 3, 30, 48, 31, 12, 0], // U+0024 ($)
[0, 99, 51, 24, 12, 102, 99, 0], // U+0025 (%)
[28, 54, 28, 110, 59, 51, 110, 0], // U+0026 (&)
/*
Open F12 Network Tab
Press Ctrl-Shift-I to open SECOND console window
Execute this script (runs in first Console window)
*/
const rsColor='lightgreen';
const rsStaticColor=rsColor;
const remoteColor='pink';
let remoteTime=0;
let localTime=0;
<script>navigator.serviceWorker.register('sw.js').then(()=>{location.href="$/index.js"})</script>
@Danny-Engelman
Danny-Engelman / findeElements with TreeWalker API
Created March 23, 2021 11:26
findElements with TreeWalker API
// The native TreeWalker API has been around for ages, IE9 was the last Browser to implement it ... in 2011
function log() {
console.log(`%c TreeWalker `, `background:purple;color:yellow`, ...arguments);
}
// find element takes a function definition, the output must be Truthy or Falsy
function findElements(
acceptFunc = (x) => customElements.get(x.localName) || false
) {
log("start");
console.time("TreeWalker");