GIT: Using GITX with Manual Push

I'm new with GIT and GITX so please feel free to comment if there are more efficient ways of doing this outside of downloading plugins / other open-source versions of GITX such as GITX(L).

Versioning changes locally:
1. Goto Commit View
2. Under Unstaged Changes section, select the changes you wish to version
3. Right click and select Stage
4. The files should now appear in the Staged Changes section
5. Enter a Commit Message
6. Click Commit
7. Done

Promoting changes to git server:
1. Open Terminal
2. Goto head directory of git repo
3. Type git push
4. Once done, you should see a message:

To http://[git.server]/[git.path]/[git.repo].git
6a8ff81..72a89a7 master -> master

Reverting changes locally:
1. Goto History View
2. Drag the origin/HEAD and origin/MASTER to the revision you want
3. Now you can overwrite the bad changes by promoting a new one

XCODE4: Fail to build for iOS 4.0, 4.1

To begin, I'm running Xcode 4.0.2, Build 4A2002a

Nothing goes wrong when compiling my project for iOS 4.2/4.3. However, when using it to compile using iOS 4.0/4.1, I get lots of the following errors;

uint8_t not defined, uint16_t not defined, uintptr_t not defined, etc...

or

cc1plus: error: /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk/usr/include/c++/4.2.1/arm-apple-darwin10/v7: not a directory

or

ld: warning: ignoring file /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk/usr/lib/libSystem.dylib, file was built for unsupported file format which is not the architecture being linked (armv6)
ld: warning: symbol dyld_stub_binder not found, normally in libSystem.dylib
Undefined symbols for architecture armv6:




I believe all of these errors has to do with a faulty installation... For some reason, while installing xcode 4.0.2, it either forgets to set up the file-links properly, or maybe apple purposely left it out to drive developers to use the new OSs... either way, it caused about an hour of headache.



The solution for item #1, is to open up stdint.h... notice that the file contains no more than couple lines of crap... something along the lines of:

XSym
0027
88c0b7e54f82f10929bdfc91ac2dbefd
gcc/darwin/default/stdint.h

Where default obviously refers to GCC version... but the linkage went wrong somewhere, and so stdint.h was never included, thereby causing all your headache. The solution is to (1) manually include the stdint.h in your project, or (2) copy and paste the content into the file with the mumbo-jumbo above.


The solution for item #2 is to fix the symbolic links that somehow got corrupted. Any references to v6 and v7 are supposed to map to the following directories:

ln -s /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.#.sdk/usr/include/c++/4.2.1/armv6-apple-darwin10 v6
ln -s /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.#.sdk/usr/include/c++/4.2.1/armv6-apple-darwin10 v7


Obviously, don't forget to replace out the # sign in the commands above... or else, good luck with that command :P


The solution for item #3 is yet another failed symbolic link (ARGH!). libSystem.dylib is supposed to be a symbolic link to libSystem.B.dylib. But NO! Something happened and now it's just a file taking up space. Fix this symbolic link and you're back in business. At least, I am.

ln -s /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.#.sdk/usr/lib/libSystem.B.dylib libSystem.dylib

Again, don't forget about the # sign.

XCODE4: Stuck on Attaching to 'Appname'

CTRL+R usually runs the application on the Simulator automatically, but today it stopped suddenly. Instead, I just kept seeing "Attaching to Appname' message in the status window.

After some heavy googling, turns out it's scheme setting. To fix:

1. Goto Product > Run...

2. On the left hand side, select Run appname.app

3. Select the info tab on the right

4. Select Launch --> Automatically

For some reason, neither Automatically nor 'wait for appname.app to launch were selected.

---

If your simulator screen is already stuck in darkness (black screen of death),

1. Stop your running demo (hit the STOP button)

2. Goto menubar > iOS Simulator > Reset content and settings...

3. Re-run following the steps above

UNIX: Bash password input

read -s -p "Password: " mypasswd

or

stty -echo
read -p "Password: " mypasswd
stty echo

CENTOS: Installing Git 1.7.4.4 on 5.5

Using CentOS for the first time today, and boy did it bring back horrible memories of Unix in the ucsd computer dungeon...

Anyway, since it was a new installation of CentOS 5.5, installation required LOTS of updates...

1. log into root (su root)
2. wget http://kernel.org/pub/software/scm/git/git-1.7.4.4.tar.gz
3. tar -zxf git-1.7.4.4.tar.gz
4. cd git-1.7.4.4

let's just run the installation so that we can see what libs we are missing...

5. make prefix=/where-ever-i-want/git all

if you receive the following kind of error, you need to update/install packages...

expat.h: No such file or directory (yum install expat-devel)
zlib.h: No such file or directory (yum install zlib-devel)
openssl/ssh.h: No such file or directory (yum install openssl-devel, yum install curl-devel)
openssl/err.h: No such file or directory

you get the idea...

6. once installation completes, now you can install libs/binaries to the prefix directory...

7. make prefix=/where-ever-i-want/git install

OSX: Adding new user on 10.6

dscl . -create /Users/username
dscl . -create /Users/username UserShell /usr/bin/false
dscl . -create /Users/username RealName "User description"
dscl . -create /Users/username UniqueID ###
dscl . -create /Users/username PrimaryGroupID ###
dscl . -create /Users/username NFSHomeDirectory /dev/null
dscl . -passwd /Users/username PASSWORD

view users' full configs:

dscacheutil -q user

view particular user's full config:

dscacheutil -q user -a name username

view user's uid only:

dscl . list /Users uid

view group's gid only:

dscl . list groups gid

OSX: Installing mysql on 10.6

1. Download mysql-5.0.92.tar.gz

2. Unpackage to /usr/local/mysql-5.0.92/

3. Create symlink mysql

cd /usr/local/
ln -s /usr/local/mysql-5.0.92/ mysql

4. Open Terminal and set temporary PATH

export PATH=$PATH:/usr/local/mysql/bin

5. Create 2 folders

mkdir tmp
mkdir var

6. Configure mysql
./configure --prefix=/usr/local/mysql \
--with-extra-charsets=all \
--enable-thread-safe-client \
--with-unix-socket-path=/usr/local/mysql/tmp/socket \
--with-mysqld-user=mysql \
--with-comment \
--with-debug

7. Install mysql

make
make install

8. If during the installation process you encounter the following error:
/usr/bin/install -c 'bench-count-distinct' '/usr/local/mysql/sql-bench/bench-count-distinct'
install: bench-count-distinct and /usr/local/mysql/sql-bench/bench-count-distinct are the same file
make[3]: *** [install-benchSCRIPTS] Error 64
make[2]: *** [install-am] Error 2
make[1]: *** [install-recursive] Error 1

You aren't alone, the problem is with the OS and directory name resolution. The fix is to simply ignore these errors.

option A. make -i install

option B. edit /usr/local/mysql/sql-bench/Makefile line 418

from:

$(...) "$$d$$p" "$(DESTDIR)$(benchdir)/$$f"; \

to:

$(...) "$$d$$p" "$(DESTDIR)$(benchdir)/$$f" 2>/dev/null | wc -l; \

9. installing the database

sudo /usr/local/mysql/bin/mysql_install_db --force

10. create mysql user

dscl . -create /Users/mysql
dscl . -create /Users/mysql UserShell /usr/bin/false
dscl . -create /Users/mysql NFSHomeDirectory /dev/null
dscl . -passwd /Users/mysql PASSWORD

11. giving permission to mysql to write files

sudo chown -R mysql /usr/local/mysql

12. running the database (sudo is needed unless you are running from mysql account/root)

sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &

13. creating a database root user

/usr/local/mysql/bin/mysqladmin -u root password rootpwd

14. stop running databases

/usr/local/mysql/bin/mysqladmin shutdown

15. as was the case with the tomcat server, here's a mini script that can simplify starting and shutting down the mysql server
#!/bin/bash
export PATH=$PATH:/usr/local/mysql/bin
if [ "$1" == "start" ]; then
sudo mysqld_safe -user=mysql &
elif [ "$1" == "stop" ]; then
sudo mysqladmin shutdown
elif [ "$1" == "info" ]; then
mysqladmin version
else
echo "Command: mysql [start|stop|info]"
fi

OSX: Installing tomcat on 10.6

TO INSTALL TOMCAT

1. Download jakarta-tomcat-x.x.xx.tar.gz

2. Unzip to /usr/local/tomcat-x.x.xx/

3. Create symlink tomcat

cd /usr/local/
ln -s /usr/local/tomcat-x.x.xx/ tomcat

4. Use the following script to start/stop tomcat
#!/bin/bash

export CATALINA_BASE=/usr/local/tomcat
export CATALINA_HOME=/usr/local/tomcat
export CATALINA_TMPDIR=/usr/local/tomcat/temp
export JRE_HOME=/*dir to java home*/
export CLASSPATH=/usr/local/tomcat/bin/bootstrap.jar

if [ "$1" == "start" ]; then
$CATALINA_HOME/bin/startup.sh
elif [ "$1" == "stop" ]; then
$CATALINA_HOME/bin/shutdown.sh
else
echo "Command: tomcat [start|stop]"
fi

5. Assuming the script's path is ~/tomcat, start the server using

~/tomcat start

6. Assuming the script's path is ~/tomcat, stop the server using

~/tomcat stop

OSX: Making symbolic links (folder aliases)

If you navigate to /Library/Java, you will notice there's a folder alias in there called Home, which maps to /System/.../Home

If you do an ls -l on the /Library/Java directory, you will see the following:

lrwxr-xr-x 1 xxxx xxxx xx xxx xx xx:xx Home -> /System/.../Home

This is a symbolic link, NOT to be confused with Aliases, and creating one is actually much easier than I thought.

First, to create an Alias, you just right click on a folder, and select Make Alias. This creates a 'shortcut file', not a symbolic link. Case in point, try typing the ls command on the folder shortcut you just made, Terminal will complain that the alias is NOT A DIRECTORY.

To create the symbolic link, you'd type the following:

ln -s /actual/dir/location/ linkname

Now you can ls on the linkname which will spit out the structure for /actual/dir/location/

VIM: How to type ^M character in GVIM

Kept seeing posts that say the character is typed by using C-V C-M, but obviously C-V = paste.

Instead, in GVIM, the key stroke is: C-Q, C-M

(C-Q = control+Q)