Skip to content

Instantly share code, notes, and snippets.

View vlad-ds's full-sized avatar

Vlad Gheorghe vlad-ds

View GitHub Profile
@vlad-ds
vlad-ds / bot_template.py
Created September 11, 2023 08:10
Telegram Bot Template
import os
from dotenv import load_dotenv
from telegram import Update
from telegram.ext import Application, CommandHandler, ContextTypes, MessageHandler, filters
load_dotenv()
TOKEN = os.environ["BOT_TOKEN"]
@vlad-ds
vlad-ds / MainActivity.kt
Created August 3, 2023 10:15
Android: Bluetooth Device App
package com.example.cyborg2
import android.bluetooth.BluetoothA2dp
import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothHeadset
import android.bluetooth.BluetoothProfile
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
@vlad-ds
vlad-ds / ec2_start.sh
Created August 1, 2023 07:43
Initial setup for EC2 Amazon Linux Image (for hosting telegram bots & other use cases)
#!/bin/bash
# install requirements
sudo yum update -y
sudo yum install -y python3-devel
sudo yum install -y python3-pip
sudo yum install -y git
# install github cli
type -p yum-config-manager >/dev/null || sudo yum install yum-utils
@vlad-ds
vlad-ds / deploy_telegram_aws.md
Last active July 21, 2024 01:46
How to deploy a Telegram bot on AWS EC2

Remote setup (AWS EC2)

If you run your Telegram bot locally, it will stop working when you close the terminal. The alternative is to host the bot somewhere.

There are many ways to do this. I chose AWS EC2 as it's a cheap and easy option.

Create an AWS account and start an EC2 instance. Install pip, git and github cli. If you use an Amazon Linux image (which is what the free tier offers) you can run the commands in this gist.

Connect to your GitHub account with gh auth login and clone this repo. Create the .env

@vlad-ds
vlad-ds / knowledge_compound_growth.ipynb
Created June 16, 2022 19:12
knowledge_compound_growth.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
-- data for 1 day: 479 MB scanned
SELECT *
FROM `bigquery-public-data.google_trends.international_top_terms`
WHERE refresh_date = DATE_SUB(CURRENT_DATE, INTERVAL 1 DAY);
-- data for 2 days: 955 MB scanned
SELECT *
FROM `bigquery-public-data.google_trends.international_top_terms`
WHERE refresh_date > DATE_SUB(CURRENT_DATE, INTERVAL 3 DAY);
@vlad-ds
vlad-ds / bq_query_1.sql
Created May 11, 2022 16:09
BigQuery SQL 1
SELECT term,
rank,
AVG(score) AS avg_score
FROM `bigquery-public-data.google_trends.international_top_terms`
WHERE refresh_date = DATE_SUB(CURRENT_DATE, INTERVAL 1 DAY)
AND country_name = "United Kingdom"
GROUP BY term, rank
ORDER BY rank ASC;
@vlad-ds
vlad-ds / fizzbuzz.py
Created April 7, 2021 08:28
A Cooler Fizzbuzz
def fizzbuzz(n):
return [('' + 'Fizz' * (not x % 3) + 'Buzz' * (not x % 5)) or x for x in range(1, n+1)]
@vlad-ds
vlad-ds / SETUP_DAY.md
Created January 11, 2021 11:51
Starting my coding journey...
@vlad-ds
vlad-ds / SETUP_DAY.md
Created January 8, 2021 09:47
Starting my coding journey...