Skip to content

Instantly share code, notes, and snippets.

View rrmerugu's full-sized avatar
🎯
Focusing

Ravi Raja Merugu rrmerugu

🎯
Focusing
View GitHub Profile
@rrmerugu
rrmerugu / state.js
Created March 5, 2024 08:03 — forked from dbisso/state.js
Simple state management in vanilla JS
function State() {
this.actions = {};
this.subscriptions = [];
this.history = [];
}
State.prototype.subscribe = function(element, action, callback) {
this.subscriptions[action] = this.subscriptions[action] || [];
this.subscriptions[action].push(function(data) {
callback.apply(element, data);
@rrmerugu
rrmerugu / k3s-cluster.md
Created January 3, 2023 19:17 — forked from kopwei/k3s-cluster.md
K3s and Rancher on Raspberry Pi 4 Cluster

Deploy K3s and Rancher on Raspberry Pi 4 cluster

Today I tried to setup a small Kubernetes cluster on top of 3 Raspberry Pi 4 (4GB Memory). Here is the steps to install the cluster.

IMG_3817

Preparation

I have 3 Raspberry Pi 4 stacked with PoE headers and connected to a PoE switch at home. The are connected to Internet through a home router. All Pis are equipped with a 64GB Samsung SDXC card flushed with Ubuntu 20.04 image.

@rrmerugu
rrmerugu / gremlin with aiohttp.py
Created February 22, 2022 08:15
gremlin with aiohttp.py
import aiohttp
import asyncio
async def async_processing():
async with aiohttp.ClientSession() as session:
async with session.ws_connect('ws://192.168.0.10:8182/gremlin') as ws:
message = b'!application/vnd.gremlin-v3.0+json{"requestId": {"@type": "g:UUID", "@value": "16f19ea9-3d61-45b5-b823-7f67199ff1b2"}, "processor": "traversal", "op": "bytecode", "args": {"gremlin": {"@type": "g:Bytecode", "@value": {"step": [["V", "98528"], ["valueMap", true]]}}, "aliases": {"g": "g"}}}'
await ws.send_bytes(message)
async for msg in ws:
@rrmerugu
rrmerugu / websocket test.py
Created February 22, 2022 08:14
gremlin query with web sockets
import asyncio
import websockets
class WebsocketHandler(object):
def __init__(self):
self.conn = None
async def connect(self, url):
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
from gremlin_python.process.anonymous_traversal import traversal
from gremlin_python.process.traversal import Order
class GraphConnection:
def __init__(self, gremlin_url):
self.connection = DriverRemoteConnection(
gremlin_url
# start GremlinServer
# bin/gremlin-server.sh -i org.apache.tinkerpop gremlin-python 3.2.2-SNAPSHOT
# bin/gremlin-server.sh conf/gremlin-server-modern-py.yaml
from gremlin_python.process.graph_traversal import GraphTraversal
from gremlin_python.process.graph_traversal import GraphTraversalSource
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.traversal import Operator
from gremlin_python.structure.io.graphson import GraphSONReader
@rrmerugu
rrmerugu / ngrok setup.txt
Last active February 17, 2022 19:36
ngrok setup as service
```bash
snap install ngrok
```
#/home/user/.ngrok2/ngrok.yml
```
authtoken: xyz-secret-from-ngrok
tunnels:
ssh:
proto: tcp
docker run -e DS_LICENSE=accept -p 8888:8888 --name local-dse-opscenter -d datastax/dse-opscenter:6.8.14
docker run -e DS_LICENSE=accept -p 8182:8182 --link local-dse-opscenter:opscenter --name local-dse-server -d datastax/dse-server:6.8.14
docker run -e DS_LICENSE=accept -p 9091:9091 --link local-dse-server --name local-dse-studio -d datastax/dse-studio:6.8.14
@rrmerugu
rrmerugu / gist:66ab13d5851dcb945ea62b025859ed2c
Created May 25, 2020 19:16
ubuntu 20.04 dark theme issue fix
sudo apt purge ubuntu-session yaru-theme-gnome-shell yaru-theme-gtk yaru-theme-icon yaru-theme-sound
sudo apt install ubuntu-session yaru-theme-gnome-shell yaru-theme-gtk yaru-theme-icon yaru-theme-sound
https://bugs.launchpad.net/ubuntu/+source/yaru-theme/+bug/1798984/comments/5
@rrmerugu
rrmerugu / gist:fd24f447bb7e23d51c9be843dbe20219
Created April 1, 2020 14:50
register classes to a dictionary
registry = {}
def register_microservice(cls):
name = cls.__name__
force_bound = False
if '__init__' in cls.__dict__:
cls.__init__.func_globals[name] = cls
force_bound = True
try: