Skip to content

Instantly share code, notes, and snippets.

View sujalmandal's full-sized avatar
🎯
Focusing

Sujal Mandal sujalmandal

🎯
Focusing
View GitHub Profile
docker run -it --rm --link some-zookeeper:zookeeper zookeeper zkCli.sh -server zookeeper
docker run -d -p 5000:5000 --restart=always --name registry registry:2
docker run --name local-postgres -e POSTGRES_PASSWORD=root -p 5432:5432 -d postgres
------ create database, users ------
create DATABASE "<DB_NAME>";
CREATE USER <USERNAME> WITH ENCRYPTED PASSWORD '<PASSWORD_TEXT>';
GRANT ALL PRIVILEGES ON DATABASE <DB_NAME> TO <USERNAME>;
@sujalmandal
sujalmandal / gist:76f5c615896eaf647acfdc5adf42d6d3
Created June 13, 2021 07:00
log into a running docker container with root
docker exec -it --user root <container_id> /bin/bash
"C:\Program Files\MongoDB\Server\4.2\bin\mongod.exe" --service --dbpath="path\to\you\db" --replSet="rs0" --bind_ip="localhost"
mongod --dbpath "path\to\your\database\folder" --replSet rs0 --bind_ip localhost
db.getCollection('MongoSequence').insert( { sequence: "0", _id: "Job" } )
/*
* use serializable isolation level to prevent multiple threads from writing the
* same sequence id
*/
@Transactional(isolation = Isolation.SERIALIZABLE)
private Job saveJobWithSeqId(Job job) {
Optional<MongoSequence> collectionSequence = mongoSeqRepo.findById(MongoCollections.JOB.toString());
if (collectionSequence.isPresent()) {
MongoSequence seq = collectionSequence.get();
seq.setSequence(seq.getSequence() + 1);
@Data
@Document(collection = "Job")
@NoArgsConstructor
public class Job {
@Id
private String id;
private Long seqId;
private JobStatus status = JobStatus.AVAILABLE;
private Boolean isDeleted = Boolean.FALSE;
private String listedByPlayerId;