Skip to content

Instantly share code, notes, and snippets.

View ketankhairnar's full-sized avatar
🎯
Focusing

Ketan Khairnar ketankhairnar

🎯
Focusing
View GitHub Profile
@ketankhairnar
ketankhairnar / weekend-dev-puzzles-list.md
Created May 13, 2022 09:16 — forked from amodm/weekend-dev-puzzles-list.md
List of all #WeekendDevPuzzles

Weekend Dev Puzzle

List

  • 2022-02-12: Limiting factor in playing an arcade style space shooter via sensors and a hooked up keyboard.
  • 2022-02-05: Does the time taken to count integers (that are less than a threshold) in an unordered array, remain the same, or vary?
  • 2022-01-29: Does splitting a service into microservices help or hurt the availability?
  • 2022-01-22: Can closures+lambdas be implemented irrespective of whether the language is garbage collected?
  • 2022-01-15: Debugger crashed before a breakpoint was hit. What happens to the program being debugged?
  • 2022-01-08: No puzzle on account of my travels
  • 2022-01-01: Relative CPU performance of a process b/w native vs
@ketankhairnar
ketankhairnar / pre-aggegations-data-access-pattern-example.txt
Last active September 5, 2021 15:26
pre-aggegations-data-access-pattern-example.txt
┌──────────────────────────────┬────────────────────┬─────────────────────────────────────────────────┐
│ Question │ Attr Params │ Sample Args │
├──────────────────────────────┼────────────────────┼─────────────────────────────────────────────────┤
│ Last n Days spend for card │ card,Day1-Day n │ card#ABCD,(Day-2021-09-05,Day-2021-08-30) │
│ Last 4 Weeks spend for user │ user,Week 1-Week 7 │ user#1234,(Week-2021-36,Week-2021-33) │
│ Total spend for organization │ org,Total │ org#12AB,(Total) │
│ Monthwise Purchase for Team │ team,Month │ org#12AB#team#22,(Month-2021-06, Month-2021-02) │
└──────────────────────────────┴────────────────────┴─────────────────────────────────────────────────┘
package co.in.shoonya.abc.prep.ds.lists;
import co.in.shoonya.abc.prep.ds.lists.ds.ListNode;
public class AggregateAtZeroNode {
public static void main(String[] args) {
ListNode<Integer> l1 = new ListNode<Integer>(1);
l1.setNext(new ListNode<Integer>(4));
l1.getNext().setNext(new ListNode<Integer>(0));
package co.in.shoonya.abc.kata;
public class CdkShoppingCart {
public static void main(String[] args) {
System.out.println(billAmount(CustomerType.Regular, 15000d));
System.out.println(billAmount(CustomerType.Premium, 20000d));
}
private static double billAmount(CustomerType type, double input) {
package co.in.shoonya.abc.prep.ds.classic.strings;
// Given a string of characters (a, b, c,....z), we want to break the string into a maximum number of substrings
// in which every character comes in only one substring. We have to return length of all substrings.
// Ex 1: Input string = "abcdefgahijklhopqrsot"
// Output = [8, 5, 6, 1]
// Ex 2: Input string = "abcd"
// Output = [1, 1, 1, 1]
import java.util.*;
@ketankhairnar
ketankhairnar / HortonGrid
Created December 28, 2017 05:10
HortonGrid
package com.example;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class GridQuestion {
<speak> All good except 2 escalations. <break time=“1s”/> We had 5 new deployments and have new release coming this Friday</speak>
[{"address":{"street":"Oude Ebbingestraat","housenumber":"12","postalcode":"9712 HJ","city":"Groningen","geoLocation":{"lat":"53.219319","lng":"6.56671"}},"distance":0,"type":"ING"},{"address":{"street":"Amsterdamsestraat","housenumber":"9","postalcode":"2587 CN","city":"Den Haag","geoLocation":{"lat":"52.111805","lng":"4.287714"}},"distance":0,"type":"ING"},{"address":{"street":"Oudenoord","housenumber":"1","postalcode":"3513 EG","city":"Utrecht","geoLocation":{"lat":"52.0970886","lng":"5.1133961"}},"distance":0,"type":"ING"},{"address":{"street":"Bloemenoordplein","housenumber":"50","postalcode":"5143 TC","city":"Waalwijk","geoLocation":{"lat":"51.6823433","lng":"5.0782567"}},"distance":0,"type":"ING"},{"address":{"street":"Dorpsstraat","housenumber":"2","postalcode":"2361 BB","city":"Warmond","geoLocation":{"lat":"52.195528","lng":"4.502244"}},"distance":0,"type":"ING"},{"address":{"street":"Waalderstraat","housenumber":"48","postalcode":"1791 EC","city":"Den Burg","geoLocation":{"lat":"53.056402","lng":"4
chapter 4: Expressions and Simple functions
===========================================================================================================================
There are 2 types of expressions.
1. def x = 5
2. val x = 5
Here # 1 represens definition and expression is at the right hand side of the = sign. It is not evaluated immediately.
Here # 2 represents value expression and its value is evaluated immediately and whenver val is being used; it replaces
it with pre-computed value of expression.
@ketankhairnar
ketankhairnar / ResultSetProcessor.java
Created March 15, 2011 10:09
ResultSet Processor
public class ResultSeProcessor extends CamelProcessor<MyJPAEntity>
{
public void process(Exchange exchange) throws Exception
{
process(exchange, getRowMapper());
}
private static ResultMapper<MyJPAEntity> getRowMapper()
{
ResultMapper<MyJPAEntity> mapper = new ResultMapper<MyJPAEntity>()