Skip to content

Instantly share code, notes, and snippets.

@angryziber
angryziber / React-Svelte.md
Created May 14, 2024 14:49
My React vs Svelte comparison

React vs Svelte

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
@angryziber
angryziber / raw-thumbnailer.sh
Created December 11, 2019 21:28
GNOME raw photo thumbnailer (cr2, nef, etc)
#!/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
@angryziber
angryziber / buildModel.ts
Last active June 27, 2019 08:40
Typegoose without extending
// 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 {
@angryziber
angryziber / test.ts
Created June 14, 2019 14:12
Test JavaScript object access performance (in TypeScript)
interface Named {
firstName: string;
lastName: string;
}
class Person implements Named {
firstName: string;
lastName: string;
constructor(firstName: string = '', lastName: string = '') {
@angryziber
angryziber / docker-compose.yml
Last active February 8, 2019 19:05
HAProxy in Docker with logging to stdout (because it's hard to figure out)
# 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'