Skip to content

Instantly share code, notes, and snippets.

View vchakoshy's full-sized avatar

Vahid Chakoshy vchakoshy

View GitHub Profile
@vchakoshy
vchakoshy / filter_bold.go
Last active June 14, 2021 18:57
Golang Gorm Gin simple list api
package api
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/spf13/cast"
)
type FilterBold struct {
@vchakoshy
vchakoshy / docker-compose.yml
Last active November 15, 2020 09:01
laravel docker compose and docker swarm with roll out and health check and cron jobs
version: "3.4"
services:
app:
image: appimage/master:stable # change me
ports:
- 8081:80
env_file:
- stage-prod.env
environment:
@vchakoshy
vchakoshy / Dockerfile
Created November 15, 2020 08:55
laravel production ready docker file
ARG PHP_EXTENSIONS="apcu bcmath opcache pcntl pdo_mysql redis zip sockets imagick gd exif soap remoteip json"
ARG APACHE_EXTENSIONS="remoteip"
FROM thecodingmachine/php:7.4-v3-apache as php_base
ENV TEMPLATE_PHP_INI=production
ENV APACHE_EXTENSION_REMOTEIP=1
ENV PHP_EXTENSION_GD=1
ENV PHP_INI_MEMORY_LIMIT=1g
ENV PHP_INI_MAX_EXECUTION_TIME=300
WORKDIR /var/www/html
COPY --chown=docker:docker . .
@vchakoshy
vchakoshy / national_code.js
Last active December 28, 2019 17:53
iran national code javascript validation
// refrence http://www.aliarash.com/article/codemeli/codemeli.htm
function checkNationalCode(code) {
var L = code.length;
if (L < 8 || parseInt(code, 10) == 0) return false;
code = ('0000' + code).substr(L + 4 - 10);
if (parseInt(code.substr(3, 6), 10) == 0) return false;
var c = parseInt(code.substr(9, 1), 10);
var s = 0;
for (var i = 0; i < 9; i++)
@vchakoshy
vchakoshy / Dockerfile
Created December 28, 2019 13:19
Docker apache php ffmpeg cuda gpu kubernetes
FROM nightseas/ffmpeg:latest AS ffdocker
FROM php:7.2-apache
# copy libs from ffmpeg
COPY --from=ffdocker /usr/local/bin/ffprobe /usr/local/bin/ffprobe
COPY --from=ffdocker /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg
COPY --from=ffdocker /usr/local/cuda-9.1 /usr/local/cuda-9.1
COPY --from=ffdocker /usr/local/bin/* /usr/local/bin/
COPY --from=ffdocker /usr/local/include/ffnvcodec /usr/local/include/
@vchakoshy
vchakoshy / reflect.go
Last active June 13, 2019 12:22
golang inject struct to another struct recursively
package main
import "reflect"
func InjectStrcut(a interface{}, b interface{}) {
v := reflect.ValueOf(a).Elem()
targetName := reflect.TypeOf(b).Name()
infector(v, b, targetName)
}
@vchakoshy
vchakoshy / update_golang.txt
Last active June 11, 2019 12:05
Update Golang to latest version
git clone https://github.com/udhos/update-golang
cd update-golang
sudo ./update-golang.sh
@vchakoshy
vchakoshy / constructor.go
Created June 3, 2019 11:26
Golang Functional Constructor
package main
// for more information please look at:
// https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis
// https://www.reddit.com/r/golang/comments/6mtbx9/useful_constructors_in_go/
// OutputComponent struct
type OutputComponent struct {
Title string `json:"title,omitempty"`
Icon string `json:"icon,omitempty"`