Skip to content

Instantly share code, notes, and snippets.

sudipto80

Block or report user

Report or block sudipto80

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ifExpr.kt
package hello
fun main() {
var x = 11
var y = if (x > 10) { println("Hey!"); ":Kotlin"} else
{
println("NO!")
"OUCH!"
}
println(y)
View intersectMany.kt
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()
View Cartesian.cs
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)
View Calculating average rainfall
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)
View UniquePrefix.cs
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 Jun 25, 2016
Longest Continuous Sequence
View LongestSeq.cs
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 Jun 20, 2016
Finding Boxing calls using Roslyn
View avoidBoxing.linq
//Avoid Boxing
var code = @"public void fun(){int x = 32;
object o = x;}";
var tree = CSharpSyntaxTree.ParseText(code);
//x - Int
View SampleProfileVectors.csv
We can make this file beautiful and searchable if this error is corrected: It looks like row 8 should actually have 15 columns, instead of 6. in line 7.
sealedClassesPerNamespaceThatAre,MethodsPerClass,ClassesPerNamespace,publicMethodsPerClass,privateMethodsPerClass,protectedMethodsPerClass,overrideMethodsPerClass,ParametersPerMethod,staticClassesPerNamespaceThatAre,UsageOfPartialClass,UsageOfVerbsInMethodNames,AverageLengthOfMethodNames,CodeToCommentRatio,PercentageOfEnglishWordTokens,Tag
0,1,1,0,0,0,0,1,0,0,0,4,0.0163934426229508,0.0833333333333333,Troelson
0,1,1,0,0,0,0,1,0,0,0,15.75,0.0855855855855856,0.0833333333333333,Troelson
0,2.5,1,0,0.5,1.5,0,1.4,0,0.0714285714285714,0.125,18,0.0561224489795918,0.333333333333333,Troelson
0,1.66666666666667,1,0,0.333333333333333,1,0,1.4,0,0.0714285714285714,0.125,9,0.049438202247191,0.958333333333333,Troelson
0,1.75,1,0,0.25,1.25,0,1.57142857142857,0,0.142857142857143,0.208333333333333,7.33333333333333,0.0446927374301676,1.08333333333333,Troelson
0,1.6,1,0,0.2,1.2,0,1.625,0,0.214285714285714,0.291666666666667,9,0.041025641025641,1.20833333333333,Troelson
0,2.33333333333333,1,0.833333333333333,0.166666666666667,1.1666
@sudipto80
sudipto80 / BenchMarkingFindingDups.cs
Created Mar 24, 2016
Bench Marking finding dups
View BenchMarkingFindingDups.cs
void Main()
{
List<PlugIn> plugIns = new List<PlugIn> ();
//Create some plugins
var keys = Enumerable.Range(0,100).Select(e => Guid.NewGuid().ToString()).ToArray();
for (int i = 0; i < 1000000; i++)
{
plugIns.Add(new PlugIn(keys[new Random().Next(keys.Length-1)],"Some thing",Console.WriteLine));
}
@sudipto80
sudipto80 / dupSimple.cs
Created Mar 24, 2016
Finding duplicates the right way
View dupSimple.cs
var hasDup = plugIns.ToLookup(plugIn => plugIn.ID).Count != plugIns.Count;
You can’t perform that action at this time.