Skip to content

Instantly share code, notes, and snippets.

View marcus-at-localhost's full-sized avatar
💭
☕

Marcus marcus-at-localhost

💭
☕
View GitHub Profile
@marcus-at-localhost
marcus-at-localhost / detect.js
Created March 15, 2021 08:43
[Online Offline Detection] add a class to html element because the body element might get changed in #unpolyjs or #turbo #turbolinks #pwa
function handleConnectionChange(event){
if(event.type == "offline"){
console.log("You lost connection.");
}
if(event.type == "online"){
console.log("You are now back online.");
}
// add to <html>, because <body> might get changed if you use unpoly, turbolinks etc.
@marcus-at-localhost
marcus-at-localhost / heartbeat-with-greenlet-web-worker-helper.markdown
Created March 13, 2021 13:38
Heartbeat with Greenlet Web Worker Helper
@marcus-at-localhost
marcus-at-localhost / _mind-the-gap-css-grid-hide-a-column.markdown
Last active December 1, 2021 18:08
[Mind the Gap - CSS Grid Hide a Column] #css #grid #column

Mind the Gap - CSS Grid Hide a Column

Depending on how the CSS grid is set up, you can't just hide a column and reflow the rest of the grid. If the column has a fixed with, the space is preserved, if the column width is 0 after hiding the grid gap adds up. The only way to fix it is to reflect the changes in the grid template.

A Pen by Marcus Obst on CodePen.

License.

@marcus-at-localhost
marcus-at-localhost / app.js
Created March 9, 2021 07:26
[Tracking Navigation with Unpoly.js] record navigation events for matomo or other website analytics #unpolyjs
// https://makandracards.com/makandra/41488-using-google-analytics-with-unpoly
up.on('up:history:pushed', function(event) {
console.log(location.pathname);
});
@marcus-at-localhost
marcus-at-localhost / pure_html_css_modal.css
Last active March 13, 2021 13:36 — forked from calebporzio/pure_html_css_modal.css
[Pure HTML/CSS modal] #nojs
details summary {
cursor: pointer;
outline: none !important;
display: inline-block;
padding: 8px 12px;
padding-top: 10px;
border-radius: 4px;
overflow: hidden;
background: #F09825;
color: white;
<?php
ob_end_flush();
ob_implicit_flush();
for ($i = 0; $i < 10; $i++)
{
echo "$i\n";
sleep(1);
}
// https://pineco.de/using-turbolinks-with-vue/
document.addEventListener('turbolinks:load', () => {
new Vue({
el: '#app',
beforeMount() {
if (this.$el.parentNode) {
document.addEventListener('turbolinks:visit', () => this.$destroy(), { once: true });
@marcus-at-localhost
marcus-at-localhost / 0_turbo.js
Last active January 5, 2021 17:18
[HOTWIRE - Turbo - Lazy Loaded Frame Event] Yeah, there are no events that tell you that <turbo-frame> got loaded, but there are MutationObservers #turbo #turbolinks
document.addEventListener('turbo:load', () => {
// Select the node that will be observed for mutations
const targetNode = document.getElementById('bookmarks');
const callback = (mutationsList, observer) => {
for(const mutation of mutationsList) {
if (mutation.type === 'childList') {
<script type="text/javascript">
// [Matomo tracking code goes here]
// Send Matomo a new event when navigating to a new page using Turbolinks
// (see https://developer.matomo.org/guides/spa-tracking)
(function() {
var previousPageUrl = null;
addEventListener('turbolinks:load', function(event) {
if (previousPageUrl) {
_paq.push(['setReferrerUrl', previousPageUrl]);
@marcus-at-localhost
marcus-at-localhost / .htaccess
Last active November 18, 2020 13:07 — forked from orvigas/.htaccess
1&1 Hosting error 500 on Laravel 5.4 API
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteBase / # <= add this
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .