Skip to content

Instantly share code, notes, and snippets.

View cristipufu's full-sized avatar

Cristi Pufu cristipufu

View GitHub Profile
@cristipufu
cristipufu / generate_dependency_graph.py
Created May 1, 2025 10:45
Generate mermaid based on relative file imports
import ast
import os
import re
def extract_imports(tree: ast.Module):
"""
Extract all import statements from an AST tree.
Args:
@cristipufu
cristipufu / agent.py
Last active May 1, 2025 11:26
LangGraph GitHub Docs Agent
import ast
import os
import re
from typing import List, Tuple
from langchain_chroma import Chroma
from langchain_core.documents import Document
from langchain_core.messages import SystemMessage
from langchain_core.output_parsers import PydanticOutputParser
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
// Curiously Recurring Pattern
// http://blogs.msdn.com/b/ericlippert/archive/2011/02/03/curiouser-and-curiouser.aspx
public class VersionedExecutorBase<T, TFunc>
where T : VersionedExecutorBase<T, TFunc>
{
private readonly Func<Version> _versionProvider;
private readonly Dictionary<Version, TFunc> _functions;
private TFunc _default;
public VersionedExecutorBase(Func<Version> versionProvider)
@cristipufu
cristipufu / markdown-details-collapsible.md
Created August 21, 2019 10:26 — forked from pierrejoubert73/markdown-details-collapsible.md
How to add a collapsible section in markdown.

A collapsible section with markdown

Click to expand!

Heading

  1. A numbered
  2. list
    • With some
    • Sub bullets
@cristipufu
cristipufu / MPRateLimitConfiguration.cs
Created May 10, 2019 00:34
Custom Rate Limit Incrementer
using System;
using System.Linq;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
namespace AspNetCoreRateLimit.Demo
{
public class MPRateLimitConfiguration : RateLimitConfiguration
{
public MPRateLimitConfiguration(
@cristipufu
cristipufu / DisableFormValueModelBindingAttribute.cs
Last active March 19, 2019 14:11
MultiPartFormData Streaming
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public class DisableFormValueModelBindingAttribute : Attribute, IResourceFilter
{
public void OnResourceExecuting(ResourceExecutingContext context)
{
var factories = context.ValueProviderFactories;
factories.RemoveType<FormValueProviderFactory>();
factories.RemoveType<JQueryFormValueProviderFactory>();
}
/* TRUNCATE ALL TABLES IN A DATABASE */
DECLARE @dropAndCreateConstraintsTable TABLE
(
DropStmt VARCHAR(MAX)
,CreateStmt VARCHAR(MAX)
)
/* Gather information to drop and then recreate the current foreign key constraints */
INSERT @dropAndCreateConstraintsTable
SELECT DropStmt = 'ALTER TABLE [' + ForeignKeys.ForeignTableSchema
+ '].[' + ForeignKeys.ForeignTableName + '] DROP CONSTRAINT ['
@cristipufu
cristipufu / EFCoreDatabaseExtensions.cs
Last active April 8, 2018 15:54
SqlQuery<T> EFCore
public static class DatabaseExtensions
{
public static SqlQuery<T> SqlQuery<T>(this DatabaseFacade database, string sqlQuery, object parameters = null)
where T : class
{
return new SqlQuery<T>
{
Database = database,
Query = sqlQuery,
Parameters = GetParameters(parameters)
extern alias redis;
using Castle.Core.Logging;
using redis::StackExchange.Redis;
using System;
using System.Net;
using UiPath.Core;
namespace UiPath.Web.Communication
{
public static class RedisConnector
@cristipufu
cristipufu / AddressController.cs
Created January 4, 2018 17:46
OData AutoMapper translate DTO queries to POCO queries
[HttpGet]
public async Task<IEnumerable<AddressModel>> GetAddresses(ODataQueryOptions<AddressModel> queryOptions, CancellationToken cancellationToken)
{
var repository = new AddressRepository(_context);
var service = new AddressService(repository);
var filter = queryOptions.ToModelQueryFilter<AddressModel>();
return await service.QueryByStreetAsync("StreetName", filter, cancellationToken);
}