Skip to content

Instantly share code, notes, and snippets.

Avatar

Steve Hannah shannah

View GitHub Profile
@shannah
shannah / main.c
Created January 20, 2022 15:07
Sample using JLI_Launch to launch JVM
View main.c
#include <jni.h>
#include <string.h>
#include <objc/objc-runtime.h>
#ifdef _WIN32
#include <windows.h>
#define LIBTYPE HINSTANCE
#define OPENLIB(libname) LoadLibrary(TEXT(libname))
#define LIBFUNC(lib, fn) GetProcAddress((lib), (fn))
View build.sh
#!/bin/bash
set -e
echo "Building on platform $(uname -s)"
export CGO_CFLAGS="-I$JAVA_HOME/include"
if [ -d "$JAVA_HOME/include/darwin" ]; then
export CGO_CFLAGS="-I$JAVA_HOME/include/darwin $CGO_CFLAGS"
elif [ -d "$JAVA_HOME/include/linux" ]; then
export CGO_CFLAGS="-I$JAVA_HOME/include/linux $CGO_CFLAGS"
elif [ -d "$JAVA_HOME/include/win32" ]; then
export CGO_CFLAGS="-I$JAVA_HOME/include/win32 $CGO_CFLAGS"
View jvm.h
#ifdef LINK_JVM
#ifndef jvm_h
#define jvm_h
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
@shannah
shannah / Error.txt
Created January 19, 2022 17:21
JavaFX startup error
View Error.txt
Jan. 19, 2022 8:54:27 A.M. com.sun.javafx.application.PlatformImpl startup
WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @56380231'
Exception in thread "Thread-5" java.lang.IllegalStateException: This operation is permitted on the event thread only; currentThread = Thread-5
at com.sun.glass.ui.Application.checkEventThread(Application.java:447)
at com.sun.glass.ui.Application.setName(Application.java:200)
at com.sun.javafx.application.PlatformImpl.lambda$setApplicationName$2(PlatformImpl.java:142)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
@shannah
shannah / tuxpin-dev-server.sh
Created December 21, 2021 16:49
Shellmarks server management script for Tuxpin
View tuxpin-dev-server.sh
#!/bin/bash
echo "Running with ${serverStatus}"
PORT="9090"
TUXPIN_PATH=/path/to/tuxpin
URL="http://localhost:$PORT"
if [ ! -z "$startServer" ]; then
ACTIVE=$(lsof -P -i TCP -s TCP:LISTEN | grep "$PORT")
if [ ! -z "$ACTIVE" ]; then
if [ ! -z "$openOnStart" ]; then
open "$URL"
@shannah
shannah / ipa-shellmarks-sample.sh
Created December 19, 2021 15:24
A sample shellmarks script for getting entitlements from an IPA file.
View ipa-shellmarks-sample.sh
#!/bin/bash
file_extracted="${file}-extracted"
if [ ! -d "${file_extracted}" ]; then
if [ ! -f "$file" ]; then
echo "Cannot find file $file"
exit 1
fi
mkdir "${file_extracted}"
cp "$file" "${file_extracted}/App.zip"
cd "${file_extracted}"
@shannah
shannah / cn1-update.sh
Created December 13, 2021 16:51
Script to update Codename one project
View cn1-update.sh
#!/bin/bash
DIR="$( cd "$(dirname "$0")" ; pwd -P )"
UPDATE_JAR=$HOME/.codenameone/UpdateCodenameOne.jar
if [ ! -f $UPDATE_JAR ]
then
curl https://www.codenameone.com/files/updates/UpdateCodenameOne.jar > $UPDATE_JAR
fi
@shannah
shannah / pom-snippet.xml
Created December 10, 2021 13:31
Kotlin profile for common/pom.xml file
View pom-snippet.xml
<profile>
<id>kotlin</id>
<activation>
<file>
<!-- To enable Kotlin, add the following file to the project base dir -->
<exists>${basedir}/src/main/kotlin</exists>
</file>
</activation>
<properties>
<kotlin.version>1.4.32</kotlin.version>
@shannah
shannah / GoogleMapsDemo.java
Created December 6, 2021 14:25
Adapted from https://github.com/shannah/googlemaps-maven-demo but with changes to test reported NPE in addPath
View GoogleMapsDemo.java
package com.codename1.demos.googlemaps;
import com.codename1.components.FloatingActionButton;
import com.codename1.components.InteractionDialog;
import com.codename1.components.ToastBar;
import com.codename1.googlemaps.MapContainer;
import com.codename1.googlemaps.MapContainer.MapObject;
import com.codename1.io.Util;
import com.codename1.maps.BoundingBox;
import com.codename1.maps.Coord;
@shannah
shannah / bcversions.sh
Created October 8, 2021 13:37
A bash script for printing out classes in a jar file with version greater than some value
View bcversions.sh
#!/bin/bash
JARPATH="$1"
MIN="$2"
if [[ "$JARPATH" == "" ]] || [[ "$MIN" == "" ]]; then
echo 'This script will scan the classes in a jar file, and print the ones whose '
echo 'bytecode versions are greater than a given value.'
echo ''
echo 'Usage bash bcversions.sh JARPATH MAXVERSION'