Skip to content

Instantly share code, notes, and snippets.

View DurandA's full-sized avatar

Arnaud Durand DurandA

View GitHub Profile
@DurandA
DurandA / main.py
Created December 18, 2023 22:45
Langchain Ollama demo
from langchain.callbacks.manager import CallbackManager
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
from langchain.llms import Ollama
from langchain.output_parsers import PydanticOutputParser
from langchain.prompts import PromptTemplate
from pydantic import BaseModel, Field, field_validator
llm = Ollama(
@DurandA
DurandA / bars.svg
Created November 21, 2023 19:51
HTMX demo with dynamic filters and infinite scroll
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@DurandA
DurandA / main.py
Created November 9, 2023 21:22
Create Pydantic obj from SQLAlchemy model with AsyncAttrs
from typing import Any, List, Type, TypeVar
from pydantic import BaseModel
from sqlalchemy import Column, ForeignKey, Integer, String, create_engine
from sqlalchemy.ext.asyncio import (AsyncAttrs, AsyncEngine, AsyncSession,
create_async_engine)
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.future import select
from sqlalchemy.inspection import inspect
from sqlalchemy.orm import RelationshipProperty, relationship, sessionmaker
@DurandA
DurandA / README.md
Last active September 12, 2023 07:47
Nettoyage WordPress

open_basedir

Ajouter la directive open_basedir dans .user.ini:

Attention, remplacer ac454cad5c2a45a3f7455b344da9511c et mydomain.ch en fonction de l'hébergement.

open_basedir "/home/clients/ac454cad5c2a45a3f7455b344da9511c/sites/mydomain.ch/"

Cette directive va empêcher PHP d'écrire en dehors du dossier spécifié. À noter que certaines attaques sont possibles pour outrepasser cette directive, comme ouvrir un shell ou un processus (bloqué par défaut sur Infomaniak) ou via des failles PHP.

@DurandA
DurandA / gitprint.js
Created September 6, 2023 07:29 — forked from beevelop/gitprint.js
Print GitHub markdown files
document.querySelector('#readme').setAttribute('style', 'position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 100; background-color: white')
document.querySelector('body').appendChild(document.querySelector('#readme'))
window.print()
@DurandA
DurandA / import-dump.md
Created November 23, 2021 08:56
Import dump using MariaDB
  1. Create database and user
create database my_database;
create user 'myUser'@'localhost' identified by 'myPassword';
GRANT ALL PRIVILEGES ON my_database.* TO 'myUser'@'localhost';
  1. Import dump
mysql -u myUser -p my_database < dump.sql
@DurandA
DurandA / dflipflop.py
Created August 30, 2021 21:42
D-Flipflop VCD generator
import asyncio
import sys
import time
from aiostream import stream
from vcd import VCDWriter
start = time.monotonic()
async def oscillator(writer, variable, freq):
@DurandA
DurandA / enable_quad.c
Created May 20, 2020 13:06
Enable Quad I/O mode on Macronix MX25xxxx35 series serial flash
#include "string.h"
#include "driver/spi_master.h"
#define PIN_NUM_MISO 19
#define PIN_NUM_MOSI 23
#define PIN_NUM_CLK 18
#define PIN_NUM_CS 12
spi_device_handle_t spi;
@DurandA
DurandA / openapi.yaml
Last active April 10, 2020 14:57
Todo-Tag API Documentation
openapi: 3.0.1
info:
title: Todo-Tag Backend
version: "1.0"
servers:
- url: http://localhost:8080
- url: http://todo.thing.zone
tags:
- name: todos
- name: tags
@DurandA
DurandA / autotag.py
Created December 8, 2019 00:28
Tag git commits according to the author
#!/usr/bin/env python3
import subprocess
tags = {
'[email protected]': 'tagname'
}
fetch = subprocess.run(['git', 'fetch', 'origin', 'master'], stderr=subprocess.DEVNULL)
assert(fetch.returncode == 0)