Skip to content

Instantly share code, notes, and snippets.

View jnorthrup's full-sized avatar

Jim Northrup jnorthrup

View GitHub Profile
@jnorthrup
jnorthrup / ctok.bash
Last active November 30, 2021 18:22
C Lang to Kotlin sed script
#!/bin/bash
set -x
#built and tested against clion default formatted c ymmv
sed --in-place --regexp-extended\
-e 's,for\s*\((\w+\s+)(\w+)\s*=\s*(\w+)\;\s*\2.*<([^;]+)\;.*(\2?(\+\+)\2?).*\),for (\2/*as \1*/ in \3 until \4),'\
-e 's,for\s*\((\w+)\s*=\s*(\w+)\;\s*\1.*<([^;]+)\;.*(\1?(\+\+)\1?).*\),for (\1 in \2 until \3),'\
-e 's,^\s*void\s*(\w+)\s*(\(.*\))\s*\{\s*$,fun \1\2:Unit{,'\
-e 's,^\s*(\w+_t)\s*(\w+)\s*(\(.*\))\s*\{\s*$,fun \2\3:\1{,'\
@kavanmevada
kavanmevada / server.kt
Last active March 25, 2023 15:33
Kotlin/Native POSIX Socket Server
package sample
import kotlinx.cinterop.*
import platform.linux.inet_ntoa
import platform.posix.*
/**
*
*/