Skip to content

Instantly share code, notes, and snippets.

View mortymacs's full-sized avatar

Morteza (Mort) NourelahiAlamdari mortymacs

View GitHub Profile
@mortymacs
mortymacs / sample.go
Created April 3, 2023 14:02
mapstructure custom data type
package main
import (
"fmt"
"log"
"reflect"
"github.com/mitchellh/mapstructure"
)
@mortymacs
mortymacs / my-nixos-installation.md
Created April 3, 2023 08:11
NixOS installation guide, tailored to my needs

Preface

This manual describes how to install, use and extend NixOS, a Linux distribution based on the purely functional package management system Nix, that is composed using modules and packages defined in the Nixpkgs project.

Installation

This section describes how to obtain, install, and configure NixOS for first-time use.

Obtaining NixOS

NixOS ISO images can be downloaded from the NixOS download page. There are a number of installation options. In this manual we will assume that the chosen option is Minimal ISO image (64bit). You can burn it on a USB stick with:

@mortymacs
mortymacs / idea1.go
Last active March 30, 2023 15:09
Implement multi-driver search provider in Go
package main
import (
"encoding/json"
"fmt"
)
// Driver
type Google struct {
@mortymacs
mortymacs / enum.go
Created March 29, 2023 19:52 — forked from lummie/enum.go
Golang Enum pattern that can be serialized to json
package enum_example
import (
"bytes"
"encoding/json"
)
// TaskState represents the state of task, moving through Created, Running then Finished or Errorred
type TaskState int
@mortymacs
mortymacs / sample.go
Created March 28, 2023 10:20
enum to string / string to enum in Go
package main
import (
"fmt"
)
type Event uint8
const (
Create Event = iota
Delete
@mortymacs
mortymacs / localstack.md
Created January 31, 2023 15:40 — forked from lobster1234/localstack.md
Working with localstack on command line

Starting localstack

C02STG51GTFM:localstack mpandit$ make infra
. .venv/bin/activate; exec localstack/mock/infra.py
Starting local dev environment. CTRL-C to quit.
Starting local Elasticsearch (port 4571)...
Starting mock ES service (port 4578)...
Starting mock S3 server (port 4572)...
Starting mock SNS server (port 4575)...
@mortymacs
mortymacs / 1_simple.go
Last active December 28, 2022 23:02 — forked from sosedoff/1_simple.go
Golang Custom Struct Tags Example
package main
import (
"fmt"
"reflect"
)
// Name of the struct tag used in examples
const tagName = "validate"
@mortymacs
mortymacs / sample-gin-binding.go
Created December 11, 2022 11:38
sample binding in Gin
package main
import (
"fmt"
"net/http"
"github.com/gin-gonic/gin"
)
type AddressTypeAttr struct {
@mortymacs
mortymacs / datetime-format.go
Last active December 11, 2022 11:31
DataTime format in Go
LongMonth // "January"
Month // "Jan"
NumMonth // "1"
ZeroMonth // "01"
LongWeekDay // "Monday"
WeekDay // "Mon"
Day // "2"
UnderDay // "_2"
ZeroDay // "02"
UnderYearDay // "__2"
@mortymacs
mortymacs / main.cpp
Created November 15, 2022 15:56
Breakpoint in C/C++
#include <iostream>
void bp(){}
void test() {
int i;
i = 100;
bp();