This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.locks.ReentrantReadWriteLock; | |
public class ConcurrentHashMap<K, V> { | |
private static final int DEFAULT_CAPACITY = 16; | |
private Entry<K, V>[] buckets; | |
private final ReentrantReadWriteLock[] locks; | |
public ConcurrentHashMap() { | |
this(DEFAULT_CAPACITY); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
import java.util.concurrent.Semaphore; | |
class OrderedPrinting { | |
Semaphore s1 = new Semaphore(1); | |
public void printFirst() throws InterruptedException { | |
synchronized (this) { | |
while (s1.availablePermits() != 1) { | |
wait(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.concurrent.Semaphore; | |
class Toilet{ | |
int semporeNum = 40; | |
Semaphore s = new Semaphore(semporeNum); | |
String MALE = "MALE"; | |
String FEMALE = "FEMALE"; | |
String NONE = "NONE"; | |
String occupiedBy = NONE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "uri" | |
require "json" | |
require "net/http" | |
url = URI("https://staging-runner.cargoes.com/services/Default/ServiceTypes/Create") | |
File.foreach('service.csv').with_index do |line, line_num| | |
https = Net::HTTP.new(url.host, url.port) | |
https.use_ssl = true | |
arr = line.split('$'); | |
request = Net::HTTP::Post.new(url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "uri" | |
require "json" | |
require "net/http" | |
url = URI("https://staging-runner.cargoes.com/services/Default/ContainerTypes/Create") | |
# SELECT concat (Code,'$', Description,'$', Mode,'$', ContainerType,'$', TEU,'$', Active,'$', TenantId ,'$', InsertUserId, '$', UpdateUserId,'$', IATAClass,'$') | |
# FROM ContainerTypes where TenantId = 143 | |
File.foreach('container_create_staging.csv').with_index do |line, line_num| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "uri" | |
require "json" | |
require "net/http" | |
url = URI("https://staging-runner.cargoes.com/services/Default/ChargeTypes/Create") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require "uri" | |
require "json" | |
require "net/http" | |
# hash map contain month and expenditure about month | |
spending_global = Hash.new | |
def getData(order_id_list,spending) | |
url = URI("https://www.swiggy.com/dapi/order/all?order_id=#{order_id_list}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Java program to find shortest path in an undirected | |
// graph | |
import java.util.*; | |
public class pathUnweighted { | |
static Map<String,Integer> mp = new HashMap<>(); | |
static Map<Integer,String> rmp = new HashMap<>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYgAAAD6CAYAAAC73tBYAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAxMDHwM/AxsCSmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsislupmz47GA38fmcUm588XWY6pHgVwpaQWJwPpP0CcllxQVMLAwJgCZCuXlxSA2B1AtkgR0FFA9hwQOx3C3gBiJ0HYR8BqQoKcgewbQLZAckYi0AzGF0C2ThKSeDoSG2ovCPC4uPr4KAQYmRhaehBwLumgJLWiBEQ75xdUFmWmZ5QoOAJDKVXBMy9ZT0fByMDIgIEBFOYQ1Z9vgMOSUYwDIZbylIHBOBcoqIEQyxJgYNj9jYFBcCtCTP0h0FtzGRgOBBQkFiXCHcD4jaU4zdgIwubezsDAOu3//8/hDAzsmgwMf6////97+///f5cxMDDfAur9BgBpmWBP/WomVQAAAAlwSFlzAAAWJQAAFiUBSVIk8AAAAZ1pVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6ZXhpZj0iaHR0cDovL25zLmFkb2JlLmNvbS9leGlmLzEuMC8iPgogICAgICAgICA8ZXhpZjpQaXhlbFhEaW1lbnNpb24+MzkyPC9leGlmOlBpeGVsWERpbWVuc2lvbj4KICAgICAgICAgPGV4aWY6UGl4ZWxZRGltZW5zaW9uPjI1MDwvZXhpZjpQaXhlbFlEaW |