Skip to content

Instantly share code, notes, and snippets.

View Ppang0405's full-sized avatar
🎉
Tet holiday

Jeremy Ppang0405

🎉
Tet holiday
  • Hanoi
View GitHub Profile
@Ppang0405
Ppang0405 / admin.py
Created January 15, 2023 16:09 — forked from herbps10/admin.py
Setting up SQLAlchemy with Application Factory pattern and Blueprints
from flask import current_app, Blueprint, render_template
from database import db_session
from model import Product
admin = Blueprint('admin', __name__, url_prefix='/admin')
@admin.route('/')
def index():
product = db_session.query(Product).first()
interface AnalyticsPayload {
username: string;
lastname: string;
firstname: string;
location: string;
}
const getIpAddress = async () => {
try {
const response = await fetch('https://api.ipify.org');

Create a new project

poetry new <project-name>

Add a new lib

potry add <library>

Remove a lib

#!/usr/bin/env /Users/truongnguyen/.asdf/shims/python
# coding: UTF-8
import requests
icons = dict({
"01d":"☀️" ,
"02d":"⛅️" ,
"03d":"☁️" ,
"04d":"☁️" ,
@Ppang0405
Ppang0405 / install.sh
Created November 24, 2021 13:26 — forked from marklit/install.sh
Bot Detection Script. Works with Apache and Nginx Log Files.
sudo apt-get update
sudo apt-get install \
python-dev \
python-pip \
python-virtualenv
virtualenv findbots
source findbots/bin/activate
curl -O http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz
@Ppang0405
Ppang0405 / AndroidManifest.xml
Created November 10, 2021 12:30 — forked from Venryx/AndroidManifest.xml
Record audio on Android in the background (even when screen is off)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.myapp">
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme">
<service android:name=".ForegroundService" android:enabled="true" android:exported="true"></service>
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
@Ppang0405
Ppang0405 / aws.md
Created October 22, 2021 09:44 — forked from colinvh/aws.md
AWS Region Names

Alternative naming schemes for AWS regions

Purpose

The intent is to define terse, standards-supported names for AWS regions.

Schemes

@Ppang0405
Ppang0405 / gist:7608277e85b253071fb78983293f52e6
Created October 21, 2021 15:38 — forked from anthonyray/gist:398fde676a7704c03d6624155ba0011e
Set up OhMyZsh on Amazon EC2 instance running Ubuntu Server 14.04
  1. Connect to your EC2 instance
  2. Install zsh : sudo apt-get update && sudo apt-get install zsh
  3. Edit your passwd configuration file to tell which shell to use for user ubuntu : sudo vim /etc/passwd
  4. Look for ubuntu user, and replace bin/bash by bin/zsh
  5. Install OhMyZsh : sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
  6. Disconnect from your instance and reconnect it.
@Ppang0405
Ppang0405 / count_messages.py
Created January 4, 2021 16:24 — forked from yi-jiayu/count_messages.py
Using Telethon and the Telegram API to count the number of messages in each of your recent conversations
from telethon import TelegramClient
from telethon.errors.rpc_errors_401 import SessionPasswordNeededError
# (1) Use your own values here
api_id = 17349
api_hash = '344583e45741c457fe1862106095a5eb'
phone = 'YOUR_NUMBER_HERE'
username = 'username'