EzDevInfo.com

osx

Shell scripts for automated OSX machine setup. Alchemists passionate/focused ruby development.

How can I Remove .DS_Store files from a Git repository?

How can I remove those annoying Mac OS X .DS_Store files from a Git repository?


Source: (StackOverflow)

Git ignore file for Xcode projects

Which files should I include in .gitignore when using Git in conjunction with Xcode?


Source: (StackOverflow)

Advertisements

Setting environment variables in OS X?

What is the proper way to modify environment variables like PATH in OS X? I've looked on google a little bit and found 3 different files to edit:

  • /etc/paths
  • ~/.profile
  • ~/.tcshrc

I don't even have some of these, and I'm pretty sure that .tcshrc is wrong, since osx uses bash now. Anybody have any idea where these variables, especially PATH, are defined?

Edit: I'm running OS X 10.5


Source: (StackOverflow)

Find (and kill) process locking port 3000 on Mac

How do I find processes that listens to/uses my tcp ports? I'm on mac os x.

Sometimes, after a crash or some bug, my rails app is locking port 3000. I can't find it using ps -ef... How do I find the stupid thing and kill it, brutally... ?

When doing rails server I get

Address already in use - bind(2) (Errno::EADDRINUSE)

2014 update:

To complete some of the answers below: After executing the kill commands, deleting the pid file might be necessary rm ~/mypath/myrailsapp/tmp/pids/server.pid


Source: (StackOverflow)

How can I develop for iPhone using a Windows development machine?

Is there any way to tinker with the iPhone SDK on a Windows machine? Are there plans for an iPhone SDK version for Windows?

The only other way I can think of doing this is to run a Mac VM image on a VMWare server running on Windows, although I'm not too sure how legal this is.


Source: (StackOverflow)

Getting "Can't connect...through socket '/tmp/mysql'" when installing MySQL on Mac OS X 10.6 with Homebrew

So I'm trying to install Mysql through homebrew, using the standard procedure: brew install mysql

But running Mysql gets this well-known error:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (38)

I'm trying this on a fresh new computer. There isn't a /etc/my.cnf, but editing the socket locations does seem to affect the above error message (but doesn't fix the problem).

Any other basic steps I missed here?


Source: (StackOverflow)

What should I set JAVA_HOME to on OSX

Many Java applications that use shell scripts to configure their environment use the JAVA_HOME environment variable to start the correct version of Java, locate JRE JARs, and so on.

On OSX 10.6, the following paths seem to be valid for this variable

/Library/Java/Home
/System/Library/Frameworks/JavaVM.framework/Home
/System/Library/Frameworks/JavaVM.framework/Versions/Current

Some of these are symlinks to the actual current VM (as defined in the Java Preference pane).

But which one should be used—or is it okay to use any of them?


Source: (StackOverflow)

What does this mean? "'NSUnknownKeyException', reason: ... This class is not key value coding-compliant for the key X"

I'm trying to link a UILabel with an IBOutlet created in my class.

My application is crashing with the following error. What does this mean? How can I fix it?

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x6e36ae0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key XXX.'


Source: (StackOverflow)

How to use/install gcc on Mac OS X 10.8 / Xcode 4.4

I have install Mountain Lion (Mac OS X 10.8) and now gcc doesn't seem to be available anymore. I've also installed Xcode 4.4 so there is no more /Developer directory.

I need gcc both for mac ports and for ruby gems (that have native extensions).

Does Xcode 4.4 include gcc or is there a way to install gcc?


Source: (StackOverflow)

`pg_tblspc` missing after installation of OS X Yosemite

I use postgres from homebrew in my OS X, but when I reboot my system, sometimes the postgres doesn't start after the reboot, and so I manually tried to start it with postgres -D /usr/local/var/postgres, but then the error occurred with the following message: FATAL: could not open directory "pg_tblspc": No such file or directory.

The last time it occurred, I couldn't get it to the original state, so I decided to uninstall the whole postgres system and then re-installed it and created users, tables, datasets, etc... It was so disgusting, but it frequently occurs on my system, say once in a few months.

So why does it lose the pg_tblspc file frequently? And is there anything that I can do to avoid the loss of the file?

I haven't upgraded my homebrew and postgres to the latest version (i.e. I've been using the same version). Also, all the things that I did on the postgres database is delete the table and populate the new data every day. I haven't changed the user, password, etc...

EDIT (mbannert): I felt the need to add this, since the thread is the top hit on google for this issue and for many the symptom is different. Homebrewers likely will encounter this error message:

No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

So, if you just experienced this after the Yosemite upgrade you now you're covered for now reading this thread.


Source: (StackOverflow)

Is there any way in the OS X Terminal to move the cursor word by word? [closed]

I know the combination Ctrl+A to jump to the beginning of the current command, and Ctrl+E to jump to the end.

But is there any way to jump word by word, like Alt+/ in Cocoa applications does?


Source: (StackOverflow)

Where is JAVA_HOME on OSX Yosemite (10.10), Mavericks (10.9), Mountain Lion (10.8) or OSX Lion (10.7)?

Java is an optional package on the latest versions of OSX.

Yet once installed it appears like the JAVA_HOME environment variable is not set properly.


Source: (StackOverflow)

Xcode 4.4 and later install Command Line Tools

How do I get the command line builds tools installed with Xcode 4.4 / Mac OS X v10.8 (Mountain Lion) or later?

Unlike Xcode 4.3 there is no installer (it's just a bundle).

It looks like all the command line tools are there (in the bundle, under Contents/Developer), but none of the appropriate environment variables set to use them.

Is there a script somewhere I can run that will setup my environment to support building from the command line?


Source: (StackOverflow)

Who is listening on a given TCP port on Mac OS X?

On Linux, I can use netstat -pntl | grep $PORT or fuser -n tcp $PORT to find out which process (PID) is listening on the specified TCP port. How do I get the same information on Mac OS X?


Source: (StackOverflow)

How to start postgreSQL server on mac os x?

FINAL UPDATE:

I forgot to run the initdb command.

< /FINAL UPDATE>

by running this command

ps auxwww | grep postgres

I see that postgres is not running

> ps auxwww | grep postgres
remcat          1789   0.0  0.0  2434892    480 s000  R+   11:28PM   0:00.00 grep postgres

this raises the question: How do I start the postgresql server?

update:

>pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
server starting
sh: /usr/local/var/postgres/server.log: No such file or directory

update 2:

The touch was not successful so I did this instead:

> mkdir /usr/local/var/postgres
> vi /usr/local/var/postgres/server.log
> ls /usr/local/var/postgres/          
server.log

But when I try to start rails server, I still see this:

Is the server running on host "localhost" and accepting
TCP/IP connections on port 5432?

update 3:

> pg_ctl -D /usr/local/var/postgres status
pg_ctl: no server running

update 4:

I found that there WAS NO pg_hba.conf (only pg_hba.conf.sample) so I modified the sample and renamed it (to remover the .sample). Here are the contents:

 # IPv4 local connections:
 host    all             all             127.0.0.1/32           trust
 # IPv6 local connections:
 host    all             all             ::1/128                trust

but I don't understand this:

> pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start     
server starting
> pg_ctl -D /usr/local/var/postgres status                                     
pg_ctl: no server running

also:

sudo find / -name postgresql.conf
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory

update 5:

sudo pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
Password:
pg_ctl: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will own the server process.

update 6:

this seems odd:

> egrep 'listen|port' /usr/local/var/postgres/postgresql.conf
egrep: /usr/local/var/postgres/postgresql.conf: No such file or directory

though, I did do this:

>sudo find / -name "*postgresql.conf*"
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/usr/local/Cellar/postgresql/9.0.4/share/postgresql/postgresql.conf.sample
/usr/share/postgresql/postgresql.conf.sample

so I did this:

egrep 'listen|port' /usr/local/Cellar/postgresql/9.0.4/share/postgresql/postgresql.conf.sample 
#listen_addresses = 'localhost'     # what IP address(es) to listen on;
#port = 5432                # (change requires restart)
                # supported by the operating system:
                #   %r = remote host and port

so I tried this:

> cp /usr/local/Cellar/postgresql/9.0.4/share/postgresql/postgresql.conf.sample /usr/local/Cellar/postgresql/9.0.4/share/postgresql/postgresql.conf        
> cp /usr/share/postgresql/postgresql.conf.sample /usr/share/postgresql/postgresql.conf 

still getting the same "Is the server running?" message.


Source: (StackOverflow)