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 / *.bat
Created January 30, 2016 18:51 — forked from michfield/*.bat
Install Gems without documentation #ruby #windows
:: Make --no-ri --no-rdoc default gem install options (without documentation)
:: Possible variations:
:: For every user:
:: echo gem: --no-ri --no-rdoc > "%PROGRAMDATA%\gemrc"
:: Only for you
:: echo gem: --no-ri --no-rdoc >> "%USERPROFILE%\.gemrc"
::
:: Note: In Windows, %PROGRAMDATA% is /etc on Linux
::
:: But finally, the best way to do it. See: http://stackoverflow.com/a/7662245/1579985
@r6m
r6m / 0_reuse_code.js
Created January 2, 2017 10:45
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@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 / 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 / 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 / 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 / terminal-git-branch-name.md
Created September 14, 2018 10:15 — forked from joseluisq/terminal-git-branch-name.md
Add Git Branch Name to Terminal Prompt (Mac)

Add Git Branch Name to Terminal Prompt (Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {
@r6m
r6m / Concepts.md
Created November 18, 2018 21:10 — forked from DarinM223/Concepts.md
Rust concept explanations

My explanation of the main concepts in Rust

There are three main concepts with Rust:

  1. Ownership (only one variable "owns" the data at one time, and the owner is in charge of deallocating)
  2. Borrowing (you can borrow a reference to an owned variable)
  3. Lifetimes (all data keeps track of when it will be destroyed)

These are fairly simple concepts, but they are often counter-intuitive to concepts in other languages, so I wanted to give a shot at

@r6m
r6m / locustfile.py
Created February 19, 2019 05:52 — forked from yamionp/locustfile.py
Websocket Locust Sample. locustfile and Echo/Chat Server
# -*- coding:utf-8 -*-
from __future__ import absolute_import
from __future__ import unicode_literals
from __future__ import print_function
import json
import uuid
import time
import gevent