Skip to content

Instantly share code, notes, and snippets.

View flavienbwk's full-sized avatar

Flavien Berwick flavienbwk

  • Montréal, Canada
  • 13:30 (UTC -04:00)
View GitHub Profile
@ryochin
ryochin / Dockerfile
Last active February 5, 2023 22:27
openresty with ngx_http_proxy_connect_module
FROM debian:stable-slim
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential libssl-dev ca-certificates wget git \
libpcre3 libpcre3-dev zlib1g zlib1g-dev \
&& apt-get clean
WORKDIR /tmp
RUN git clone --depth=1 https://github.com/chobits/ngx_http_proxy_connect_module.git ngx_http_proxy_connect_module \
@diegopacheco
diegopacheco / latest-protobuf-ubuntu-18-04.md
Created June 7, 2018 20:13
How to Install Latest Protobuf on Ubuntu 18.04
sudo apt-get install autoconf automake libtool curl make g++ unzip -y
git clone https://github.com/google/protobuf.git
cd protobuf
git submodule update --init --recursive
./autogen.sh
make
make check
sudo make install
sudo ldconfig
@tiantuxu
tiantuxu / ffmpeg-common.sh
Last active April 6, 2024 02:29
Common ffmpeg Command Lines (with NVIDIA GPU Support)
# Decode a video to yuv420 raw format
ffmpeg -vsync 0 -c:v h264_cuvid -i input.mp4 -c:v rawvideo -pix_fmt yuv420p -f null /dev/null
ffmpeg -vsync 0 -c:v h264_cuvid -i input.mp4 -c:v rawvideo -pix_fmt yuv420p output.yuv
# Resize videos to 640x480
ffmpeg -c:v h264_cuvid -i input.mp4 -vf scale=640:480 -c:v h264_nvenc output.mp4
# Downsampling frame rate to 30fps
ffmpeg -i input.mp4 -r 30 -c:v h264_nvenc output.mp4
@erikyo
erikyo / Max_Dissolved_Oxigen.c
Created May 8, 2018 20:25
Max Dissolved Oxigen Saturation over a range of user-specified values for water temperature, barometric pressure, and salinity or specific conductance.
// --------- Max Dissolved Oxigen Saturation ------------//
//
// Equation for the Henry coefficient as a function of temperature and salinity is used to calculate values
// for unit standard atmospheric concentrations (USAC) in freshwater and seawater in equilibrium with air at a total pressure
// of 1 atmosphere. It is estimated that the possible error in the new USAC values is no greater than $\pm 0.1%$ and probably less.
// Tables and equations are presented for obtaining accurate USAC values in the ranges $0^\circ < t < 40^\cir C and 0 < S < 40$.
// Simple procedures are given for calculating standard atmospheric concentrations at pressures different from 1 atm.
//
// Reference https://water.usgs.gov/software/DOTABLES/
// Dissolved oxygen (DO) solubility over a range of user-specified values for
@jmbjorndalen
jmbjorndalen / asyncio_executors_threads_procs.py
Created April 26, 2018 08:10
Combining Python 3 asyncio coroutines with thread pool and process pool executors
#!/usr/bin/env python3
# Combining coroutines running in an asyncio event loop with
# blocking tasks in thread pool and process pool executors.
#
# Based on https://pymotw.com/3/asyncio/executors.html, but this version runs both
# threads and processes at the same time and interleaves them with asyncio coroutines.
#
# All appears to be working.
#
@nlohmann
nlohmann / remove_empty_elements.py
Created March 12, 2018 14:19
Remove empty arrays, objects or null elements from a JSON value
def remove_empty_elements(d):
"""recursively remove empty lists, empty dicts, or None elements from a dictionary"""
def empty(x):
return x is None or x == {} or x == []
if not isinstance(d, (dict, list)):
return d
elif isinstance(d, list):
return [v for v in (remove_empty_elements(v) for v in d) if not empty(v)]
# ---- Base python ----
FROM python:3.6 AS base
# Create app directory
WORKDIR /app
# ---- Dependencies ----
FROM base AS dependencies
COPY gunicorn_app/requirements.txt ./
# install app dependencies
RUN pip install -r requirements.txt
@ahadyekta
ahadyekta / convert
Created January 27, 2018 09:51
Batch convert JPG to WebP in Ubuntu
#First install the webp converter by this
sudo apt-get install webp
#go inside the directory where all images are there
#make sure all images are in RGB color mode, otherwise you will get error for CMYK images.
#Convert all images to RGB by this command (you should install ImageMagik to do that)
for f in *.jpg; do convert -colorspace RGB "$f" "${f}"; done
#finally convert all images to Webp format
@Remiii
Remiii / README.md
Created October 17, 2017 08:43
VPN (OpenVPN) server and clients setup 🚂🚇😀

VPN (OpenVPN) server and clients setup 🚂🚇😀

This gist give all the steps in order to build a VPN (OpenVPN) network with server and clients (automatic generation for clients certificates). 😀

  1. Server configuration
  2. Clients configuration
  3. Security
  4. Generate automatic certificates for clients

Server configuration

@joenas
joenas / matrix_synapse.nginx.conf
Last active May 14, 2021 16:53
Nginx example conf for Synapse matrix Homeserver
# vim: syntax=nginx
server {
listen 80;
server_name example.com www.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;