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 / SmartDiff.cs
Last active March 3, 2022 11:00
Smart Diff For Source Code using Roslyn
//A very basic but smart code comparer for C#
//Written using Microsoft.CodeAnalysis.CSharp and LINQ
public class SmartComparer
{
public static string Code1 { get; set; }
public static string Code2 { get; set; }
public static IEnumerable<ClassDeclarationSyntax> Classes1 { get; set; }
public static IEnumerable<ClassDeclarationSyntax> Classes2 { get; set; }
@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)
@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
@sudipto80
sudipto80 / sentiment.fs
Created January 22, 2016 19:29
Sentiment Analysis
open System.Text.RegularExpressions
type SentiWordNetEntry = {POS:string; ID:string; PositiveScore:string; NegativeScore:string; Words:string}
let sentiWordList = System.IO.File.ReadAllLines(@"SentiWordNet_3.0.0_20130122.txt")
|> Array.filter (fun line -> not (line.StartsWith("#")))
|> Array.map (fun line -> line.Split '\t')
|> Array.map (fun lineTokens -> {POS = lineTokens.[0];
ID = lineTokens.[1];
PositiveScore = lineTokens.[2].Trim();
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 / CollaborativeFiltering.fs
Created January 21, 2016 08:56
Collaborative Filtering
// Learn more about F# at http://fsharp.org
// See the 'F# Tutorial' project for more help.
//Comprehensive coverage of Collaborative Filtering Techniques
//http://www.hindawi.com/journals/aai/2009/421425/
module confusion =
let TP (matches : int [] []) =
matches |> Array.mapi( fun i j -> matches.[i].[i]) |> Array.sum
@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)