Skip to content

Instantly share code, notes, and snippets.

View mthri's full-sized avatar
🦄

Amir Motahari mthri

🦄
View GitHub Profile
@mthri
mthri / boot.py
Created January 10, 2021 17:14
MicroPython AP and WiFi
import network
# wlan = network.WLAN(network.STA_IF)
# wlan.active(True)
# wlan.connect('mthri', '123456789')
# print('connecting...')
# while not wlan.isconnected():
# pass
# print('connected!')
@mthri
mthri / githubusercontent.md
Created November 27, 2020 11:18
Direct Link on Github

Direct link to uploaded file on github repo https://raw.githubusercontent.com/{username}/{repo name}/{branche}/{directory + filename}

@mthri
mthri / esptool-micropython.md
Last active November 13, 2020 17:42
Install MicroPython on NodeMCU(ESP8266) with esptool.py

esptool.py --port <PORT> --baud 460800 write_flash -e --flash_size=detect -fm dout 0 <FIRMWARE ADDRESS> NOTICE: after install, default baud rate is 115200

@mthri
mthri / main.py
Created October 26, 2020 12:20
PySerial Arduino
import serial
ser = serial.Serial('/dev/ttyACM0', baudrate=9600, timeout=1)
data = ser.readline()
data = str(data, encoding='utf-8')
data = data.strip()
ser.close()
ser.open()
@mthri
mthri / self_restart.py
Created October 9, 2020 10:55
Self Restart Python Module
import os, sys
os.execl(sys.executable, sys.executable, * sys.argv)
@mthri
mthri / command-line-hero.MD
Created October 1, 2020 20:32
Command Line Hero (Part Software)

Command Line Hero (Part Software)


echo

Display a line of text/string on standard output or a file.

Syntax

echo [Options] [Strings]

Options:

@mthri
mthri / code-pro.md
Last active January 27, 2021 22:08
Programming Hints

Use Comment

Use TODO keyword in comment

Obey Naming rule from each language

Use Changelog file

@mthri
mthri / base-template.md
Created July 4, 2020 16:55
send data to base template in django

If you need to use data in base template the was sent to child template use block.super in some tag

{% block tmp %}
    {{ block.super }}
{% endblock %}

@mthri
mthri / django-secure.md
Created June 24, 2020 17:48
A checklist to secure Django site

1- use rate limit to block brute force attack like this
2- use anti bot services like reCAPTCHA
3- config web server to disable directory browsing (like here)
4- scanning all file and check allowed type before upload to server(ClamAV).

@mthri
mthri / vim.md
Created April 25, 2020 10:56
Vim Cheatsheet