Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ajeetraina's full-sized avatar
💭
Whalify Yourself !

Ajeet Singh Raina, Docker Captain, ARM Innovator, ajeetraina

💭
Whalify Yourself !
View GitHub Profile
@ajeetraina
ajeetraina / gist:6891f1562b09182eabf16d8650ca5e4f
Last active January 16, 2022 09:46
Getting Started with Redis using Docker Container
Redis is basically an open source, in-memory, data structure store that can be used as a cache, primary database and message broker. It is a multi-model database that supports search, graph, real-time streaming, analytics and many other use cases beyond that of a simple data store. With over 52,000+ GitHub stars, 20,000+ forks and over 500+ contributors, Redis is quite popular among the developers. Redis gives developers building applications the tools and information they need in a very efficient manner. Redis today can be deployed on-premises, across clouds, hybrid environments as well as over the Edge devices flawlessly.
# Ensure that Docker is installed
docker -v
# Create a dedicated Docker network
% docker-compose ps
NAME COMMAND SERVICE STATUS PORTS
compose-adapter-1 "/adapter/redis-ts-a…" adapter running
compose-grafana-1 "/run.sh" grafana running 0.0.0.0:3000->3000/tcp
compose-prometheus-1 "/bin/prometheus - c…" prometheus running 0.0.0.0:9090->9090/tcp
compose-redis-1 "docker-entrypoint.s…" redis running 0.0.0.0:6379->6379/tcp
@ajeetraina
ajeetraina / gist:efe01e4282fbfa59f18d38c36b57488f
Created January 14, 2022 05:26
Docker Compose for Monitoring Prometheus and Grafana
version: '3'
services:
prometheus:
image: "prom/prometheus:v2.8.0"
command: [" - config.file=/prometheus.yml"]
volumes:
- ./prometheus.yaml:/prometheus.yml
ports:
- 9090:9090
adapter:
@ajeetraina
ajeetraina / gist:35a69298c854826d1062292b038943d0
Created December 7, 2021 10:33
Rate Limiting using Go over OpenShift Sandbox
98 lines
Cloning "https://github.com/redis-developer/basic-redis-rate-limiting-demo-go-lang" ...
Commit: 0fae74a58a4a90c0c375f5b9125ca141933ef8ee (Added)
Author: ajeetraina <ajeetraina@gmail.com>
Date: Wed Aug 25 07:47:10 2021 +0530
time="2021-12-07T10:29:49Z" level=info msg="Not using native diff for overlay, this may cause degraded performance for building images: kernel has CONFIG_OVERLAY_FS_REDIRECT_DIR enabled"
I1207 10:29:49.472081 1 defaults.go:102] Defaulting to storage driver "overlay" with options [mountopt=metacopy=on].
Caching blobs under "/var/cache/blobs".
Pulling image golang ...
How to create a powerful drone system using Redis to protect crop insurers from false claims
Innovating at Enterprise Pace
How to Build a Squad Health Check Application with Redis
Guest Post: How Redis Is Enabling the Future of Real-Time AI
How to build a Real-Time Geo-distributed Multiplayer Top-down arcade shooting game using Redis
Create a Real-time Vehicle Tracking System with Redis
Introducing Redis Launchpad
The “Impedance Mismatch Test”: Is Your Data Platform Simple or a Complex Mess?
RedisMart: A Fully-Featured Retail Application With Redis
Indexing, Querying, and Full-Text Search of JSON Documents with Redis
@ajeetraina
ajeetraina / hit.txt
Created October 1, 2021 08:43
Player Hit Function
def hit(self, game_id, user_id, enemy_user_id):
"""
Determines if the projectile has hit a user [user_id]
Extrapolates projectile position based on when projectile has spawned, and the time now.
Publishes a hit even if target is hit.
"""
projectiles = self.games_states[game_id]["projectiles"]
player = self.games_states[game_id]["players"][enemy_user_id]
for projectile in projectiles:
@ajeetraina
ajeetraina / player_function.txt
Created October 1, 2021 08:43
Player Functions
def click(self, game_id, user_id, x, y, o):
"""
Handle player main key pressed event.
"""
player = self.games_states[game_id]["players"][user_id]
self.games_states[game_id]["projectiles"].append({
"timestamp": self.ts, # server time
"x": player["x"] if player['x'] is not None else 9999,
"y": player["y"] if player['y'] is not None else 9999,
@ajeetraina
ajeetraina / leave_game.txt
Created October 1, 2021 08:41
Leave Game Function
class LeaveGameFunctionBuilder(BaseFunctionBuilder):
def __init__(self):
super().__init__(command_name='leave_game')
def register_command(self):
"""
Determines best public server to join to.
- Removes USER to the ROOM.
- Decrements playercount
- Publishes a notification
@ajeetraina
ajeetraina / join_game.txt
Created October 1, 2021 08:40
Join Game Function
class JoinGameFunctionBuilder(BaseFunctionBuilder):
def __init__(self):
super().__init__(command_name='join_game')
def register_command(self):
"""
Determines best public server to join to.
- Assings User to the Game.
- Increments playercount
Arguments:
@ajeetraina
ajeetraina / create_user_function.txt
Created October 1, 2021 08:38
Create User Function
class CreateUserFunctionBuilder(BaseFunctionBuilder):
def __init__(self):
super().__init__(command_name='create_new_user')
def register_command(self):
"""
Registers create_new_user redis gears fucntion to redis.
For each create_new_user call creates a new HASH under user namespace:
USER:[u_id] name [str], settings [str], secret [str]