Mostrando entradas con la etiqueta mac os x. Mostrar todas las entradas
Mostrando entradas con la etiqueta mac os x. Mostrar todas las entradas

12 de febrero de 2016

Tweaking hidden files in Mac OS X

Aloha!

Ever wondered how to show/hide hidden files in your Mac OS X in the Finder app?

If so, let's get right to it:

Add this two aliases in your ~/.bash_profile file:

# Hidden files tweaks

alias show_hidden_files='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app'
alias hide_hidden_files='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app'

And that's it!

Now, if you want to show the hidden files, just run this command in the console:

$ show_hidden_files

And if you want to hide them back:

$ hide_hidden_files

And that's it! :)


Cheers!


M.-

26 de junio de 2014

How to revive Mac App Store when its stuck forever waiting...


How to revive Mac App Store when its stuck forever waiting...

I recently went to the App Store application on my Mac to download the Lion version of Apple's Xcode development tools.  I was prompted for my Apple ID and password (which I provided) and then I left the App Store app on its own to complete the download and install.  After about 30 minutes I went to check in on its progress and saw that it had downloaded exactly 0 bytes.  The status on the Purchased page was Waiting...

Waiting for Godot

...and waiting and waiting.  I quit and restarted App Store and still my downloads were stuck waiting.  I dug around a little and it turns out this is not an uncommon problem but the remedies suggested were all over the place.  Everything from installing updates and deleting caches (both good ideas) to deleting your Library folder (not a good idea).  I like to attack problems like this by starting with the easiest and least invasive measures.

I should state right off the bat that these solutions are meant to incur as little disruption as possible but do require the use of some programs that might not be in your usual repertoire: Activity Monitor and Terminal.  If you are at all uncomfortable using these tools you can always use that old Windows chestnut... reboot.  Yes, rebooting your Mac should have the same affect as solution 1 at least.  But if you don't want the hassle of rebooting then read on.


Solution 1: Kill the Zombie

The App Store uses a process called "storeagent" that runs continuously in the background.  It seems that sometimes this process can go a little wonky and fail to respond to requests to download app purchases.  What we want to do is kill this zombie process (it will start up again automatically).

Start Activity Monitor
First, quit the App Store application (e.g. by selecting "App Store->Quit App Store" or pressing Cmd-Q or click the red dot in the top left corner of the window).  Start upActivity Monitor (you'll find it on Lion's launchpad in the Utilities collection or using Finder in Applications/Utilities/Activity Monitor.  Activity monitor is used to display the processes running on your Mac.  You could go hunt around for the process called "storeagent" but an easier method is to enter "storeagent" in the Activity Monitor filter box as illustrated below (some of the numbers will be different).  Highlight the "storeagent" process by clicking on it.  The "Quit Process" stop sign should become available.  Go ahead and click on Quit Process to kill "storeagent". You'll be asked if you really want to quit the process.  Confirm by clicking "Quit".  Normally this should do the trick and the process will disappear immediately and be replaced a little while later by a new process (with a different number in the PID column).  However, if the process is a deep zombie, you will need to click "Force Quit" in the confirmation dialog.  Do this only as a last resort as it is possible to damage system files by using Force Quit too often. 

Activity Monitor Filtered for "storeagent".  Note the "Quit Process" stop sign is now clickable.
Now go ahead and restart the App Store application.  Click on Purchased, find your purchase and select Resume. After you enter your Apple ID and password your purchase should start downloading.   However, if the App Store is still stuck in Waiting move on to Solution 2.

Solution 2 - Purge the Caches

Solution 1 has always worked for me but I've heard of cases where more intervention is required.  If this fits your situation then go ahead and quit the App Store application again.  Now we do some typing into Terminal. You can find Terminal in the same Utilities folder that you found Activity Monitor.  When you start it, it should look something like below.

At the Terminal prompt
What we're going to do is use some commands to delete App Store caches.  You do not need to worry about deleting these files since, by definition, they are a copy of what is already stored on the Apple servers and will automatically be restored.  Type of the following commands exactly as you see below (in fact, go ahead and copy and paste them into Terminal).

rm -r ~/Library/Caches/com.apple.appstore
rm -r ~/Library/Caches/com.apple.storeagent
rm ~/Library/Preferences/com.apple.appstore.plist
rm ~/Library/Preferences/com.apple.storeagent.plist
rm ~/Library/Cookies/com.apple.appstore.plist

Now go and do the steps in Solution 1 again.  Once you're done that, start up App Store, go to Purchases, and select Resume on your download.  Enter your Apple ID and password and you're off to the races.

Source: http://scheyeniam.blogspot.com.ar/2011/08/how-to-revive-mac-app-store-when-its.html?spref=bl

How to merge two folders in Mac OS X or Linux


Short answer


Using the command line (Terminal):
cp -r -n ~/Desktop/src/* ~/Desktop/destination/
The command above adds the src content and the subdirectories to the destination without overwriting the content already present in the destination.

Long answer

Even if the content overlaps, you can still use cp to do it. Assume that you have two folders on your desktop: the src and the destination folders and you want to merge src into destination:
enter image description here
To merge, just do:
cp -r ~/Desktop/src/* ~/Desktop/destination/
NOTE When you use this, the content in src overwrites the content in the destination folder and adds the extra stuff that are missing in the destination. It shouldn't matter if you just want to add the missing files from src into destination.
ALSO it doesn't matter how many subdirectories are there, it will just go through each folder recursively and it will overwrite the content and will add the stuff that is missing in the destination folder.
BUT
PITFALL If you have huge files (like video files), you don't want to wait until everything is overwritten, it adds a lot of overhead.
PITFALL SOLUTION: Instead, you can use the -n flag to skip the overwriting:
cp -r -n ~/Desktop/src/* ~/Desktop/destination/
This is the description of the -n flag from the man page:
man cp
 -n    Do not overwrite an existing file.  (The -n option overrides any
       previous -f or -i options.)
Further Reading
  1. http://stackoverflow.com/questions/5088332/overhead-of-a-flag-in-cp-command
Source:

7 de abril de 2014

Installing MySQL-Python in Mac OS X Mavericks

If you are in Mac OS X Mavericks and while trying to install MySQL-Python you run into this error:



This is a what makes the trick:



Then, pip works its way towards installing MySQL-Python OK:



Voilà!

5 de noviembre de 2013

List merge conflicts with GIT


Made a merge, particularly, a big one and you want to know which where the files that had conflicts?

Then, this command might come handy:



You can also make a GIT alias this way:



and then use it like this:

25 de septiembre de 2013

Nice app for Mac OS X

Aloha!

I came across this app, that is very useful for cleaning up your Mac menu bar layout and have a cleaner visual landscape: http://www.macbartender.com/

Aloha! [1]



[1] "Since the middle of the 19th century, it also has come to be used as anEnglish greeting to say goodbye and hello."
Source: http://en.wikipedia.org/wiki/Aloha

Unix exit status code reference

0    # successful termination 
64   # base value for error messages 
64   # command line usage error 
65   # data format error 
66   # cannot open input     
67   # addressee unknown     
68   # host name unknown 
69   # service unavailable 
70   # internal software error 
71   # system error (e.g., can't fork) 
72   # critical OS file missing 
73   # can't create (user) output file 
74   # input/output error 
75   # temp failure; user is invited to retry 
76   # remote error in protocol 
77   # permission denied 
78   # configuration error

24 de septiembre de 2013

Pimp my GIT: mejorando la interfaz para el uso de GIT

Siguiendo con el post de ayer, acá les comparto otras cosas del setup que tengo para git.

El setup este, y va dentro del .git/config de su clone git:


Con esto seteado, verán, por ejemplo, los git status con colores:




Podrán usar abreviaciones de los comandos, como:

- "git st" en vez de "git status"
- "git ci" en vez de "git commit"

Podrán ver un log más interesante y con colores con git log.

Verán los diff coloreados y con formato piola:



Git branch muestra coloreado el branch actual (los branches locales aparecen en amarillo):



Y los branches remotos aparecen en verde:

Inline image 4


Saludos!

23 de septiembre de 2013

Mostrar el branch de GIT y el status actual en el shell prompt y más!

Algunos trucos para configurar nuestro setup local de GIT:

Hace algunos años encontré algo como eso y, con el tiempo, armé una serie de scripts (algunas cosas que hice yo, algunas cosas que fui encontrando en la web), que hacen varias cosas con bash, que están piolas.

¿Qué cosas?

- que se detecte automáticamente si se está en una carpeta perteneciente a un repo git, y que, en el caso que sí lo sea, el prompt muestre información relevante del repo en que se está: branch y estado. Ejemplo:



en ese caso, estoy en el branch "master" y tengo archivos modificados (por eso la "m") y archivos que borré (por eso la "d").

- otra cosa muy piola es tener tab completion (que al apretar tab, con un comando a medio escribir, se muestren opciones para completar ese comando -o que se completen, si hubiera una opción posible). Imaginen eso aplicado a nombres de branch, comandos git y comandos de django (como "python manage.py runserver", por ejemplo).

- Algunas cosas más, como:
-- aumentar el tamaño del history de bash, pero eliminando duplicados, para que al hacer "ctrl r" en la consola, podamos buscar en el historial de los comandos que hicimos y encontrar resultados interesantes.
-- Una larga lista de colores definidos, para directamente poder usarlos en la definición del prompt.

Etc!

Les paso adjuntas las scripts para hacer todo esto:


Las dos primeras las ponen derecho en el home. El .profile pueden ponerlo derecho en el home (si usan Mac y no tienen otro .profile armado) o copiar su contenido a su .profile existente. Si usan Linux, pueden hacer esto mismo con el archivo .bashrc.
(notar que tienen un underscore los archivos, a propósito, para que no sobreescriban cosas sin querer y para que no los tome el file browser como archivos ocultos).


Un abrazo y may the bash be with you (?),


17 de mayo de 2012

VOX USB-MIDI Driver for Mac OS X

After digging around the web for a while, searching for the VOX USB-MIDI Driver for Mac OS X for the VOX ToneLab EX, I found it on the VOX Japanese site.

Here's the link: http://voxamps.jp/support/download/usb-midi/mac.html

Direct download link: link.

23 de febrero de 2012

Keyboard shortcut to unhide or unminimize a window in Mac OS X Lion

  • press Command-Tab to show your running apps
  • press tab until you've selected the minimized app
  • here's the magic trick => then press the option key, and let go of the command key (you must depress the command key after pressing the option key!)
Source: Link.

7 de febrero de 2012

Repairing PostgreSQL after upgrading to Mac OSX Lion

I upgraded to Mac OSX to 10.7.3 (Lion) yesterday and had some issues with PostgreSQL.

For instance, when I tried to run the South migrations for the Django project I'm working at, I got this:

psycopg2.OperationalError: could not connect to server: Permission denied
    Is the server running locally and accepting
    connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
How I fixed this?

  1.  Edit PostgreSQL's config to define the unix_socket_directory setting:

    $ sudo nano /Library/PostgreSQL/9.0/data/postgresql.conf

    In my case I changed the setting to unix_socket_directory = '/var/pgsql_socket/'.
  2. Exceute the following commands:

    $ sudo dscl . append /Groups/_postgres GroupMembership postgres
    $ sudo chmod g+w,o+rx /var/pgsql_socket/

  3.  Restart the server:

    $ sudo -u postgres /Library/PostgreSQL/9.0/bin/pg_ctl -D /Library/PostgreSQL/9.0/data/ restart
Note: You may want to add an alias for this command in your ~/.profile file. If so, it is just a matter of adding a line like this:

alias restart_postgres='sudo -u postgres /Library/PostgreSQL/9.0/bin/pg_ctl -D /Library/PostgreSQL/9.0/data/ restart'

25 de octubre de 2011

Add forwards search to bash command history

Hi!

While using the bash console, the ctrl+r command comes extremely handy to search backwards through the command history.

But while searching backwards, we may want to be able to navigate both ways (i.e., backwards and forwards). This is not activated by default.

How to activate it? Just run this command:

$ stty -ixon -ixoff 

Tadaa! And now you can do ctrl+r and ctrl+s to navigate backwards and forwards.

You can also add this to your .profile file (in Mac OS X) or your .bashrc file (in Linux) for this to be available every time you open a Bash terminal.

Cheers!

13 de septiembre de 2011

How to install meld in Mac OS X Lion


Missing the nice and sweet meld program for your SVN or GIT diffs in Lion?

Try this:

  1. Get and install pygtk:
  2. Get meld
  3. Extract the tar.bz2, go to the extracted directory and then run:
    1. Note: This assumes you have brew installed. If not, see here.
      • $ brew install intltool
      • $ brew install gettext
      • $ export PATH=/usr/local/Cellar/gettext/0.18.1.1/bin/:$PATH
      • $ make prefix=/usr/local/ install 
  4. Now you should now have the 'meld' command available.

Some useful links I went through to figure the above mentioned steps:
  • http://meld.sourceforge.net/
  • http://meld.sourceforge.net/install.html
  • http://www.mail-archive.com/pygtk@daa.com.au/msg20559.html

How to fix Brew Update Error ( mxcl / homebrew, Mac OS X Lion)


Did you, like myself, get something like this while running a brew update?

[matias@MacBookPro]:~ $ sudo brew update
Password:
remote: Counting objects: 588, done.
remote: Compressing objects: 100% (253/253), done.
remote: Total 455 (delta 348), reused 298 (delta 193)
Receiving objects: 100% (455/455), 52.32 KiB, done.
Resolving deltas: 100% (348/348), completed with 124 local objects.
From http://github.com/mxcl/homebrew
 * branch            master     -> FETCH_HEAD
error: The following untracked working tree files would be overwritten by merge:
        .gitignore
        Library/Aliases/0mq
        Library/Aliases/4store
(.... lots of lines ....)
        Library/Formula/android-sdk.rb
        Library/Formula/angband.rb
        Library/Formula/ansifilter.rb
        Library/Formula/antiword.rb
        Library/Formula/antlr.rb
        Library/Formula
Aborting
Error: Failed while executing git pull origin master
The fix is easy. Luckily. Goes like this:
$ sudo chown -R `whoami` /usr/local
$ cd /usr/local
$ git reset --hard origin/master
$ cd

Now you can try again:
[matias@MacBookPro]:local (git: master ?) $ brew update
From http://github.com/mxcl/homebrew
   3dc7fe2..09ebe32  master     -> origin/master
Updated Homebrew from 3dc7fe29 to 09ebe32c.
==> New formulae
aespipe       fuse4x        fuse4x-kext   ntfs-3g       parmetis      s3fs          scotch        sshfs
==> Removed formulae
unix2dos
==> Updated formulae
(.... lots of stuff here ....)

9 de septiembre de 2011

Cómo Instalar NINJA IDE en Mac OS X Lion

Hace poquito actualicé mi compu a Lion y reinstalé NINJA. Con Diego Sarmentero hicimos luego una mini-sprint para dejar NINJA andando aceitadamente y bien nativo en Mac.

Acá les dejo las instrucciones para instalar NINJA desde el repositorio en desarrollo:

  1. Instalar XCode desde el App Store:
    • http://itunes.apple.com/us/app/xcode/id448457090?mt=12
  2. Instalar HomeBrew:
    • https://github.com/mxcl/homebrew/wiki/Installation
  3. Instalar Qt y PyQt:
    • $ brew install qt
    • $ brew install pyqt
    • Agregar esta línea en el archivo ~/.profile:
      • export PYTHONPATH=/usr/local/lib/python:$PYTHONPATH
  4. Hacer un checkout del repositorio de NINJA:
    • Hace falta tener instalado Mercurial para hacer el clone del repositorio. Si no lo tenés instalado, lo podés instalar así:
      • sudo easy_install mercurial
  5. Ejecutar NINJA:
    • Vamos a la carpeta del checkout:
      • $ cd ~/NINJA_IDE/ninja-ide/
      •  $ python ninja-ide.py

Y ahora, a disfrutar de NINJA-IDE!

Disable autocorrection in Mac OS X Lion

I found that Mac OS X Lion came by default with an autocorrection functionality. This can be useful... or a big annoyance!

For instance, it annoyed me when I typed "TRAC" and replaced it with "trace" in one of my daily SCRUM meetings.


Then, how to disable it?

Go to System Preferences -> Language and Text -> Text tab, and disable the check:





Done!

9 de agosto de 2011

Installing cairo and pycairo in Mac OS X with python 2.6



Mac OS X includes an old version of Cairo(usually 1.8.6) which is too old for new software to link against. For the installation of py2cairo to succeed, we need 1.8.10.

Let's check which version we have:

$ pkg-config --atleast-version=1.8.10 cairo
$ echo $?
1

That means there's no a version 1.8.10 or above of the 'cairo' lib.

Let's install it using Brew:

$ brew install cairo

Let's now check again:


$ pkg-config --atleast-version=1.8.10 cairo
$ echo $?
1

No luck again! Why? We need to tell the system where the recently installed version of cairo lives:

$  export PKG_CONFIG_PATH=
Note: In my case, the path is: /usr/local/Cellar/cairo/1.10.2/lib/pkgconfig/


Let's check again:

$  pkg-config --atleast-version=1.8.10 cairo
$ echo $?
0

Awesome!

Let's now install py2cairo, the Python binding for cairo:

1. Download this.
2. Uncompress, go inside the directory.
3. Run the following command, expecting an output like the depicted below:

$ ./waf configure
  ./set_options
  ./init
  ./configure
Checking for program gcc or cc           : /usr/bin/gcc
Checking for program cpp                 : /usr/bin/cpp
Checking for program ar                  : /usr/bin/ar
Checking for program ranlib              : /usr/bin/ranlib
Checking for gcc                         : ok 
Checking for program python              : /Users/matias/Dev/CPI/Env/bin/python
Checking for Python version >= 2.6.0     : ok 2.6.1
Checking for library python2.6           : yes
Checking for program python2.6-config    : /usr/local/bin/python2.6-config
Checking for header Python.h             : yes
Checking for cairo >= 1.8.10             : yes
'configure' finished successfully (0.416s)
  ./shutdown

4. Now build:

$ ./waf build

5. Install:

$ ./waf install
6. Update your PYTHONPATH(you may want to add this line at the bottom of your ~/.profile):

export PYTHONPATH=/usr/local/lib/python2.6/site-packages/:$PYTHONPATH 

7. Check everything worked:

$ python
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cairo
>>> cairo.version
'1.8.10'
 Happiness!

 

FYI: The output of the configure, build and install commands in my case was the following(I include it for reference, in case it might be of any help):

(Env)matias@[13:51:34]:pycairo-1.8.10 $ ./waf configure  ./set_options
  ./init
  ./configure
Checking for program gcc or cc           : /usr/bin/gcc
Checking for program cpp                 : /usr/bin/cpp
Checking for program ar                  : /usr/bin/ar
Checking for program ranlib              : /usr/bin/ranlib
Checking for gcc                         : ok 
Checking for program python              : /Users/matias/Dev/CPI/Env/bin/python
Checking for Python version >= 2.6.0     : ok 2.6.1
Checking for library python2.6           : yes
Checking for program python2.6-config    : /usr/local/bin/python2.6-config
Checking for header Python.h             : yes
Checking for cairo >= 1.8.10             : yes
'configure' finished successfully (0.416s)
  ./shutdown
(Env)matias@[13:52:07]:pycairo-1.8.10 $ ./waf build
  ./set_options
  ./init
Waf: Entering directory `/Users/matias/Dev/CPI/Stuff/pycairo-build'
  ./build
  src/build
[1/9] cc: src/cairomodule.c -> ../pycairo-build/default/src/cairomodule_2.o
[2/9] cc: src/context.c -> ../pycairo-build/default/src/context_2.o
[3/9] cc: src/font.c -> ../pycairo-build/default/src/font_2.o
[4/9] cc: src/path.c -> ../pycairo-build/default/src/path_2.o
[5/9] cc: src/pattern.c -> ../pycairo-build/default/src/pattern_2.o
[6/9] cc: src/matrix.c -> ../pycairo-build/default/src/matrix_2.o
[7/9] cc: src/surface.c -> ../pycairo-build/default/src/surface_2.o
[8/9] copy: pycairo.pc.in -> ../pycairo-build/default/pycairo.pc
In file included from /usr/X11/include/X11/Xlib.h:64,
                 from /usr/local/Cellar/cairo/1.10.2/include/cairo/cairo-xlib.h:44,
                 from ../pycairo-1.8.10/src/surface.c:1360:
/usr/X11/include/X11/Xosdefs.h:145:1: warning: "_DARWIN_C_SOURCE" redefined
In file included from /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:8,
                 from ../pycairo-1.8.10/src/surface.c:32:
/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h:1075:1: warning: this is the location of the previous definition
[9/9] cc_link: ../pycairo-build/default/src/cairomodule_2.o ../pycairo-build/default/src/context_2.o ../pycairo-build/default/src/font_2.o ../pycairo-build/default/src/path_2.o ../pycairo-build/default/src/pattern_2.o ../pycairo-build/default/src/matrix_2.o ../pycairo-build/default/src/surface_2.o -> ../pycairo-build/default/src/_cairo.so
Waf: Leaving directory `/Users/matias/Dev/CPI/Stuff/pycairo-build'
'build' finished successfully (0.764s)
  ./shutdown
(Env)matias@[14:05:51]:pycairo-1.8.10 $ ./waf install
  ./set_options
  ./init
Waf: Entering directory `/Users/matias/Dev/CPI/Stuff/pycairo-build'
  ./build
  src/build
* installing src/pycairo.h as /usr/local/include/pycairo/pycairo.h
* installing /Users/matias/Dev/CPI/Stuff/pycairo-build/default/src/_cairo.so as /usr/local/lib/python2.6/site-packages/cairo/_cairo.so
* installing /Users/matias/Dev/CPI/Stuff/pycairo-build/default/pycairo.pc as /usr/local/lib/pkgconfig/pycairo.pc
Waf: Leaving directory `/Users/matias/Dev/CPI/Stuff/pycairo-build'
* installing src/__init__.py as /usr/local/lib/python2.6/site-packages/cairo/__init__.py
* byte compiling '/usr/local/lib/python2.6/site-packages/cairo/__init__.py'
'install' finished successfully (0.832s)
  ./shutdown


29 de junio de 2011

How to share files with VirtualBox between Mac and Windows

Today I needed to setup a Windows XP virtual machine with Virtual Box at work. Doing that, I happened to need files from my computer to be accessible from the virtual machine with Windows XP.


How did I get that done? Well, I used the guide of this excellent post(which I borrow here :P ): link.


Here it goes:

I recently felt the need of changing my VMWare Fusion 2.0 Beta, because it kept on locking my Mac. I found VirtualBox, which is recently acquired by Sun, offered for free and has a recent release 1.6. I read some nice reviews, and although it lacks some features, looks like it’s quite fast and reliable (will review it when I get to use it more).
First thing I needed to do with VirtualBox, after setting up a Windows was to share files between my Mac (Leopard) and Windows (XP). VirtualBox does not offer drag and drop for now, but hopefully will do soon. To share files between 2 computers:

1. Install Guest Additions

Go to “Devices->Install Guest Additions”. After selecting this, open “My Computer”, and you will see there is Guest Additions installer mounted. Just double click and install. After installing, do not forget to reboot (that’s important).

2. Create a shared folder

Go to “Devices & Shared Folders”. Press “Add” (+ sign on right side). Browse for your shared folder on your mac. Pick up a good name and note it down (we will use the name later on). I suppose you selected a folder to share and named it “shared”.

3. Create a batch file

On Windows XP, shared folders are browsable. Easiest way to mount shared folders is to create a batch file, instead of writing a command each time you login. To do that, right click on Desktop, select “New->Text file”. Rename your text file to “Mount.bat” (or something else you wish). After renaming, right click on it and select “Edit” and paste the code below (with necessary modification, depending on your shared folder name. I assume it’s “shared” in our case)
net use x: \\vboxsvr\shared
Beware of the space in between “x:” and “\\” otherwise you will get;
System error 67 has occured
Which in my opinion a common mistake. Save the file and you are done. Just double click on “Mount.bat” on your desktop and you will see X: drive will appear with your shared folder on My Computer.
Enjoy :)