Skip to content

Instantly share code, notes, and snippets.

View mehmetcantas's full-sized avatar
🎯
Focusing

Mehmet Can Taş mehmetcantas

🎯
Focusing
View GitHub Profile
@mehmetcantas
mehmetcantas / .cs
Created December 14, 2018 11:02
Request headers must contain only ASCII characters. (Solution)
public static string Serialize(object o, StringEscapeHandling stringEscapeHandling)
{
StringWriter wr = new StringWriter();
var jsonWriter = new JsonTextWriter(wr);
jsonWriter.StringEscapeHandling = stringEscapeHandling;
new JsonSerializer().Serialize(jsonWriter, o);
return wr.ToString();
}
//usage
@mehmetcantas
mehmetcantas / .html
Created December 28, 2018 10:59
dogo party new revision
<div class="info">
<h1>#dogoparty, #dogostore, #dogohq</h1>
<p>Profilini "HERKESE AÇIK" duruma getirmeyi unutma!</p>
<a class="" href="/">
<div class="Igw0E rBNOH eGOV_ ybXk5 _4EzTm">
<span class="glyphsSpriteApp_instagram__outline__24__grey_9 u-__7" aria-label="Instagram"></span>
<div class="SvO5t"></div>
<div class="cq2ai">
<span class="glyphsSpriteMobile_nav_type_logo u-__7" aria-label="Instagram"></span>
</div>
using System;
using StackExchange.Redis;
namespace RedisNetApi.Handlers
{
public static class ConnectionHandler
{
public static IDatabase GetRedisDatabase(string connectionString = "redis_image")
{
if (string.IsNullOrEmpty(connectionString))
using System;
using StackExchange.Redis;
namespace RedisNetApi.Caching
{
public interface IRedisProvider
{
T Get<T>(IDatabase cache, string key);
void Set(IDatabase cache, string key, object value, TimeSpan experation);
bool DeleteCacheKeyContains(IDatabase database, string keyPattern, string connectionString = "127.0.0.1");
using System;
using System.Diagnostics;
using Newtonsoft.Json;
using StackExchange.Redis;
namespace RedisNetApi.Caching
{
public class RedisProvider : IRedisProvider
{
//string tipinde alınan veriyi deserialize ederek T tipinde bir objeye çevirir.
using System;
using System.Threading.Tasks;
namespace RedisNetApi.Caching
{
public interface IResponseCacheFactory
{
Task CacheResponseAsync(string cacheKey, object response, TimeSpan expireTimeSeconds);
Task<string> GetCachedResponseAsync(string cacheKey);
}
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Caching.Distributed;
using Newtonsoft.Json;
namespace RedisNetApi.Caching
{
public class ResponseCacheFactory : IResponseCacheFactory
{
private readonly IDistributedCache _distrubtedCache;
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.DependencyInjection;
using RedisNetApi.Caching;
using System;
using System.Collections.Concurrent;
public class Program
{
public static void Main()
{
ConcurrentDictionary<string,int> dictionary = new ConcurrentDictionary<string,int>();
dictionary.TryAdd("Mehmet",25);
dictionary.TryAdd("İlker",22);
dictionary.TryAdd("Beril",30);
using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
Dictionary<string,int> dictionary = new Dictionary<string,int> { {"Mehmet",25}, {"İlker",22}, {"Beril",30}, {"Bihter",28},{"Kutay",28},{"Tuğçe",26}};
foreach(var item in dictionary)
{