Sw33tCode

Smart code for developers

Sw33tCode header image 1

Git warning: you may want to set your diff.renamelimit variable

December 7th, 2013 · No Comments

If you get this error message:

warning: inexact rename detection was skipped due to too many files.
warning: you may want to set your diff.renamelimit variable to at least 918 and retry the command.

You need to set and unset that rename limit:

git config merge.renameLimit 999999
git config --unset merge.renameLimit

Hope this helps. I was trying to do a brew update on a mac and ran into this issue.

→ No CommentsTags: Git · Mac

Shutdown/Restart Windows 8 Remotely

December 2nd, 2013 · No Comments

If you are finding your way to Windows 8 like I am (either voluntarily or involuntarily) then you might run into this issue if you remote desktop into the machine:    How do I reboot or shutdown???

Well it turned out to be fairly easy.   While in the desktop session press ALT+F4.   Then you’ll be presented the following options:

  • Disconnect
  • Sign Out
  • Shutdown
  • Restart

That’s it!   Here’s a screenshot:

Windows 8 Remote Commands for Shutdown/Restart

Hope this helps!

→ No CommentsTags: Windows 8

adding a background image to UITableViewController in a navigation based app

November 14th, 2012 · No Comments

This proved to be an issue for me so I wanted to be a good egg and pass this quick and easy information on to others. If you are using a navigation based app and want to have a custom image for your UITableViewController you want to do something like this:

For iOS 5 and under:
self.navigationController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"myAwesomeImage.png"]];
self.tableView.backgroundColor = [UIColor clearColor];

In iOS 6 the above approach does not work and proved to be buggy. This is the preferred method that I found to work:

UIImageView *boxBackView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myAwesomeImage.png"]];
[self.tableView setBackgroundView:boxBackView];

Cheers.

→ No CommentsTags: iPhone · objective-c

March 4th, 2012 · No Comments

Over the next few weeks I’ll be posting things I learn on iPhone development that might be helpful to others out there. I’m semi-new to the mac world, so some of these things might seem trivial to you but are new to me :)

First up…

Application(s) Freezing up on you for example Xcode just stops working or the iPhone simulator. These are 4 ways you can use to kill that application.

1st Way:

  • Press CMD + Option + ESC
  • Select the application causing all the problems
  • Click “Force Quit”

2nd Way:

  • Hold down the ‘Option’ key
  • Locate the freezing application in the dock
  • Click and hold on the icon
  • The bottom option should say “Force Quit”, let go of the pointer on that option

3rd Way:

  • Open the Activity Monitor app (Applications > Utilities > Activity Monitor app)
  • Under the processes, locate the freezing application and click it
  • On the top left, click “Quit Process”
  • Then click “Force Quit”

4th Way: (my favorite way because i’m a console guy)

  • Open the Terminal app (Applications > Utilities > Terminal app)
  • Type “killall *Application*” where *Application* is the exact name of the freezing app (including capitalization) and without the quotation marks
  • It should close the application immediately

→ No CommentsTags: iPhone · Mac · OS X Lion

IntelliJ extremely slow to redraw screen when used over remote desktop

February 13th, 2012 · No Comments

This is probably not a common problem but I do a lot of development through remote desktop onto a Windows 7 virtual machine running on a ESXi 4 server. I noticed that IntelliJ 10 is VERY slow on redrawing the graphics when I navigate around the idea. I did some googling and searching through JetBrains development forum and found that others do have this issue as well. Take a look here:

http://devnet.jetbrains.net/thread/280673

To sum it up this is what you do:

To fix it go here: C:\Program Files (x86)\JetBrains\IntelliJ IDEA 10.5.1\bin\idea.properties and set this property to false:

sun.java2d.noddraw=false

So far so good for me. Hopefully this helps for you.

→ No CommentsTags: IntelliJ · java

Add all new files to subversion repository

June 20th, 2011 · No Comments

I was having issues with tortoise (windows product for svn GUI) the other day with it not adding all the files that I wanted to the repository. Then I realized that the command line is always god.

To add all files to svn repo from the command line:


svn add --force *

If anyone is curious why tortoise was giving me issues it was because of my global ignore patterns… I had the bin directory in there which prevented tortoise from checking it in.

→ No CommentsTags: Subversion

Setting up FreeNAS to use gmail for email service

April 1st, 2011 · 8 Comments

If you choose to use FreeNAS S.M.A.R.T service then you will want to make sure you have an email service to use for sending emails. I choose to use gmail for this service since it’s rocks. This explains what settings to use.

  1. Using the FreeNAS WebGUI go to System -> Advanced and select the Email tab.
  2. Fill in the following fields:
    1. From Email: youremail@gmail.com
    2. Outgoing Mail Server: smtp.gmail.com
    3. Port: 465
    4. Security: SSL
    5. Authentication: Check Enable SMTP Authentication
    6. Username: youremail@gmail.com
    7. Password: xxxxxxxx
    8. Authentication Method: Login

Once this is done send yourself a test email by clicking the button and you should have no issue getting an email….. however….

I did have an issue where it couldn’t find the server smtp.gmail.com which appeared to be a dns issue. To fix this I appended google’s dns server to my /etc/resolv.conf (which unfortunately this files gets overridden after every reboot, but it didn’t matter since this command kicked it in the butt to get it working).

If you go into System -> Advanced menu, there is option to set commands to be executed after every reboot. I just added new postinit command:

echo "nameserver 8.8.8.8" >> /etc/resolv.conf

Please let me know if you have any questions. Thanks!

→ 8 CommentsTags: freenas

Installing Ruby on Rails with Lovdbyless on a Windows machine

April 13th, 2008 · 14 Comments

I know a lot of people who use ruby are either doing their development on linux machines or macs, but for those people who are brave….. here is a guide for you setting up LovdByLess with Ruby on Rails on Windows machine. The machine I used is Windows XP.

LovdByLess is built with Ruby on Rails and is a social networking solution that has everything you need to build your community.
The folowing installation of Ruby and Ruby on Rails was created with guidance from the RubyOnRails.org documentation which can be found here.

Install Ruby compiler
For Windows I used the One-Click Installer – Windows found here: rubyforge.org(Which for me at the time of this post was version ruby186-26)

I like to be able to run ruby from where ever I am in the command prompt so in order to do that just add this line (if not there already) to your Path variable in the System Variables:
c:\ruby\bin;

Setup RubyGems and Rails on Ruby
Download from here rubyforge.org the latest release of Ruby gems. I used the zip version 1.1.0 for this installation. Extract the zip file to where ever you want. Open a console (cmd.exe) window and proceed to where you extracted the rubygems 1.1.0. Run this command:
c:\[rubygems 1.1.0 Path]\ ruby setup.rb

Now we want to setup Rails. Just type this in the command prompt:
gem install rails --include-dependencies

Download and extract the zip file from LOVDbyLESS.

We have to install the following gems using the RubyGems program we just installed. From the command prompt, run the following:
c:\gem install youtube-g
c:\gem install rflickr
c:\gem install uuidtools
c:\gem install colored
c:\gem install hpricot
c:\gem install mocha
c:\gem install redgreen
c:\gem install RedCloth
c:\gem install acts_as_ferret
c:\gem install ferret
c:\gem install win32console
c:\gem install avatar
c:\gem install tzinfo
c:\gem install rails

****If you get asked during these gem installations to Install hoe, rubyforge, Rake, mime-types, xml-simple, etc just type Yes for these.****

Get rmagick gem here, download and extract. Execute:
ImageMagick-6.3.7-8-Q8-windows-dll.exe
In the console change directory to where you extracted the gem.
gem install rmagick-2.0.0-x86-mswin32
This will require a reboot of your machine at some point before you try to use this gem. (Trust me. this took me a long time to figure out!)

We need to create a mysql user account to run the LovdByLess database with. This assumes you have Mysql running on your machine. From the command prompt type and hit enter:
mysql --user=root mysql -p
Enter your password. Create mysql user:
GRANT ALL PRIVILEGES ON *.* TO 'lovdbyless'@'%'
IDENTIFIED BY 'my_password' WITH GRANT OPTION;

Then exit mysql:
quit mysql

Go to the directory where you extracted LovdByLess and open the config folder. Copy database.yml.tmp to database.yml. Edit this file and replace the values for username and password with the mysql user you created above.

From the command prompt, proceed to your LovdByLess directory, run the following:
rake db:create:all
rake db:migrate a=no
rake

The last command should run all ruby tests for the project. Now run this from your lovdbyless folder in the command console:
ruby script\server
The rails server is now up and running. Open up a web browser and go to this address:
http://localhost:3000/

Please let me know if you had any issues setting this up. Thanks!

→ 14 CommentsTags: Mysql · Ruby · Ruby On Rails

Building Mysql Database contents from batch script in Windows

April 5th, 2008 · 2 Comments

I needed a way to build my database quickly on a project I was working on and I was constantly making changes to the database that supplied content to my application. So I came up with an easy batch script that would help facilitate the changes in my database environment.

Here is a mocked version of the batch script that I wrote to build the database:

@echo off
 
REM: Command File Created To Create MySQL Experiments Database
REM: Date Generated: 4/5/2008
REM: Usage: CommandFilename [Host] [Username] [Password]if '%1' == '' goto usage
 
if '%2' == '' goto usage
if '%3' == '' goto usage
if '%1' == '/?' goto usage
if '%1' == '-?' goto usage
if '%1' == '?' goto usage
if '%1' == '/help' goto usage
 
echo experiments.build.database START
mysql -h %1 -u %2 -p%3 > "experiments.build.database.sql"
if %ERRORLEVEL% NEQ 0 goto errors
echo experiments.build.database END
 
echo experiments.build.tables START
mysql -h %1 -u %2 -p%3 "experiments" > "experiments.build.tables.sql"
if %ERRORLEVEL% NEQ 0 goto errors
echo experiments.build.tables END
 
echo building stored procedures START
mysql -h %1 -u %2 -p%3 "experiments" > "sprocs\uspAddUser.sql"
if %ERRORLEVEL% NEQ 0 goto errors
echo uspAddUser
echo building stored procedures END
 
echo experiments.insertdata.messenger START
mysql -h %1 -u %2 -p%3 "experiments" > "experiments.insertdata.sql"
if %ERRORLEVEL% NEQ 0 goto errors
echo experiments.insertdata.messenger END
 
echo Finished Building Database 
 
goto finish
REM: How to use screen
 
:usage
echo.
echo Usage:    MyScript Server Database
echo Host:     MySQL Server
echo Database: the name of the target database
echo Username: username to be used on target database
echo Password: password to be used on target database
echo.
echo Example: BuildDatabase.cmd "localhost" "root" "password"
echo.
echo.
goto done
 
REM: error handler
:errors
echo.
echo WARNING! Error(s) were detected!
echo --------------------------------
echo Please evaluate the situation and, if needed,
echo restart this command file. You may need to
echo supply command parameters when executing
echo this command file.
echo.
pause
goto done
 
REM: finished execution
:finish
echo.
echo Script execution is complete!
 
:done
@echo on

This script will call the sql files that contain the commands to build the database, tables, stored procedures, and even create some test data. To call this command file all you have to do is supply the host, username, and password parameters. Like this:

c:\BuildDatabase.cmd "localhost" "root" "password"

This script example will call your database: experiments. But if you wanted to dynamically name your database you can just add another parameter onto your batch script and replace all the mysql calls above with this code:

mysql -h %1 -u %2 -p%3 %4  > "sql_code.sql"

Then your call to the command file will be like this:

c:\BuildDatabase.cmd "localhost" "root" "password" "database_name"

If you wish to try out the code in action please download the zip file below. You will need MySql Version 5 or above to test this. Please let me know if you have any questions.

Sample Mysql Batch Script

→ 2 CommentsTags: Mysql · Windows Batch Script