Skip to content

Instantly share code, notes, and snippets.

@alexjlockwood
alexjlockwood / androidx-class-mapping.csv
Last active March 10, 2024 21:08
Android X migration script
android.support.v7.widget.util.SortedListAdapterCallback androidx.recyclerview.widget.SortedListAdapterCallback
android.support.v7.widget.helper.ItemTouchUIUtilImpl androidx.recyclerview.widget.ItemTouchUIUtilImpl
android.support.v7.widget.helper.ItemTouchUIUtil androidx.recyclerview.widget.ItemTouchUIUtil
android.support.v7.widget.helper.ItemTouchHelper androidx.recyclerview.widget.ItemTouchHelper
android.support.v7.widget.WithHint androidx.appcompat.widget.WithHint
android.support.v7.widget.ViewUtils androidx.appcompat.widget.ViewUtils
android.support.v7.widget.ViewStubCompat androidx.appcompat.widget.ViewStubCompat
android.support.v7.widget.ViewInfoStore androidx.recyclerview.widget.ViewInfoStore
android.support.v7.widget.ViewBoundsCheck androidx.recyclerview.widget.ViewBoundsCheck
android.support.v7.widget.VectorEnabledTintResources androidx.appcompat.widget.VectorEnabledTintResources
@alexjlockwood
alexjlockwood / RingOfCirclesView.kt
Last active January 10, 2024 14:07
Kotlin implementation of a Ring of Circles animation, inspired by https://twitter.com/InfinityLoopGIF/status/1101584983259533312
import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.util.AttributeSet
import android.view.View
private const val N = 16
private const val PERIOD1 = -10000.0
private const val PERIOD2 = -500.0
@alexjlockwood
alexjlockwood / WaveSquare.kt
Created September 9, 2020 03:21
A composable wave square animation.
package com.alexjlockwood.wavesquare
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.animation.animatedFloat
import androidx.compose.animation.core.AnimationConstants
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.repeatable
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Canvas
@alexjlockwood
alexjlockwood / animated_cat.xml
Last active September 12, 2023 12:55
Android implementation of an animated cat loading spinner. Inspired by https://twitter.com/marcedwards/status/1109431862030524418
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:name="vector"
android:width="100dp"
android:height="100dp"
android:viewportWidth="100"
android:viewportHeight="100">
<group
@alexjlockwood
alexjlockwood / generate-style-descriptions.ts
Last active September 12, 2023 12:54
Generates style descriptions for each color style in the current Figma file.
// Get the list of color styles in the current Figma file.
const colorStyles = figma.getLocalPaintStyles();
const updatedColorStyles = colorStyles.filter(style => {
const { paints } = style;
if (paints.length !== 1) {
// Skip styles containing multiple colors.
return false;
}
const [paint] = paints;
@alexjlockwood
alexjlockwood / flatten-icons.ts
Last active September 12, 2023 12:49
Flattens all components in a Figma file. Note that this script assumes that (1) every component in the file is an icon, (2) each icon contains a single color, and (3) the icons don't use masks. The `figma.flatten` function may not work as you expect if one of these conditions aren't met.
// Create a list of all component nodes in the Figma file.
const componentNodes = figma.root.children.flatMap(pageNode => {
return pageNode.findAll(node => node.type === 'COMPONENT');
}) as readonly ComponentNode[];
// Create a list of component nodes that have more than one child node.
const unflattenedComponentNodes = componentNodes.filter(componentNode => {
const childrenNodes = componentNode.findAll(() => true);
return childrenNodes.length > 1;
});
@alexjlockwood
alexjlockwood / detach-color-styles.ts
Last active September 12, 2023 12:49
This plugin recurses every layer in every page of the current figma file, and detaches color styles that are backed by a single bound color variable.
// This plugin recurses every layer in every page of the current figma file, and detaches
// color styles that are backed by a single bound color variable.
(function main() {
recurseLayerHierarchy(figma.root, false);
figma.closePlugin();
})();
function recurseLayerHierarchy(node: BaseNode, isChildOfInstanceNode: boolean) {
if (node.type === 'INSTANCE') {

How a path is generated

Step 1

Place two 4x1 vertical stack of tiles and three 3x1 vertical stack of tiles on the grid. The order in which you place the tiles is random (so for example there would be a 2 / 5 = 40% chance that the path could end with a 4x1 line to the finish). The stacks are placed such that the top of one stack will align to the bottom of the next stack. The tips of the stacks are not allowed to intersect.

For example, after step 1 it could look like this:

|x| | | | | | | | | |
using System;
using System.Collections.Generic;
using System.Linq;
using FG.Common;
using SRF;
using UnityEngine;
namespace Levels.CrownMaze
{
// Token: 0x020004C1 RID: 1217
using System;
using System.Collections.Generic;
using System.Linq;
using FG.Common;
using Levels.ProceduralGeneration;
using MPG.Utility;
using UnityEngine;
namespace Levels.CrownMaze
{