This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <Cocoa/Cocoa.h> | |
#import <unistd.h> | |
BOOL copy_to_clipboard(NSString *path) | |
{ | |
// http://stackoverflow.com/questions/2681630/how-to-read-png-image-to-nsimage | |
NSImage * image; | |
if([path isEqualToString:@"-"]) | |
{ | |
// http://caiustheory.com/read-standard-input-using-objective-c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func openAndSelectFile(filename:String){ | |
let files = [NSURL(fileURLWithPath: filename)]; | |
NSWorkspace.sharedWorkspace().activateFileViewerSelectingURLs(files); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Intent i = new Intent(this, WatchFaceActivity.class); | |
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); | |
startActivity(i); | |
finish(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getDistance(lon1, lat1, lon2, lat2) { | |
var R = 6371; // Radius of the earth in km | |
var dLat = toRad(lat2-lat1); | |
var dLon = toRad(lon2-lon1); | |
var a = Math.sin(dLat/2) * Math.sin(dLat/2) + | |
Math.cos(toRad(lat1)) * Math.cos(toRad(lat2)) * | |
Math.sin(dLon/2) * Math.sin(dLon/2); | |
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); | |
return R * c; // Distance in km | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AppKit | |
import SwiftUI | |
/// Based on https://github.com/ipedro/SmoothGradientView | |
/// See documentation on `interpolate:` | |
/// | |
/// How to use: | |
/// | |
/// You can interpolate any array of `CGColor`, `NSColor` or `Color`to any array of any of the 3 supported types. | |
/// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Blobs.swift | |
// SwiftUI Demos | |
// | |
// Created by Morten Just on 1/31/23. | |
// | |
import SwiftUI | |
struct Blobs: View { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Appdelegate, view did finish loading | |
var win = NSApplication.sharedApplication().windows.first! | |
win.titlebarAppearsTransparent = true | |
win.movableByWindowBackground = true | |
win.styleMask = win.styleMask | NSFullSizeContentViewWindowMask; | |
win.title = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DarkModeMasker.swift | |
// SwiftUI Demos | |
// | |
// Created by Morten Just on 1/22/23. | |
// https://twitter.com/joshguospace/status/1617101052192649216?s=12 | |
import SwiftUI | |
import Charts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DarkModeMasker.swift | |
// SwiftUI Demos | |
// | |
// Created by Morten Just on 1/22/23. | |
// https://twitter.com/joshguospace/status/1617101052192649216?s=12 | |
import SwiftUI | |
import Charts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
// MARK: Main | |
struct TwitterBluePlus: View { | |
@State var topMenuItems : [MenuItem] = [MenuItem(title: "For you", icon: nil), MenuItem(title: "Following", icon: nil)] | |
@State var selectedIdx = 0 | |
var selected : MenuItem { topMenuItems[selectedIdx] } |
NewerOlder