Skip to content

Instantly share code, notes, and snippets.

View sachaarbonel's full-sized avatar
👨‍💻
Uncovering bugs

Sacha Arbonel sachaarbonel

👨‍💻
Uncovering bugs
View GitHub Profile
import 'dart:typed_data';
import 'package:drift/drift.dart';
import 'package:google_generative_ai/google_generative_ai.dart';
import 'connection/connection.dart' as impl;
part 'database.g.dart';
@DriftDatabase(include: {'sql.drift'})
import '/features/architecture/logging.dart';
class CachedQuery<T> {
final Duration invalidation;
final Future<T> Function(String key) fn;
CachedQuery(
this.fn,
this.invalidation,
);
@rphlmr
rphlmr / protect-routes.ts
Last active August 31, 2024 22:06
Protected routes middleware with HonoJS with Remix-Hono
import { getSession, session } from "remix-hono/session";
import { pathToRegexp } from "path-to-regexp";
/**
* Add protected routes middleware
*
*/
app.use(
protect({
@rain-1
rain-1 / Prompt Injection and AutoGPT.md
Last active September 11, 2023 11:12
Prompt Injection and AutoGPT

Does prompt injection matter to AutoGPT?

Executive summary: If you use AutoGPT, you need to be aware of prompt injection. This is a serious problem that can cause your AutoGPT agent to perform unexpected and unwanted tasks. Unfortunately, there isn't a perfect solution to this problem available yet.

Prompt injection can derail agents

If you set up an AutoGPT agent to perform task A, a prompt injection could 'derail' it into performing task B instead. Task B could be anything. Even something unwanted like deleting your personal files or sending all your bitcoins to some crooks wallet.

Docker helps limit the file system access that agents have. Measures like this are extremely useful. It's important to note that the agent can still be derailed.

@init27
init27 / app.py
Last active February 13, 2024 14:39
ArXiv Chat: Chat with the latest Arxiv papers
# Credit 🙏: I just used the example from langchain docs and it works quite well: https://python.langchain.com/en/latest/use_cases/question_answering.html
# Note 2: The Arxiv -> PDF logic is a bit messy, I'm sure it can be done better
# Note 3: Please install the following:
# To run:
# Save this in a `app.py`
# pip install arxiv PyPDF2 langchain chromadb
# The chat feature was shipped in H2O nightly this week, we will need to install from nightly link:
@perrysmotors
perrysmotors / ScrollEffects.tsx
Last active June 20, 2024 21:07
Overrides to create scroll interactions on Framer sites
import type { ComponentType } from "react"
import { useState, useEffect } from "react"
import type { MotionValue, Transition } from "framer-motion"
import {
useScroll,
useVelocity,
useTransform,
useMotionValue,
animate,
@K024
K024 / trim.py
Last active April 29, 2023 09:29
# trim.py
# trim the vocabulary of mt5 model in huggingface.co
# MIT License
# Copyright (c) 2022 K024
# %%
import torch
from tqdm.auto import tqdm
# %%
@justaguywhocodes
justaguywhocodes / leetcode.json
Created September 26, 2021 04:37
LeetCode questions converted to JSON
This file has been truncated, but you can view the full file.
[{
"id": "1",
"title": "Two Sum",
"question": "Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.\nYou may assume that each input would have exactly one solution, and you may not use the same element twice.\nYou can return the answer in any order.",
"examples": [
"Input: nums = [2,7,11,15], target = 9",
"Output: [0,1]",
"Output: Because nums[0] + nums[1] == 9, we return [0, 1].",
"Input: nums = [3,2,4], target = 6",
"Output: [1,2]",
float[][] result;
float t, c;
float ease(float p) {
p = c01(p);
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
p = c01(p);
@gbrls
gbrls / main.rs
Created December 25, 2020 21:31
Parser combinator examples in Rust using Nom
/// This is a small program to show how to use nom v6 crate to create parsers
/// and how to implement precedence with a parser combinator library.
/// Useful resources:
/// Nom's reference: https://docs.rs/nom/6.0.1/nom/index.html
/// 'Parsing with Nom' section of Gentle rust intro: https://stevedonovan.github.io/rust-gentle-intro/nom-intro.html (it uses an outdated version of nom)
/// Nom's github documentation: https://github.com/Geal/nom/blob/master/doc/making_a_new_parser_from_scratch.md
/// combinators explanations: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
use nom::{character::complete::digit1, IResult};
use std::str::FromStr;