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
/** | |
* Restaurant CQRS and CDC Example | |
* | |
* This file demonstrates the Command Query Responsibility Segregation (CQRS) | |
* and Change Data Capture (CDC) patterns using a restaurant analogy. | |
*/ | |
// ===== Event Emitter (simulating a message bus) ===== | |
const EventEmitter = require('events'); |
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
class Stream { | |
constructor() { | |
this.source = []; // Queue to hold incoming events | |
this.operations = []; // List of transformations (filter, map) | |
this.reduction = null; // Stores reduction function (if any) | |
this.isProcessing = false; // Prevents duplicate processing | |
this.totals = {}; // Object to track totals by category | |
} | |
/** |
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.List; | |
class Solution { | |
public boolean canFinish(int numTasks, int[][] prerequisites) { | |
List<Integer>[] adjacencyList = new ArrayList[numTasks]; | |
int[] prereqCount = new int[numTasks]; | |
for (int i = 0; i < prerequisites.length; i++) { | |
if(adjacencyList[prerequisites[i][1]] == null) { | |
adjacencyList[prerequisites[i][1]] = new ArrayList<>(); | |
} |
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.List; | |
class Solution { | |
public boolean canFinish(int numTasks, int[][] prerequisites) { | |
... | |
for (int i = 0; i < numTasks; i++) { | |
if (adjacencyList[i] != null) { | |
return false; | |
} | |
} |
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.List; | |
class Solution { | |
public boolean canFinish(int numTasks, int[][] prerequisites) { | |
... | |
boolean proceed = true; | |
while (proceed) { | |
proceed = false; | |
for (int i = 0; i < numTasks; i++) { | |
if (prereqCount[i] == 0 && adjacencyList[i] != null) { |
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.List; | |
class Solution { | |
public boolean canFinish(int numTasks, int[][] prerequisites) { | |
List<Integer>[] adjacencyList = new ArrayList[numTasks]; | |
int[] prereqCount = new int[numTasks]; | |
for (int i = 0; i < prerequisites.length; i++) { | |
if(adjacencyList[prerequisites[i][1]] == null) { | |
adjacencyList[prerequisites[i][1]] = new ArrayList<>(); | |
} |
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
node { | |
size: 30px; | |
fill-color: #777; | |
z-index: 0; | |
} | |
edge { | |
shape: line; | |
fill-color: #222; | |
arrow-size: 8px, 5px; |
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
#!/bin/bash | |
usage() | |
{ | |
echo -e "Usage: $0 -i <input folder path containing files to append garbage> -b <garbage size>" \ | |
"\nExample Usage: ./append-garbage.sh -i ~/Pictures/000-large -b 10M" 1>&2; exit 1; | |
} | |
while getopts i:b: option | |
do | |
case "${option}" | |
in |
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
#!/bin/sh | |
usage() | |
{ | |
echo -e "Usage: $0 -i <input folder path containing files to search> -j <file name pattern> -p <pattern to search> -e <pattern to exclude from search results> -l <Character to compare for uniqueness> -f <Number of prefix fields to ignore while printing matching lines" \ | |
"\nExample Usage: ./count-pattern.sh -i /mnt/installation/crx-quickstart/logs -j *log* -p *ERROR* -e 'Non-existant pattern' -l 25 -f 6" 1>&2; exit 1; | |
} | |
while getopts i:j:p:e:l:f: option | |
do | |
case "${option}" | |
in |
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
#!/bin/sh | |
usage() | |
{ | |
echo -e "Usage: $0 -i <input folder path containing files to upload> -c <credentials of the server to upload to> -u <url to upload to>" \ | |
"\nExample Usage: ./upload-files.sh -i /src/folder -u http://server.com/path -c user:password" 1>&2; exit 1; | |
} | |
while getopts i:u:c: option | |
do | |
case "${option}" | |
in |
NewerOlder