Skip to content

Instantly share code, notes, and snippets.

View mortymacs's full-sized avatar

Morteza NourelahiAlamdari mortymacs

View GitHub Profile
@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();
@mortymacs
mortymacs / jsonapi_oas.yml
Created November 15, 2022 09:10 — forked from naesean/jsonapi_oas.yml
OpenAPI 3.0 schemas that comply with the JSON:API 1.0 specification
JSONAPIObject:
description: Includes the current JSON:API version for this specification as well as optional meta information
type: object
required:
- version
properties:
version:
type: string
default: '1.0'
example: '1.0'
@mortymacs
mortymacs / tls-client.go
Created November 15, 2022 07:59 — forked from michaljemala/tls-client.go
SSL Client Authentication Golang sample
package main
import (
"crypto/tls"
"crypto/x509"
"flag"
"io/ioutil"
"log"
"net/http"
)
@mortymacs
mortymacs / sample-any.go
Last active November 9, 2022 12:40
GORM model with different attributes
package main
import (
"gorm.io/gorm"
"log"
)
import "gorm.io/driver/postgres"
type StaffAttribute struct {
Department string `gorm:"type:string"`
@mortymacs
mortymacs / code.sh
Created November 8, 2022 09:09
Restore an old deleted directory in Git
$ git rev-list -n 1 HEAD -- /path/to/dir
a92a0d4bd882a352cd3866882b44bb5efa58116f
$ git checkout a92a0d4bd882a352cd3866882b44bb5efa58116f^ -- /path/to/dir
# https://stackoverflow.com/questions/30875205/restore-a-deleted-folder-in-a-git-repo
@mortymacs
mortymacs / aws-vpc.tf
Created October 29, 2022 10:20 — forked from gkze/aws-vpc.tf
variable "aws_access_key" {}
variable "aws_secret_key" {}
provider "aws" {
access_key = "${var.aws_access_key}"
secret_key = "${var.aws_secret_key}"
region = "us-east-1"
}
resource "aws_vpc" "terraform-testing" {
@mortymacs
mortymacs / PKGBUILD
Created October 19, 2022 12:34
tabbed AUR package
# Maintainer: Morteza NourelahiAlamdari <[email protected]>
# This project is the copy of tabbed-git AUR package but with some changes.
pkgname=tabbed
pkgver=0.7
pkgrel=1
pkgdesc="Simple generic tabbed fronted to xembed aware applications"
arch=('x86_64')
url="https://tools.suckless.org/tabbed/"
license=('MIT/X')
depends=('libxft')
@mortymacs
mortymacs / main.go
Created October 19, 2022 12:33
Context WithValue + chaning value
package main
import (
"context"
"fmt"
)
func main() {
c := context.WithValue(context.Background(), "foo", map[string]string{"name": "mort"})
var foo map[string]string
@mortymacs
mortymacs / main.go
Created October 19, 2022 12:31
Composition sample in Go
package main
import (
"fmt"
)
type User struct {
Name string
Age int
}