Skip to content

Instantly share code, notes, and snippets.

@yasinuygun
yasinuygun / whisper_subtitle_generator.py
Last active January 6, 2024 08:43
Whisper Subtitle Generator
import sys
import whisper
from whisper.utils import write_srt
def run(input_path: str, output_path: str) -> None:
model = whisper.load_model("base")
result = model.transcribe(input_path)
@kbravh
kbravh / adjust-cron-for-dst.py
Last active March 26, 2023 17:14
Adjust cron events for DST (Daylight Savings Time) automatically with a Python function to be run on AWS Lambda.
from datetime import datetime
import pytz
import boto3
# define our CloudEvents client
client = boto3.client('events')
# Let's grab our current time in GMT and convert it to local time (US Central)
utc_time = datetime.utcnow().replace(tzinfo=pytz.utc)
# Set your timezone here! See timezones here: https://gist.github.com/heyalexej/8bf688fd67d7199be4a1682b3eec7568
@tomhicks
tomhicks / plink-plonk.js
Last active March 18, 2024 02:23
Listen to your web pages
@2b3pro
2b3pro / ffmpeg_merge_videos_in_folder.md
Last active May 12, 2021 21:48
[Automator] Quick Action to Concatenate Videos in a Folder for YT-ready Upload

Q: How do I combine individual video clips into one movie file for upload to YouTube using ffmpeg?

The following assumes you have ffmpeg installed on your Mac. If you need to install it, please use Homebrew.

The settings for encoding for YouTube with ffmpeg can be found here and here.

There is no error checking here. It assumes that there are videos in the folder, and that they have mp4 extensions.


@sorashido
sorashido / google_calendar_python_api.py
Last active September 18, 2023 07:41
Google Calendar API Python Quickstart
from __future__ import print_function
import httplib2
import os
from apiclient import discovery
from oauth2client import client
from oauth2client import tools
from oauth2client.file import Storage
import datetime
@freem
freem / twitter-killjunk.js
Last active December 28, 2022 22:22
disabling extraneous twitter features
/* NOTICE: THIS WAS MADE BACK IN 2017, OF COURSE IT'S NOT GOING TO WORK WELL NOW THAT TWITTER'S FUCKED THINGS UP */
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("twitter.com") {
[data-component-context="suggest_recap"],
[data-component-context="suggest_who_to_follow"],
[data-component-context="suggest_activity"],
[data-component-context="suggest_activity_tweet"],
[data-component-context="suggest_recycled_tweet_inline"],
[data-component-context="suggest_recycled_tweet"]{
<!-- SEO / Google -->
<meta name="author" content="Author name here....">
<meta name="description" content="Description text here.....">
<link rel="canonical" href="URL here...">
<!-- Social: Twitter -->
<!-- After inserting META need to validate at https://dev.twitter.com/docs/cards/validation/validator -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@8bit_code">
<meta name="twitter:creator" content="8bit_code">
#!/bin/bash
# Anh Nguyen <anh.ng8@gmail.com>
# 2016-04-30
# MIT License
# This script takes in same-size images from a folder and make a crossfade video from the images using ffmpeg.
# Make sure you have ffmpeg installed before running.
# The output command looks something like the below, but for as many images as you have in the folder.
@dannguyen
dannguyen / README.md
Last active December 28, 2023 15:21
Using Python 3.x and Google Cloud Vision API to OCR scanned documents to extract structured data

Using Python 3 + Google Cloud Vision API's OCR to extract text from photos and scanned documents

Just a quickie test in Python 3 (using Requests) to see if Google Cloud Vision can be used to effectively OCR a scanned data table and preserve its structure, in the way that products such as ABBYY FineReader can OCR an image and provide Excel-ready output.

The short answer: No. While Cloud Vision provides bounding polygon coordinates in its output, it doesn't provide it at the word or region level, which would be needed to then calculate the data delimiters.

On the other hand, the OCR quality is pretty good, if you just need to identify text anywhere in an image, without regards to its physical coordinates. I've included two examples:

####### 1. A low-resolution photo of road signs

@ozen
ozen / Selenium PhantomJS Python Header.py
Last active September 6, 2021 05:12
How to set request headers when using Selenium Python with PhantomJS driver
from selenium import webdriver
from selenium.webdriver import DesiredCapabilities
desired_capabilities = DesiredCapabilities.PHANTOMJS.copy()
desired_capabilities['phantomjs.page.customHeaders.User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) ' \
'AppleWebKit/537.36 (KHTML, like Gecko) ' \
'Chrome/39.0.2171.95 Safari/537.36'
driver = webdriver.PhantomJS(desired_capabilities=desired_capabilities)