Skip to content

Instantly share code, notes, and snippets.

@fatihbahceci
fatihbahceci / VerifyTCKNo.cs
Created November 21, 2021 21:07
Verify TCKNo - TCKNO Doğrulama
public static bool IsValidTCK(long tck)
{
byte[] digits = (tck + "").Select(x => byte.Parse(x + "")).ToArray();
//11 Basamak ve ilk Basamak 0 olamaz
if ((digits.Length == 11) && (digits[0] > 0))
{
//Tek basamakları topla (1,3,5,7,9)
int sumOdds = digits[0] + digits[2] + digits[4] + digits[6] + digits[8];
//Çift basamakları topla (2,4,6,8)
int sumEvens = digits[1] + digits[3] + digits[5] + digits[7];
@fatihbahceci
fatihbahceci / App.axaml
Created October 31, 2021 13:33
Avalonia DateTimePicker
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:AvaloniaTest"
xmlns:v="using:AvaloniaTest.Views"
x:Class="AvaloniaTest.App">
<Application.DataTemplates>
<local:ViewLocator/>
</Application.DataTemplates>
<Application.Styles>
@fatihbahceci
fatihbahceci / MultiTryCatch.cs
Created March 11, 2020 07:58
Multi try catch example
//C# Interactive code. Select all and press (Ctrl + E, Ctrl + E)
/// <summary>
/// Tries each action until success
/// </summary>
/// <param name="onException">Action on each exception</param>
/// <param name="acts">Actions which is will try</param>
/// <returns></returns>
int MultiTryCatchUntil(Action<Exception> onException, params Action[] acts)
{
int i = 0;
@fatihbahceci
fatihbahceci / ThreadIsAliveTest.cs
Created March 8, 2020 20:35
C# Thread.IsAlive test
//C# Interactive code. (Ctrl + E, Ctrl + E)
using System.Threading;
volatile bool stop = false;
Thread thread = new Thread(() => {
while (stop == false)
{
Thread.Sleep(500);
Console.WriteLine(DateTime.Now);
}
Console.WriteLine("Finished");
@fatihbahceci
fatihbahceci / isnull.js
Created March 9, 2019 09:26
javascript null-coalescing function
function isNull() {
for (var i = 0; i < arguments.length; i++) {
if (
typeof arguments[i] !== 'undefined'
&& arguments[i] !== undefined
&& arguments[i] != null
&& arguments[i] != NaN
&& arguments[i]
) return arguments[i];
}
@fatihbahceci
fatihbahceci / pagination.js
Created October 2, 2018 10:46
Javacript Bootstrap Pagination
function GeneratePagination(total, perPage, current, visible, prefix) {
var r = "";
total = parseInt(total || 0);
perPage = parseInt(perPage || 0);
current = parseInt(current || 1);
visible = parseInt(visible || 0);
prefix = prefix || '';
if (total <= 0) {
@fatihbahceci
fatihbahceci / doc.html
Created August 28, 2018 11:07
JavaScript - Hafıza Oyunu (Memory Game)
<!doctype html>
<html>
<head>
<!--<meta charset="utf-8">-->
<title>Hafıza Oyunu</title>
<script src="game.js"></script>
</head>
<body>
<h1>JavaScript Hafıza Oyunu</h1>