Skip to content

Instantly share code, notes, and snippets.

View andreasvirkus's full-sized avatar
made you look

andreas andreasvirkus

made you look
View GitHub Profile
iwill / semverCompare.js
Last active January 19, 2024 12:42
JavaScript - Comparison of Semantic Versioning
* Semantic Versioning Comparing
* #see
* #see
* #see
function semverCompare(a, b) {
if (a.startsWith(b + "-")) return -1
if (b.startsWith(a + "-")) return 1
return a.localeCompare(b, undefined, { numeric: true, sensitivity: "case", caseFirst: "upper" })
pngwn /
Last active December 26, 2023 07:26
A Simple Svelte SSG.

The Simplest Svelte Static Site Generator

Assuming you don't want to statically export a Sapper app, most of the parts to build a simple SSG for Svelte already exist. The only thing that is missing is the tooling ('only').

However, you don't need a lot to get things going: just a couple of rollup builds and a config file will get you most of the way there. Just some glue.

What follows is a bunch of rambling, half thought out thoughts on how I would probably go about this. Most of the stuff discussed here is stuff I've actually done or half done or am in the process of doing with varying degrees of success. It is something I'll be spending more time on in the future. There are other things I have done, want to do, or think would be a good idea that are not listed here as they don't fall into the scope of a simple SSG.

*Dislaimer: This is how I would build an SSG, this isn't the only way, but I like this approach as there are a bunch of compile-time optimisations you can per

function addComments(arg, name) {
// 当参数前的注释不存在的情况, 加入 webpackChunkName 注释
if (!arg.leadingComments) {
arg.leadingComments = [
type: 'CommentBlock',
value: ` webpackChunkName: '${name}' `,
tbutts /
Last active February 29, 2024 08:11
For tmux configs: Merge deprecated/removed -fg, -bg, and -attr options into the -style option
#!/usr/bin/env python
# vim: set fileencoding=utf-8
# Back up your tmux old config, run the script and redirect stdout to your conf
# file. Example:
# $ cp ~/.tmux.conf ~/.tmux.conf.orig
# $ python ./ ~/.tmux.conf.orig > ~/.tmux.conf
jakecobley / .browserslistrc
Last active April 29, 2020 16:13
Browserslist configuration explicitly targeting modern browsers.
last 2 ChromeAndroid versions
last 2 Chrome versions
last 2 iOS versions
last 2 Safari versions
last 2 Samsung versions
last 2 FirefoxAndroid versions
last 2 Firefox versions
Akryum / vue.config.js
Created September 27, 2018 10:18
Per-page split chunks
module.exports = {
pages: {
pageA: 'src/pageA.js',
pageB: 'src/pageB.js',
pageC: 'src/pageC.js',
chainWebpack: config => {
const options = module.exports
const pages = options.pages
alexamies /
Last active February 2, 2021 10:35
Using NGINX with Brotli

Using NGINX with Brotli

This Gist demonstrates enabling Brotli in Nginx in App Engine Flex using a custom container.

Running in Docker locally

Use of basic Nginx image adapting the example nginx.conf adapted from Full Example Configuration

docker run --rm -itd --name test-nginx \
  -v $(pwd):/usr/share/nginx/html:ro \
usrme /
Last active April 19, 2023 06:37
Various oneliners from various languages/tools



  • Basic for loop to iterate over lines in a file:
for pkg in $(cat pkgs.txt); do sudo apt purge "$pkg" -y; done
JaySunSyn / index.js
Created January 21, 2018 12:48
Firebase functions Dynamic OG-Tags = functions.https.onRequest((req, res) => {
const userAgent = req.headers['user-agent'].toLowerCase();
let indexHTML = fs.readFileSync('./hosting/index.html').toString();
const path = req.path ? req.path.split('/') : req.path;
const ogPlaceholder = '<meta name="functions-insert-dynamic-og">';
const metaPlaceholder = '<meta name="functions-insert-dynamic-meta">';
const isBot = userAgent.includes('googlebot') ||
userAgent.includes('yahoou') ||
userAgent.includes('bingbot') ||
Vue.directive('longpress', {
bind: function (el, binding, vNode) {
// Make sure expression provided is a function
if (typeof binding.value !== 'function') {
// Fetch name of component
const compName =
// pass warning to console
let warn = `[longpress:] provided expression '${binding.expression}' is not a function, but has to be`
if (compName) { warn += `Found in component '${compName}' ` }