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
iwill / semverCompare.js
Last active October 2, 2024 09:14
JavaScript - Comparison of Semantic Versioning
/**
* Semantic Versioning Comparing
* #see https://semver.org/
* #see https://stackoverflow.com/a/65687141/456536
* #see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/Collator#options
*/
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
pngwn / ssg.md
Last active May 30, 2024 13:33
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
tbutts / tmux-migrate-options.py
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
#
# USAGE:
# 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-migrate-options.py ~/.tmux.conf.orig > ~/.tmux.conf
#
@jakecobley
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
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
alexamies / README.md
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
usrme / ONELINERS.md
Last active April 19, 2023 06:37
Various oneliners from various languages/tools

Oneliners

Bash

  • Basic for loop to iterate over lines in a file:
for pkg in $(cat pkgs.txt); do sudo apt purge "$pkg" -y; done
@JaySunSyn
JaySunSyn / index.js
Created January 21, 2018 12:48
Firebase functions Dynamic OG-Tags
exports.host = 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 = vNode.context.name
// 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}' ` }