Skip to content

Instantly share code, notes, and snippets.

View meysampg's full-sized avatar
🖖
bit bit 0 bit

Meysam P. Ganji meysampg

🖖
bit bit 0 bit
View GitHub Profile
@meysampg
meysampg / protobuf_import.md
Last active January 23, 2019 11:40
protobuf_import.md

Dummy Introduction to Protobuf Compile

Import protobuf models into other and compile them

tsjd [To short, just do];

  1. Define go_package option something like:
option go_package = "github.com/meysampg/project_name/pb/folder_name_which_compiled_model_must_be_on_it";
@meysampg
meysampg / nginx_for_lumen_cors_disabled.conf
Last active January 26, 2019 13:19
Laravel/Lumen Configurations for Nginx with CORS Disabled for Local Development Purposes
server {
listen 80;
listen [::]:80;
root PATH_OF_DEVELOPMENT_DIRECTORY;
index index.php index.html;
server_name DOMAIN.FAKE;
@meysampg
meysampg / myconfig.vim
Created February 18, 2019 16:16
my .vimrc
set nocompatible " Just use ViImporved!
"# Enable generic configurations
set backspace=indent,eol,start " Set backspace behavior normal as other editors
set number " Activate line numbers
set expandtab " Extends tab by default
set tabstop=4 " A tab actually is 4 spaces
set shiftwidth=4 " Number of spaces to use for autoindenting
set smarttab
set autoindent " Always auto indent based on previous
@meysampg
meysampg / progress.go
Created February 18, 2019 18:39
Show a progress bar
package main
import (
"fmt"
"time"
)
const total = 5 * time.Second
type process struct {
@meysampg
meysampg / zeshter.php
Last active October 10, 2019 09:05
Zeshter function remove all comments and docblocks from a given php file or a folder of php files.
#!/usr/bin/env php
<?php
/**
* Zeshter function remove all comments and docblocks from a given
* php file or a folder of php files. Yep, it just mirine into file.
*
* @param string|null $path path of a php file or a folder contains php files
*/
function zeshter(?string $path, bool $debugMode = false)
{
@meysampg
meysampg / curl-github-downloader.sh
Created April 13, 2019 06:42
Download a release from Github API with a token and cURL
curl --create-dirs --silent --output /OUTPUT/ADRESS/FILE.tar.gz -L https://api.github.com/repos/OWNER/REPOSITORY/tarball/VERSION?access_token=TOKEN
@meysampg
meysampg / hackerrank_io.go
Created April 27, 2019 11:22
Hackerrank IO template
func main() {
reader := bufio.NewReaderSize(os.Stdin, 1024 * 1024)
stdout, err := os.Create(os.Getenv("OUTPUT_PATH"))
checkError(err)
defer stdout.Close()
writer := bufio.NewWriterSize(stdout, 1024 * 1024)
@meysampg
meysampg / array_to_tree.php
Created April 27, 2019 17:10
Create a tree from a flat array (like data retrieved from DB)
<?php
// Data from stackoverflow
$a = array(
array('id'=>100, 'parentid'=>0, 'name'=>'a0'),
array('id'=>102, 'parentid'=>101, 'name'=>'a012'),
array('id'=>103, 'parentid'=>101, 'name'=>'a011'),
array('id'=>101, 'parentid'=>100, 'name'=>'a01'),
array('id'=>104, 'parentid'=>100, 'name'=>'a02'),
);
@meysampg
meysampg / closure_encapsulation.go
Last active May 3, 2019 08:34
A usage of encapsulation of a clousre for Saman
package main
import "fmt"
func main() {
// this is a function which accept an int and return a function which accept an int and return an int :D
var add func(int) func(int) int = func(n int) func(int) int {
return func(a int) int {
return a + n
}
@meysampg
meysampg / randn.go
Created May 10, 2019 08:47
To show what is deterministic meaning in the rand.Intn function on golang context
package main
import "fmt"
import "math/rand"
import "time"
func constantSeed() int64 {
return 100
}