Skip to content

Instantly share code, notes, and snippets.

View euclid1990's full-sized avatar
🍔
Code for food

Nguyen Van Vuong (Vic) euclid1990

🍔
Code for food
View GitHub Profile
@linxGnu
linxGnu / workerpool.go
Created February 19, 2019 09:55
We will publish this code soon. This code is a worker pool power many products at LINE Corp. Please respect to the copyright.
// Copyright 2019 LINE Corporation
//
// LINE Corporation licenses this file to you 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
@thatisuday
thatisuday / fan-in-fan-out.go
Created November 19, 2018 15:32
fan-in and fan-out concept in go lang
package main
import (
"fmt"
"sync"
)
// return channel for input numbers
func getInputChan() <-chan int {
// make return channel
input := make(chan int, 100)
@huahuayu
huahuayu / port_config.json
Created August 13, 2018 14:27
阿里云vpn端口配置(开放UDP 500和4500端口)
[
{
"SourceCidrIp": "0.0.0.0/0",
"DestCidrIp": "",
"Description": "vpn",
"NicType": "intranet",
"DestGroupName": "",
"PortRange": "4500/4500",
"DestGroupId": "",
"Direction": "ingress",
@mjohnsullivan
mjohnsullivan / incrementer_snackbar.dart
Created July 3, 2018 00:29
The classic Flutter incrementer app with added SnackBar
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Snackbars',
theme: ThemeData(
@holmberd
holmberd / php-pools.md
Last active April 19, 2024 07:24
Adjusting child processes for PHP-FPM (Nginx)

Adjusting child processes for PHP-FPM (Nginx)

When setting these options consider the following:

  • How long is your average request?
  • What is the maximum number of simultaneous visitors the site(s) get?
  • How much memory on average does each child process consume?

Determine if the max_children limit has been reached.

  • sudo grep max_children /var/log/php?.?-fpm.log.1 /var/log/php?.?-fpm.log
@kekru
kekru / 1-Enable Docker Remote API with TLS client verification.md
Last active January 11, 2024 18:21
Docker Remote API with client verification via daemon.json

Enable Docker Remote API with TLS client verification

Docker's Remote API can be secured via TLS and client certificate verification.
First of all you need a few certificates and keys:

  • CA certificate
  • Server certificate
  • Server key
  • Client certificate
  • Client key

Create certificate files

version: '3.1'
services:
helloworld:
image: muresan/node-helloworld:${TAG:-1.0}
deploy:
labels:
traefik.port: "3000"
traefik.protocol: "http"
traefik.backend.loadbalancer.sticky: "true"
@kiki67100
kiki67100 / ffmpeg_hardware_acceleration_h264_videotoolbox.bash
Created July 25, 2017 08:15
ffmpeg hardware accelaration mac os
#!/bin/bash
#Verify the quality with difference bitrate ( crf no work with h264_videotoolbox use -b:v )
#You can use the same audio codec change -c:a ac3 to -c:a copy i use it because it work my multimedia player
for bitrate in 500k 1000k 1500k 2500k 3000k 3500k;do
ffmpeg -i Movie.mkv -c:v h264_videotoolbox -c:a ac3 -b:a 128k -y -b:v $bitrate -ss 00:01:00 -t 00:00:10 Movie_$bitrate.mp4;
done
#With 2500k bitrate
ffmpeg -i Movie.mkv -c:v h264_videotoolbox -c:a ac3 -b:a 128k -y -b:v $bitrate -b:a 128k Movie_$bitrate.mp4;
@ngse
ngse / audit_mixin.py
Last active May 21, 2023 13:56
Rough attempt at implementing an audit log against Flask/Flask Login/SQLAlchemy models
# Requires use of Flask Login for the user tracking
# Implement by using AuditableMixin in your model class declarations
# e.g. class ImportantThing(AuditableMixin, Base):
import json
from flask_login import current_user
from sqlalchemy import event, inspect
from sqlalchemy.orm import class_mapper
from sqlalchemy.orm.attributes import get_history
@alexei-led
alexei-led / create_swarm_cluster.sh
Last active April 15, 2024 20:45
Deploy Docker Compose (v3) to Swarm (mode) Cluster
#!/bin/bash
# vars
[ -z "$NUM_WORKERS" ] && NUM_WORKERS=3
# init swarm (need for service command); if not created
docker node ls 2> /dev/null | grep "Leader"
if [ $? -ne 0 ]; then
docker swarm init > /dev/null 2>&1
fi