Showing posts with label Mac. Show all posts
Showing posts with label Mac. Show all posts

Thursday, 21 June 2018

How to clean and manage "Recent Places" in Mac OS X

Background

Whenever you save files in your Mac, OS X will save this folder in a “Recent Places” category which will be available the next time you save another file. This feature enables quick access to the folders you commonly use which saves a lot of time.


But sometimes you need to have a granular control over this. For example, you may have to clear recent places or limit the number of folders that are stored under this category. In this post, I am going to show you exactly the same thing.

How to clean and manage "Recent Places" in Mac OS X

Let's start with how we can limit the number of folders that are stored in the "Recent places" category. For me by default, it stores 3 folders. It may vary as per your OS version.
To increase the limit execute following command in your terminal -

Here NUMBER is the number of entries you want. Making it  Zero will disable the recent places list. 




To remove this limit you can execute the following command -



And finally, if you want to clear recent places list then you can execute the following command -



Friday, 11 May 2018

How to enable touch to click on your Mac

Background

If you are a Mac user then you must be familiar with the peculiar trackpad gestures and usage Mac offers. Personally, I feel touch to click is a much better option then physically pressing the trackpad. In this post, I will show you how to do the same. I am using MacBook Pro running Sierra (10.13.4).

How to enable touch to click on your Mac

  • Go to "Preferences" and select "Trackpad"
  • Under "Point and Click" select "Tap to Click"




  • Notice how "Click with two fingers" is also changed to "Click or tab with two finders" for secondary click.
  • You can use this checkbox to enable or disable "Tap to click"

How to enable touch to click on your Mac with command line

You can do the same above setting with the command line. Execute following commands in your Terminal.

  • sudo defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
  • sudo defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
  • sudo defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1

NOTE: You will need to reboot your system for changes to take effect.

Similarly, to disable you can do

  • sudo defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool false
  • sudo defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 0
  • sudo defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 0
Again reboot your machine to take effect.



Related Links




Sunday, 10 September 2017

Installing and Using OpenGrok on Mac OS X

Background

In previous couple of posts we saw how we can setup git repositories, install git client and maintain your codebase. 
In this post we will see how to set up opengrok. This is a code base search tool that you can use to index and search your huge complex codebase. I am going to show this on my mac laptop. If you want to setup a proper server please refer to official documentation.


Installing and Using OpenGrok on Mac OS X

I am going to use Homebrew to do most of the setup here. If you are not aware of homebrew then you can read -
 Couple of things you need to install before are -
  • A servlet container like GlassFish or Tomcat to run and deploy your grok server. I will use tomcat.
  • Exuberant Ctags for analysis.
You can run following commands to set these up -
  • brew update
  • brew install tomcat
  • brew install ctags 
You can just type catalina to see tomcat is properly installed -


Next set environment variable as follows -
  • export OPENGROK_TOMCAT_BASE=/usr/local/Cellar/tomcat/8.5.20/libexec
 For path you can refer to catalina screenshot above. This environment variable will basically tell where grok needs to be deployed.

Download the latest opengrok binary from-
 I am using opengrok-1.1-rc13.tar.gz.

Next go yo your opengrok bin directory. In my case it is -
  • /Users/athakur/Documents/Softwares/opengrok-1.1-rc13/bin
and run -
  • ./OpenGrok deploy
 This will deploy grok code on your tomcat container. Now start the tomcat container




 You can now access it via -


 The error you see is ok since we have not provided our codebase source directory yet.

Noe lets add source directory. My code is in-
  •  ~/Documents/git/DataStructures
NOTE : DataStructures is a local copy of my github repo -
I am going to maintain all codebase references in
  • ~/local_repos/src/
So create a directory and add soft links as below -


 Now it's time to define your code directory that opengrok can understand. So define another environment variable -

  • export OPENGROK_INSTANCE_BASE=/Users/athakur/local_repos

That's now lets index this content. To index it go to you opengrok bin directory and run -
  • ./OpenGrok index.

You can see it automatically creates directory it needs. Just make sure it has appropriate permissions -




That's it you can refresh grok page and start searching code.


 NOTE : For every update to your actual repository or for any new repository getting added you need to call ./Opengrok index to index it. You can probably write a cron job that does an automatic pull of your repository and runs index on it.


Related Links

Monday, 31 July 2017

Install Oracle instant client and sqlplus using Homebrew

Background

 In one of the previous posts we say how to install and run sql plus  and Oracle instant client  on Ubuntu operating system -
In this post we will see the same for a Mac.

This post expects you have homebrew installed. If not please refer -

 Install Oracle instant client and sqlplus using Homebrew

For this you need to download following two files -
  1. instantclient-basic-macos.x64-12.1.0.2.0.zip 
  2. instantclient-sqlplus-macos.x64-12.1.0.2.0.zip 
You can download these files from oracle site - http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html

Once download copy these files into following folder-
  •  ~/Library/Caches/Homebrew 
 Once done run following commands -
  • brew tap InstantClientTap/instantclient
  • brew install instantclient-basic
  • brew install instantclient-sqlplus
 This should install sqlplus for you.


Related Links

Friday, 28 July 2017

How to Disable a MacBook’s Built-In TrackPad When Using a Mouse or Wireless Trackpad

Background

For me this became a requirement as my trackpad started malfunctioning. But it can be a useful feature as well. When we connect a mouse we would not want trackpad to work. For eg. lets say you are playing counter strike with a mouse you definitely don't want trackpad to change your aim in game. So it would be better if you disable in build trackpad while mouse is connected. In this post I will show you how you can do this.



Disable Trackpad in OS X Lion and Above

For this you need to go to -
  • System Preferences > Accessibility > Mouse & Trackpad
Here you will find a checkbox saying "Ignore built-in trackpad when mouse or wireless trackpad is present". Click it and make sure you have checked it. Setting should take effect immediately.



Disable Trackpad in OS X Snow Leopard

Setting is the same here too. It's just at different path. So head to 
  • System Preferences > Universal Access > Mouse & Trackpad
Here again you will find the same checkbox. Check it and you should be good to go.






Sunday, 9 July 2017

How to install wine and run windows programs on your mac

Background

Sometimes it becomes necessary to install windows program on your Linux or mac machine. Like I mentioned in a post sometime back there may be some sites that require IE only -
In this post I will show you how to install wine on your mac. Wine is a very handy software that allows you to install and run windows programs in a windows like simulated environment.


Installing Wine on Mac

You need to have homebrew installed on your mac. If not please refer -
 Next Homebrew uses an extension called Homebrew Cask to install other programs. You can install the Cask extension by running following command -
  • brew tap caskroom/cask


Wine needs -
  • Java and 
  • XQuartz 
as dependencies to be already installed. I am assuming you already have Java installed on your machine and set it up in classpath. You can install  XQuartz with following command -
  • brew cask install xquartz


NOTE :  You can similarly install Java if you already done have it -
  • brew cask install java
 Once dependencies are done you can directly install wine with following command -
  • brew install wine


Also install winetricks -
  • brew install winetricks

 Use winetricks to set environment as windows 7 -
  • winetricks win7

Installing and running Windows program from wine

Go to the directory where you have downloaded your exec file and run -
  • wine installer.exe
where installer.exec is your exe file.

 You can find installed files in dir -
  • /Users/athakur/.wine/drive_c
You can then navigate to program files, find your installed program and run it -


 Once in the program directory you can simply run it as -
  • wine ioexplorer.exe


And you are done :)

Related Links

How to display or hide line numbers in vi or vim text editor

Background

Line number come in very handy when you are working with any Text Editor. However if you take vi or vim editor then line numbers are hidden by default. In this post we will see how we can turn it on.


How to display or hide line numbers in vi or vim text editor

This post assumes you are a vim user and are aware of basic usage. Like for example when you need to save and quit data in vim you-
  • press escape followed by :wq
or if you want to exit without saving
  • :q!
 vi support a lot of commands to use and  options to be set by using colon (:)

To show line numbers in vi simple type below are pressing escape -
  • :set number OR
  • :set nu
 To hide it you can type -
  • :set nu! OR
  • set nonumber





This you need to do every time you launch into vi editor. To make it default edit your file at location ~/.vimrc and append following line at the end -

  • set number
NOTE : You can create this file if it does not exist already.

Now you will always get line numbers when you launch vim editor.




 Now that we have seen how to hide and display line numbers in vim editor lets see how we can jump to a particular line in vim -

How to jump to a particular line in vim

This is also fairly simple. Once you have launched vim you can simply move to any line number using following command -
  • : linenumber
Eg.
  • :6


 You can ever jump directly to your line number immediately as you open vim. To do that use following command while opening vim -
  • vi +linenumber filename
Eg.
  •  vi +6 test.txt
This should open your file and move to the linenumber you have provided.


General Info

vim provides a lot of configurable options to set. To see them all type following command -
  • :set all

To see everything that you have set so far you can type following command -
  • :set
For me it is as follows -



Related Links

Wednesday, 28 June 2017

How to access websites on your Mac that requires Internet Explorer

Background

There are certain websites that can be accessed from Internet Explorer only. This happens because of the websites compatibility with IE. But this will not work on your Mac laptop or Linux machine since you cannot run IE on it. At least not in traditional way - You can always install a software like Wine and then run your windows application in that simulated environment. But there is a much simpler way.

How to access websites on your Mac that requires Internet Explorer

I will take Safari browser in our Mac as an example. 
  • Open Safari browser and open preferences from menu bar at the top.
  • Once opened go to "Advanced Tab"
  • In "Advanced Tab" select the "Show Develop menu in menu bar" check box.

  • Once done you should be able to see "Develop" menu in menubar on top. 
  • Under "Develop" menu you can select "User Agent" and then select the user agent you want. For eg - "Internet Explorer 7"

  • Once you select that your IE compatible page should load fine.

 On other operating systems and browser  - Linux/Chrome/Firefox

Above approach was specific to Safari but the solution remains same - You need to change the user agent. So you have plugins to do so -


Similar you can find a similar plugin in chrome store. 

Manual way

    FIREFOX 4.0 :  In Firefox type in the URL Address: about:config. A webpage will appear saying a warning about the use of the Config. Click on the button about you being careful. In the search bar in the Config type agent and look for the variable general.useragent.override. Double click on it and overwrite the value it has with one of the following (For the default leave the value EMPTY):

    IE6 - Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
    IE7 - Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)
    IE8 - Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)


    CHROME :  Chrome has an about page to CHECK if you have changed your User Agent about: and other options like about:labs, about:memory, about:hang, about:plugins and many others that depending on your version they could be available or not. But for the question at hand this option is not yet in any of the about pages i have found. To have it manually in chrome you need to start chrome with the option user-agent. For example google-chrome --user-agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" which will open Chrome like it were IE6. The IE User Agents are from the Firefox option above.

    OPERA : In Opera type in the URL Address: about:config. A list will appear and a search address in the upper part of the list. Type in the search address user agent. The option for User Agen will appear below the search address. Click on it and depending on the Browser you want you have several options that change depending on version. For example:

    1 - Opera (this is the default user agent string used by Opera)
    2 - Mozilla (With the Opera String in it)
    3 - Internet Explorer (With the Opera String in it)
    4 - Mozilla (Without the Opera String in it. 100% Mozilla)
    5 - Internet Explorer (Without the Opera String in it. 100% IE)


    But this values could change so you would need to test each one to know what User Agent value it has.

Related Links

Wednesday, 29 March 2017

CS 1.6 redirection to other server issue

Background

This is not a technical post rather a solution for the issue I faced while playing CS 1.6 online. I had bought it on Steam and happen to play around online on different servers. After a while it seemed to be redirecting to other servers and that seems to be issue. How can it connect to a server without Me telling it to? Well well see that in a moment.

I have steam installed and playing CS 1.6 on my mac. So path and files location may be different for you.

CS 1.6 redirection to other server issue

First of all find your counter strike installation directory. For me it is -
  • /Users/athakur/Library/Application Support/Steam/steamapps/common/Half-Life/cstrike
It would be different for you based on which OS you are using and how did you install it.

One you locate it try to find files with .cfg extension. The file we are interested in is 
  • config.cfg OR
  • userconfig.cfg  (If you have it)
In these files look for bind commands that ask to redirect to some IP. For eg. -
  • bind "F12" "Connect 93.119.24.96:27015";
When you connect to a rogue server it can alter these files to change your bindings and user configuration. You can see the permissions of these files. Your user would have write permissions on  it.



NOTE : Word of advice. Do not connect to servers that don't have folks playing in it and the ones you don't trust.

Now that we know what the issue is lets see how we can fix it.

Solution : CS 1.6 redirection to other server issue

  1. Close your CS game and delete the compromised config file.
  2. Restart you game and you can see that the config.cfg file is created again with default values. You can also go in game and click on reset to defaults. Do not connect to any servers.
  3. Once you have confirmed your file exist and you have made chances to it based on your configurations (binding keys etc) you need to make it read only.
  4. For this you can execute chmod ugo-w config.cfg command i.e you remove write permissions for the file. And your gamming life will be back to normal :)



NOTE : For me it was just config.cfg but if you open config.cfg it internally execute userconfig.cfg. So make sure if you have it, it is not compromised too.

 Related Links

Sunday, 25 December 2016

Combine multiple PDF files into one in your Mac OS

Background

Couple of days back I had to upload a signed copy of an online document So I took it's printout and then scanned each page as a PDF. TO re upload I had to make it back into a single pdf file. Well of its a generic document you can use online pdf tools. But in my case the document was somewhat private and well it had my sign. So I could not do it online. In mac you can do it offline with in in built application called preview. Let us see how we can do it.


Combine multiple PDF files into one in your Mac OS

  • First open your PDF file with preview application. To do so you can right click and select over with preview.

  • Next go to View and Enable Thumbnails. You should see your current pfd in thumbnail panel on the left.

  • Now go to edit and select edit -> Page from file and then select other pdf file you need to combine. Do this for as many pdf files as you need to combine.

  • You can also drag and reorder pdf files in the thumbnail panel. You can also select pdf in this panel and click delete to delete the page.

  • Finally click on File -> Save to save the combined PDF.

Thursday, 1 September 2016

How to change default apps to open files with on the Mac

Background

So sometime back I had to install pgAdmin . It is basically client to connect to your postgres DB. From then all my sql files started opening in that. I wanted to open it in my regular sublime text. In this post I will show you how you can change the default application your file open in.


 How to change default apps to open files with on the Mac

  • Go to Finder and select the type of file you want to change default application that opens it.
  • Go to File -> Get info
  • Expand "Open with:" section.
  • select the application you want to open it with
  • Then click on "Change All".
  • Accept the confirmation dialog.

Above sequence with screenshots -





And you are done! All you .sql files will now start opening with sublime text.


Related Links


Saturday, 20 August 2016

Resolving issue of losing links when saving word document to PDF in Mac

Background

I had a word document already saved in my dropbox which was initially created on windows I think. When I moved to mac I could open the same document in mac word with links working just fine. Now I edited the doc and exported it as PDF. On opening the PDF I realized the links do not work though it gets displayed a hyperlink in the PDF. After bit of poking around I found out it is an known issue. In this post I provide an alternative approach that worked for me.


Making the links work in PDF

  • I had word document of following format - Microsoft Word 97 - 2004 document - 61 KB
  • Open pages app in your mac and open your word doc in it.

  • Verify all links are working. If you need to edit you can edit it here.
  • Save the opened document as pages document. Its format would be - Pages Publication - 271 KB
  • Next reopen this pages document and go to File -> Export to -> PDF and save it as PDF. Links should work now.

Thursday, 18 August 2016

Installing MongoDB in Mac

Background

Sometime back I had written a post on MongoDB. Installation and basic syntax in Windows - Getting Started with MongoDB . This post is starting of series of posts on MongoDB. In this post we will see installation and configuration of MongoDB in Mac.

Installing MongoDB

  • Go to MongoDb download center and download the tgz of the latest build. Your OS should already be selected and you should see the download link.
  • You can also install MongoDB using homebrew
    • brew install mongodb  (To install the MongoDB binaries)
    • brew install mongodb --with-openssl (To install the MongoDB Binaries with TLS/SSL Support)
    • brew install mongodb --devel  (To install the latest development release)
  • Once you have downloaded that tarball you can unpack it using following command - 
    • tar xvf mongodb-osx-ssl-x86_64-3.2.9.tgz
  • Once you have unpacked it navigate to that folder and then into bin folder inside it. Here you will see list of programs. There are two programs here of out interest - 
    • mongo : This is the mongo shell used to connect to the mongo DB.
    • mongod : This is the actual server.
  • That's it your mongo db is installed and ready to be run.
NOTE : MongoDB by default stores its data in directory "/data/db". So make sure this directory is created with necessary permissions. 
  • sudo mkdir -p /data/db
  • sudo chmod -R 777 /data/

If you want to give a custom path you can give it when you start mongodb - 
  --dbpath arg                          directory for datafiles - defaults to "/data/db"
Eg.
  • mongod --dbpath /data/mydb

Running and connecting MongoDB

  • To run MongoDB server go to bin directory and start mongod program.
    • ./mongod
  • This should start your mongodb server listening on default port 27017.
  • To see all mongod configuration options you can type - 
    • ./mongod --help



Once mongodb is up you can try connecting to it using mongo shell.
You can start mongo shell by
  • ./mongo
You can also see incoming connection in your server console -
  • 2016-08-18T22:34:27.315+0530 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:56356 #1 (1 connection now open)
     
Once you are connected you can try following operations - 
  • use mydb
  • db
  • show dbs
  • db.testCollection.insert({"Name":"John"})
  • show collections
  • db.testCollection.find()
 That's it for the basic of installing Mongo DB on your Mac. To avoid always going till bin to execute your programs you can do either of of the follwing -
  1. Add you path to bin to your PATH and export it. OR
  2. Add all these binaries to /usr/local/bin/ by
    • cp * /usr/local/bin
  3. You can verify it by wither running - 
    1. which mongod OR
    2. mongod --help

Related Links

t> UA-39527780-1 back to top