Skip to content

Instantly share code, notes, and snippets.

@ruvnet
ruvnet / *specification.md
Last active March 17, 2025 09:17
TikTok-like recommender Algorithm

Detailed Technical Algorithm for a TikTok-like Recommendation System


1. Introduction

The objective is to develop a recommendation system that maximizes user engagement by analyzing a multitude of user interaction signals to present the most appealing content. The system optimizes for two key metrics:

  • User Retention: Encouraging users to return to the platform.
  • Time Spent: Increasing the duration users spend on the platform per session.
@rphlmr
rphlmr / clear-db.ts
Last active March 12, 2025 07:41
Drizzle snippets
// Credits to Louistiti from Drizzle Discord: https://discord.com/channels/1043890932593987624/1130802621750448160/1143083373535973406
import { sql } from "drizzle-orm";
const clearDb = async (): Promise<void> => {
const query = sql<string>`SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'public'
AND table_type = 'BASE TABLE';
`;
@barbietunnie
barbietunnie / custom-fonts-taliwindcss-nextjs.md
Last active February 25, 2025 06:51
How to Use Custom Fonts in TailwindCSS + NextJS

How to Use Custom Fonts in TailwindCSS + NextJS

Assuming your have already set up your NextJS + Tailwind project,

1. Select your desired custom Google font

2. Scroll to the bottom and select all the styles you are interested in

Select all your desired styles

@mihaisavezi
mihaisavezi / draft-vs-final.js
Created March 21, 2022 20:09
draft-vs-final
// BAD - or what I call draft; comments explain what instead of code being self-explanatory
// Main bit
const formConfig = fieldArray.reduce((fields, field) => {
if (!Array.isArray(fields)) {
field = [field];
}
// Currently last field in section
const last = fields.slice(-1)[0],
lastValue = this.values[last.id];
@markmichon
markmichon / CircuitBreaker.js
Last active July 23, 2021 21:13
Basic CircuitBreaker Node
class CircuitBreaker {
constructor(request) {
this.request = request
this.state = "CLOSED"
this.failureThreshold = 3
this.failureCount = 0
this.successThreshold = 2
this.successCount = 0
this.timeout = 6000
this.nextAttempt = Date.now()
@zarv1k
zarv1k / abstract-unique-validator.ts
Last active January 30, 2025 14:26
Unique Validator Example for NestJS
import { ValidationArguments, ValidatorConstraintInterface } from 'class-validator';
import { Connection, EntitySchema, FindConditions, ObjectType } from 'typeorm';
interface UniqueValidationArguments<E> extends ValidationArguments {
constraints: [
ObjectType<E> | EntitySchema<E> | string,
((validationArguments: ValidationArguments) => FindConditions<E>) | keyof E,
];
}
@stefanocoding
stefanocoding / macos_on_ubuntu.md
Last active August 17, 2024 21:04
Install macOS in a VirtualBox machine on Ubuntu

Important: I'm writing this when the last version of macOS (and the one I have installed) is Mojave. There is already a script which installs Mojave in a virtual machine here https://github.com/img2tab/okiomov. But if you are curios how to do everything manually to install High Sierra, then this guide may be useful.

After reading a few articles I ended up with these steps:

  1. On macOS, download the High Sierra installer (even if you have Mojave installed): https://itunes.apple.com/us/app/macos-high-sierra/id1246284741?ls=1&mt=12
  2. If the High Sierra Installer starts, quit it.
  3. Open "Disk Utility".
  4. Click on "File" > "New Image" > "Blank image...". Or just press cmd+N.
@joeyklee
joeyklee / mysql-setup-mac-with-sequel-pro.md
Last active November 17, 2023 05:27
Setting up mysql on mac with sequel pro and homebrew

Setup instructions

Setting up mysql on mac with sequel pro and homebrew

MacOS high sierra 10.13.6
Homebrew version 1.7.6

Assuming you've installed homebrew...

@ernestkamara
ernestkamara / AdbCommands
Created June 26, 2018 08:42 — forked from Pulimet/AdbCommands
Adb useful commands list
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
== Shell
@greyscaled
greyscaled / README.md
Last active February 21, 2025 08:33
Sequelize + Express + Migrations + Seed Starter