Skip to content

Instantly share code, notes, and snippets.

@mvasin
mvasin / transcribe.sh
Last active May 18, 2023 17:02
Transcribing audio files to text using OpenAI's Whisper model
#!/bin/sh
# A Mac utility to transcribe audio files using OpenAI's API (Whisper)
#
# Usage:
#
# $OPENAI_API_KEY='your-key-here' sh ./transcribe.sh [/path/to/the/dir/with/the/audio/files]
#
# If the path to the files is not specified, the utility will work in the current directory
// POST request body to /stub BFF endpoint
interface StubSetup {
method: 'GET' | 'POST' | 'PUT' | 'DELETE'
path: string
headers: { [headerName: string]: string }
responseCode: number
responseBody: any
}
// Not ready yet, don't try this at home
import React, { useState } from 'react';
type Model = number;
interface AgGridMethods {
getModel: () => Model;
setModel: (model: Model) => void;
}
@mvasin
mvasin / hello-browserstack.js
Created November 5, 2018 11:36
Hello World on BrowserStack
const {Builder, By} = require('selenium-webdriver');
const {BROWSERSTACK_USERNAME, BROWSERSTACK_KEY} = process.env;
if (!BROWSERSTACK_USERNAME || !BROWSERSTACK_KEY)
throw Error('Specify BROWSERSTACK_USERNAME and BROWSERSTACK_KEY env vars!');
const chrome = {
browserName: 'Chrome',
browser_version: '70.0',
os: 'Windows',
const nullNode = null;
const node1 = {
left: nullNode,
right: nullNode,
value: 1
};
const node3 = {
left: nullNode,
@mvasin
mvasin / throttle.js
Last active September 19, 2018 16:46
// wait in milliseconds
function throttle(fn, wait) {
// unix timestamp
let lastTimeExecuted;
return function (args) {
const currentTime = new Date();
// this condition is satisfied only the very first time
if (!lastTimeExecuted) {
@mvasin
mvasin / export-import-volumes.sh
Last active February 22, 2018 22:09
Export a Docker volume to a .tar / Import into Docker volume from a .tar / Duplicate volumes (via tar)
# Usage: export_volume volume_name
# export_volume volume_name > file.tar
#
# prints to STDOUT a volume in .tar format
export_volume() {
# Quit if volume name is not specified
vol=${1:?}
# If there is no such container, a new container will be created, we don't need that
docker volume inspect $vol > /dev/null || (echo "Container specified for export doesn't exist" && return 1)
@mvasin
mvasin / docker-compose.yml
Last active January 31, 2018 16:02
A way to start bedrock-flavoured WordPress site in Docker
# A way to quickly start bedrock-flavored (see roots.io) WordPress site in Docker
# Here are the steps:
# - Add `127.0.0.1 your-site.com` to /etc/hosts files with `sudo nano /etc/hosts`
# - Save this file as docker-compose.yml in the root of your project (along with composer.json)
# - Put your database to db.sql in the root of the project, if any
# - Execute `docker-compose up -d`
# - Wait for approximately 10-100 seconds
# - Navigate to `localhost`
version: "3"
@mvasin
mvasin / config.ru
Created January 18, 2018 11:20
A simple rack app for educational purposes: upload a file and have it presented in the browser
class App
def self.call env
new(env).call
end
def initialize env
@request = Rack::Request.new env
@response = Rack::Response.new
end
# PubSub with a microservice: send a message to a fleet of workers,
# let one of workers pick the task and send the result message directly to the requester.
# the manager
# pub.rb
require 'redis'
trap(:INT) { puts 'Bye!'; exit }
r = Redis.new