Tagged: mac-os-x

New file in Mac OS X Finder

- by admin

Sometimes we need to create a file from Finder directly. And this is strange that Finder allows easily to create a folder but not a file! Although Linux and Windows file browsers have this option. So, let's enhance Finder!

First start Automator (Launchpad / Other / Automator). In the chooser that appears next, select Service.



At the top of the Automator main window, set the "Service Receives Selected" drop-down to "files or folders". Then select Library / Utilities in the left tree menu. Next drag (or just double click) "Run AppleScript" into the main working area (mid-right). Here you will get "Run AppleScript" box. Paste the following AppleScript into this code box, then click the hammer icon to compile the code:
on run {input, parameters}
tell application "Finder"
set currentPath to insertion location as text
set x to POSIX path of currentPath
end tell
return x
end run

Next double click on "Set Value of a Variable" (also in the LIbrary / Utilities section). Click the "Variable" drop-down and create a new variable. Let's call it currentFolder.

Select Library / Text in the left tree menu. Next drag (or just double click) "New Text File" into the main working area (mid-right). Here you will get "New Text File" box.

Drag the variable you just created (currentFolder) from the Variable panel at the bottom of the Automator window to the "Where" selector of the "New Text File" action. Change "Encoding" to "Unicode (UTF-8)". Click the New Text File's "Options" button (at the bottom of the box) and select "Show this action when the workflow runs". This will allow you to specify the names of new files.



Save the service with "File / Save ..." top menu and give it a name (For example "New File"). To test it, in the Finder go to the folder where you want to create a new file. Control-click on an existing file within that folder and select "New File" from the "Services" submenu. A dialog should appear requesting a filename. Enter one then click "Continue"; your new file should appear.



This obviously creates a text or RTF empty file (file with .txt or .rtf extension). You can change the extension to whatever you need as the last step.

How to check DNS cache status in Mac OS X

- by admin

As a follow-up to How to Flush DNS Cache in Mac OS X I have received a question:

how do I know if it worked? In other words, is there a way to check if the DNS cache is cleared?

To see the DNS cache status you may run
sudo killall -INFO mDNSResponder

Thus the SIGINFO signal will dump a snapshot summary of the DNS internal state to
/var/log/system.log

Voilà :-)


 

Print-screen (screenshots) in Mac OS X

- by admin

Keyboard shortcuts



  • Command-Shift-3: Take a screenshot of the screen, and save it as a file on the desktop

  • Command-Shift-4, then select an area: Take a screenshot of an area and save it as a file on the desktop

  • Command-Shift-4, then space, then click a window: Take a screenshot of a window and save it as a file on the desktop

  • Command-Control-Shift-3: Take a screenshot of the screen, and save it to the clipboard

  • Command-Control-Shift-4, then select an area: Take a screenshot of an area and save it to the clipboard

  • Command-Control-Shift-4, then space, then click a window: Take a screenshot of a window and save it to the clipboard


In Leopard and later, the following keys can be held down while selecting an area (via Command-Shift-4 or Command-Control-Shift-4):

  • Space, to lock the size of the selected region and instead move it when the mouse moves

  • Shift, to resize only one edge of the selected region

  • Option, to resize the selected region with its center as the anchor point


Formats


Different versions of Mac OS X have different formats for screenshots.

  • Mac OS X 10.2 (Jaguar): jpg

  • Mac OS X 10.3 (Panther): pdf

  • Mac OS X 10.4 (Tiger) and later: png


In Mac OS X 10.4 and later, the default screenshot format can be changed, by opening Terminal (located at /Applications/Utilities/Terminal) and typing in:
defaults write com.apple.screencapture type image_format
killall SystemUIServer

Where image_format is one of jpg, tiff, pdf, png, bmp or pict (among others). If you omit the second line, you will need to log out and in again for the change to take effect.

Grab and Preview


Instead of using the keyboard shortcuts above, screenshots can be taken by using the Grab application included with Mac OS X. It is located at /Applications/Utilities/Grab.

In Mac OS X 10.4, the Preview application can also be used to take screenshots, by using the Grab submenu in the File menu.

From the Terminal


The screencapture command in the Terminal can also be used to capture screenshots, and is useful for scripts. Here is an example.
screencapture -iW ~/Desktop/screen.jpg

Postfix restart in Mac OS X 10.8 Mountain Lion

- by admin

Actually it is no so easy to restart Postfix in Mac OS X 10.8 Mountain Lion like in Linux :-)

However you can restart Postfix by plist unload / reload:
sudo launchctl unload /System/Library/LaunchDaemons/org.postfix.master.plist
sudo launchctl load System/Library/LaunchDaemons/org.postfix.master.plist

By the way, if you have a problem with Postfix, look at this article: Cannot send mail in Mac OS X 10.8 Mountain Lion

How to Flush DNS Cache in Mac OS X

- by admin

After upgrading to 10.8.2 I have got a problem with adding a new entry into hosts file: the update was recognised only after system restart. But a more easy solution was just to flash DNS cache! So,

... flushing your DNS cache in Mac OS X is actually really easy, and there are two different commands to use, one for Leopard and for Tiger. Depending on your version of OS X, open your Terminal and follow the appropriate directions below:

Flushing DNS Cache in OS X Lion (10.7) and OS X Mountain Lion (10.8)


Launch Terminal and enter the following command, you will need to enter an administrative password:
sudo killall -HUP mDNSResponder

Note the dscacheutil still exists in 10.7 and 10.8, but the official method to clear out DNS caches is through killing mDNSResponder. You can also find that process running in Activity Monitor.

Flush DNS Cache in Mac OS X 10.5, Mac OS X 10.6


Launch Terminal and issue the following command:
dscacheutil -flushcache

All done, your DNS has been flushed. On a side note, the dscacheutil is interesting in general and worth taking a look at, try the -statistics flag instead for some stats.

Flush your DNS Cache in Mac OS X 10.4 Tiger


Type the following command in the Terminal:
lookupd -flushcache

That’s it - now your DNS settings should be as you intended them to be :-)

Cannot send mail in Mac OS X 10.8 Mountain Lion

- by admin

There is an error while sending mail in Mac OS X Mountain Lion 10.8:

send-mail: fatal: chdir /Library/Server/Mail/Data/spool: No such file or directory

To fix just run in terminal:
sudo mkdir -p /Library/Server/Mail/Data/spool
sudo /usr/sbin/postfix set-permissions
sudo /usr/sbin/postfix start

The solution also fixes an error in 10.8 where the fax service has stopped sending emails after the 10.8 upgrade.

Another Postfix Mac OS X issue solution can be found here: Mac OS, MySQL: No such file or directory (trying to connect via unix:///var/mysql/mysql.sock)

Disable automatic unzipping on file download in Safari (Mac OS X)

- by admin

After file downloading a ZIP file with Safari this file is unzipped automatically. The original ZIP file appears to be deleted. Not so good!

To fix this behaviour just go to
Safari->Preferences->General

and uncheck "Open Safe Files After Downloading".

Mac OS, MySQL: No such file or directory (trying to connect via unix:///

- by admin

Error on attempt to connect locally to MySQL server DB with PHP on MacOS X Lion 10.7:

No such file or directory (trying to connect via unix:///var/mysql/mysql.sock)

Solution 1:

instead of localhost use 127.0.0.1:
mysql_connect ('127.0.0.1', $user, $password);

Solution 2:

In /etc/php.ini change
pdo_mysql.default_socket = /var/mysql/mysql.sock
mysql.default_socket = /var/mysql/mysql.sock
mysqli.default_socket = /var/mysql/mysql.sock

to
pdo_mysql.default_socket = /tmp/mysql.sock
mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock

Do not forget to restart Apache after update :-)

FYI: If no /etc/php.ini found just copy /etc/php.ini.default to /etc/php.ini

Mac X11 window font size change

- by admin

The most simple way is adding the following new command in the X11-> application -> customize:
xterm -geometry 72x34+100+40 -fn *-fixed-*-*-*-20-* &

Mac OS X Lion: configure: error: C compiler cannot create executables

- by admin

After Xcode installation and trying to build mc I've got:
configure: error: C compiler cannot create executables

Google offers to install Xcode correctly (this is a different story however) or to reinstall it. Hmmm. Good idea but in my case the following simple action solved the issue: symlinks for compilers - that's all ! KISS
sudo ln -s /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2

sudo ln -s /usr/bin/llvm-g++-4.2 /usr/bin/g++-4.2

Voila !

« All tags

Older posts »