Skip to content

Instantly share code, notes, and snippets.

View razorcd's full-sized avatar

Cristian Dugacicu razorcd

View GitHub Profile
@razorcd
razorcd / diagram2_QuickSolution1.md
Created November 22, 2020 21:34
Scaling reactive APIs with Redis-Streams - www.razorcodes.com
Kafka Topic A, Partition 3 --> Service Instance 2 --> internal Kafka topic +---> Service Instance 1 --> Event stream listener /customer1
                                                                            `--> Service Instance 2
@razorcd
razorcd / diagram1_start.md
Last active November 22, 2020 21:33
Scaling reactive APIs with Redis-Streams - www.razorcodes.com
                       +----------------------------+
                       | Kafka Topic A, Partition 1 +------.    +--------------+                     +-----------+
                       +----------------------------+       `-->+   Service    |                     |           |
                                                                |  Instance 1  +<---------------+    |           |         API HTTP request
                       +----------------------------+       ,-->+              |                |    |           +<----- Event stream listener
                       | Kafka Topic A, Partition 2 +------`    +--------------+                |    |    API    |            /customer1
                       +----------------------------+                                           +----+  Gateway  |
                                                                +--------------+                     |           |
                       +----------------------------+           |   Service    |DataUp
@razorcd
razorcd / install-rabbitmq.sh
Created October 5, 2018 08:14 — forked from yetanotherchris/install-rabbitmq.sh
RabbitMQ on Docker with admin UI
# AWS specific install of Docker
sudo yum update -y
sudo yum install -y docker
sudo service docker start
sudo usermod -a -G docker ec2-user
# exit the SSH session, login again
# Docker
docker run -d --hostname my-rabbit --name some-rabbit -p 4369:4369 -p 5671:5671 -p 5672:5672 -p 15672:15672 rabbitmq
@razorcd
razorcd / custom_flux_emitter.java
Created August 20, 2018 16:10
Flux: custom emitter simulation
/**
* Custom emitter.
*/
@GetMapping(value = "/custom-emitter", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<String> getCustomEmitter() {
EmitterProcessor<String> hotSource = EmitterProcessor.create();
Flux<String> hotFlux = hotSource.publish().autoConnect();
@razorcd
razorcd / es_create_document.md
Last active August 2, 2018 07:59
Elasticsearch - CRUD document sync

CREATE

POST localhost:9200/index/type?refresh

{
  "ssoId": "s0000000001",
  "externalSsoType": "U",
  "socketNumber": "s0000000001",
  "deviceNote": null,
 "isTaken": null,
-- MIGRATION1: (copy data)
-- create new table
CREATE TABLE cdm.adresses (
id BIGINT(20) AUTO_INCREMENT PRIMARY KEY,
enrichment_erp_id BIGINT(20) UNIQUE NOT NULL,
latitude DECIMAL(20,6) NOT NULL,
longitude DECIMAL(20,6) NOT NULL,
zip_code VARCHAR(20) NOT NULL,
street VARCHAR(255),
@razorcd
razorcd / gist:f44320c64347bd09943d625322485b6b
Created June 16, 2018 22:58 — forked from psayre23/gist:c30a821239f4818b0709
Runtime Complexity of Java Collections
Below are the Big O performance of common functions of different Java Collections.
List | Add | Remove | Get | Contains | Next | Data Structure
---------------------|------|--------|------|----------|------|---------------
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array
@razorcd
razorcd / create_user.commands
Last active June 20, 2018 12:43
create user in mongo db
//login as admin using the db where the admin user is defined
mongo --port 27017 -u "admin" -p "admin" --authenticationDatabase "admin"
// or the default:
mongo --port 27017 -u "root" -p "password" --authenticationDatabase "root"
//list all system users:
db.system.users.find()
@razorcd
razorcd / parse.js
Created March 23, 2018 23:47
Log parser
var fs = require('fs');
var content = readFile("19_3_2018log.txt");
var allLines = getLines(content);
console.log("All lines:");
console.log(allLines);
var result = allLines.map(line => parseLineToObject(line));
console.log("Result:");
console.log(result);
@razorcd
razorcd / subtree_merge.sh
Last active January 14, 2018 20:48
Git Subtree merging while keeping the commits
# add remote repo from another filepath:
git remote add -f springBootSippetsFullRepo ../1/spring-boot-snippets-full-folder
# merge to current master (will not messup original files)
git merge -s ours springBootSippetsFullRepo/master
# move new repo in a subfolder:
git read-tree --prefix=springBootSnippets -u springBootSippetsFull/master
# comit new folder: