Skip to content

Instantly share code, notes, and snippets.

View codedeep79's full-sized avatar

Nguyễn Trung Hậu codedeep79

View GitHub Profile
@codedeep79
codedeep79 / Cài đặt Python 3.8 trên Ubuntu 20.04.md
Last active April 4, 2022 02:21
Cài đặt Python 3.8 trên Ubuntu 20.04

Python là một ngôn ngữ lập trình thông dịch, cấp cao, hướng đối tượng. Nó đủ linh hoạt và có thế mạnh về lập trình kịch bản, tự động hóa, phân tích dữ liệu, học máy và phát triển back-end. Được xuất bản lần đầu vào năm 1991 với tên lấy cảm hứng từ nhóm hài Monty Python của Anh, nhóm phát triển muốn biến Python trở thành một ngôn ngữ thú vị để sử dụng.

Step 1 – Installing Prerequisite

sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev \
    libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev

Step 2 – Download Python 3.8

cd /opt
@codedeep79
codedeep79 / Errror of git push.md
Created April 4, 2022 03:35
Errror of git push in Ubuntu: Support for password authentication was removed. Please use a personal access token instead
  • Go to your GitHub Account settings
  • Click Developer Settings
  • Select Personal Access
  • Generate a token with the given permissions, e.g.,
  • Now git pull inside your Git repository
  • Provide a username and the generated token as a password
@codedeep79
codedeep79 / SearchFiles.py
Last active April 9, 2022 10:04
Search for files with a specific extension and put them in a list Python
import os
def dirLS (dirPath, ext):
files = os.listdir(dirPath)
foundFiles = []
for curfile in files:
try:
prefix, frame, suffix = curfile.split('.')
print suffix
if suffix == ext :
@codedeep79
codedeep79 / ColorsConsole.py
Created April 9, 2022 09:39
python colors console
print '\033[1;30mGray like Ghost\033[1;m'
print '\033[1;31mRed like Radish\033[1;m'
print '\033[1;32mGreen like Grass\033[1;m'
print '\033[1;33mYellow like Yolk\033[1;m'
print '\033[1;34mBlue like Blood\033[1;m'
print '\033[1;35mMagenta like Mimosa\033[1;m'
print '\033[1;36mCyan like Caribbean\033[1;m'
print '\033[1;37mWhite like Whipped Cream\033[1;m'
print '\033[1;38mCrimson like Chianti\033[1;m'
print '\033[1;41mHighlighted Red like Radish\033[1;m'
@codedeep79
codedeep79 / SendEmail.py
Last active April 9, 2022 10:04
Send an email in Python
import os
import smtplib
import mimetypes
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.MIMEAudio import MIMEAudio
from email.MIMEImage import MIMEImage
from email.Encoders import encode_base64
@codedeep79
codedeep79 / GoogleDocumentList.py
Last active April 9, 2022 10:04
Here's a short program to print a list of all of the documents in your Google Documents account in Python
import gdata.docs.service
client = gdata.docs.service.DocsService()
client.ClientLogin('[email protected]', 'password')
documents_feed = client.GetDocumentListFeed()
for document_entry in documents_feed.entry:
print document_entry.title.text
@codedeep79
codedeep79 / GetIPAddress.py
Last active April 9, 2022 10:03
Get IP Address (only linux) in Python
def getIpAddress(self, ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(
fcntl.ioctl(s.fileno(), 0x8915, struct.pack("256s", ifname[:15]))[20:24]
)
@codedeep79
codedeep79 / SendMail.py
Last active April 9, 2022 10:03
Send mail with attachments in Python
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.Utils import COMMASPACE, formatdate
from email import Encoders
import os
def sendMail(to, subject, text, files=[], server="localhost"):
@codedeep79
codedeep79 / Sockets.py
Created April 9, 2022 10:07
Sockets on Python
from socket import *
host = "localhost"
port = 21567
buf = 1024
addr = (host, port)
UDPSock = socket(AF_INET, SOCK_DGRAM)
def_msg = "===Enter message to send to server==="
@codedeep79
codedeep79 / Install Nodejs in Ubuntu.md
Last active June 3, 2022 03:20
Install Nodejs in Ubuntu
    sudo apt-get update
    sudo apt-get install nodejs
    sudo apt install npm
    node -v 
    npm -v