Skip to content

Instantly share code, notes, and snippets.

View ypujante's full-sized avatar

Yan Pujante ypujante

View GitHub Profile
@ypujante
ypujante / gen_macos_iconset.py
Created November 25, 2022 18:19
Generate a macos iconset (.icns) from an svg file using Google Chrome
#!/usr/bin/env python3
import sys
import tempfile
from pathlib import Path
import subprocess
import os
import platform
scale = 1.0
@ypujante
ypujante / svg_2_png.py
Last active November 29, 2022 19:53
Convert an svg to a png using Google Chrome
#!/usr/bin/env python3
import argparse
import tempfile
from pathlib import Path
import subprocess
import os
import platform
scale = 1.0
@ypujante
ypujante / extract_vocals.py
Created October 18, 2020 18:42
python 3 script to extract vocals from a song using the Docker researchdeezer/spleeter image
#!/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 September 18, 2020 13:51
Display TimeMachine logs (acts like tail -f)
#!/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!)
#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 June 11, 2019 14:36
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
// 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 June 4, 2019 13:30
Pass command line arguments to ktor server
// ... 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 August 29, 2017 15:43
Start a local web server (nginx) serving local files using docker
#!/bin/bash
PORT=80
WWW_DIR=`pwd`
###############################################################################
#
# Function Name : usage()
# Arguments : N/A
# Return Result : N/A, exit 0
@ypujante
ypujante / PublishSubjectBehavior.kt
Created July 5, 2017 14:47
Backing code to Stack Overflow PublishSubject question
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 March 6, 2016 18:41
Workaround to El Capitan Slow Time Machine speed
<?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>