Skip to content

Instantly share code, notes, and snippets.

@m00shm00sh
m00shm00sh / omri.c
Created June 5, 2019 07:47
omri_tut
// cc omri.c -shared -o omri.so; LD_PRELOAD=`pwd`/omri.so ...
#include <errno.h>
int isatty(int unused) {
errno = ENOTTY;
return 0;
}
// omri pls
@m00shm00sh
m00shm00sh / trimalb.sh
Created November 17, 2016 09:19
Trim an album description to remove the last instance of (...) . File format invariant
#!/bin/bash
ALB="$(ffprobe "$1" 2>&1 | grep album | cut -d: -f2 | sed -re \
's/^\s+//
s/\s+$//
s/\s+\([^()]+\)$//' )"
ffmpeg -i "$1" -c copy -metadata album="$ALB" "$(echo "$1" | sed 's/_$//')"
@m00shm00sh
m00shm00sh / m4a.pl
Last active November 20, 2016 09:33
Transcoder *->m4a jig
#!/usr/bin/env perl
use strict;
use warnings;
use threads;
use sigtrap qw(die INT QUIT);
use File::Basename;
use File::Path qw/make_path/;
use Data::Dumper;
use POSIX;
@m00shm00sh
m00shm00sh / devnull_streambuf.hh
Created February 16, 2015 04:31
std::basic_streambuf<CT,TT> that behaves like /dev/null
#include <iostream>
template < typename CT, typename TT = std::char_traits<CT> >
class devnull_streambuf : public std::basic_streambuf<CT, TT> {
protected:
// null
typename std::basic_streambuf<CT,TT>::int_type
overflow(typename std::basic_streambuf<CT,TT>::int_type c = TT::eof());
};
@m00shm00sh
m00shm00sh / ( ͡° ͜ʖ ͡°).cs
Created January 15, 2015 08:02
Morse code encoder, with extra ( ͡° ͜ʖ ͡°)
using System;
using System.Collections.Generic;
using System.Text;
class Program {
static readonly Dictionary<char, string> morseCodes
= new Dictionary<char, string> {
// ITU-R M.1677-1 1.1.1
{'a', ".-"}, {'i', ".."}, {'r', ".-."},
{'b', "-..."}, {'j', ".---"}, {'s', "..."},
@m00shm00sh
m00shm00sh / stack-opshift.cc
Created January 7, 2015 05:02
Stream operators for std::stack
#include <iostream>
#include <stack>
#include <type_traits>
#include <boost/tti/has_member_function.hpp>
BOOST_TTI_HAS_MEMBER_FUNCTION(push)
BOOST_TTI_HAS_MEMBER_FUNCTION(pop)
BOOST_TTI_HAS_MEMBER_FUNCTION(top)
template <typename C>
@m00shm00sh
m00shm00sh / stlcontainer-oplshift.cc
Last active August 29, 2015 14:12
Implementation of operator<< for containers which have insert or push_{back,front}
#if __cplusplus < 201103L
#error "missing -std=c++11"
#endif
#include <utility>
#include <string>
#include <iostream>
#include <vector>
#include <map>
#include <list>