This file contains hidden or 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
/* | |
Original problem from LeetCode: Course Schedule II | |
Leetcode Link: https://leetcode.com/problems/course-schedule-ii/ | |
*/ | |
// Approach-1 (Using BFS Topological Sort Concept) | |
import java.util.*; | |
class Solution { | |
// Using Kahn's algorithm |
This file contains hidden or 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
//Credits: https://medium.com/@surajshende247/token-bucket-algorithm-rate-limiting-db4c69502283 | |
import { CronJob } from 'cron'; | |
import express from 'express'; | |
const app = express(); | |
app.use(express.json()); | |
const PORT = process.env.PORT || 5000; |
This file contains hidden or 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
package org.example; | |
import org.apache.zookeeper.*; | |
import java.io.IOException; | |
import java.util.List; | |
import java.util.UUID; | |
public class Locks { | |
static ZooKeeper zooKeeper; |
This file contains hidden or 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
| AWS | | | |
| -------------------------------------------------------------------------------- |-----------------------------------------------------------------------------| | |
| API Gateway | ALB | | |
| Manages the routing and processing of API requests from clients | Distributes incoming traffic across multiple instances of service | | |
| Can implement rate limiting, bursting for APIs | No rate limiting, bursting capability | | |
| Not possible to get a static IP addresss for endpoint (always a URL) | Possible to get a static IP address for load balancer endpoint | | |
| Accepts HTTPS traffic |
This file contains hidden or 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
/* Producer Consumer */ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <pthread.h> | |
#define BUF_SIZE 3 /* Size of shared buffer */ | |
int buffer[BUF_SIZE]; /* shared buffer */ | |
int add = 0; /* place to add next element */ |
This file contains hidden or 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
/* PThread Creation Quiz 3 */ | |
#include <stdio.h> | |
#include <pthread.h> | |
#define NUM_THREADS 4 | |
void *threadFunc(void *pArg) { /* thread main */ | |
int myNum = *((int*)pArg); | |
printf("Thread number %d\n", myNum); |
This file contains hidden or 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
/* A Slightly Less Simple PThreads Example */ | |
#include <stdio.h> | |
#include <pthread.h> | |
#define NUM_THREADS 4 | |
void *threadFunc(void *pArg) { /* thread main */ | |
int *p = (int*)pArg; | |
int myNum = *p; |
This file contains hidden or 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
/* PThread Creation Quiz 1 */ | |
#include <stdio.h> | |
#include <pthread.h> | |
#define NUM_THREADS 4 | |
void *hello (void *arg) { /* thread main */ | |
printf("Hello Thread\n"); | |
return 0; |
This file contains hidden or 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
/* PThread Creation */ | |
#include <stdio.h> | |
#include <pthread.h> | |
void *foo (void *arg) { /* thread main */ | |
printf("Foobar!\n"); | |
pthread_exit(NULL); | |
} |
This file contains hidden or 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
from __future__ import print_function | |
from threading import Thread | |
from datetime import datetime | |
def sum(results, thread_id, SUM_RANGE): | |
print(thread_id, SUM_RANGE) | |
sum = i = 0 | |
start = thread_id * SUM_RANGE |