Skip to content

Instantly share code, notes, and snippets.

View petergam's full-sized avatar

Peter Gammelgaard petergam

View GitHub Profile
@petergam
petergam / SearchBar.swift
Last active March 23, 2024 22:36
Wrapper for UISearchBar for SwiftUI
struct SearchBar: UIViewRepresentable {
let placeholder: String
@Binding var text: String
func makeCoordinator() -> SearchBarCordinator {
SearchBarCordinator(text: $text)
}
func makeUIView(context: Context) -> some UIView {
let searchBar = UISearchBar()
let calendarName = 'Peakon'
let sort = function(a, b) {
let aStartDate = Date.parse(a.startDate)
let bStartDate = Date.parse(b.startDate)
let now = new Date().getTime()
return Math.abs(aStartDate - now) > Math.abs(bStartDate - now)
}
let calendar = await Calendar.forEventsByTitle(calendarName)
class Usbmuxd < Formula
desc "USB multiplexor daemon for iPhone and iPod Touch devices"
homepage "http://www.libimobiledevice.org/"
revision 1
stable do
url "http://www.libimobiledevice.org/downloads/libusbmuxd-1.0.10.tar.bz2"
sha256 "1aa21391265d2284ac3ccb7cf278126d10d354878589905b35e8102104fec9f2"
# Backport of upstream security fix for CVE-2016-5104.
class Libimobiledevice < Formula
desc "Library to communicate with iOS devices natively"
homepage "http://www.libimobiledevice.org/"
url "http://www.libimobiledevice.org/downloads/libimobiledevice-1.2.0.tar.bz2"
sha256 "786b0de0875053bf61b5531a86ae8119e320edab724fc62fe2150cc931f11037"
revision 2
bottle do
cellar :any
sha256 "7440711e4b0b3c52a1b543b770b18de751a362086419ded9310f55fe104f546f" => :sierra
#!/usr/bin/env ruby
url = ARGV[0]
system('wget -nH -r -np -k -P app.app ' + url + ' 2&>1 >/dev/null')
system('xcrun simctl install booted app.app 2&>1 >/dev/null')
system('rm -rf app.app')
@petergam
petergam / hacking-imageview.swift
Created December 23, 2015 13:01
Hacking UIImageView adjustsImageWhenAncestorFocused with rounded corners
private class ImageView : UIImageView {
private class Layer: CALayer {
override func addSublayer(layer: CALayer) {
let configuration = layer.valueForKey("_configuration")
let cornerRadiusKey = "_cornerRadius"
if ((configuration?.respondsToSelector(NSSelectorFromString(cornerRadiusKey))) != nil) {
configuration?.setValue(25, forKey: cornerRadiusKey)
}
super.addSublayer(layer)
}