Skip to content

Instantly share code, notes, and snippets.

View way2datta's full-sized avatar
🐌
Not only working software but also well crafted software.

Dattatray Kale way2datta

🐌
Not only working software but also well crafted software.
View GitHub Profile
@way2datta
way2datta / flag-argument.js
Last active December 27, 2018 17:52
Login to the system and send access code via email or sms notifications.
function login(email, password, sendEmail, sendSMS) {
// logic for user authentication
this.authenticate(username, password);
// logic to fetch user, access code, message content, settings login token in storage
if(sendEmail) {
// logic to send access code via email
}
if(sendSMS) {
@way2datta
way2datta / gst-calculator-long-method.js
Last active August 21, 2019 06:11
GST Calculator long method example
using System;
using System.Collections.Generic;
namespace NMart.Billing
{
internal class NMartStore
{
private static Dictionary<string, int> CategoryGstRatesInPercentage = new Dictionary<string, int>();
private static Dictionary<string, string> ItemsCategoryMapping = new Dictionary<string, string>();
@way2datta
way2datta / gist:0c6d460948411dd69962944119b12522
Created November 7, 2019 11:27
Links for technical reading
How browsers work - Behind the scenes of modern web browsers: http://taligarsiel.com/Projects/howbrowserswork1.htm
@way2datta
way2datta / ViolateImmurable.cs
Created July 12, 2020 06:54
Protect Your Immutable Object Invariants
public class Student
{
public readonly string Name;
public readonly string Email;
public readonly List<String> Subjects;
public Student(string name, string email, List<String> subjects)
{
@way2datta
way2datta / SampleForRunningManyProgramsAtOnce.cs
Last active July 8, 2021 06:26
This program will be used to show "Running Many Programs At Once"
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Security;
using System.Threading;
internal class Program
{
[DllImport("Kernel32.dll"), SuppressUnmanagedCodeSecurity]
public static extern int GetCurrentProcessorNumber();
@way2datta
way2datta / BinarySearch.cs
Last active July 9, 2021 05:28
Human Readable Binary Search
public class IntArray
{
public static int BinarySearch(int[] items, int searchTerm)
{
return SearchRecursively(items, searchTerm, 0, items.Length - 1);
}
private static int SearchRecursively(int[] items, int searchTerm, int lowerIndex, int upperIndex)
{
var scannedAllItems = lowerIndex > upperIndex;
@way2datta
way2datta / Elvis.kt
Created September 11, 2021 14:05
Elvis operator in Kotlin
fun main(args: Array<String>) {
val arnav = Person();
println(arnav);
arnav.name = "Arnav Kale";
println(arnav);
}
class Person {
var name: String? = null
override fun toString(): String {