Skip to content

Instantly share code, notes, and snippets.

View r6m's full-sized avatar
🏠
Working from home

Reza r6m

🏠
Working from home
  • localhost
View GitHub Profile
@r6m
r6m / bash.sh
Created February 25, 2017 13:36
convert images into video using ffmpeg
ffmpeg -i input.flv -vf fps=1 out%04d.png
# fps=1 (1 image per second)
# fps=2 (2 image per second)
# fps=1/60 (1 image per minute)
# fps=1/600 (1 image per 10 minutes)
@r6m
r6m / slice_exists.go
Last active November 10, 2019 23:53
golang check if item exists in slice
package main
import(
"fmt"
"reflect"
)
func main() {
items := []int{1,2,3,4,5,6}
fmt.Println(SliceExists(items, 5)) // returns true
@r6m
r6m / image.rb
Last active December 18, 2017 05:55 — forked from seancdavis/image.rb
Rails has_many :through Polymorphic Association (http://goo.gl/lxmehk)
# app/models/image.rb
class Image < ActiveRecord::Base
has_many :taggings, :as => :taggable
has_many :tags, :through => :taggings
end
@r6m
r6m / my-custom.cnf
Created December 22, 2017 16:19 — forked from pascalandy/my-custom.cnf
This mysql config is made to run within the official mysql container.
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
#
# _dockerfile/mysql/conf.d/my.cnf
# Last update: 2017-01-05_10h05
#
# This mysql config is made to run within the official mysql container.
# https://hub.docker.com/_/mysql/
#
# Inspired by:
# https://www.percona.com/blog/2016/10/12/mysql-5-7-performance-tuning-immediately-after-installation/
@r6m
r6m / bash.sh
Last active September 9, 2018 17:24
install docker & docker-compose on ubuntu 16.04 or newer
#### install docker on ubuntu 16.04 or newer ####
# update repository
sudo apt update
# Install packages to allow apt to use a repository over HTTPS:
sudo apt install \
apt-transport-https \
ca-certificates \
@r6m
r6m / main.go
Last active December 30, 2017 11:05
golang regex ip v4 & ip v6
package main
import(
"fmt"
"regexp"
)
const (
regexIPv4 = `(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})`
regexIPv6 = `((?:[0-9A-Fa-f]{1,4}))((?::[0-9A-Fa-f]{1,4}))*::((?:[0-9A-Fa-f]{1,4}))((?::[0-9A-Fa-f]{1,4}))*|((?:[0-9A-Fa-f]{1,4}))((?::[0-9A-Fa-f]{1,4})){7}`
@r6m
r6m / golang-json-stream-decoder
Created January 2, 2018 17:48 — forked from atedja/golang-json-stream-decoder
Example of using JSON Stream Decoder from STDIN
package main
import (
"encoding/json"
"fmt"
"os"
)
func main() {
decoder := json.NewDecoder(os.Stdin)
@r6m
r6m / Dockerfile
Created January 6, 2018 07:33
Laravel docker example
FROM php:7
RUN apt-get update -y && \
apt-get install -y \
openssl zip unzip git php7.0-mysql \
php7.0-cli php7.0-common \
mysql-client
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
@r6m
r6m / Dockerfile
Created January 8, 2018 21:38
golang multi stage docker build
## builder docker
FROM golang:1.9.2 as builder
WORKDIR /go/src/buddytest
copy ./ .
RUN curl https://glide.sh/get | sh
RUN glide install
RUN go test
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o app .
@r6m
r6m / Dockerfile
Last active January 22, 2018 06:41
goaccess Dockerfile
FROM debian:jessie
MAINTAINER Reza Morsali
# install dependencies
RUN apt-get update && apt-get install -y wget git autoconf build-essential gettext libgettextpo-dev libgeoip-dev libncursesw5-dev pkg-config libglib2.0 && git clone https://github.com/allinurl/goaccess.git && cd goaccess && autoreconf -fiv && ./configure --enable-geoip --enable-utf8 && make && make install && apt-get purge -y wget git autoconf build-essential libncursesw5-dev pkg-config && apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* && cd .. && rm -rf goaccess
RUN mkdir -p /home/root/www
RUN touch /home/root/www/report.html