Skip to content

Instantly share code, notes, and snippets.

@cspinetta
cspinetta / docker-compose.yml
Created May 21, 2020 12:26
Promtail example extracting data from json log
version: "3.6"
services:
promtail:
image: grafana/promtail:1.4.0
container_name: promtail
command: [ "-config.file=/etc/promtail/local-config.yaml" ]
volumes:
- './promtail.yml:/etc/promtail/local-config.yaml:ro'
- '__path_to_logs_directory__:/app/log:ro'
@igorzakhar
igorzakhar / README.md
Last active April 6, 2021 07:10
aiohttp stream response example

Сервер на aiohttp, который стримит текущее серверное время.

Как запустить:

python server.py

Откройти в браузере страницу http://127.0.0.1:8080/, на ней отобразится время. Каждую секунду будет добавляться новая запись о времени:

@s3rvac
s3rvac / limit-virtual-memory-of-subprocess.py
Created May 3, 2018 07:54
Limits the maximal virtual memory for a subprocess in Python on Linux.
#!/usr/bin/env python3
#
# Limits the maximal virtual memory for a subprocess in Python.
#
# Linux only.
#
import subprocess
import resource
@virolea
virolea / upload.js
Last active October 10, 2024 15:11
Tracking file upload progress using axios
upload(files) {
const config = {
onUploadProgress: function(progressEvent) {
var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total)
console.log(percentCompleted)
}
}
let data = new FormData()
data.append('file', files[0])
@styblope
styblope / docker-api-port.md
Last active November 15, 2024 23:06
Enable TCP port 2375 for external connection to Docker

Enable TCP port 2375 for external connection to Docker

See this issue.
Docker best practise to Control and configure Docker with systemd.

  1. Create daemon.json file in /etc/docker:

     {"hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]}
    
@t-io
t-io / xvfb_screen_recording.py
Created November 17, 2017 10:34
ScreenRecording xvfb
from selenium import webdriver
import sys, getopt, time, subprocess, shlex
from xvfbwrapper import Xvfb
def run():
print('Sreencast website animation')
xvfb = Xvfb(width=1280, height=720, colordepth=24)
xvfb.start()
@mosquito
mosquito / proxy.py
Last active May 5, 2022 05:25
AIOHTTP async proxy streaming
import platform
import unittest
from http import HTTPStatus
from urllib.parse import urlencode, unquote
import aiohttp
import asynctest
from aiohttp import web
from aiohttp.test_utils import TestClient
from multidict import MultiDict
@NickNaso
NickNaso / proxy.js
Last active January 25, 2023 18:40
Log or modify the request body in the node-http-proxy before to pass it to the express.js application
/*******************************************************************************
* Copyright (c) 2017 Nicola Del Gobbo
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the license at http://www.apache.org/licenses/LICENSE-2.0
*
* THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
* IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
* MERCHANTABLITY OR NON-INFRINGEMENT.
@doobeh
doobeh / vort.html
Created March 2, 2016 19:40
DatePicker JS Example Flask
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>DatePicker Example</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script>
@Humerus
Humerus / index.html
Created April 16, 2015 00:09
Docker Exec Web Console
<html>
<head>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<script src="//cdn.rawgit.com/chjj/term.js/0b10f6c55d5113d50d0ff94b6c38a46375a5f9a5/src/term.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>