Skip to content

Instantly share code, notes, and snippets.

View halityurttas's full-sized avatar

Halit YURTTAŞ halityurttas

View GitHub Profile
@halityurttas
halityurttas / propertyaccessor.cs
Created May 20, 2024 13:18
Property accessor
static Func<T, TResult> CreatePropertyAccessor<T, TResult>(string propertyName)
{
var parameter = Expression.Parameter(typeof(T), "x");
var property = Expression.Property(parameter, propertyName);
var lambda = Expression.Lambda<Func<T, TResult>>(property, parameter);
return lambda.Compile();
}
@halityurttas
halityurttas / hiercopy.sh
Created May 20, 2024 13:17
Path copy with hierarcy
#!/bin/bash
# Hedef dizin
hedef_dizin="C:/Depo/gitbackup"
# Kaynak dosyaların yolu
kaynak_dosya1="Path/To/file1.txt"
kaynak_dosya2="Path/To/Another/file2.txt"
# Dizinleri oluştur (eğer yoksa)
mkdir -p "$hedef_dizin/$(dirname $kaynak_dosya1)"
mkdir -p "$hedef_dizin/$(dirname $kaynak_dosya2)"
# Dosyaları kopyala
@halityurttas
halityurttas / default.conf
Created July 30, 2023 17:50
vscode server nginx settings
location / {
proxy_pass http://127.0.0.1:8443/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
@halityurttas
halityurttas / fl.ps2
Created January 7, 2023 20:19
file list
PS D:\> Get-ChildItem -Path D:\LogTest\FTP-02\ -File -Recurse | Format-List FullName
@halityurttas
halityurttas / koSelect2MultipleBinding.js
Created November 5, 2022 22:32
Select2 Multiple Custom Binding
ko.bindingHandlers.select2multiValues = {
init: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
$(element).select2({multiple: true});
$(element).val(valueAccessor()()).trigger('change');
$(element).on('select2:select', function (e) {
valueAccessor()($(element).val());
});
$(element).on('select2:unselect', function (e) {
valueAccessor()($(element).val());
});
@halityurttas
halityurttas / randomnumber.sql
Created June 8, 2022 20:39
Satır bazında random number üretme
SELECT (((CAST( ABS(CHECKSUM(NewId())) % 10 AS DECIMAL)+1)/10)+1), * FROM table1
@halityurttas
halityurttas / PredicateBuilder.cs
Created February 7, 2022 01:53
Csharp predicate builder
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Collections.Generic;
public static class PredicateBuilder
{
public static Expression<Func<T, bool>> True<T> () { return f => true; }
public static Expression<Func<T, bool>> False<T> () { return f => false; }
@halityurttas
halityurttas / list-table-with-scheme.sql
Created June 23, 2021 22:39
List table with scheme (where in table names)
select schema_name(t.schema_id) + '.' +
t.name as table_name,
t.create_date,
t.modify_date
from sys.tables t
where t.name IN (
'ABC'
)
order by table_name;
@halityurttas
halityurttas / recaptcha2.php
Created May 26, 2021 22:31
ReCaptcha v2 Laravel Validation Rule
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class recaptcha2 implements Rule
{
/**
* Create a new rule instance.
@halityurttas
halityurttas / rename_to_lower.ps1
Created May 19, 2021 00:41
Rename all files to lowercase
dir . -r | % { if ($_.Name -cne $_.Name.ToLower()) { ren $_.FullName $_.Name.ToLower() } }