Skip to content

Instantly share code, notes, and snippets.

View murataslan1's full-sized avatar
🎯
Focusing

Murat Aslan murataslan1

🎯
Focusing
View GitHub Profile
@murataslan1
murataslan1 / Example: Framework-Agnostic Agent Interface
Created January 19, 2025 08:36
Example: Framework-Agnostic Agent Interface
@app.post("/agent/execute")
async def execute_agent(request: AgentRequest):
# Framework-independent logic
return await process_agent_request(request)
@murataslan1
murataslan1 / 5. Minimizing JavaScript and CSS Bundles
Created December 15, 2024 20:00
5. Minimizing JavaScript and CSS Bundles
// BundleConfig.cs (for older versions)
// Use third-party libraries like WebOptimizer for .NET Core
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/main").Include(
"~/wwwroot/js/*.js"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/wwwroot/css/*.css"));
}
@murataslan1
murataslan1 / 4. Caching Strategies with MemoryCache and Distributed Cache
Created December 15, 2024 19:59
4. Caching Strategies with MemoryCache and Distributed Cache
// Service Example
public class ProductService
{
private readonly IMemoryCache _cache;
private readonly DataContext _context;
public ProductService(IMemoryCache cache, DataContext context)
{
_cache = cache;
_context = context;
@murataslan1
murataslan1 / 3. Implementing Image Optimization Best Practices:
Created December 15, 2024 19:58
3. Implementing Image Optimization Best Practices:
<img src="image.jpg" loading="lazy" alt="Description">
@murataslan1
murataslan1 / 3. Implementing Image Optimization
Created December 15, 2024 19:57
3. Implementing Image Optimization
// Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddResponseCompression(options =>
{
options.MimeTypes = new[] { "image/jpeg", "image/png", "image/gif" };
});
}
public void Configure(IApplicationBuilder app)
@murataslan1
murataslan1 / 2. Prefetching Resources Based on User Interaction
Created December 15, 2024 19:56
2. Prefetching Resources Based on User Interaction
<!-- View Example -->
<a href="/products/details/1" onmouseover="prefetch('/products/details/1')">Product Details</a>
<script>
function prefetch(url) {
fetch(url, { method: 'GET', headers: { 'X-Prefetch': 'true' } });
}
</script>
@murataslan1
murataslan1 / 1. Implementing Server-Side Rendering with ASP.NET Core
Created December 15, 2024 19:55
1. Implementing Server-Side Rendering with ASP.NET Core
// Controller Example
public class HomeController : Controller
{
public IActionResult Index()
{
// Fetch data required for the view
var model = GetData();
return View(model);
}
}
@murataslan1
murataslan1 / 3. Enhancing Search Functionality with Semantic Search
Created December 15, 2024 19:26
3. Enhancing Search Functionality with Semantic Search
@murataslan1
murataslan1 / 2. Language Translation Feature
Created December 15, 2024 19:25
2. Language Translation Feature
public async Task<string> TranslateText(string text, string targetLanguage)
{
var requestBody = new
{
q = text,
target = targetLanguage,
format = "text"
};
var httpContent = new StringContent(JsonConvert.SerializeObject(requestBody), System.Text.Encoding.UTF8, "application/json");
@murataslan1
murataslan1 / 1. Implementing ChatGPT in a .NET Application
Created December 15, 2024 19:23
1. Implementing ChatGPT in a .NET Application
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
public class ChatGPTService
{
private readonly string apiKey = "YOUR_OPENAI_API_KEY";
private readonly HttpClient client;