Skip to content

Instantly share code, notes, and snippets.

View oguzhaneren's full-sized avatar
🐍
it depends

Oğuzhan Eren oguzhaneren

🐍
it depends
View GitHub Profile
@oguzhaneren
oguzhaneren / x.ts
Last active February 20, 2022 19:16
<div class="card shadow-sm card-tab">
<div class="card-body">
<span> {{ activeTab.name }} {{ activeTab.index }} / {{tabs.length}} <button @click="previousTab($event)" type="button" class="btn btn-light">&lt;</button> <button @click="nextTab($event)" type="button" class="btn btn-light"> &gt;</button></span>
</div>
</div>
<div class="b-example-divider"></div>
<div class="card shadow-sm card-tab">
<div class="card-body">
<ul class="nav nav-pills nav-fill nav-flush flex-row mb-auto text-center" id="myTab" role="tablist">
<li class="nav-item border-end" role="presentation" v-for="(tab, index) in tabs" :key="tab.id">
$( document ).ready(function() {
console.log( "ready!" );
$("[class^='trigger_']").on('change', function () {
// Get CSS class list from the input parameter. Find the one with the 'trigger_' prefix,
// and use it to identify which 3D scene (iFrame) will be updated
var sceneName = null;
var $this = $(this);
console.log("clicked:")
@oguzhaneren
oguzhaneren / SearchAllWithParallelScrollAsStream.cs
Created April 8, 2021 13:33
Elasticsearch - Search all with parallel scroll as stream extension (AsyncEnumerable)
public static async IAsyncEnumerable<T> SearchAllWithParallelScrollAsStream<T>(this IElasticClient elasticClient,
Func<SearchDescriptor<T>, ISearchRequest> query,
int shardSize = 2,
Expression<Func<T, object>> routingPath = null,
[EnumeratorCancellation] CancellationToken cancellationToken = default,
string scrollTimeout = "2m", int scrollSize = 1000) where T : class
{
shardSize = Math.Max(shardSize, 1);
var scrolls = new ConcurrentQueue<string>();
var stream = elasticClient.ScrollAll<T>(scrollTimeout, shardSize, s => s
@oguzhaneren
oguzhaneren / bounded-context-canvas.md
Last active February 18, 2021 20:59
The Bounded Context Canvas v4 Markdown

Name

Description

What benefits does this context provide, and how does it provide them?

Strategic Classification

Domain

@oguzhaneren
oguzhaneren / EnumerableTplExtensions.cs
Created October 18, 2020 10:21
TPL Dataflow Extensions for IEnumerable<T>
public static class EnumerableTplExtensions
{
public static Task ForeachWithTpl<TSource>(this IEnumerable<TSource> source,
Action<TSource> action,
ExecutionDataflowBlockOptions options
)
{
if (source == null)
{
throw new ArgumentNullException(nameof(source));
using System;
using System.Collections.Generic;
using System.Linq;
namespace [YOURNAMESPACEHERE]
{
public static class TypeExtensions
{
public static bool IsDerivingFrom(this Type type, Type searchType)
@oguzhaneren
oguzhaneren / IDistributedLocker.cs
Created July 7, 2020 15:39
redis distributed lock .net
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddRedisDistributedLocker( this IServiceCollection serviceCollection,IDatabase database)
{
serviceCollection. AddSingleton<IDistributedLocker>(sp=>new RedisDistributedLocker(database));
return serviceCollection;
}
public static IServiceCollection AddRedisClientDistributedLocker( this IServiceCollection serviceCollection)
{
@oguzhaneren
oguzhaneren / DistributedLock.cs
Last active July 7, 2020 15:02
Distributed Lock with redis (.net)
public class DistributedLock
: IAsyncDisposable
{
private const string AtomicReleaseScript = @"
if redis.call(""get"",KEYS[1]) == ARGV[1] then
return redis.call(""del"",KEYS[1])
else
return 0
end
";
@oguzhaneren
oguzhaneren / ISingletonInitializerFactory.cs
Created May 6, 2020 08:35
SingletonInitializerFactory
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace XXX
{
public static class SingletonExtensions
{

Regex to match numbers except numbers between quotes

-?\d+(.\d+)?(?=(([^"]*'){2})*[^"]*$)