Skip to content

Instantly share code, notes, and snippets.

View dominikwilkowski's full-sized avatar
🤖
Working

Dominik Wilkowski dominikwilkowski

🤖
Working
View GitHub Profile
@rohan-deshpande
rohan-deshpande / CONDITIONALLY_ASYNC_LOAD_BY_VIEWPORT_SIZE.md
Last active June 23, 2020 23:34
What is the best way to conditionally async load components based on initial viewport size?

Question:

Thinking about this in a nextjs context, let's say we have two components Video and AnimatedGif. For larger screens, we want to load the video, but for smaller screens, and perhaps slower devices, we want to show the gif. We also want to async load these, because they shouldn't block the rest of the page. They are media items so they don't need to be SSR'd, and also it would be good if this could be done with Suspense in mind. Any ideas?

Answer:

Create a custom hook, something like useDeviceAndViewport() that returns the relevant info. You need to know the network status, the viewport dimensions and whether the element is within the viewport.

@jackdomleo7
jackdomleo7 / Useful_global_CSS.css
Last active March 30, 2025 14:05
A set of useful global CSS defaults to add to your site alongside a reset stylesheet (with explanations)
/*! NOTE: These are just recommended default global styles, edit as required */
@import ('Import reset stylesheet here, (I recommend modern-normalize) or even better, import the reset stylesheet in the HTML as the first imported stylesheet');
::selection { /* Optional */
/* It can be really hard to read highlighted text with a text-shadow, it should be removed when selected */
text-shadow: none;
/* NOTE: Using this means the color and background-color are set to transparent for selected text... */
/* So you can customise your styles below */
@fnky
fnky / ANSI.md
Last active May 14, 2025 09:17
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
var https = require('https');
// CONFIGURATION #######################################################################################################
var token = '';
var delay = 300; // delay between delete operations in millisecond
// GLOBALS #############################################################################################################
var baseApiUrl = 'https://slack.com/api/';
@jasonlong
jasonlong / example-sparkline.md
Last active May 14, 2018 02:36
Example for generating SVG sparklines – Released under CC0-1.0 (https://creativecommons.org/publicdomain/zero/1.0/)

example-sparkline

@tunguskha
tunguskha / Gradient shadow in pure CSS.md
Last active October 12, 2024 17:02
Gradient shadow in pure CSS

Gradient shadow in pure CSS

alt text

HTML
<button>Let's Go !</button>
@dominikwilkowski
dominikwilkowski / Readme.md
Last active October 9, 2024 15:00
How to install a man page into a node.js app

How to install a man page into a node.js app

Cuttlebelle man page

Installing a man page is not easy as there are little infos out there about it.

After a lot of trial and error, google searches and alpha publishing my app I finally have a collection of things I need to do to get it working:

@kitze
kitze / conditionalwrap.js
Created October 25, 2017 16:54
one-line React component for conditionally wrapping children
import React from 'react';
const ConditionalWrap = ({condition, wrap, children}) => condition ? wrap(children) : children;
const Header = ({shouldLinkToHome}) => (
<div>
<ConditionalWrap
condition={shouldLinkToHome}
wrap={children => <a href="/">{children}</a>}
>
@m-richo
m-richo / cf-app-audit.sh
Last active December 12, 2017 22:15
query Cloud Foundry environment for all running applications and dump them into a CSV file
#!/bin/bash
set -eu
set -o pipefail
API_ENDPOINT=$(cf api |grep "endpoint" |awk -F "https://" '{print $2}')
rm -f $API_ENDPOINT.csv
echo "Running audit for $API_ENDPOINT"
echo "Output is in $API_ENDPOINT.csv"
@slightlyoff
slightlyoff / push_payloads_userland.md
Last active September 30, 2022 23:11
Delivering H/2 Push Payloads To Userland

Background

One of the biggest missed opportunities thus far with HTTP/2 ("H/2") is that we are not yet able to sunset WebSockets in favor of H/2. Web Sockets and H/2 both support multiplexing messages bi-directionally and can send both textual and binary data.

Server Sent Events ("SSE"), by contrast, are not bi-directional (they're a "server-push-only" channel) and binary data cannot be sent easily. They are, however, very simple to implement. Adding to the menagerie of options, RTCPeerConnection can also be used to signal data to applications in a low-latency (but potentially lossy) way.

Because H/2 [does not support the handshake (upgrade) that WebSockets use to negotiate a connection](https://daniel.haxx.se/blog/2016/06/15/no-websockets-