Skip to content

Instantly share code, notes, and snippets.

View sudipto80's full-sized avatar
🎯
Focusing

SUDIPTA MUKHERJEE sudipto80

🎯
Focusing
View GitHub Profile
@sudipto80
sudipto80 / RoslynDemo.cs
Created March 23, 2024 07:52
Roslyn code to find out property names that starts with the classname
// See https://aka.ms/new-console-template for more information
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
public class Demo
{
private static Dictionary<string, List<string>> _classWisePropMap
= new Dictionary<string, List<string>>();
@sudipto80
sudipto80 / cookies.fs
Created December 10, 2021 14:57
cookies
let cookieA = ["refined wheat flour";"sugar";"edible vegetable oil";"edible coconut products";
"invert syrup";"milk solids";"edible starch";"raising agent";"edible common salt";
"baking powder";"solbake";"emulsifier"]
let cookieB = ["refined wheat flour";"cocoa powder";"sugar";"cocoa butter";"dextrose";"lecithin";"vanillin";
"editable vegetable oil";"raising agent";"cocoa solids";"edible common salt";"emulsifier"];
@sudipto80
sudipto80 / CreateModelFromCSV.cs
Created January 25, 2020 01:15
Code to create ModelInput from CSV
void Main()
{
string csvFile = @"C:\MLDOTNET\iris.csv";
var columns = File.ReadLines(csvFile)
.Take(1)
.First()
.Split(new char[] { ',' });
var firstLine = File.ReadLines(csvFile)
.Skip(1)
.Take(1)
package hello
fun main() {
var x = 11
var y = if (x > 10) { println("Hey!"); ":Kotlin"} else
{
println("NO!")
"OUCH!"
}
println(y)
package hello
fun main() {
var xs = listOf(listOf(1,2,3),
listOf(1,5,6,2),
listOf(7,8,2,11,1))
var result = xs[0]
for(i in 1 .. xs.size - 1)
{
result = result.intersect(xs[i]).toList()
@sudipto80
sudipto80 / Cartesian.cs
Created October 22, 2016 10:00
CartesianProduct
void Main()
{
Cartesian<string>(new List<List<string>>()
{
new List<string>() { "A", "B" },
new List<string>() { "C", "D", "E" }
}).Dump();
}
public static List<List<T>> Cartesian<T>(List<List<T>> sets)
let rainfall = [[1.17;0.78];[1.24;3.22];[1.277;1.4]]
let months = [|"January";"February"|]
let rainfalStats = [ 0 .. months.Length - 1]
|> List.map
(
fun index ->
(
months.[index],
rainfall |> List.map (fun row -> List.nth row index)
@sudipto80
sudipto80 / UniquePrefix.cs
Created June 25, 2016 08:29
Unique Prefixes
string[] words = new string[]
{"zebra","beard","duck","zest", "ducklin", "bearcat","dumb","beautiful","zebracrossing"};
//{ "zebra", "dog", "duck", "zimbawae", "zest","god","dove", "dig","got","dumb"};
Array.Sort(words);
Func<string, string, int> DiffersAt = (a, b) =>
{
int m = a.Length;
int n = b.Length;
@sudipto80
sudipto80 / LongestSeq.cs
Created June 25, 2016 05:27
Longest Continuous Sequence
string[] words = new string[]
{"zebra","beard","duck","zest", "ducklin", "bearcat","dumb","beautiful","zebracrossing"};
//{ "zebra", "dog", "duck", "zimbawae", "zest","god","dove", "dig","got","dumb"};
Array.Sort(words);
Func<string, string, int> DiffersAt = (a, b) =>
{
int m = a.Length;
int n = b.Length;
@sudipto80
sudipto80 / avoidBoxing.linq
Created June 20, 2016 08:45
Finding Boxing calls using Roslyn
//Avoid Boxing
var code = @"public void fun(){int x = 32;
object o = x;}";
var tree = CSharpSyntaxTree.ParseText(code);
//x - Int