Skip to content

Instantly share code, notes, and snippets.

View asvechkar's full-sized avatar

Aleksey Svechkar asvechkar

View GitHub Profile
@asvechkar
asvechkar / extract_audio_from_video.py
Created June 28, 2023 07:21
Извлечь аудио с видеофайла
pip install moviepy
from moviepy.editor import VideoFileClip
# Define the path to the video file
video_path = "path/to/video/file.mp4"
# Create a VideoFileClip object
video_clip = VideoFileClip(video_path)
@asvechkar
asvechkar / load_from_instagram.py
Created June 28, 2023 07:19
Загружать посты с Нельзяграмма
pip install instaloader
import instaloader
# Create an instance of Instaloader
loader = instaloader.Instaloader()
# Define the target Instagram profile
target_profile = "instagram"
@asvechkar
asvechkar / google_search.py
Created June 28, 2023 07:18
Google поиск через Python
pip install googlesearch-python
from googlesearch import search
# Define the query you want to search
query = "Python programming"
# Specify the number of search results you want to retrieve
num_results = 5
@asvechkar
asvechkar / public_to_whatsapp.py
Created June 28, 2023 07:17
Автоматизировать сообщения в WhatsApp
pip install pywhatkit
import pywhatkit
# Set the target phone number (with country code) and the message
phone_number = "+1234567890"
message = "Hello, this is an automated WhatsApp message!"
# Schedule the message to be sent at a specific time (24-hour format)
hour = 13
@asvechkar
asvechkar / youtube_downloader.py
Created June 28, 2023 07:15
Загружать видео с Youtube
pip install pytube
from pytube import YouTube
# Specify the URL of the YouTube video
video_url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
# Create a YouTube object
yt = YouTube(video_url)
@asvechkar
asvechkar / mysql-docker.sh
Created December 23, 2019 14:09 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@asvechkar
asvechkar / routes.py
Created August 31, 2018 17:57
Django 2 routes list
# app/management/commands/routes.py
from django.core.management import BaseCommand
from django.urls import resolvers, URLResolver, URLPattern
class Command(BaseCommand):
"""
Show routes list
"""
@asvechkar
asvechkar / http.js
Last active March 3, 2018 14:18
Vue interceptors
// HTTP service http.js
axios.interceptors.response.use(response => {
return response
}, error => {
if (error.response.status === 401) {
bus.$emit('errors:401')
return Promise.reject()
} else {
bus.$emit('error', error.response.data)
return Promise.reject()
@asvechkar
asvechkar / enable_pgcrypto_extension.rb
Last active March 3, 2018 14:16
rails generate migration enable_pgcrypto_extension
# enable_pgcrypto_extension.rb
class EnablePgcryptoExtension < ActiveRecord::Migration[5.1]
def change
enable_extension 'pgcrypto'
end
end
# config/application.rb
config.generators do |g|
g.orm :active_record, primary_key_type: :uuid
@asvechkar
asvechkar / swift_searchbar.swift
Created August 1, 2016 08:34
Отзывчивый searchbar
func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {
weak var weakSelf: ProductPickerTableViewController = self
var searchDelay: Double = 0.3
if self.searchBlock != nil {
//We cancel the currently scheduled block
cancel_block(self.searchBlock)
}
self.searchBlock = dispatch_after_delay(searchDelay, {() -> Void in
//We "enqueue" this block with a certain delay. It will be canceled if the user types faster than the delay, otherwise it will be executed after the specified delay