Skip to content

Instantly share code, notes, and snippets.

@MaskRay
MaskRay / johnson.cc
Last active December 29, 2024 02:12
Johnson's algorithm - Finding All the Elementary Circuits of a Directed Graph
#include <algorithm>
#include <cstdio>
#include <type_traits>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (remove_cv<remove_reference<decltype(b)>::type>::type i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
@chenhunghan
chenhunghan / llama_cpp_dspy_evaluate.py
Created April 1, 2024 13:15
DSPy llm evaluation with metric using llama.cpp
# A gist for using the `llama.cpp` model with the `dspy` library.
#
# DSPy features used in this gist
# - `dspy.Predict`
# - `dspy.Signature`
# - `dspy.context`
# - `dspy.evaluate.Evaluate`
#
# The script first prompts the model to answer a example question and assess the correctness and engagingness of the answer using a evaluator.
#
@Ellivers
Ellivers / main.md
Last active December 29, 2024 02:08
Practices and Tricks

Good Data Pack Practices and Common Tricks

Structuring and Consistency

An organized structure to your data pack's folders and file names always helps you understand your code better and leads to less bugs. Place files that have something in common in the same folder, and name them based on what their purpose is.

Consistency in naming stuff like tags, files, and scores can help keep you sane. Always have a clear structure in place, such as prefixing tag and objective names with your namespace (namespace.name) and giving tags different categories (namespace.entity.name, namespace.block.name).

If you are unsure of how a good structure could look, you could take a look at some vanilla assets, such as the lang file or the built-in data pack, as well as get ideas from looking at data packs that other people have made.

@jan-bar
jan-bar / index-2fa.html
Created November 22, 2024 05:34
trilium two-factor authentication
<div style="text-align: center">
<p id="secs2fa"></p>
<p id="GetCode"><button>GetCode</button></p>
<div id="show2fa"></div>
</div>
@MaxXor
MaxXor / btrfs-guide.md
Last active December 29, 2024 02:06
Btrfs guide to set up an LUKS-encrypted btrfs raid volume with included maintenance & recovery guide

Encrypted Btrfs storage setup and maintenance guide

Initial setup with LUKS/dm-crypt

This exemplary initial setup uses two devices /dev/sdb and /dev/sdc but can be applied to any amount of devices by following the steps with additional devices.

Create keyfile:

dd bs=64 count=1 if=/dev/urandom of=/etc/cryptkey iflag=fullblock
chmod 600 /etc/cryptkey
@Grayda
Grayda / WIN11-INSTALL.txt
Last active December 29, 2024 02:04
Autopilot / Intune onboarding BadKB scripts
REM This script automates the Windows 11 installation from a USB stick.
REM You'll probably need to adjust the delays to match your hardware,
REM because each machine takes a different amount of time to load various screens
DEFAULTDELAY 300
REM Move to the locale selector and select English (Australia), then press Next and then Install Now
TAB
STRING English (Australia)
ALT N
@extratone
extratone / apps.md
Last active December 29, 2024 02:00
APPS
#version 300 es
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
out vec4 fragColor;
uniform vec2 resolution;
uniform vec3 orientation;
@jer-k
jer-k / _1-README.md
Last active December 29, 2024 01:54
Setting up Zero with Ruby on Rails (session based auth) and Next.js

Reading through the Zero docs on authentication, I saw that JWT authentication was all that was supported (for now). I'm building a project using Ruby on Rails as an API and Next.js for the UI. While JWT auth is possible with Rails, most auth implementations are session based, included the built in auth solution to the latest Rails 8 release. Thus I wanted to figure out how to best set up Zero while still using the built in session based auth.

In this reply @aa, outlined how the Zero constructor can take a function for the auth param https://bsky.app/profile/aaronboodman.com/post/3ldyz5bet3s2s

This all sounds right. The auth param to Zero's constructor can be a function. When the token expires, Zero invokes the function to get a new token. It's async so you can call an endpoint or whatever.

and later

To clarify further:

  • keep the refresh token in an http-only cookie
@yordanoweb
yordanoweb / fix-dirty-ntfs.md
Created January 17, 2024 16:11
Fix dirty NTFS disk from Linux

Fix dirty NTFS disk from Linux

The problem

Sometimes when try to mount an NTFS disk in Linux, you get at journalctl the error:

ene 17 10:52:55 hp3nvyl17 kernel: ntfs3: sda1: It is recommened to use chkdsk.
ene 17 10:52:55 hp3nvyl17 kernel: ntfs3: sda1: volume is dirty and "force" flag is not set!