Skip to content

Instantly share code, notes, and snippets.

View mortymacs's full-sized avatar

Morteza (Mort) NourelahiAlamdari mortymacs

View GitHub Profile
@mortymacs
mortymacs / enable_if.go
Created August 21, 2022 07:22
Sample enableIf in Go
package main
import "log"
// types.
type Fn func(id string, name string) error
// actions.
func Insert(id string, name string) error {
log.Println("Insert ID:", id, " Name:", name)
@mortymacs
mortymacs / solution.md
Created August 17, 2022 10:59
set tmux pane width in tmux and tmuxp

bash:

$ tmux set-window-option main-pane-width 20; tmux select-layout main-vertical

tmuxp:

session_name: DB
@mortymacs
mortymacs / main.go
Created August 3, 2022 21:17 — forked from llonchj/main.go
Proof of concept
package main
import (
"fmt"
"net/http"
"github.com/gocolly/colly"
)
type MyCollector struct {
@mortymacs
mortymacs / 1.srp.py
Created June 26, 2022 09:34 — forked from dmmeteo/1.srp.py
SOLID Principles explained in Python with examples.
"""
Single Responsibility Principle
“…You had one job” — Loki to Skurge in Thor: Ragnarok
A class should have only one job.
If a class has more than one responsibility, it becomes coupled.
A change to one responsibility results to modification of the other responsibility.
"""
class Animal:
def __init__(self, name: str):

Install dependencies

apt-get install gcc-arm-linux-gnueabihf qemu

Prepare work directory

mkdir qemu-arm-sandbox && cd qemu-arm-sandbox
@mortymacs
mortymacs / qemu-1.md
Created June 5, 2022 15:13
qemu basic commands
$ qemu-img create arch.img 30G
$ qemu-system-x86_64 -boot d -cdrom archlinux-x86_64.iso -m 4096 -hda arch.img -net nic -net user
@mortymacs
mortymacs / main.rs
Created May 28, 2022 17:12
Sample Rust Tokio library for an infinit loop
use std::time::Duration;
async fn action() {
loop {
print!("Hello!");
tokio::time::sleep(Duration::from_millis(1)).await;
}
}
@mortymacs
mortymacs / alacritty-instance.sh
Created May 4, 2022 12:00
Run alacritty instance instead of a individual new process
#!/bin/sh
env WINIT_UNIX_BACKEND=x11 alacritty msg create-window 2>/dev/null || alacritty
@mortymacs
mortymacs / parse-sample.go
Last active April 26, 2022 14:33
Sample XML Parsing in Golang
package main
import (
"encoding/xml"
"fmt"
)
const data = `<?xml version='1.0' encoding='UTF-8'?>
<response-data><data target="server1"></data></response-data>
`
@mortymacs
mortymacs / cross-compile-go-arm64.md
Created April 16, 2022 15:44 — forked from conoro/cross-compile-go-arm64.md
Cross-compiling Golang for ARM64 (aarch64) e.g. Pine64 on Fedora AMD64
  • Install Go for Linux the usual way on your main Linux box:
cd
wget https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz
tar -zxvf go1.6.2.linux-amd64.tar.gz
sudo mv go /usr/local/
export GOROOT=/usr/local/go
mkdir -p ~/gitwork/go/src
mkdir ~/gitwork/go/bin