Skip to content

Instantly share code, notes, and snippets.

View Thunor's full-sized avatar

Eric Freitas Thunor

View GitHub Profile
@Thunor
Thunor / gist:c27b7ba61d2a53929ed375d4db70a2d9
Created March 3, 2025 03:11
Point light for RealityView
// MARK: Point light source.
func getLightEntity() throws -> Entity {
let entity = Entity()
let pointLightComponent = PointLightComponent( cgColor: .init(red: 1, green: 1, blue: 1, alpha: 1), intensity: 500000, attenuationRadius: 2000.0 )
entity.components.set(pointLightComponent)
entity.position = .init(x: 0.6, y: 0, z: 0.6)
return entity
}
@Thunor
Thunor / WavyPlaneView.swift
Created February 22, 2025 00:42 — forked from Matt54/WavyPlaneView.swift
RealityView with a plane (modulated by a sine wave) and a point light
import SwiftUI
import RealityKit
struct WavyPlaneView: View {
@State private var phase: Float = 0.0
@State private var mesh: LowLevelMesh?
@State private var timer: Timer?
let resolution = 60
var body: some View {
import SwiftUI
import os
@main
struct ios14DemoApp: App {
@StateObject var notificationCenter = NotificationCenter()
@UIApplicationDelegateAdaptor private var appDelegate: AppDelegate
var body: some Scene {
WindowGroup {
@Thunor
Thunor / NavigationBarTitleStyle.swift
Created September 29, 2020 21:44
Style the NavigationBar Title in SwiftUI
struct MyView: View {
var body: some View {
VStack {
Text("Hello World")
}
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .principal) {
HStack {
@Thunor
Thunor / UINavigation+Appearance.swift
Last active September 29, 2020 20:34
Modify the NavigationBar in SwiftUI
import Foundation
import UIKit
extension UINavigationController {
override open func viewDidLoad() {
super.viewDidLoad()
let appearance = UINavigationBarAppearance()
//background color of the navigation and status bar
@Thunor
Thunor / podforceupdate.sh
Created February 12, 2020 16:37 — forked from mbinna/podforceupdate.sh
Clear CocoaPods cache, re-download and re-install all pods
#!/usr/bin/env bash
rm -rf "${HOME}/Library/Caches/CocoaPods"
rm -rf "`pwd`/Pods/"
pod update
### Keybase proof
I hereby claim:
* I am thunor on github.
* I am eric_freitas (https://keybase.io/eric_freitas) on keybase.
* I have a public key ASApoyy8EwJdq4RxBL0EgUCnBg0NTznDAAp0Am0BvQ2muQo
To claim this, I am signing this object:
@Thunor
Thunor / TimePicker24HRenderer.cs
Created June 15, 2017 16:51 — forked from hjerpbakk/TimePicker24HRenderer.cs
Custom renderer for Xamarin.Forms TimePicker on iOS. This will make the TimePicker always show time using 24H format (aka no AM or PM).
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
using PersonalTrainer.iOS.View.Controls;
[assembly: ExportRenderer (typeof (TimePicker), typeof (TimePicker24HRenderer))]
namespace YourNamespace.iOS.View.Controls {
public class TimePicker24HRenderer : TimePickerRenderer {
@Thunor
Thunor / ALLOY.md
Created January 20, 2017 21:48 — forked from kbshl/ALLOY.md
If you want to your CommonJS modules to work in both Alloy and plain Titanium projects, you might need a way to detect if you're in Alloy. For instance, if you're in Alloy you would get Underscore from the alloy-module, while in plain Titanium you would require Underscore directly.

If you want to your CommonJS modules to work in both Alloy and plain Titanium projects, you might need a way to detect if you're in Alloy. For instance, if you're in Alloy you would get Underscore from the alloy-module, while in plain Titanium you would require Underscore directly.

Well, you can:

var _ = require((typeof ENV_TEST === 'boolean') ? 'alloy' : 'underscore')._;

The above works by utilizing Alloy's optimization process. In this process, constants like ENV_TEST will be either TRUE or FALSE. The actual expressions in wich they are used will then be evaluated. If FALSE the code block will be removed. In plain Titanium projects the constants are undefined and this typeof ENV_TEST will be undefined, so the code block will be executed.

@Thunor
Thunor / background_demo.js
Created January 20, 2017 21:47 — forked from kosso/background_demo.js
Background Service notification for Titanium
/* Kosso : March 12th 2011
This the only way I managed to do this without the app crashing on resume.
Done slightly differently to the KS example, since they unregister the service and
do not use a setInterval timer.
*/
//############ in app.js :
// test for iOS 4+