Skip to content

Instantly share code, notes, and snippets.

View kshyju's full-sized avatar

Shyju Krishnankutty kshyju

View GitHub Profile
@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>
{
public class ValdationResult
{
public bool Status { Set;get;}
public List<string> Errors { set;get;}
}
@kshyju
kshyju / jQuery autocomplete
Created February 28, 2014 16:14
jQuery autocomplete load data from a custom object list via ajax
$("#txtSearch").autocomplete({
source: function (request, response) {
$.ajax({
url: "/Home/Getsrchresult",
type: "POST",
dataType: "json",
data: { term: request.term,location:$('#location').val() },
success: function (data) {
response($.map(data, function (item) {
return { label: item.srchresult+"-"+item.place, value: item.srchresult+"-"+item.place };