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 September 9, 2018 15:50
docker expose api and TCP
sudo systemctl edit docker
# add the following lines to opened file
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock
sudo systemctl daemon-reload
sudo systemctl restart docker
@r6m
r6m / bash.sh
Created September 6, 2018 09:48
Dokku golan glide private repo
// https://github.com/heroku/heroku-buildpack-go#private-git-repos
// every period (.) must be replaced with underscore (_)
dokku config:set --global GO_GIT_CRED__<PROTOCOL>__<HOSTNAME>=<TOKEN>
// dokku config:set --global GO_GIT_CRED__HTTPS__GITHUB__COM=<TOKEN>
-- create user
create user user;
-- check user
select user, host, password from mysql.user;
-- set password
use mysql;
update user set password=PASSWORD("secret") where User='user';
@r6m
r6m / template.tmpl
Last active June 9, 2018 15:12
golang template using delimeter
{{$equipment := .Equipment}}
{{ range $index, $element := .Equipment}}
{{if $index}},{{end}}
{{$element.Name}}
{{end}}
// or if it's an array
// then register a function using template.Funcs(templte.FuncMap{"Join", strings.Join})
{{ Join .Array ", " }}
@r6m
r6m / get_topic.lua
Created April 23, 2018 13:48
module
local function get_topic(context, payload)
local query = "SELECT * from game_topics WHERE id = $1"
local parameters = {payload.id}
local ok, rows = pcall(nk.sql_query, query, parameters)
if ok then
return { topic = rows[1] }
else
error(rows)
return { status = "error", error = rows}
@r6m
r6m / divisors.py
Last active April 15, 2018 21:17
find integer with most divisors
my_list = [int(i) for i in input().split(' ')] # get items from input with spaces between
def find_integer_with_most_divisors(input_list):
num, div = 0, 0 # tmp
for item in my_list: # iterate list
div_count = 0
for i in range(1, item + 1): # genrate numbers
if item % i == 0: # check divisor
div_count += 1
@r6m
r6m / cloudSettings
Last active April 9, 2018 08:39
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-04-09T08:39:39.707Z","extensionVersion":"v2.9.0"}
@r6m
r6m / dockergrep.sh
Created January 27, 2018 07:13 — forked from roylee0704/dockergrep.sh
how to grep docker log
docker logs nginx 2>&1 | grep "127."
# ref: http://stackoverflow.com/questions/34724980/finding-a-string-in-docker-logs-of-container
@r6m
r6m / shell_output.go
Created January 23, 2018 07:38 — forked from hivefans/shell_output.go
get the realtime output for a shell command in golang
package main
import (
"bufio"
"fmt"
"io"
"os"
"os/exec"
"strings"
)
@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