Skip to content

Instantly share code, notes, and snippets.

@s3rvac
s3rvac / double-dispatch.cpp
Last active May 6, 2024 08:46
An example of using double dispatch in C++ to implement expression evaluation without type casts.
// $ g++ -std=c++14 -pedantic -Wall -Wextra double-dispatch.cpp -o double-dispatch
// $ ./double-dispatch
//
// Also works under C++11.
#include <iostream>
#include <memory>
#if __cplusplus == 201103L
namespace std {
@deveworld
deveworld / encode.py
Last active May 6, 2024 08:45
Diff-SVC Audio Data Preprocess Python Script
import os
import glob
import parmap
import multiprocessing
import subprocess as sp
FFMPEG_BIN = "ffmpeg"
def encode(input, output_path):
@jbd
jbd / 01-form-single.html
Created November 22, 2023 10:25 — forked from ve3/01-form-single.html
Slice large file into chunks and upload using JavaScript.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>XHR upload large file with slice</title>
<style>
#debug {
border: 3px dashed #ccc;
margin: 10px 0;
padding: 10px;
@fntlnz
fntlnz / self-signed-certificate-with-custom-ca.md
Last active May 6, 2024 08:45
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@webarchitect609
webarchitect609 / php8_docker.sh
Last active May 6, 2024 08:41
Quick docker PHP 8 setup for composer and unit testing
# Terminal Tab #1 (with privileges inside container)
# =============
cd "/the/dir/you/want/to/work/with/php8"
docker run --name php8 \
-it \
-v $PWD:/var/php:rw \
php:8.0-cli-alpine3.12 \
ash
cd /tmp
@urwx
urwx / sys-btrfs.txt
Last active May 6, 2024 08:38
Arch Linux Encrypted LVM Luks Btrfs Guide (EFI)
Arch Linux Encrypted LVM Luks Btrfs Guide (EFI)
# Wipe disk with random data (optional)
badblocks -c 10240 -s -w -t random -v /dev/sda
# Partition
parted -a minimal /dev/sda
- mklabel gpt
- unit Mib
- mkpart ESP fat32 0% 512
- set 1 boot on
- mkpart primary ext4 512 100%

Transparent Restaurant Backend

In this task, you're going to implement a REST API for a interacting with a menu of a restaurant. The menu is given to you as a JSON file which you will parse and perform operations on. The required features will be listed below.

Description

In this restaurant, honesty is extremely promoted. So extreme, that the restaurant declares that differing quality of ingredients are used in their meals. Like that's not enough, it also allows the customers to choose the ingredients of each meal in different qualities. Each ingredient has the following quality levels:

  • low: the cheapest
  • medium: moderate
@marlosirapuan
marlosirapuan / app-context.ts
Created August 31, 2023 18:09
Context App Provider with zustand in Typescript
import { createContext, useContext } from 'react'
import { createStore, StoreApi } from 'zustand'
import { immer } from 'zustand/middleware/immer'
import { useStoreWithEqualityFn } from 'zustand/traditional'
type State = {
total: number
increase: () => void
decrease: () => void
@bashbunni
bashbunni / .zshrc
Created January 4, 2023 16:28
CLI Pomodoro for Linux
# study stream aliases
# Requires https://github.com/caarlos0/timer to be installed. spd-say should ship with your distro
declare -A pomo_options
pomo_options["work"]="45"
pomo_options["break"]="10"
pomodoro () {
if [ -n "$1" -a -n "${pomo_options["$1"]}" ]; then
val=$1