Skip to content

Instantly share code, notes, and snippets.

View kshyju's full-sized avatar

Shyju Krishnankutty kshyju

View GitHub Profile
[MemoryDiagnoser]
public class LastBenchmarks
{
string[] segments = "abc/xyz".Split('/');
[Benchmark]
public string LastitemUsingLINQ()
{
return segments.Last();
}
@kshyju
kshyju / UserAgents
Last active May 11, 2024 19:28
User agents
// Opera 63 in OSX
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36 OPR/63.0.3368.35
Chrome in OSX
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36
Safari in OSX
@kshyju
kshyju / ConfigurationRootBenchmark
Last active March 9, 2019 17:18
Benchmark for ConfigurationRoot get method change using for loop instead of Reverse method call
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Memory;
namespace Microsoft.Extensions.Primitives.Performance
{
public class ConfigurationBenchmark
{
@kshyju
kshyju / CodeToGetCookieValue
Last active June 8, 2020 02:23
CodeToGetCookieValue
document.cookie.split(';').filter(function(item) {
if(item.indexOf('eupubconsent') >= 0){
return item.trim();
}
})
/ Token: 0x06000001 RID: 1 RVA: 0x00002048 File Offset: 0x00000248
.method private hidebysig static
void Main (
string[] args
) cil managed
{
// Header Size: 12 bytes
// Code Size: 25 (0x19) bytes
// LocalVarSig Token: 0x11000001 RID: 1
.maxstack 2
Safari
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.2 Safari/605.1.15" = $15
@kshyju
kshyju / Nested-callback-hell
Created June 23, 2014 18:37
Nested ajax callbacks to make sure that we load look up data in all dropdowns before loading the page data.
//What is the alternative of getting rid of the nested callback hell ?
//Load the data for the 3 dropdowns
$http.get('Products/AllProducts/').success(function (data) {
$scope.products = data;
$http.get('Colors/AllColors/').success(function (colordata) {
$scope.colors = colordata;
$http.get('Products/AllSizes/').success(function (sizedata) {
@kshyju
kshyju / gist:11264331
Created April 24, 2014 18:20
Unity with generics
using System;
using Microsoft.Practices.Unity;
public class Program
{
public interface ILoader<IPoco>
{
string Name {get;}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class Program
{
public static void Main()
{
@kshyju
kshyju / gist:11238354
Created April 24, 2014 01:25
generics with interface
public class KPIDataProcessor<T> : IDataProcessor<T>
{
public IEnumerable<T> Dtos { set; get; }
public void ProcessData()
{
Console.WriteLine("Processing KPI data");
}
}
public interface IDataProcessor<T>
{