Skip to content

Instantly share code, notes, and snippets.

View robert-wallis's full-sized avatar

Robert Wallis robert-wallis

View GitHub Profile
@mholt
mholt / macapp.go
Last active April 8, 2024 17:54
Distribute your Go program (or any single binary) as a native macOS application
// Package main is a sample macOS-app-bundling program to demonstrate how to
// automate the process described in this tutorial:
//
// https://medium.com/@mattholt/packaging-a-go-application-for-macos-f7084b00f6b5
//
// Bundling the .app is the first thing it does, and creating the DMG is the
// second. Making the DMG is optional, and is only done if you provide
// the template DMG file, which you have to create beforehand.
//
// Example use:
#![cfg_attr(any(target_os = "ios", target_os = "android"), no_main]
fn main() {
main2();
}
#[cfg(any(target_os = "ios", target_os = "android"))]
#[no_mangle]
#[allow(non_snake_case)]
pub extern "C" fn SDL_main() -> i32 {

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

@Calinou
Calinou / build_windows.bat
Last active June 16, 2022 14:57
Compile Godot for Windows easily
:: This script must be run from a Windows machine with
:: Visual Studio 2015, Python 2.7 and SCons installed at their
:: default locations. 7-Zip also needs to be installed (to compress editor binaries).
:: NOTE: You need Pywin32 to be installed to use multi-threaded compilation.
:: You may need to set "threads" to 1 for the first build, even if you have it installed.
:: Place this script at the root of your Godot Git clone.
:: CC0 1.0 Universal
@benjaminjackman
benjaminjackman / README
Last active October 26, 2019 10:09
Instructions on how to open Unity3d scripts in Rider on Ubuntu
#Simple instructions for using Unity3d with project rider on Ubuntu
#1. Download and install latest .deb for Unity3d from:
http://forum.unity3d.com/threads/unity-on-linux-release-notes-and-known-issues.350256/
#2. Download and install the Project Rider EAP (not sure if publicly available but you
can sign up for early access here: https://www.jetbrains.com/rider/
#3. Open the Unity3d (.deb installs the executable at /opt/Unity/Editor/Unity )
@Flafla2
Flafla2 / Perlin_Tiled.cs
Last active April 27, 2024 19:43
A slightly modified implementation of Ken Perlin's improved noise that allows for tiling the noise arbitrarily.
public class Perlin {
public int repeat;
public Perlin(int repeat = -1) {
this.repeat = repeat;
}
public double OctavePerlin(double x, double y, double z, int octaves, double persistence) {
double total = 0;
@tskaggs
tskaggs / OSX-Convert-MOV-GIF.md
Last active October 9, 2023 12:15
Creating GIFs from .MOV files in OSX using FFmpeg and ImageMagick

Convert MOV to GIF using FFmpeg and ImageMagick

I tried a few different techniques to make a GIF via command-line and the following gives me the best control of quality and size. Once you're all setup, you'll be pumping out GIFs in no time!

Preparation

Install FFmpeg

  • $ brew install ffmpeg [all your options]
    • Example: $ brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libass --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools

Install ImageMagick

@freeformz
freeformz / WhyILikeGo.md
Last active October 6, 2022 23:31
Why I Like Go

A slightly updated version of this doc is here on my website.

Why I Like Go

I visited with PagerDuty yesterday for a little Friday beer and pizza. While there I got started talking about Go. I was asked by Alex, their CEO, why I liked it. Several other people have asked me the same question recently, so I figured it was worth posting.

Goroutines

The first 1/2 of Go's concurrency story. Lightweight, concurrent function execution. You can spawn tons of these if needed and the Go runtime multiplexes them onto the configured number of CPUs/Threads as needed. They start with a super small stack that can grow (and shrink) via dynamic allocation (and freeing). They are as simple as go f(x), where f() is a function.

@kylelemons
kylelemons / regexpswitch.go
Created August 18, 2011 16:34
Switch on a regex pattern
package main
import "fmt"
import "regexp"
var email = regexp.MustCompile(`^[^@]+@[^@.]+\.[^@.]+$`)
var shortPhone = regexp.MustCompile(`^[0-9][0-9][0-9][.\-]?[0-9][0-9][0-9][0-9]$`)
var longPhone = regexp.MustCompile(`^[(]?[0-9][0-9][0-9][). \-]*[0-9][0-9][0-9][.\-]?[0-9][0-9][0-9][0-9]$`)
func main() {