Skip to content

Instantly share code, notes, and snippets.

View martinschierle's full-sized avatar

Martin Schierle martinschierle

View GitHub Profile
@martinschierle
martinschierle / NewsViewer.py
Last active October 23, 2024 10:54
EInkNewsViewer
import network
import urequests as requests
import machine
import os
import random
import time
import inky_frame
from picographics import PicoGraphics, DISPLAY_INKY_FRAME_7 as DISPLAY
graphics = PicoGraphics(DISPLAY)
import ntptime # To get the current date and time from an NTP server
#include <SPI.h>
#include <LoRa.h>
#include <Wire.h>
#include <BME280I2C.h>
#include "SSD1306.h"
#include <TinyGPS++.h>
#include <HardwareSerial.h>
#define GPS_TX 34
#include <SPI.h>
#include <LoRa.h>
#include <Wire.h>
#include "SSD1306.h"
#include "SPIFFS.h"
#define SCK 5 // GPIO5 -- SX1278's SCK
#define MISO 19 // GPIO19 -- SX1278's MISO
#define MOSI 27 // GPIO27 -- SX1278's MOSI
#define SS 18 // GPIO18 -- SX1278's CS
#include <SPI.h>
#include <LoRa.h>
#include <Wire.h>
#include <BME280I2C.h>
#include "SSD1306.h"
#include <TinyGPS++.h>
#include <HardwareSerial.h>
#define GPS_TX 34
#include "SPIFFS.h"
void setup() {
Serial.begin(115200);
if(!SPIFFS.begin(true)){
Serial.println("An Error has occurred while mounting SPIFFS");
return;
}
let po = new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
console.log(entry);
}
});
po.observe({type: 'layout-shift', buffered: true});
let po2 = new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
@martinschierle
martinschierle / paywallDetector.js
Last active December 18, 2020 12:47
Serverside paywall vs clientside paywall js snippet
function checkPaywall() {
let structured = JSON.parse(document.querySelector("script[type*='ld+json']").innerText);
let hasPart = null;
if(structured.hasPart) {
hasPart = structured.hasPart;
}
else if(structured.length) {
for(var i = 0; i < structured.length; i++) {
if(structured[i].hasPart) {
hasPart = structured[i].hasPart;
const puppeteer = require('puppeteer');
const { createCanvas, loadImage } = require('canvas')
var fs = require('fs');
const fsExtra = require('fs-extra')
const mergeImg = require('merge-img');
const mustache = require('mustache')
let MAX_URLS = 50;
let TEMPLATE = fs.readFileSync('template.html', 'utf8');
@martinschierle
martinschierle / cls_source_crawler.js
Created August 20, 2020 07:48
Crawler to crawl for layout shift sources
const puppeteer = require('puppeteer');
const { createCanvas, loadImage } = require('canvas')
const mustache = require('mustache')
var fs = require('fs');
const fsExtra = require('fs-extra')
let MAX_URLS = 50;
let TEMPLATE = fs.readFileSync('template.html', 'utf8');
@martinschierle
martinschierle / layout_shifts_in_wpt
Created August 5, 2020 13:03
Use this snippet in "inject script" in advanced tab of webpagetest. When you do later customize waterfall and show custom marks, you will see layout jumps in wpt waterfall.
let po = new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
//console.log(entry);
let val = entry.value;
window.performance.mark('layout_shift_'+val);
}
});
po.observe({type: 'layout-shift', buffered: true});