Setting up SQL Server 2012

This tutorial should work for setting up a brand new SQL Server instance. In this case, I am using SQL Server 2012.
  • If you can't find SQL Server Management Studio, you may need to install it first.
    1. Download SQLManagementStudio_x64_EMU, run setup
    2. During the Feature Selection step, select Management Tools - Basic (or Complete)
    3. After the installation is complete the executable can be located at:
      • C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\ssms.exe
    4. NOTE: Make sure the database supports both Windows authentication and SQL Server Authentication
  • Creating credentials for remote SQL server access
    1. NOTE: If you have the sa user password, you can just use that account to connect remotely
    2. On the SQL Server, sign in as Administrator or sa (If you forgot your sa password, it can be reset)
    3. Once connected to the local DB Engine, go to Object Explorer > SERVERNAME > Security > Logins
    4. Right click on Logins > New Login ...
    5. Under General > enter Login name
    6. Under General > select SQL Server authentication, uncheck Enforce password policy
    7. Under Server Roles > check public, sysadmin
    8. Click OK to save
At this point, you should have properly set up the credentials for remote login. This next section discusses how to set up the server such that it can be accessed remotely. Keep in mind I don't go over my Windows Firewall setup, that'd be on you.
  • On the SQL server, open up Computer Management
  • Expand Services and Applications
  • Expand SQL Server Configuration Manager
  • Select SQL Server Network Configuration
    1. Select Protocols for SERVERNAME
    2. Right click TCP/IP > Enable
    3. Right click > Properties > IP Addresses tab
    4. Note the IP Address (ie. 192.168.1.35)
    5. Enter 1433 for TCP Port (Your firewall needs to open 1433)
    6. Click OK to save
  • Select SQL Server Services, you should see...
    1. SQL Server (SERVERNAME) Running
    2. SQL Server Agent (SERVERNAME) Stopped
    3. SQL Server Browser Running
  • Restart #1 and #3 services listed directly above
At this point you should be good to go. Just 1 last step inputting the correct hostname, username, etc.
  • Server type: Database Engine
  • Server name: 192.168.1.35\SERVERNAME
  • Authentication: SQL Server Authentication
  • Login: Username set up above, or sa
  • Password: Self-explanatory
Done.





Qt Unresolved external symbol QMetaObject error

This one was incredibly frustrating as a Qt noob...

Error   4   error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall Counter::metaObject(void)const " (?metaObject@Counter@@UBEPBUQMetaObject@@XZ) 
Error   5   error LNK2001: unresolved external symbol "public: virtual void * __thiscall Counter::qt_metacast(char const *)" (?qt_metacast@Counter@@UAEPAXPBD@Z)
Error   6   error LNK2001: unresolved external symbol "public: virtual int __thiscall Counter::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@Counter@@UAEHW4Call@QMetaObject@@HPAPAX@Z)  
Error   7   error LNK2019: unresolved external symbol "protected: void __thiscall Counter::valueChanged(int)" (?valueChanged@Counter@@IAEXH@Z) referenced in function "public: void __thiscall Counter::setValue(int)" (?setValue@Counter@@QAEXH@Z
This happens when you use the Q_OBJECT macro in your class extending QObject. Turns out in Qt you need to call run qmake first in order to invoke the moc compiler. So, the proper solution: 1. Run qmake 2. Build 3. Run

Install Scrapy via cygwin

Take the following with a grain of salt, because I'm not 100% sure all the dependencies, but the following should give you enough info to figure out anything which is missing.



1. Install cygwin64
2. Install cygwin packages: python, python3, libxml2-devel, libxslt-devel, libpcre-devel, libffi-devel, gcc-core
3. Install PIP
- wget https://bootstrap.pypa.io/get-pip.py
- python get-pip.py
4. Install scrapy
- CFLAGS="-I/cygdrive/c/Cygwin64/lib/libffi-3.0.13/include -I/cygdrive/c/Cygwin64/usr/include/libxml2 -I/cygdrive/c/Cygwin64/usr/include/libxslt" pip2.7 install scrapy



In the process I saw lots of:

- fatal error: libffi/ffi.h: No such file or directory
- fatal error: libxml/xmlversion.h: No such file or directory
- fatal error: libxslt/xsltconfig.h: No such file or directory
- error: command 'gcc' failed with exit status 1


Think these were all resolved by adding the CFLAGS includes.

Unknown table engine 'InnoDB'

Sometimes on initial mysql setup, you will find that you can log into the db, use db. But when you select * from table, you get the following error message:
Table 'db.tablename' doesn't exist

This is most likely because the data you are importing was intended for a non-transactional configured database.

To reconfigure the database as a non-transactional one: execute C:/.../MySQL Server X.Y/bin/MySQLInstanceConfig.exe

After this is done, you still need to alter the my.ini configuration file to tell mysql to use the innodb engine. If not you will likely see this error message:
Unknown table engine 'InnoDB'

To which the solution is to make sure you have the following line in your my.ini file:
default-storage-engine=INNODB

PHP with CGI crash with extensions

When enabling PHP extensions, IIS is crashing even for a simple phpinfo() call, that is, as I uncomment extension=php_mssql.dll I immediately get:

HTTP Error 500.0 - Internal Server Error

The FastCGI process exited unexpectedly


Turns out, the issue is that the default php.ini has extension_dir = "./", the fix is to change this to:

extension_dir = "./ext"

Dont forget to restart IIS (Stop & start the server not just the Site).

Setting up host urls in IIS

The following was done in IIS7.

When you add a new website:
Site name: WhateverYouWant
Application pool: Pick the appropriate .NET pool
Physical path: Path to root (can be anywhere on you HDD)
Type: http
IP address: 127.0.0.1
Port: 80
Host name: whatever-you-want.com

Edit C:\windows\system32\drivers\etc\hosts

Add the following line:
127.0.0.1    whatever-you-want.com

Flush DNS in command prompt:
ipconfig /flushdns

Load the page in browser:
http://whatever-you-want.com

Backing up SQL Server (the hard way)

Here's 1 way to back up SQL Server database without access to the physical hardware.

1. Start Menu > Sql Server 2008 R2 > Import and Export Data (64-bit)
2. Data Source (source sql server & credentials)
3. Data Target (local sql server & credentials)
4. Select tables to export

Note, this only exports tables & their respective data.

If all you want is to copy the schema...

1. Right click on the database you want to export
2. Tasks > Generate Scripts...
3. Select ALL
4. Save to clipboard
5. Copy & paste clipboard contents to local database query window
6. Execute query

Note, if there are any custom data types, you'll probably have to create those manually

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)

REGEX: Cleaning up sourcecode

remove comment lines
[\s\t]+//.+

remove multi-comment
\/\*([\s\S]*?)\*\/

remove empty lines
^\s*[\r\n]+

XP: Registry hack for JAD files

couple things I like to add to the context menu when I right click the jadfile:

1. open with wtk
2. open with vim

here's how to accomplish these things with a simple regedit hack:

STEP 1: Set up the open with...

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jad\OpenWithList]
"a"="gvim.exe"
"MRUList"="ab"
"b"="emulator.exe"

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jad\OpenWithProgids]
"jadfile"=hex(0):

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jad\UserChoice]
"Progid"="jadfile"

STEP 2: Set up the jadfile attribute

[HKEY_CLASSES_ROOT\jadfile\shell\vim]
@=">> vim"

[HKEY_CLASSES_ROOT\jadfile\shell\vim\command]
@="\"c:\\program files (x86)\\Vim\\vim73\\gvim.exe\" \"%1\""

[HKEY_CLASSES_ROOT\jadfile\shell\wtk]
@=">> wtk"

[HKEY_CLASSES_ROOT\jadfile\shell\wtk\command]
@="c:\\WTK2.5.2_01\\bin\\emulator.exe -Xheapsize:5M -Xdescriptor:\"%1\""

ANDROID: Factory Flash DroidX

Motorola Droid X SBF
http://www.multiupload.com/NYV7593UM3
http://www.multiupload.com/HS3Q4U95CG
http://rootzwiki.com/

Instructions (Linux)
1. Unzip the SBF and place VRZ_MB810_1.13.6.2_1FF_01.sbf and sbf_flash in the downloads folder
2. Put the Droid X in bootloader and connect it via usb.
3. Open a terminal window.
4.Change your directory: CD Downloads
5. Then type: ./sbf_flash VRZ_MB810_1.13.6.2_1FF_01.sbf
6. Wait and finish!