Skip to content

Instantly share code, notes, and snippets.

@jbelloncastro
jbelloncastro / ddispatch.cc
Created January 28, 2020 17:39
Double dispatch C++
enum class Kind : unsigned int;
struct Base {
const Kind kind;
explicit Base(Kind kind) : kind(kind) {}
template <class T> bool is() const { return kind == T::kind; }
template <class T> const T* cast() const { return is<T>()? static_cast<const T*>(this) : nullptr; }
};
@jbelloncastro
jbelloncastro / ytsearch.sh
Last active March 28, 2020 14:45
Search in youtube using youtube-dl and pipe the audio to VLC
#!/bin/bash -x
search="$@"
vlc_options=":sout=#transcode{vcodec=none,scodec=none}:http{mux=ogg,dst=:8080/} :no-sout-all :sout-keep"
youtube-dl "ytsearch1:$search" -r 200k -f 'bestaudio[ext=m4a]' -o - | cvlc - ${vlc_options}