Skip to content

Instantly share code, notes, and snippets.

@serkanberksoy
serkanberksoy / cloudSettings
Created December 1, 2018 21:15
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-12-01T21:15:43.026Z","extensionVersion":"v3.2.2"}
@serkanberksoy
serkanberksoy / cdcatalog.xsl
Last active August 22, 2018 23:10
Add a default valued node if that node does not exists in xml
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/*">
<xsl:copy>
@serkanberksoy
serkanberksoy / Md5.cs
Created April 5, 2017 11:16
C# MD5 Generator same as JavaScript
// Working C# equivalent
public static string GetMD5Working(string input)
{
MD5 md5 = MD5.Create();
byte[] hash = md5.ComputeHash(Encoding.UTF8.GetBytes(input));
StringBuilder sb = new StringBuilder();
for (int j = 0; j < hash.Length; j++)
{
sb.Append(hash[j].ToString("X2"));
@serkanberksoy
serkanberksoy / DictionaryVSRedisClientTest.cs
Created March 12, 2017 12:49
DictionaryVSRedisClientTest.cs is a performance test between ConcurrentDictionary, Dictionary and StackExchange.Redis client to redis server.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using StackExchange.Redis;
using ZeroFormatter;
namespace ConsoleApplication2
@serkanberksoy
serkanberksoy / DictionaryVSRedisClientTest.cs
Created March 12, 2017 12:48
DictionaryVSRedisClientTest.cs is a performance test between ConcurrentDictionary, Dictionary and StackExchange.Redis client to redis server.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using StackExchange.Redis;
using ZeroFormatter;
namespace ConsoleApplication2
@serkanberksoy
serkanberksoy / FindMySQLServers.cs
Last active March 22, 2019 09:19
Find MySQL Servers with default port on network and try to connect
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
@serkanberksoy
serkanberksoy / GetMousePosition.js
Created June 6, 2015 09:10
Get mouse position
var posX, posY;
$(document).mousemove(function(e) {
posX = e.clientX;
posY = e.clientY;
});
@serkanberksoy
serkanberksoy / ColorLuminance.js
Last active August 29, 2015 14:22
Color Luminance
/*
This is the solution that I use in my projects for dynamic colors.
Don't know where I got it.
ColorLuminance("#69c", 0); // returns "#6699cc"
ColorLuminance("6699CC", 0.2); // "#7ab8f5" - 20% lighter
ColorLuminance("69C", -0.5); // "#334d66" - 50% darker
ColorLuminance("000", 1); // "#000000" - true black cannot be made lighter!
Real life example:
@serkanberksoy
serkanberksoy / HandleBarsHelper.js
Last active August 29, 2015 14:22
HandleBars Helper
/*
Serkan Berksoy May 2015
Create a list of tagnames that consist handlebars mustache template
CompileTemplates method gathers all templates and compiles them. Also stores them for rebind
Also it hides them before first binding so there is no flicker and tags being shown on screen
example usage:
handleBarsHelper.compileTemplates();
handleBarsHelper.elements.tagName1.html(handleBarsHelper.templates.tagName1(
@serkanberksoy
serkanberksoy / TraceLogger.js
Last active August 29, 2015 14:22
Simple Trace Logger With Commas
// usage logTrace("name", val1, "name2", val2);
function logTrace()
{
var result = "TRACE : "; // you may add milliseconds here
for(var i = 0; i < arguments.length; i++)
{
if(i > 0)
{
result += " - ";