Skip to content

Instantly share code, notes, and snippets.

Avatar

Mhd Hejazi mhdhejazi

View GitHub Profile
@mhdhejazi
mhdhejazi / Catalyst-ScaleFactor.swift
Created Apr 27, 2020
Change the window scale factor in a Mac Catalyst app with the help of Dynamic (https://github.com/mhdhejazi/Dynamic)
View Catalyst-ScaleFactor.swift
override func viewDidAppear(_ animated: Bool) {
view.window?.scaleFactor = 1.0 // Default value is 0.77
}
extension UIWindow {
var scaleFactor: CGFloat {
get {
Dynamic.NSApplication.sharedApplication
.windows.firstObject.contentView
.subviews.firstObject.scaleFactor ?? 1.0
@mhdhejazi
mhdhejazi / Catalyst-NSOpenPanel.swift
Last active Apr 27, 2020
Use NSOpenPanel from a Mac Catalyst app with the help of Dynamic (https://github.com/mhdhejazi/Dynamic)
View Catalyst-NSOpenPanel.swift
// macOS App
let panel = NSOpenPanel()
panel.beginSheetModal(for: view.window!, completionHandler: { response in
if let url: URL = panel.urls.first {
print("url: ", url)
}
})
// Mac Catalyst (with Dynamic)
let panel = Dynamic.NSOpenPanel()
@mhdhejazi
mhdhejazi / Catalyst-ToggleFullScreen.swift
Last active Apr 27, 2020
Enter fullscreen in a Mac Catalyst app with the help of Dynamic (https://github.com/mhdhejazi/Dynamic)
View Catalyst-ToggleFullScreen.swift
// macOS App
NSApplication.shared
.windows.first?
.toggleFullScreen(nil)
// Mac Catalyst (with Dynamic)
Dynamic.NSApplication.sharedApplication
.windows.firstObject
.toggleFullScreen(nil)
@mhdhejazi
mhdhejazi / Catalyst-NSWindow.swift
Last active Apr 27, 2020
Get the NSWindow from UIWindow in a Mac Catalyst app with the help of Dynamic (https://github.com/mhdhejazi/Dynamic). Credit: @steipete
View Catalyst-NSWindow.swift
extension UIWindow {
var nsWindow: NSObject? {
Dynamic.NSApplication.sharedApplication.delegate.hostWindowForUIWindow(self)
}
}
@mhdhejazi
mhdhejazi / CopyAsanaTasks.php
Created Oct 24, 2012
Copy/Move project to a new workspace in Asana
View CopyAsanaTasks.php
function asanaRequest($methodPath, $httpMethod = 'GET', $body = null)
{
$apiKey = 'ASANA_API_KEY_HERE'; /// Get it from http://app.asana.com/-/account_api
$url = "https://app.asana.com/api/1.0/$methodPath";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC ) ;
curl_setopt($ch, CURLOPT_USERPWD, $apiKey);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
You can’t perform that action at this time.