This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ast | |
import os | |
import re | |
def extract_imports(tree: ast.Module): | |
""" | |
Extract all import statements from an AST tree. | |
Args: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.Extensions.Options; | |
namespace AspNetCoreRateLimit.Demo | |
{ | |
public class MPRateLimitConfiguration : RateLimitConfiguration | |
{ | |
public MPRateLimitConfiguration( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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>(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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 [' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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); | |
} |
NewerOlder