Skip to content

Instantly share code, notes, and snippets.

@boehs
boehs / UniFFI.md
Last active February 16, 2026 18:52
A little guide to UniFFI for iOS (using Proc macros)

Hi all! My app, Love Your Music, needs a cross platform backend shared between a swift and kotlin codebase. UniFFI has been an absolute joy to use, but unfortunately the setup process is a little bit poorly documented. No problem! I got you <3. This tutorial assumes you have a file structure like

Note

Why Rust × Swift? A common use for rust is FFI, which we are actually doing right here anyway! But if you can FFI to Swift, you can FFI to anywhere. Cross platform apps writen in native code (e.g. apps with a Kotlin counterpart) benefit greatly from shared libraries and UniFFI. In addition, the Rust community is significantly larger, and so it's very likely you'll find crates that are more battletested, more featureful, higher performance, more documented, or even nonexistant in Swift.

app/
app.xcodeproj/
app.xcworkspace/
myCrate/
@ThomasG77
ThomasG77 / geojson_to_h3_hexagons.py
Created April 28, 2019 18:00
Take a GeoJSON as an input, take all H3 hexagons within and output GeoJSON hexagons with their id
from h3 import h3
geoJson = {'type': 'Polygon',
'coordinates': [[[37.813318999983238, -122.4089866999972145],
[ 37.7866302000007224, -122.3805436999997056 ],
[37.7198061999978478, -122.3544736999993603],
[ 37.7076131999975672, -122.5123436999983966 ],
[37.7835871999971715, -122.5247187000021967],
[37.8151571999998453, -122.4798767000009008]]] }
@adamgraham
adamgraham / UIColor+HSL.swift
Last active December 5, 2024 14:09
An extension of the iOS class UIColor to provide conversion to and from HSL (hue, saturation, lightness) colors.
/// An extension to provide conversion to and from HSL (hue, saturation, lightness) colors.
extension UIColor {
/// The HSL (hue, saturation, lightness) components of a color.
struct HSL: Hashable {
/// The hue component of the color, in the range [0, 360°].
var hue: CGFloat
/// The saturation component of the color, in the range [0, 100%].
var saturation: CGFloat
@AljoschaMeyer
AljoschaMeyer / cargo.toml
Created March 12, 2018 16:51
Example of statically typed messages.
[package]
name = "demo-ssb-client"
version = "0.1.0"
authors = ["AljoschaMeyer <mail@aljoscha-meyer.de>"]
[dependencies]
tokio = "0.1.3"
futures = "0.1.18"
sodiumoxide = "0.0.16"
@squito
squito / _summary.md
Last active February 5, 2020 14:15
spark sql timestamp semantics, and how they changed from 2.0.0 to 2.0.1 (see query_output_2_0_0.txt vs query_output_2_0_1.txt) changed by SPARK-16216

Spark "Timestamp" Behavior

Reading data in different timezones

Note that the ansi sql standard defines "timestamp" as equivalent to "timestamp without time zone". However Spark's behavior depends on both the version of spark and the file format

format \ spark version <= 2.0.0 >= 2.0.1
@ssimeonov
ssimeonov / DataFrameFunctions.scala
Last active September 1, 2016 18:30
Querying DataFrame with SQL without explicit registration of a temporary table
object DataFrameFunctions {
final val TEMP_TABLE_PLACEHOLDER = "~tbl~"
/** Executes a SQL statement on the dataframe.
* Behind the scenes, it registers and cleans up a temporary table.
*
* @param df input dataframe
* @param stmtTemplate SQL statement template that uses the value of
* `TEMP_TABLE_PLACEHOLDER` for the table name.
@porglezomp
porglezomp / README.md
Last active May 29, 2024 09:18
Serializing Binary Data in Rust

Serializing Binary Data in Rust

The way I like to serialize data in Rust into binary formats is to let a data structure blit itself into a mutable buffer. This is a relatively composable, low level way to work that lends itself to having other abstractions built on top of it. I recently was serializing network packets, so let's make up a small packet format that illustrates how we can do this.

+-------------+-------------+
|  Tag (u16)  | Count (u16) |
+-------------+-------------+
|                           |
~        Entry (u32)        ~
@martijnvermaat
martijnvermaat / nixos.md
Last active November 3, 2025 16:08
Installation of NixOS with encrypted root
@tomysmile
tomysmile / brew-java-and-jenv.md
Last active November 18, 2025 23:30
How To Install Java 8 on Mac

Install HomeBrew first

brew update
brew tap caskroom/cask
brew install brew-cask

If you get the error "already installed", follow the instructions to unlink it, then install again:

@rauchg
rauchg / README.md
Last active December 30, 2025 06:51
require-from-twitter