Skip to content

Instantly share code, notes, and snippets.

Avatar

Yan Pujante ypujante

View GitHub Profile
@ypujante
ypujante / extract_vocals.py
Created Oct 18, 2020
python 3 script to extract vocals from a song using the Docker researchdeezer/spleeter image
View extract_vocals.py
#!/usr/bin/env python3
# Example:
# > cd /tmp
# extract_vocals.py '/Users/ypujante/Music/iTunes/iTunes Music/Music/Janet Jackson/Janet/08 This Time.m4a'
# Generates /tmp/08 This Time/vocals.wav and /tmp/08 This Time/accompaniment.wav
import argparse
import os
import subprocess
@ypujante
ypujante / tm-log.sh
Created Sep 18, 2020
Display TimeMachine logs (acts like tail -f)
View tm-log.sh
#!/usr/bin/env bash
# Usage: tm-log.sh [last]
# last: displays up to "last" events before streaming. defaults to 1h (see --last option for log)
LAST=${1:-1h}
ARGS=( --info --predicate 'processImagePath contains "backupd" and subsystem beginswith "com.apple.TimeMachine"' )
# Implementation note: tr -u and sed -l are required (nothing shown until buffer full otherwise!)
View re-jbox-logvalues.h
#include <JukeboxTypes.h>
/**
Replace code like this:
TJBox_Value values[] = {noteCVValue, gateCVValue};
JBOX_TRACEVALUES("Note CV ^0 Gate CV ^1 ", values, 2);
with
@ypujante
ypujante / Kotlin_JS_SubmitFormViaFetch.kt
Created Jun 11, 2019
Example snippet code to post the content of a form to a rest api which then returns some json response using kotlin compiled (=transpiled) to javascript and the fetch api
View Kotlin_JS_SubmitFormViaFetch.kt
// This is an example snippet code to post the content of a form to a rest api which
// then returns some json response using kotlin compiled (=transpiled) to javascript
//
// <form method="POST" action="<url to rest api which returns json>">
// ...fields...
// <input type="button" id="my-submit-button" value="Click Me!">
// </form>
import org.w3c.dom.HTMLInputElement
import org.w3c.xhr.FormData
@ypujante
ypujante / CLI_args_to_ktor_server.build.gradle
Last active Jun 4, 2019
Pass command line arguments to ktor server
View CLI_args_to_ktor_server.build.gradle
// ... build.gradle
// ...
def webFolder = new File(project.buildDir, "web")
// ...
task run(type: JavaExec, dependsOn: [jvmMainClasses, jsJar]) {
main = "sample.SampleJvmKt"
classpath {
[
@ypujante
ypujante / webserver.sh
Created Aug 29, 2017
Start a local web server (nginx) serving local files using docker
View webserver.sh
#!/bin/bash
PORT=80
WWW_DIR=`pwd`
###############################################################################
#
# Function Name : usage()
# Arguments : N/A
# Return Result : N/A, exit 0
@ypujante
ypujante / PublishSubjectBehavior.kt
Created Jul 5, 2017
Backing code to Stack Overflow PublishSubject question
View PublishSubjectBehavior.kt
import io.reactivex.Observable
import io.reactivex.schedulers.Schedulers
import io.reactivex.subjects.PublishSubject
import java.util.*
// see https://stackoverflow.com/questions/44634758/unexpected-behavior-with-rxjava2-publishsubject
fun withAutoConnect() {
val subject = PublishSubject.create<Int>()
@ypujante
ypujante / fix-el-capitan-slow-time-machine-speed.plist
Created Mar 6, 2016
Workaround to El Capitan Slow Time Machine speed
View fix-el-capitan-slow-time-machine-speed.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Copy under /Library/LaunchDaemons and issue sudo launchctl load /Library/LaunchDaemons/fix-el-capitan-slow-time-machine-speed.plist -->
<plist version="1.0">
<dict>
<key>Label</key>
<string>fix-el-capitan-slow-time-machine-speed</string>
<key>ProgramArguments</key>
<array>
<string>/usr/sbin/sysctl</string>
View GluConfigViaChild
// The glu script for the app (parent)
class AppGluScript
{
def onConfigChanged = { config ->
log.info("From AppGluScript.onConfigChanged => ${config}")
}
// required for parent/child relationship
def createChild = { args ->
@ypujante
ypujante / ExceptionJdk17Workaround.groovy
Last active Dec 15, 2015
The purpose of this class is to workaround an issue with groovy when running code compiled under jdk1.6 and running it under jdk1.7 (see forum thread: http://groovy.329449.n5.nabble.com/jdk7-and-IncompatibleClassChangeError-for-exception-class-td5714582.html)
View ExceptionJdk17Workaround.groovy
/*
* Copyright (c) 2013 Yan Pujante
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software