Skip to content

Instantly share code, notes, and snippets.

Avatar

Yan Pujante ypujante

View GitHub Profile
@ypujante
ypujante / gen_macos_iconset.py
Created Nov 25, 2022
Generate a macos iconset (.icns) from an svg file using Google Chrome
View gen_macos_iconset.py
#!/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 Nov 29, 2022
Convert an svg to a png using Google Chrome
View svg_2_png.py
#!/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 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>