Skip to content

Instantly share code, notes, and snippets.

View kunthar's full-sized avatar
🖖
live long and prosper

Gokhan Boranalp kunthar

🖖
live long and prosper
View GitHub Profile
@kunthar
kunthar / llist_ops.py
Last active August 6, 2020 20:02
Create a linkedlist and remove dups from llist
"""
There is no direct implementation of Linkedlist in Python even in 3. So we have to implement it first.
Please note that we have a collections.deque class but delete operation is nearly the same polynomial time bruh.
To get more detail on this please read here:
https://realpython.com/linked-lists-python/
"""
class Node:
def __init__(self, data):
self.data = data
@kunthar
kunthar / gist:e7aa391719f93722f7bc73c23175d745
Created June 30, 2020 09:07
Prometheus global config example Mariadb Galera, Redis, Haproxy, Gluster
# my global config
global:
scrape_interval: 60s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 60s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
@kunthar
kunthar / colorscale.sh
Created May 27, 2020 21:49
show colorscale of xterm
#!/bin/bash -
#title :colorscale.sh
#description :Show a rainbow of colors.
#author :bgw
#date :20111002
#version :0.1
#usage :./colorscale.sh
#notes :
#bash_version :4.1.5(1)-release
@kunthar
kunthar / shell.sh
Created March 28, 2020 10:24
Linux sh*te can't remember on time @kunthar
vim line nums
================
set nu
set nonumber
find greater than
=================
find . -type f -size +600MB
.bash_profile
@kunthar
kunthar / messaging_jobs.py
Created February 22, 2020 22:09
ROC Messaging Job Worker
# -*- coding: utf-8 -*-
from zopsm.workers.base_jobs import BaseWorkerJobs
from zopsm.lib.log_handler import zlogger
from datetime import datetime
from zopsm.lib.utility import generate_uuid
from zopsm.lib.settings import DATETIME_FORMAT
from zopsm.lib.settings import CACHE_ONLINE_SUBSCRIBERS
from zopsm.lib.settings import CACHE_IDLE_SUBSCRIBERS
from zopsm.lib.settings import CACHE_STATUS
@kunthar
kunthar / contact_request.py
Created February 22, 2020 22:04
ROC Resource Contact Request
from falcon import HTTPBadRequest, HTTPMethodNotAllowed
from zopsm.lib.rest.fields import ZopsStringField, ZopsAlphaNumericStringField
from zopsm.lib.rest.parameters import ZopsBooleanParam
from zopsm.lib.rest.serializers import ZopsBaseDBSerializer
from zopsm.roc.validators import invite_approve_validator
from zopsm.lib.rest.custom import ZopsRetrieveUpdateDeleteApi, \
ZopsContinuatedListCreateApi
from zopsm.lib.cache.subscriber_cache import SubscriberCache
@kunthar
kunthar / server.py
Created February 22, 2020 21:56
MSA Example ROC Server
import falcon
import consul
import os
from graceful.authentication import Token
from zopsm.lib.rest.authentication import ZopsKeyValueUserStorage
from zopsm.lib.rest.response_logger import ResponseLoggerMiddleware
from zopsm.roc.resources.banned_channel import BannedChannel, BannedChannelList
from zopsm.roc.resources.banned_contact import BannedContact, BannedContactList
from zopsm.roc.resources.channel import Channel, ChannelList
from zopsm.roc.resources.contact import Contact
FROM python:3.6-jessie
ENV LANG C.UTF-8
ENV TZ=Europe/Istanbul
RUN apt-get update && apt-get install -y gcc musl-dev libpq-dev git libjpeg-dev zlib1g-dev libffi-dev libxml2-dev libxslt1-dev vim xfonts-75dpi xfonts-base
RUN pip3 install --upgrade virtualenv \
&& virtualenv zarupa-venv
COPY entrypoint.sh /entrypoint.sh
@kunthar
kunthar / entrypoint.sh
Created February 15, 2020 11:33
Zarupa entrypoint.sh example
#!/bin/bash
. /zarupa-venv/bin/activate
#git clone https://github.com/kunthar/zarupa
pip install -r /zarupa/requirements.txt
pip install gunicorn
export FLASK_APP=/zarupa/zarupa/server.py
export FLASK_CONFIGURATION=production
export POSTGRES_USER=zarupa
export POSTGRES_PASSWORD=
export POSTGRES_HOST=
@kunthar
kunthar / docker-compose.yml
Created October 12, 2019 14:57
postgresql docker compose file
version: '3'
services:
db:
image: postgres:12
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgress
- POSTGRES_DB=postgres
ports: