Archive for Posts Tagged ‘OSX’


Comments Off on Dealing with SQLite files in mobile apps

Dealing with SQLite files in mobile apps

Recently I found myself wanting to inspect what was in the application database outside of the mobile application I was working on, which as usual lead me to search for a solution on DuckDuckGo.

I found a great link here, which basically says:

  1. Download and install SQLite command line tools if necessary (OSX comes with one).
  2. Find the SQLite file you want to inspect
  3. Run the command to open the database and inspect it:
sqlite3 /Users/<username>/Library/Developer/CoreSimulator/Devices/<Simulator device ID>/data/Containers/Data/Application/<App id>/Library/Private\ Documents/_alloy_.sql 
sqlite> .tables 
user order item 
sqlite> .schema user 
CREATE TABLE user (id INETGER PRIMARY KEY, uname TEXT, fname TEXT, lname TEXT); 
sqlite>select * from user; 
read more


Comments Off on How to determine and set your default java version on OSX

How to determine and set your default java version on OSX

Open terminal and do the following:
[korey@localhost ~]$ cd /Library/Java/JavaVirtualMachines
[korey@localhost /Library/Java/JavaVirtualMachines]$ ls -al
This will give you a list of JDKs that you have installed. To set the default java version to 1.8.0_131 for example, use the following command:
[korey@localhost ~]$ /usr/libexec/java_home -v 1.8.0_131 --exec javac -version
Related link read more


Comments Off on Manage Apache on OSX (Updated or Yosemite)

Manage Apache on OSX (Updated or Yosemite)

Here is a little tip for customizing apache on OSX. The first thing you have to do is turn on Web Sharing in your System Preferences. This will start the local Apache server and you can access it by going to http://localhost. From here, you can start modifying it to your will. Apache customization is a big topic and you can find all you need on the Apache website. Here are a few tips:
  • Apache is installed at: /etc/apache2
  • Apache config is at: /etc/apach2/httpd.conf
  • Apache user config is at: /etc/apach2/users/<username>.conf
  • Apache extra config is at: /etc/apach2/extra/*.conf
  • You can customize your own virtual server by modifying: /etc/apach2/users/<username>.conf
  • You can start/stop Apache by:
    • Enabling/disabling Web Sharing in System Preferences
    • running the following in terminal:
      sudo apachectl 
In order for you to get going and have a user directory, you will need to make sure the following is done.
  • Create folder to host your files (e.g. /Users/<my_username>/Sites/)
  • Create an index file in the above folder with a message so you know when it is working.
  • In /etc/apach2/httpd.conf, make sure:
    • userdir_module is loaded (i.e. not commented out).
      LoadModule userdir_module libexec/apache2/
    • httpd-userdir.conf is included.
      Include /etc/apache2/extra/httpd-userdir.conf
  • In /etc/apache2/extra/httpd-userdir.conf, make sure that user configuration files are included.
    Include /private/etc/apache2/users/*.conf
  • In /etc/apache2/users, make sure to create a user file for yourself (note: you will have to use sudo to make sure permissions on the file are set to 644 and owned by root:wheel).
    <Directory "/Users/<my_username>/Sites/">
      Options Indexes MultiViews
      AllowOverride All
      Require all granted
      DirectoryIndex index.html
At this point you can should be able to start (or restart) Apache and test your setup. http://localhost/~<my_username> read more



Getting Fancy with Terminal

One of my recent adventures into NodeJS has led me down the path of MEAN and reading various articles on that, I came across various Terminal alternatives and enhancements. I know, I know, I am late to the party, but when I saw FishShell, I was sold. Then I saw Powerline and liked that too, so here is how to set these up. First thing is to make sure you have Homebrew installed. Then you can install fish simply by running the following command:
[korey@localhost ~]$ brew install fish
Now that fish is installed, you will have a few options in making it your default shell. Homebrew provides instructions already, but I just wanted it on my account for Terminal, so I changed the shell command in Terminal’s preferences. term_prefs Great, now you can use fish anytime you open terminal, but what about getting Powerline setup? The instructions are here, but I will include what I did here for completeness.
[korey@localhost ~]$ brew install python
[korey@localhost ~]$ pip install powerline-status
The next step is to install the patched fonts so your prompt will not have strange characters on it. For this part, you need to download the patched fonts zip from github, and then run the script included there. The last step here is equally important; you should change the font used by your selected terminal profile to one of the fonts for Powerline. term_prefs2 Now that Powerline is installed, you will need to update your Fish config to load it.
[korey@localhost ~]$ vi ~/.config/fish/
# source autojump
[ -f /usr/local/share/autojump/ ]; and . /usr/local/share/autojump/

#source powerline
set fish_function_path $fish_function_path "/usr/local/lib/python2.7/site-packages/powerline/bindings/fish"
My last step was to install auto jump, which is another great tool and you can see that it has also been included in the above listing in my Fish config.
[korey@localhost ~]$ brew install autojump
You should now end up with a autocomplete terminal similar to this: terminal read more


Comments Off on Installing MongoDB on OSX (Yosemite)

Installing MongoDB on OSX (Yosemite)

Installing MongoDB on OS X is an easy task. However, if you want the service to start each time your computer is restarted, some additional effort is required. The easiest way to get MongoDB installers is to use Homebrew.
[korey@localhost ~]$ brew install mongodb
At this point MongoDB is installed. To start it manually, first create the location where the DB will be stored (default is /data/db):
[korey@localhost ~]$ mkdir /data/db
[korey@localhost ~]$ mongd
Note that the user running mongod needs to have write access to the DB folder. The downside here is that the DB needs to be started manually each time and it will run as your userid. In order to automatically start the service, it is necessary to create a LaunchDaemon which will allow the service to start as soon as the computer starts.
    1. The first step is to create a service account so the service does not run as root. 2. Next, is to create a proper location for the log and database location:
    [korey@localhost ~]$ sudo mkdir -p /var/lib/mongodb
    [korey@localhost ~]$ sudo mkdir -p /var/log/mongo
    [korey@localhost ~]$ sudo chown -R _mongo:_mongo /var/lib/mongodb
    [korey@localhost ~]$ sudo chown -R _mongo:_mongo /var/log/mongo
    3. Now that we have an account and location, it is time to create the daemon plist file:
    Store this file at: /Library/LaunchDaemons and name it: org.mongo.mongod.plist.
Now you can start and stop the service without having to restart your computer by using the following commands:
[korey@localhost ~]$ sudo launchctl load /Library/LaunchDaemons/org.mongo.mongod.plist
[korey@localhost ~]$ sudo launchctl unload /Library/LaunchDaemons/org.mongo.mongod.plist
read more


Comments Off on Creating a service account on OS X (Yosemite)

Creating a service account on OS X (Yosemite)

Creating service users on OS X is not as straight forward as doing so on Linux system.  For starters, the useradd command is not available. So in order to perform the same action on OS X, open a terminal window and run the following commands. For this example, I will create a group and user in order to run MongoDB.
[korey@localhost ~]$ sudo dscl . -list /Users UniqueID
_amavisd                83
_appleevents            55
_appowner               87
_appserver              79
_ard                    67
_assetcache             235
_astris                 245
_atsserver              97
_avbdeviced             229
_calendar               93
_ces                    32
_clamav                 82
_coreaudiod             202
_coremediaiod           236
_cvmsroot               212
The above command lists all the current users along with their UID. This is necessary so that we can pick an unused ID below 500 (UIDs above 500 are for normal users). You can run the same command with /Groups instead of /Users to get a list of groups. First, lets create a group for the users with the same name:
[korey@localhost ~]$ sudo dscl . -create /Groups/_mongo gid 300
[korey@localhost ~]$ sudo dscl . -create /Groups/_mongo RealName "Mongo DB Server Group"
[korey@localhost ~]$ sudo dscl . -create /Groups/_mongo passwd "*"
As you can see the group ID is set to 300, and the password is set to “*”. This is a special password not to allow logins as that group of user. I am not certain if this is necessary, but looking at other similar groups on OS X, it seems to be the right way to do this. Now, lets create the user and make sure that it will not show up as a user on the login screen:
[korey@localhost ~]$ sudo dscl . -create /Users/_mongo
[korey@localhost ~]$ sudo dscl . -create /Users/_mongo uid 300
[korey@localhost ~]$ sudo dscl . -create /Users/_mongo gid 300
[korey@localhost ~]$ sudo dscl . -create /Users/_mongo NFSHomeDirectory /var/empty
[korey@localhost ~]$ sudo dscl . -create /Users/_mongo UserShell /usr/bin/false
[korey@localhost ~]$ sudo dscl . -create /Users/_mongo RealName "Mongo DB Server"
[korey@localhost ~]$ sudo dscl . -create /Users/_mongo passwd "*"
At this point, the service account is created, and its primary group set to the one we just created. Setting the shell and home folders are necessary to make sure that the account does not show up on the login screen and to ensure that even if someone does login as that user, they will not have access to anything. Once again, the account password here is set to “*” in order to not allow logins. If you look at /etc/passwd on your OS X machine, you’ll notice that most service accounts are listed in there, but the above account is not. I am not sure if this will be problematic over the long term, but for all intents and purposes, the service account works as expected. Naturally, I searched a good while before I came up with the above command set and here are some links that helped me: read more


Comments Off on New iPads coming?

New iPads coming?

apple_oct_eventApple has invited the press to an October 22nd event since they “still have a lots to cover.” It is highly expected that they will announce the next generation of iPads, along with the new Mac Pro and OSX Mavericks, not to mention updates to existing MacBook Pros and possibly an Apple TV update. As always, the rumours are flying and tech geeks are psyched for the event. You can get more details on the rumours on TechCrunch. read more


Comments Off on Cleanup Your Open With Context Menu in OSX

Cleanup Your Open With Context Menu in OSX

Recently I noticed that I had many duplicate entries in the Open With context menu on my Mac (Mountain Lion). Then after a clean re-install, I noticed the same behaviour repeating. For example, I had three entries for Even Note. Well, a little googling lead me to this link with this magic command to reset the menu and clean it up.
LaunchServices.framework/Support/lsregister -kill -r -domain local \
-domain system -domain user
  • This all has to be on one line, but I had to break it up to fit here with the back slash. So to execute, copy it to one line and remove the backslash.
  • The location may be different if you are on an older version of OSX per the link above.

read more


Comments Off on Is Mountain Lion Worth The Upgrade? (Updated)

Is Mountain Lion Worth The Upgrade? (Updated)

OSX Mountain Lion was released yesterday and it brings with it many new features and add-ons which is a great offer at $20 for the upgrade, but there are a few catches:
  • You have to have a relatively recent Mac to get all the features.  For example, AirPlay screen sharing is only available if you have an early 2011 Mac Book Pro or later.
  • You lose some features that you may have depended on.  My pet peeve here is Web Sharing which I used all the time.  OSX still have Apache with it, but the web sharing feature which allowed for user based folders is gone.  To bring it back, all you need to do, is find your old user conf file (from a time machine backup) and add it back to /etc/apache2/users/.
  • Looks like you can also only enter Time Machine if it is enabled.  I typically turn it off and do manual backups using its menu bar option and I do not recall having issues with Lion in getting into time machine while automatic backup was not enabled.
Had I known this yesterday, I may have held off for a bit, but it is still worth the $20 upgrade. read more


Comments Off on Default path on OSX

Default path on OSX

Started working with Homebrew recently instead of Macports to install third party packages on OSX. Homebrew comes with a doctor command that lets you know any conflicts that may cause it to not function properly. Short of it all is that Homebrew told me I needed to modify my path to make sure the /usr/local/bin is before /usr/bin. But where is the path defined on OSX? it is in /etc/paths (at least on OSX Mountain Lion). This file is a list of paths, each defined on a separate line which also specified their order. In order to update it run:
sudo vi /etc/paths
here is what mine looks like:
read more

Page 1 of 212