Skip to content

Instantly share code, notes, and snippets.

@pixlwave
pixlwave / Rakefile
Last active August 29, 2015 14:05
Override RubyMotion build tasks to do more stuff
namespace :build do
desc "Post build tasks"
task :development do
# do stuff
end
desc "Post release build tasks"
task :release do
# do stuff
end
@pixlwave
pixlwave / Rakefile
Created August 30, 2014 16:23
RubyMotion Rakefile build locations
puts App.config.build_dir #=> ./build
puts File.join(App.config.versionized_build_dir('MacOSX')) #=> ./build/MacOSX-10.9-Development
puts App.config.app_bundle('MacOSX') #=> ./build/MacOSX-10.9-Development/MyApp.app/Contents
puts File.dirname(App.config.app_bundle_executable('MacOSX')) #=> ./build/MacOSX-10.9-Development/MyApp.app/Contents/MacOS
puts App.config.app_bundle_executable('MacOSX') #=> ./build/MacOSX-10.9-Development/MyApp.app/Contents/MacOS/MyApp
@pixlwave
pixlwave / core_ext.rb
Last active August 29, 2015 14:15
Swift style initializers for RubyMotion
class NSObject
def self.with(args = {})
args.count == 0 ? method = "init" : method = "initWith"
objc_args = []
args.each do |a|
a[0] = a[0][0].capitalize + a[0][1..-1] if objc_args.size < 1
method << a[0] << ":"
@pixlwave
pixlwave / console
Last active April 1, 2018 16:37
Cuberite Daemon
#!/bin/bash
echo "Connecting to the Cuberite console"
echo "Press Ctrl+A+D to disconnect"
screen -r Cuberite
@pixlwave
pixlwave / ViewController.swift
Created December 14, 2019 15:35
NSDiffableDataSourceSnapshot reloadItems
import UIKit
class ViewController: UITableViewController {
var things = [Thing]()
var dataSource: UITableViewDiffableDataSource<Int, Thing>!
override func viewDidLoad() {
super.viewDidLoad()
@pixlwave
pixlwave / Task
Created September 19, 2022 09:26
import Foundation
extension Task where Failure == Never {
public static func dispatched(on queue: DispatchQueue,
priority: TaskPriority? = nil,
operation: @escaping @Sendable () -> Success) -> Task<Success, Failure> {
Task.detached(priority: priority) {
await withCheckedContinuation { continuation in
queue.async {
continuation.resume(returning: operation())
@pixlwave
pixlwave / FrameReader.swift
Created October 29, 2022 20:06
SwiftUI Frame Reader
import SwiftUI
extension View {
func frameReader(frame: Binding<CGRect>) -> some View {
modifier(FrameReaderModifier(frame: frame))
}
}
struct FrameReaderModifier: ViewModifier {
@Binding var frame: CGRect
@pixlwave
pixlwave / rosetta.sh
Created July 22, 2024 15:10
VirtualBuddy Rosetta
mount -t virtiofs Rosetta /mnt/rosetta
/usr/sbin/update-binfmts --install rosetta /mnt/rosetta \
--magic "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00" \
--mask "\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff" \
--credentials yes --preserve yes --fix-binary yes