Skip to content

Instantly share code, notes, and snippets.

View akazuko's full-sized avatar
🎯
Focusing

AYUSH SHARMA akazuko

🎯
Focusing
  • Microsoft | Nutanix | BITS Pilani
  • India
View GitHub Profile
@akazuko
akazuko / blog-leader-election-my-app-concrete-with-main.cpp
Last active May 23, 2021 18:33
Show the concrete app with main func for leader election blog on medium
#include <iostream>
#include <memory>
#include <chrono>
#include "etcd/Client.hpp"
#include "etcd/KeepAlive.hpp"
#include "etcd/Watcher.hpp"
using namespace std::chrono_literals;
@akazuko
akazuko / blog-leader-election-my-app-concrete.cpp
Last active May 23, 2021 18:04
Show the concrete app for leader election blog on medium
using namespace std::chrono_literals;
std::string ELECTIONKEY = "MyApp/leader";
class MyApp
{
public:
MyApp(const char* etcdConnectionString, std::string id)
: m_id(std::move(id)), m_leaderId("")
{
@akazuko
akazuko / blog-leader-election-my-app-skeleton.cpp
Last active May 23, 2021 17:05
Show the skeleton app for leader election blog on medium
class MyApp
{
public:
MyApp(const char* etcdConnectionString, std::string id);
~MyApp();
bool isLeader();
std::string& GetID();
@akazuko
akazuko / timeout_checker.rs
Created May 31, 2020 21:19
Implementing a timeout checker in rust
use std::sync::mpsc::{RecvTimeoutError};
use std::sync::mpsc;
use std::thread;
use std::time::{Duration};
use std::result::{Result};
fn actual_fn() -> i32{
thread::sleep(Duration::from_millis(5001));
1
}
@akazuko
akazuko / custom-default-network-docker-compose.yaml
Last active March 24, 2020 23:47
custom-default-network-docker-compose
version: '3.5'
services:
selenium:
image: selenium/standalone-chrome-debug
ports:
- 4444:4444
- 5900:5900
networks:
@akazuko
akazuko / blog-traefik-auth-traefik.toml
Created December 14, 2019 22:38
blog-traefik-auth-traefik.toml
[log]
level = "debug"
[serversTransport]
insecureSkipVerify = true
[api]
insecure = true
dashboard = true
debug = true
@akazuko
akazuko / blog-traefik-auth-docker-compose.yaml
Created December 14, 2019 22:37
blog-traefik-auth-docker-compose
version: '3'
services:
reverse-proxy:
image: traefik:v2.0
ports:
- "80:80"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
@akazuko
akazuko / auth-main.py
Created December 14, 2019 22:00
traefik blog auth service flask app
import json
from datetime import datetime
from flask import (
Flask, url_for,
jsonify, request,
redirect
)
from authlib.integrations.flask_client import OAuth
@akazuko
akazuko / micro-service-foo.py
Last active December 14, 2019 20:43
traefik blog: micro-service A
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return "<p>Hello, I am service foo!</p>"
if __name__ == '__main__':
app.run(
@akazuko
akazuko / django_util.md
Last active March 3, 2019 17:14
How to use mongoengine with newer versions of Django

MongoDB user authentication work around in Django 1.10 and mongengine 0.8 MongoEngine/mongoengine#966

Changes that are to be made to make login work with MongoDB:

  • in django.auth.init.py
    from bson.objectid import ObjectId
    def _get_user_session_key(request):
        # This value in the session is always serialized to a string, so we need