Skip to content

Instantly share code, notes, and snippets.

View smileart's full-sized avatar
:octocat:
Work In Progress

Serge Bedzhyk smileart

:octocat:
Work In Progress
View GitHub Profile
@smileart
smileart / ini_edit
Last active January 2, 2022 14:36
A little bash functions set to work with *.ini files
#!/usr/bin/env bash
# param_1: string | param_2: file
is_option_in_file () {
if [[ ! -z "$1" && ! -z "$2" ]]; then
egrep -q "$1" "$2"
if [[ $? = '0' ]]
then
echo '1'
@smileart
smileart / apple_music.js
Created July 4, 2015 15:25
JXA script which automates playlists import to the Apple Music using iTunes
// ======= Motivation ========
// http://www.theverge.com/2015/6/30/8871591/spotify-to-apple-music-migrate
// http://i.giphy.com/1zTqgW6bS2jWU.gif
// https://goo.gl/lMTvOj
// All the delays in this script could be adapted
// for your own needs…
// Add this code to the Script Editor (OS X Only!)
// and press Run… http://i.giphy.com/QfGMSZ25v3pGU.gif
@smileart
smileart / parse_fields.rb
Last active February 3, 2021 16:22
A little AWK-like method to parse fields in a string of text
text = <<~DOC
ID Name Type Size Date
735557379 Mitch Murder - Kung Fury (Lost Tapes) - 2015 FOLDER 38.37 MB 8 months ago
589243897 A Game Of Thrones ~ Books 1-5 EPUB,MOBI & PDF [GrYff0N] FOLDER 83.36 MB 2 years ago
735557525 VA - Kung Fury (2015) FOLDER 109.84 MB 8 months ago
819683233 19000 FOLDER 1.77 GB 2 days ago
819682329 18000 FOLDER 3.12 GB 2 days ago
819681592 17000 FOLDER 4.23 GB 2 days ago
784060241 Doctor.Who.2005.S12.1080p.BluRay.x264-SHORTBREHD FOLDER 31.73 GB 2 months ago
601795129 chill.institute FOLDER 51.66 GB 2 days ago
@smileart
smileart / docker_volumes_backup.sh
Last active October 13, 2020 23:20
Backing up and Restoring named Docker volumes
# Based on
https://stackoverflow.com/questions/38298645/how-should-i-backup-restore-docker-named-volumes
# Dependencies
brew install fzf fx
# Backup (docker-compose running and we're in the same dir)
export CONTAINER_NAME=$(docker ps --format '{{.Names}}' | fzf) && \
export VOLUME_NAME=$(docker inspect $CONTAINER_NAME | fx '.[0].Mounts[0].Name') && \
docker stop $(docker inspect $CONTAINERNAME | fx '.[0].Id') && \
@smileart
smileart / tapp_amazing_print.rb
Created September 22, 2020 07:04
tapp + amazing_print
require 'tapp'
require 'tapp/printer'
require 'amazing_print'
# Module to define own Tapp printer
module Tapp::Printer
# Custom AmazingPrint based printer for Tapp
class AmazingPrint < Base
# Prints the object using custom (AmazingPrint) printer
#

How to download your Udemy course videos using youtube-dl

$ youtube-dl --list-extractors | grep udemy

Steps

  1. Get link to the course to download. e.g. https://www.udemy.com/course-name/
  2. Login into udemy website, save the cookie from chrome using Chrome (Cookie.txt)[1] export extension. Save it to file udemy-cookies.txt
  3. Get the link of the video that you want to download. usually in format. Use the command provided below where you have to replace the {course_link} and {path_to_cookies_file} with respective paths.
$ youtube-dl {course_link} --cookies {path_to_cookies_file}
@smileart
smileart / ranged_hash.rb
Created July 10, 2018 14:51
Benchmarking different RangedHash implementations
require 'benchmark/ips'
class RangedHashSelect
def initialize(hash)
@data = Hash[
hash.keys.map do |el|
el.respond_to?(:member?) ? el : (el..el)
end.zip(hash.values)
]
end