Skip to content

Instantly share code, notes, and snippets.

View Gounlaf's full-sized avatar
🤩
I'm trying to port Magick.NET to Kotlin

Florian Levis Gounlaf

🤩
I'm trying to port Magick.NET to Kotlin
View GitHub Profile
@erikhuizinga
erikhuizinga / CartesianProduct.kt
Last active March 30, 2025 21:38
Kotlin function for cartesian product of any number of sets of any size
import kotlin.reflect.KFunction
typealias CartesianProduct = Set<List<*>>
/**
* Create the cartesian product of any number of sets of any size. Useful for parameterized tests
* to generate a large parameter space with little code. Note that any type information is lost, as
* the returned set contains list of any combination of types in the input set.
*
* @param a The first set.
@ubergesundheit
ubergesundheit / readme.md
Last active April 17, 2025 16:30
systemd traefik.service

systemd Service Unit for Traefik

Adapted from caddy systemd Service Unit

The provided file should work with systemd version 219 or later. It might work with earlier versions. The easiest way to check your systemd version is to run systemctl --version.

Instructions

We will assume the following:

@negz
negz / kubedump.sh
Last active July 11, 2024 10:57
Dump Kubernetes cluster resources as YAML
#!/usr/bin/env bash
set -e
CONTEXT="$1"
if [[ -z ${CONTEXT} ]]; then
echo "Usage: $0 KUBE-CONTEXT"
exit 1
fi
@jimschubert
jimschubert / .gitignore
Last active March 27, 2025 09:49
Prototyping a Flags/Bitmasks implementation in Kotlin 1.1.1
META-INF/
*.class
public class SpacingItemDecoration extends RecyclerView.ItemDecoration {
private int spacing;
public SpacingItemDecoration(Context context, int padding) {
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
spacing = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, padding, metrics);
}
@Override
public final void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
@andreibosco
andreibosco / creative-cloud-disable.md
Last active December 19, 2024 08:28
disable creative cloud startup on mac
@vipulshah2010
vipulshah2010 / RetrofitException.java
Created June 6, 2016 05:39
RxAndroid Error Handling
public class RetrofitException extends RuntimeException {
public static RetrofitException httpError(String url, Response response, Retrofit retrofit) {
String message = response.code() + " " + response.message();
return new RetrofitException(message, url, response, Kind.HTTP, null, retrofit);
}
public static RetrofitException networkError(IOException exception) {
return new RetrofitException(exception.getMessage(), null, null, Kind.NETWORK, exception, null);
}
@jonfinerty
jonfinerty / CrashlyticsTree.java
Created May 12, 2016 16:46
Report Android Exceptions - Crashlytics Tree for Timber
import android.util.Log;
import com.crashlytics.android.Crashlytics;
import timber.log.Timber;
public class CrashlyticsTree extends Timber.Tree {
@Override
protected boolean isLoggable(int priority) {
@codezjx
codezjx / CircleImageTransformation.java
Last active July 28, 2023 12:15
A picasso circle image transformation. Optimized version of: https://gist.github.com/julianshen/5829333. Use shader.setLocalMatrix() method to draw circle bitmap not from source bitmap left-top. So, we no need to create square bitmap!
/**
* Created by codezjx on 2016/5/4.
*/
public class CircleImageTransformation implements Transformation {
/**
* A unique key for the transformation, used for caching purposes.
*/
private static final String KEY = "circleImageTransformation";
public class RealmListParcelConverter implements TypeRangeParcelConverter<RealmList<? extends RealmObject>, RealmList<? extends RealmObject>> {
private static final int NULL = -1;
@Override
public void toParcel(RealmList<? extends RealmObject> input, Parcel parcel) {
if (input == null) {
parcel.writeInt(NULL);
} else {
parcel.writeInt(input.size());
for (RealmObject item : input) {