Skip to content

Instantly share code, notes, and snippets.

View Ribesg's full-sized avatar
🇫🇷

Gael Ribes Ribesg

🇫🇷
View GitHub Profile
@Ribesg
Ribesg / !README.md
Last active June 20, 2022 15:00
How to use a Kotlin MPP library depending on an iOS Framework in a XCode iOS App

This gist demonstrates how to use a Kotlin MPP library which depends on an iOS Framework in a native iOS application (XCode project).

First, see [how the Kotlin MPP Library is built][lib-build].

Key ideas:

  • We can currently only use a single Kotlin MPP library in an iOS project, so we need to create a MPP project local to our iOS XCode project whose sole purpose is to aggregate multiple MPP dependencies into a single Framework.
  • To keep our working environment clean, we create the gradle project in a subdirectory instead of at the root of our iOS XCode project. I name my subdirectory mpp.
  • We need to have the Frameworks used by our dependencies locally, as we only have bindings provided by the cinterop klibs, so we use [Carthage] again.
  • As the only goal of our gradle project is to create a Framework, we only use ios* targets.
  • Our project won't have any source code, but we NEED at least one source file, or Gradle will refuse to build anything, returning just a rude NO-SOURCE. Just create
@Ribesg
Ribesg / !README.md
Last active June 20, 2022 15:00
How to use an iOS Framework in a Kotlin MPP library published to Maven

This gist demonstrates how to build a Kotlin MPP library so that the iOS sourceSet depends on and uses an iOS Framework as a dependency.

Key ideas:

  • We use [Carthage] to retrieve/build the iOS Framework.
  • We use [cinterop] to create bindings allowing us to use the iOS Framework from Kotlin
  • We build and publish the library using ./gradlew publishToMavenLocal
  • We build and publish [klib] artifacts for both the arm64 and x86_64 architectures, you can easily add arm32 if you need.
  • Note that the publish process also publishes a cinterop klib artifact, allowing dependents to also know about the iOS Framework headers.

You can find a gist explaining how to use such library in an iOS app [here][ios-app].

@file:Suppress("NOTHING_TO_INLINE")
package org.jetbrains.anko
import android.app.Fragment
import android.view.View
/*
* This class must be named Dialogs2 to not override Anko.
*/
@Ribesg
Ribesg / fabric-beta-testers-scraper.js
Last active April 18, 2016 23:52
Use on the Beta tab of Fabric to get the list of beta testers as a CSV file. This code is GPLv3.
(function(){
function escapeCsvValue(str) {
var res = str;
if (res.indexOf('"') >= 0) {
res = res.replace(/"/g, '""');
}
if (res.indexOf('"') >= 0 || res.indexOf(' ') >= 0) {
res = '"' + res + '"';
}
@Ribesg
Ribesg / Foo.java
Last active January 3, 2016 12:29
// INPUT
final Map<ItemStack, Double> myItemsWithWeight; // Initialized somewhere before that
// Data
final List<ItemStack> myItems = new ArrayList<>(myItemsWithWeight.size());
final double[] risingWeights = new double[myItemsWithWeight.size()];
// Compute total weight
double total = 0;
for (final double d : myItemsWithWeight.values()) {
// Java 6
SomeStream stream
try {
stream = new SomeStream(someArg);
// Stuff
} catch (SomeStreamExceptions e) {
// Stuff
} final {
try {
stream.close();
@Ribesg
Ribesg / bash_aliases.sh
Last active December 31, 2015 12:09
Here's my server's Starbound related config files and scripts.
alias sb_start="sudo start starbound"
alias sb_stop="sudo stop starbound"
alias sb_restart="sb_stop;sb_start"
alias sb_update="sudo /home/ribesg/sb_update"
alias sb_online="netstat -nt | grep -c 21025"
alias sb_status="sudo status starbound"
#####################################################################
## Config file for NPlayer plugin ##
## If you don't understand something, please ask on dev.bukkit.org ##
## Ribesg ##
#####################################################################
# Maximum login attempts before punishment. Possible values: Positive integers
# Default : 3
maximumLoginAttempts: 1
# How do we punish people after too many attempts? Possible values: 0, 1, 2
#####################################################################
## Config file for NTalk plugin ##
## If you don't understand something, please ask on dev.bukkit.org ##
## Ribesg ##
#####################################################################
# The template used to parse chat messages
# Default : &f<[prefix][name][suffix]&f> [message]
template: "[prefix][name][suffix] &f: [message]"
# The template used to parse private messages
import java.util.ArrayList;
import java.util.List;
/** @author dumptruckman, Ribesg */
public class ArgumentParser {
/**
* Transform a Bukkit-provided args array, considering quotes in the original String.
* Example:
* - Input = { a | 'b | c | d' | "e | f | g" | h"i | j" | "k | l'm | n" | 'o | p | q }