React | Svelte | |
---|---|---|
Since | 2011 (before ES6) | 2016 (after ES6) |
Type | Library (slower) | Compiler (faster) |
Reactivity | Hooks, runtime | Plain variables, compile-time |
Virtual DOM (2 DOMs) | Yes | No |
Performance | Mostly ok, DOM diffing, easy to screw up | Very fast by default |
Memory usage | High | Low |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Save this script to /bin in order to generate RAW photo thumbnails in Ubuntu | |
# Save raw.thumbnailer to /usr/share/thumbnailers | |
# Note: you cannot put the script to e.g. /home, as thumnailers are now run in a sandbox provided by bwrap | |
# Requires exiftool and imagemagick (note: use real binary name of convert instead of /etc/alternatives, because it's not accessible from bwrap) | |
INPUT=$1 | |
OUTPUT=$2 | |
SIZE=$3 | |
# use -PreviewImage to get a slower, but high quality thumbnail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If you want to use Mongoose with TypeScript, you are in trouble. | |
// Typegoose comes to the rescue, but it requires model classes to extend Typegoose class, | |
// which breaks using model classes as interfaces for casting in your code | |
// Here is the solution: don't extend Typegoose and use this function to create your models: | |
import {InstanceType, Typegoose} from 'typegoose' | |
import {Connection, Model} from 'mongoose' | |
function buildModel<T, U>(constructor: {new (): T} & U, db: Connection, collectionName: string): Model<InstanceType<T>> & U { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Named { | |
firstName: string; | |
lastName: string; | |
} | |
class Person implements Named { | |
firstName: string; | |
lastName: string; | |
constructor(firstName: string = '', lastName: string = '') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The trick here is to run syslogd, writing output to the stdout of PID1, which Docker daemon captures | |
# This may be a useful trick with other executables as well that can only write to syslog | |
version: '3' | |
services: | |
haproxy: | |
image: haproxy:1.9-alpine | |
entrypoint: '' | |
command: sh -c 'syslogd -O /proc/1/fd/1; /docker-entrypoint.sh haproxy -f /etc/haproxy/haproxy.cfg' |