macos

Why is the local notification I created with UNUserNotificationCenter not shown in the upper-right corner of my screen?

谁说胖子不能爱 提交于 2021-02-17 02:47:26
问题 Running the code below doesn't show the notification in the upper-right corner of my screen (as a banner or alert). The notification is shown in the notification center. I made sure "Do not disturb" is disabled on my system. I also tried both the "Banner" and "Alert" setting in System Preferences -> Notifications -> Name of my app. Source: import Cocoa import UserNotifications @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { func applicationDidFinishLaunching(_

opencv compile with clang ok, with gcc not ok os x 10.9

夙愿已清 提交于 2021-02-17 02:06:44
问题 I am on OS X 10.9, with opencv-2.4.8.2 installed. I am trying to compile a simple code: #include <stdio.h> #include <opencv2/opencv.hpp> using namespace cv; int main(int argc, char** argv ) { if ( argc != 2 ) { printf("usage: DisplayImage.out <Image_Path>\n"); return -1; } Mat image; image = imread( argv[1], 1 ); if ( !image.data ) { printf("No image data \n"); return -1; } namedWindow("Display Image", WINDOW_AUTOSIZE ); imshow("Display Image", image); waitKey(0); return 0; } and can do that

opencv compile with clang ok, with gcc not ok os x 10.9

一曲冷凌霜 提交于 2021-02-17 02:06:42
问题 I am on OS X 10.9, with opencv-2.4.8.2 installed. I am trying to compile a simple code: #include <stdio.h> #include <opencv2/opencv.hpp> using namespace cv; int main(int argc, char** argv ) { if ( argc != 2 ) { printf("usage: DisplayImage.out <Image_Path>\n"); return -1; } Mat image; image = imread( argv[1], 1 ); if ( !image.data ) { printf("No image data \n"); return -1; } namedWindow("Display Image", WINDOW_AUTOSIZE ); imshow("Display Image", image); waitKey(0); return 0; } and can do that

cd to a folder name starting with tilde (~) in bash script

此生再无相见时 提交于 2021-02-16 21:15:29
问题 I'm trying to create a very simple bash script that does the following: Inputs the user to enter a project folder Sets the value entered in a variable cd to the folder entered remove the readme.md file From what I've read around I've come up with this: #!/bin/bash echo "Enter the project folder path:" read -e DESTINATION_FOLDER cd "$DESTINATION_FOLDER" rm -rf "$DESTINATION_FOLDER/readme.md" The folder's path I entered was ~/Dropbox/myproject And the error I get is the one below. However that

DYLD_LIBRARY_PATH environment variable is not forwarded to external command in Makefile on macOS

时间秒杀一切 提交于 2021-02-16 20:48:10
问题 I am debugging some test failures ( make test ) for a Perl module on macOS. I discovered that the problem seems to be that the environment variable DYLD_LIBRARY_PATH is not forwarded to an external command run from within the Makefile . Here is a minimal example: .PHONY: all all: @echo $$DYLD_LIBRARY_PATH On Linux from the Bash shell, I can do (or rather replace DYLD_LIBRARY_PATH with LD_LIBRARY_PATH which is used for this purpose on Linux): $ export DYLD_LIBRARY_PATH=bar $ make bar However,

How to grep an exact string with slash in it?

谁说胖子不能爱 提交于 2021-02-16 18:24:12
问题 I'm running macOS. There are the following strings: /superman /superman1 /superman/batman /superman2/batman /superman/wonderwoman /superman3/wonderwoman /batman/superman /batman/superman1 /wonderwoman/superman /wonderwoman/superman2 I want to grep only the bolded words. I figured doing grep -wr 'superman/|/superman' would yield all of them, but it only yields /superman. Any idea how to go about this? 回答1: You may use grep -E '(^|/)superman($|/)' file See the online demo: s="/superman

How to grep an exact string with slash in it?

两盒软妹~` 提交于 2021-02-16 18:24:05
问题 I'm running macOS. There are the following strings: /superman /superman1 /superman/batman /superman2/batman /superman/wonderwoman /superman3/wonderwoman /batman/superman /batman/superman1 /wonderwoman/superman /wonderwoman/superman2 I want to grep only the bolded words. I figured doing grep -wr 'superman/|/superman' would yield all of them, but it only yields /superman. Any idea how to go about this? 回答1: You may use grep -E '(^|/)superman($|/)' file See the online demo: s="/superman

sudo python wrong version

你离开我真会死。 提交于 2021-02-16 18:06:56
问题 I get python 2.7 when running sudo. I've tried changing my .bash_profile and .bashrc from my original user and root, but to no avail. $ python Python 3.5.2 (default, Oct 11 2016, 05:05:28) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> ^D $ sudo python Python 2.7.10 (default, Oct 23 2015, 19:19:21) [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin Type "help", "copyright",

Printing in Cocoa

佐手、 提交于 2021-02-16 15:41:07
问题 I have made a view that pretty much fits A4 page. Now I want to print it. Note that I am not using drawRect or anything like that, just a normal view with subviews and text labels. My problem is that I have a few views on that view which I use layers to put background colors and rounded rects around the items. The subviews don't print, but all text labels print. The _printReport is just a plain window with a view and bunch of text labels. What am I doing wrong and how could I do this better ?

macOS: simulated mouse event only works when launching binary, not application bundle

大兔子大兔子 提交于 2021-02-16 14:28:05
问题 I have the following code which moves the mouse cursor on a Mac: void moveCursorPos() { CGPoint ppos; ppos.x = 100; ppos.y = 100; CGEventRef e = CGEventCreateMouseEvent(nullptr, kCGEventMouseMoved, ppos, kCGMouseButtonLeft); CGEventPost(kCGHIDEventTap, e); CFRelease(e); } It works when I run my software directly from its binary - e.g. ./foo.app/Contents/MacOS/foo . It does not not work when I start it through open foo.app . Doing open ./foo.app/Contents/MacOS/foo works. The first time I