Skip to content

Instantly share code, notes, and snippets.

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 / Elvis.kt
Created Sep 11, 2021
Elvis operator in Kotlin
View Elvis.kt
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 {
@way2datta
way2datta / BinarySearch.cs
Last active Jul 9, 2021
Human Readable Binary Search
View BinarySearch.cs
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 / SampleForRunningManyProgramsAtOnce.cs
Last active Jul 8, 2021
This program will be used to show "Running Many Programs At Once"
View SampleForRunningManyProgramsAtOnce.cs
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 / ViolateImmurable.cs
Created Jul 12, 2020
Protect Your Immutable Object Invariants
View ViolateImmurable.cs
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)
{
View gist:0c6d460948411dd69962944119b12522
How browsers work - Behind the scenes of modern web browsers: http://taligarsiel.com/Projects/howbrowserswork1.htm
@way2datta
way2datta / gst-calculator-long-method.js
Last active Aug 21, 2019
GST Calculator long method example
View gst-calculator-long-method.js
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 / flag-argument.js
Last active Dec 27, 2018
Login to the system and send access code via email or sms notifications.
View flag-argument.js
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 / ExpenseTracker.txt
Created Nov 25, 2018
Simple Expense tracker application for study purpose
View ExpenseTracker.txt
**Use Cases**
- User can register his/her account.
- An account owner can log into the system.
- An account owner can view, add, update, and delete category for expenses.
- An account owner can view, add, update, and delete expense.
@way2datta
way2datta / list-urls-and-verbs-in-restful-service.js
Created Nov 22, 2018
List down endpoints urls and http verbs that was built by using Node + Express
View list-urls-and-verbs-in-restful-service.js
const express = require('express');
import routes from './routes/rest-api';
const app = express();
const port = 3000;
const hostUrl = "http://localhost:3000"
app.use('/', routes);
routes.stack.forEach(function (element) {
@way2datta
way2datta / Poorly formatted and poorly named urls and http methods
Last active Nov 21, 2018
Poorly formatted and poorly named urls and http methods
View Poorly formatted and poorly named urls and http methods
HTTP GET http://localhost:3000/userJWTValidation
HTTP GET http://localhost:3000/JwtValidation
HTTP GET http://localhost:3000/creationOfUserDetails
HTTP GET http://localhost:3000/getAllusersDetails
HTTP GET http://localhost:3000/fetchUserDetails
HTTP GET http://localhost:3000/deletionOfUserDetails
HTTP GET http://localhost:3000/updationOfUserDetails
HTTP GET http://localhost:3000/getExpenseCategoryOfUsers
HTTP GET http://localhost:3000/getExpenseCategoryOfUser
HTTP GET http://localhost:3000/deletionExpenseCategoryOfUser