Skip to content

Instantly share code, notes, and snippets.

Avatar

Jim Northrup jnorthrup

  • here, now
View GitHub Profile
@jnorthrup
jnorthrup / gist:fb105a5aef7241ec2513bcdef10a4c5f
Last active Jul 4, 2022
add simplest possible zstd to kde konq,dolphin context menu
View gist:fb105a5aef7241ec2513bcdef10a4c5f
x=$(kf5-config --path services|cut -f1 -d:)&&mkdir -p $x/ServiceMenus&&pushd $x/ServiceMenus&&
cat <<EOF
[Desktop Entry]
Type=Service
ServiceTypes=all/allfiles
MimeType=all/all;
Actions=CompressZstd
X-KDE-Priority=TopLevel
X-KDE-Submenu=7-Zip
@jnorthrup
jnorthrup / kernel.sh
Last active Apr 24, 2022
grub-mkconfig WIP
View kernel.sh
cfg=(
--bootloader=grub2
--no-mrproper
--no-clean
--makeopts=-j8
--no-firmware
--no-busybox
--no-keymap
@jnorthrup
jnorthrup / ctok.bash
Last active Nov 30, 2021
C Lang to Kotlin sed script
View ctok.bash
#!/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{,'\
View FuzzyReference.java
/**
* Numerically re-prioritizable reference.
* Repurposes SoftReference.timestamp field as a priority value.
* <p>
* Intended to re-use all SoftReference-related VM features
* except its time-as-priority behavior.
*
* TODO this requires some modifications to internal JVM GC behavior.
@jnorthrup
jnorthrup / server.kt
Created Oct 29, 2021 — forked from kavanmevada/server.kt
Kotlin/Native POSIX Socket Server
View server.kt
package sample
import kotlinx.cinterop.*
import platform.linux.inet_ntoa
import platform.posix.*
/**
*
*/
View unsafe_vs_array.java
import java.lang.reflect.Field;
import sun.misc.Unsafe;
public class Test {
private static final int N = 128 * 1024 * 1024;
public static void main(String[] args) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
{
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
@jnorthrup
jnorthrup / JSObj.kt
Last active Oct 15, 2021 — forked from mpetuska/JSObj.kt
Fluent Kotlin DSL for building JSON trees
View JSObj.kt
@DslMarker
annotation class JSBuilderDsl
@DslMarker
annotation class JSSetterDsl
data class JSObj(val map: MutableMap<String, Any?> = linkedMapOf()) : MutableMap<String, Any?> by map {
object Arr {
@JSBuilderDsl
View CoinsAndPairings.kt
package com.fnreport.org.bereft
import com.binance.api.client.BinanceApiClientFactory
import vec.util.logDebug
import java.io.FileWriter
import java.util.*
/**
* maybe this is two classes? or maybe it's just a rarely used loop filter thing that needs no more attention.
*/
@jnorthrup
jnorthrup / shell res
Created Apr 20, 2020
kotlinc vs python3
View shell res
jim@OJFQCCK22EVHS7YKLYN6LXTEZ2JR4HAZ:~/work/columnar/superannuate$ export JAVA_HOME=/opt/jdk-15/ JAVA_OPTS=-Xmx512m ;export PATH=/opt/jdk-15//bin/:$PATH;time kotlinc-jvm -jvm-target 13 -Xnew-inference -cp $(find ../cursor/target/ -name '*jar'|xargs -n999 echo|tr ' ' :) -script histogram.kts
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
1
emulating
import pandas as pd;
View StringParser.java
/*
* StringParser.java
*
* Copyright (C) 2008 Pei Wang
*
* This file is part of Open-NARS.
*
* Open-NARS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or