Skip to content

Instantly share code, notes, and snippets.

@aradalvand
aradalvand / DockerfileForSvelteKit.md
Last active April 29, 2024 12:08
Dockerfile and .dockerignore for SvelteKit:

*This Dockerfile is intended for SvelteKit applications that use adapter-node. So, the Dockerfile below assumes that you have already installed and configured the adapter.

Dockerfile:

FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json .
RUN npm ci
COPY . .
RUN npm run build
@NielsMasdorp
NielsMasdorp / Media3Composite.kt
Last active September 6, 2022 10:14
Composite player implementation in media3
@UnstableApi
class StreamService : MediaSessionService(),
Listener, MediaSession.SessionCallback, SessionAvailabilityListener {
private lateinit var player: CompositePlayer
private lateinit var mediaSession: MediaSession
override fun onCreate() {
super.onCreate()
initialize()
@rharter
rharter / Scoped.kt
Last active August 9, 2022 14:58
A kotlin property delegate to scope any object to an android lifecycle. Blog post at https://ryanharter.com/blog/easy-android-scopes/
import androidx.lifecycle.get
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelStore
import androidx.lifecycle.ViewModelStoreOwner
/**
* Returns a property delegate to access the wrapped value, which will be retained for the
* duration of the lifecycle of this [ViewModelStoreOwner].
*
/**
* We are combining unit and intrumentation test reports
* if no one uses instrumentation then delete createDebugCoverageReport
* and it output outputs/code-coverage/connected/*coverage.ec
*/
/**
* Since jacoco does not support android out of the box we create a custom task per variant
* for test coverage.All the coverage reports are created in the root projects build directory.
* These are then archived in the pages folder which is then deployed on the project.
@dlew
dlew / script.sh
Created November 9, 2018 16:36
Simple AndroidX Migration Script
#!/usr/bin/env bash
# I've found that the "Migrate to AndroidX" converter in Android Studio doesn't work very
# well, so I wrote my own script to do the simple job of converting package names.
#
# You can download a CSV of package names here: https://developer.android.com/topic/libraries/support-library/downloads/androidx-class-mapping.csv
#
# It'll run faster on a clean build because then there are fewer files to scan over.
#
# Uses `gsed` because I'm on a Mac. Can easily replace with `sed` if you don't have `gsed`.

⚠️ this is now stupidly out of date

Computers

  • 13" Macbook Pro 3.3 GHz i7 (late 2016)
  • Microsoft Surface Book (2016)

Peripherals

Where you able to produce a binary directly from the Rust build tools that you could submit to the app/play store?


Not quite, but I tried to get as close to that as was reasonably possible. Alas, things ended up a little convoluted.

For iOS, I have a nearly empty Xcode project with a build script that copies my cargo produced executable into the .app that Xcode generates (before Xcode signs it). The build script also uses lipo to merge the executables for each architecture I’m targeting (e.g. armv7 and aarch64 for non-simulator devices) into a single, universal binary.

On top of that, there are various iOS-y things that need to happen before my application’s main method is called. SDL2 provides the Objective-C code that does all of that. In a C or C++ game, SDL2 renames main to SDL_main, and then [inserts its own mai

@nickbutcher
nickbutcher / MainActivity.java
Last active August 20, 2021 16:15
A quick sample of the new physics-based animation library added in Support Library 25.3.0 docs: https://developer.android.com/reference/android/support/animation/package-summary.html output: https://twitter.com/crafty/status/842055117323026432
/*
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@amake
amake / android-7-localization.org
Last active July 25, 2023 22:34
Correct localization on Android 7

Correct localization on Android 7

Prior to Android 7, the system had a single preferred locale, and fallback behavior was quite rudimentary. Starting with Android 7, the user can now specify a priority list of locales, and fallback behavior is improved.

However, in many cases it is still surprisingly difficult to make full use of locale fallback, and there are some hidden gotchas when trying to fully support both Android 7 and earlier versions.

@minsik-ai
minsik-ai / Jetbrains IDE Essential Shortcuts.md
Last active February 18, 2021 04:50
Essential Shortcuts for Jetbrains IDEs, including IntelliJ IDEA, Android Studio & others.

Jetbrains IDE Essential Shortcuts

This is a list of Jetbrains IDE shortcuts I use everyday.

Comments welcome! Tell me your favorites.

Navigating Between Windows

Change Focus to Window