Skip to content

Instantly share code, notes, and snippets.

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

Mohammad Rajabloo mrsoftware

🏠
Working from home
View GitHub Profile
@mrsoftware
mrsoftware / yandexDirectionMapper.go
Created January 14, 2024 16:00
calculate yandex direction based on lat/lng
type Point struct {
Lat float64
Lng float64
}
func YandexDirectionMapper(old Point, new Point) (float64, float64) {
length := math.Sqrt(math.Pow(new.Lng-old.Lng, 2) + math.Pow(new.Lat-old.Lat, 2))
if length == 0 {
return 0, 0
@mrsoftware
mrsoftware / stype.css
Created November 16, 2022 20:50
some reusable css
:root {
--clr-primery-200: some color;
--ff-primery: "Roboto", sans-serif;
}
*, *::before, *::after {
box-sizing: border-box;
}
body, h1, h2, h3, p {
// generate react native splash screen
// image must be 2208 2208 and psd format and small logo in center center
yo rn-toolbox:assets --splash splashscreen.psd --android
for repo in $(curl "https://gitlab.com/api/v4/projects?private_token=TOKEN&owned=yes" | jq '.[].ssh_url_to_repo' | tr -d '"'); do git clone $repo; done;
package main
import (
"os"
"os/signal"
"syscall"
)
func main() {
`SELECT
*
FROM
Posts
WHERE
CreateAt `+direction+` (SELECT CreateAt FROM Posts WHERE Id = :PostId)
AND ChannelId = :ChannelId
AND DeleteAt = 0
ORDER BY CreateAt `+sort+`
LIMIT :Limit
dbHost := viper.GetString(`database.host`)
dbPort := viper.GetString(`database.port`)
dbUser := viper.GetString(`database.user`)
dbPass := viper.GetString(`database.pass`)
dbName := viper.GetString(`database.name`)
connection := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s", dbUser, dbPass, dbHost, dbPort, dbName)
val := url.Values{}
val.Add("parseTime", "1")
val.Add("loc", "Asia/Jakarta")
dsn := fmt.Sprintf("%s?%s", connection, val.Encode())
func init() {
viper.SetConfigFile(`config.json`)
err := viper.ReadInConfig()
if err != nil {
panic(err)
}
if viper.GetBool(`debug`) {
fmt.Println("Service RUN on DEBUG mode")
}
@mrsoftware
mrsoftware / pars config file with viper
Created September 27, 2019 10:33
With this method you can open any config file that supported by viper
// go run main.go --config ./config/config.yaml
// go run main.go --config ./config/config.json
// go run main.go --config ./config/config.toml
// file name also can be any name : config, app and etc.
var configFile = flag.String("config", "./config/config.yaml", "Address of config file")
func parseConfig() {
dir, file := path.Split(*configFile)
ext := path.Ext(file)
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
" Add plugins here
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'gkapfham/vim-vitamin-onec'
Plugin 'itchyny/lightline.vim'