Skip to content

Instantly share code, notes, and snippets.

@soywiz
soywiz / KtorAutoReload.kt
Created February 12, 2022 07:52
Ktor Autoreload Snippet
// implementation("io.methvin:directory-watcher:0.15.0")
import io.ktor.server.application.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
import io.methvin.watcher.*
import java.io.*
var resourceVersion = 0L
@soywiz
soywiz / main.c
Last active March 14, 2020 13:46 — forked from andormade/main.c
Audio Queue example
// gcc -framework Audiotoolbox -framework CoreAudio -framework CoreServices main.c
#include <stdlib.h>
#include <math.h>
#include <AudioToolbox/AudioQueue.h>
#include <CoreAudio/CoreAudioTypes.h>
#include <CoreFoundation/CFRunLoop.h>
#define NUM_CHANNELS 2
@soywiz
soywiz / TvShowNfo.kt
Last active April 17, 2024 02:53
VideoStation's VsMeta File Format (released as PUBLIC DOMAIN) https://unlicense.org/
package com.soywiz.util
import com.soywiz.klock.*
import com.soywiz.korio.file.*
import com.soywiz.korio.serialization.xml.*
class TvShowNfo {
data class Info(
var title: String = "",
var sortTitle: String? = null,
@soywiz
soywiz / docker_volume.sh
Last active January 19, 2019 18:54
Small script to manage docker volumes (list, cat, delete or copy from and to volumes)
#!/usr/bin/env bash
export CMD=$1
export VOLUME=$2
export FILE=$3
if [ "$CMD" == "" ] || [ "$VOLUME" == "" ] || [ "$FILE" == "" ]; then
echo "Missing argument/s: $0 [ls|rm|get|put] volume file"
exit
fi
export gpgconf_path=`which gpgconf`
echo "gpgconf_path: $gpgconf_path"
if [ "$gpgconf_path" = "" ]; then
echo Non gpg2 in path
exit 1
fi
read -r -d '' homebrew_gpg_gpg_agent_plist << \
_______________________________________________________________________________
class SimplifiedXmppClient private constructor(
val user: String,
val password: String,
val host: String,
val port: Int,
val domain: String
) {
companion object {
suspend fun connectTo(
@soywiz
soywiz / benchmark.php
Created June 4, 2017 01:03
jtransc PHP benchmark
This file has been truncated, but you can view the full file.
<?php
// JTransc 0.6.3-snapshot : https://github.com/jtransc/jtransc
// php program.php
// hhvm -v Eval.EnableHipHopSyntax=true program.php
if (defined('HHVM_VERSION')) {
// @TODO: Check minimum HHVM_VERSION
} else {
if (version_compare(phpversion(), '7.1.0', '<')) die('Requires PHP 7.1 or higher but was ' . phpversion());
@soywiz
soywiz / executable.sh
Created February 3, 2017 00:01
Mark file as executable on Git repo
git update-index --chmod=+x file.sh
git ls-tree HEAD
@soywiz
soywiz / gradle_to_m2.kts
Created December 6, 2016 17:27
Copy gradle cache structure into local m2 folder structure
import java.io.File
import java.security.MessageDigest
val gradleBase = System.getenv("HOME") + "/.gradle/caches/modules-2/files-2.1"
val m2Base = System.getenv("HOME") + "/.m2/repository"
fun ByteArray.toHex() = this.map { "%02x".format(it) }.joinToString("")
operator fun File.get(name: String) = File(this, name)
for (groupFolder in File(gradleBase).listFiles().filter { it.isDirectory }) {
val group = groupFolder.name
// Depends on code defined here (related to EventLoop and promise implementation):
// https://gist.github.com/soywiz/a2a26b9375f1f85048ab3ce7ffdb5501
// More examples here: httpshttps://github.com/kotlin-es/coroutine-examples/blob/master/src/example-async-generator.kt
import java.util.*
fun main(args: Array<String>) = EventLoop.main {
// Asynchronous Producer