Skip to content

Instantly share code, notes, and snippets.

@crcdng
crcdng / prepare_itch.sh
Last active October 6, 2024 22:46
shell script to build and prepare a Flutter/Flame web project for itch.io
#!/bin/sh
# builds and prepares a Flutter/Flame web build for itch.io
# tested on Mac
# added: create output dir if it does not exist
# added: mitigate bug where keyboard keys are working fine locally but aren’t recognized on itch.io.
# after uploading set the dimensions in the "Embed options" section on itch.io
# set these parameters before running
PROJECT_NAME='NAME'
@crcdng
crcdng / hydra_local.md
Last active June 11, 2023 22:00
Mini Tutorial - run hydra locally (tested on Mac Ventura / Chrome 113)

prerequisites: git, node.js, yarn, chrome browser as decribed here: https://github.com/hydra-synth/hydra#running-locally. run the commands below in Terminal

note: the parameters reduce the size of the download a bit

git clone --depth 1 --branch "main" https://github.com/hydra-synth/hydra.git

cd hydra

note: the --ignore-engines parameter is necessary because at the time of this writing the dependencies of hydra won't allow node.js > 16

@crcdng
crcdng / leap_macos.md
Last active August 1, 2024 08:25
Set up Leap Motion for Python development on macOS 11 Big Sur

NOTE this tutorial was written Dec 2020 and I don't use Leap on Mac since then. Use at your own risk. It still seems to work for some people, but I cannot support it further or answer questions unless I get a project with Leap / Mac again.

The Leap Motion Controller (https://www.ultraleap.com/product/leap-motion-controller/) has been a favourite input device for user interface designers and hackers alike. It allows to create touchless user interfaces that track hand movement and recognize gestures (not bad in the current situation).

Unfortunately the company who made it has decided to go big and bold on VR and Windows only and stopped supporting development on a Mac. There are still options available, for example getting the Leap Motion data via node.js. Yet Python can be the right choice, especially if you want to feed the data into a machine learning pipeline or use any of the numerous libraries that the Python ecosystem offers.

Getting this to work on macOS requires a few steps (tested on macOS 11

A temporary note on machine vision with ML Kit and Flutter

  1. Firebase ML Kit is deprecated (https://developers.google.com/ml-kit/migration). All 3rd-party published tutorials I could find on September 6, 2020 are referring to the deprecated APIs.

  2. As of June 3, 2020 the new products / APIs are ML Kit (https://developers.google.com/ml-kit) and Firebase Machine Learning aka Firebase ML, in beta (https://firebase.google.com/products/ml).

  3. Flutter (https://flutter.dev/) features a plugin from the Firebase team named firebase_ml_vision, described as "A Flutter plugin to use the capabilities of Firebase ML, which includes all of Firebase's cloud-based ML features, and ML Kit, a standalone library for on-device ML, which can be used with or without Firebase" (https://pub.dev/packages/firebase_ml_vision). Thus the plugin is supposed to cover both ML Kit (which can be used without Firebase) and Firebase ML. Its name therefore could lead to confusion.

  4. As of September 6, 2020, the plugin, however, does no

@crcdng
crcdng / Unity3D tips.md
Last active August 2, 2020 21:05
A few learnings from working with Unity3D https://unity.com/ (regularly updated)

Unity3D tips

1. Avoid creating objects inside the game loop.

Unfortunately one of the first things you see in many Unity game tutorials is a mistake.

Wrong:

using System.Collections;
@crcdng
crcdng / mta_td.md
Last active July 3, 2020 13:28
How to get MTA live data in TouchDesigner

How to get New York city subway live data in TouchDesigner

This is a short write up on how I am getting live data from the New York city subway https://new.mta.info/ (metro, underground, U-Bahn, however you call it) in TouchDesigner https://derivative.ca/. It is a bit terse and requires some tinkering, installing, using git and changing settings. Hit me up on Twitter if you have any questions (https://twitter.com/crcdng).

Many live data feeds come with a REST API where you can call a web service and get data back back in JSON format. The realtime subway data uses a different mechanism called GTFS Realtime, which is based on Protocol Buffers (https://developers.google.com/transit/gtfs-realtime/). I believe you can get the data in JSON format for Google Maps, but here I will retrieve it directly with Python, the included scripting language of choice in TouchDesigner.

Before retrieving the data within Touch, I will get it with a Python script running outside of Touch. The reasons are (1) in this way the ne

@crcdng
crcdng / pd_crash_on_startup.md
Last active June 14, 2020 23:06
An old bug that causes pure data (https://puredata.info/) to crash at startup.

pd startup crash

When pure data (https://puredata.info/) crashes at startup, open the sketch with a text editor.

If you see a minus in a line like this

#N canvas 38 -769 692 735 12;

delete the minus

@crcdng
crcdng / p5_catalina_dev.md
Last active October 9, 2024 01:03
How to fix Processing on MacOSX 15 Catalina

How to fix Processing (https://processing.org) Camera and Microphone on macOS 10.15 Catalina

This solution requires that you are a member of the Apple Developer program

Last updated on 2020_11_08

Update: In Processing alpha2 (15 September 2020) with the libraries Sound 2.2.3 and Video 2.0, Audio and Video input are still broken. The workaround below should work with that version as well, although I have not tested it.

Apple has been changing around things for developers quite a lot since 2019. This concerns (among others):

  • newly required permissions for apps that access the camera and microphone
// http://www.99-bottles-of-beer.net/
void main() {
for (int beer = 99; beer >= 0; beer--) {
String bottles = beer > 1 ? "bottles" : "bottle";
String bottlesLeft = beer == 1 ? "no more" : (beer - 1).toString();
String leftBottles = beer == 2 ? "bottle" : "bottles";
String beerline =
'$beer $bottles of beer on the wall, $beer $bottles of beer.\nTake one down and pass it around, $bottlesLeft $leftBottles of beer on the wall.';
String lastline =
@crcdng
crcdng / main.dart
Last active February 22, 2020 03:59
Dart Future example
import 'dart:async';
import 'dart:math';
void main() {
print("The main UI thread starts here.");
print("Now it will take 10 seconds to display news headlines.");
displayNews();
print("The main UI thread ends.");
}