Skip to content

Instantly share code, notes, and snippets.

View mortymacs's full-sized avatar

Morteza NourelahiAlamdari mortymacs

View GitHub Profile
@nickoala
nickoala / 0_python_email.md
Last active February 11, 2025 20:23
Use Python to send and receive emails

Use Python to:

  • send a plain text email
  • send an email with attachment
  • receive and filter emails according to some criteria
@roylee0704
roylee0704 / dockergrep.sh
Created December 9, 2016 08:24
how to grep docker log
docker logs nginx 2>&1 | grep "127."
# ref: http://stackoverflow.com/questions/34724980/finding-a-string-in-docker-logs-of-container

Aligning images

This is a guide for aligning images.

See the full Advanced Markdown doc for more tips and tricks

left alignment

@arxdsilva
arxdsilva / working_directory.go
Last active January 6, 2025 19:29
How to get the current working directory in golang
package main
// More info on Getwd()
// https://golang.org/src/os/getwd.go
//
import(
"os"
"fmt"
"log"
)
@TySkby
TySkby / timeout.py
Last active June 5, 2024 17:06
Timeout decorator/context manager using signals (for Python 3)
#!/usr/bin/env python3
"""Easily put time restrictions on things
Note: Requires Python 3.x
Usage as a context manager:
```
with timeout(10):
something_that_should_not_exceed_ten_seconds()
```
@wojteklu
wojteklu / clean_code.md
Last active May 17, 2025 14:58
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@onjin
onjin / docker-compose.yml
Created September 5, 2016 09:17
example docker compose for postgresql with db init script
postgres:
image: postgres:9.4
volumes:
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
@mjkillough
mjkillough / CMakeLists.txt
Last active March 17, 2024 09:09
Generating and using a virtualenv from CMake
cmake_minimum_required(VERSION 3.6)
project(CmakeVirtualenv)
enable_testing()
# Find Python and Virtualenv. We don't actually use the output of the
# find_package, but it'll give nicer errors.
find_package(PythonInterp 2.7 REQUIRED)
find_program(VIRTUALENV virtualenv)
@matishsiao
matishsiao / pipe.go
Last active April 14, 2025 17:10
named pipe sample code
package main
import (
"bufio"
"fmt"
"log"
"os"
"syscall"
"time"
)
@subfuzion
subfuzion / curl.md
Last active May 13, 2025 18:51
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.