Code Prostitute

the sordid details of my career as a code prostitute

Samsung Blu-ray player network woes and solution!

leave a comment »

So, we got this Samsung Blu-ray player that also does Netflix, Blockbuster, Pandora, etc. But of course, it needs a network connection.

If you don’t have a LAN cable to plug in (we didn’t), then you have to buy Samsung’s ~$80 wireless network adaptor. Reportedly, it was originally on sale for $35, and is the same hardware I believe, but, they probably discovered they could charge more. I understand their position on this. There are lots of network adaptors out there, they want one that already has the drivers on it because the player and TV don’t act like a computer and can download / install drivers. However, they could have allowed you to connect a computer to it to download the needed drivers, but whatever. Their product, their choice.

Anyway, we looked quite a bit for a USB adaptor and ways to resolve this without having to shell out $80 on top of the not-so-cheap player already. I even considered dropping a LAN cable in the wall.

Anyway, you want to hear about the solution. As it turns out we have AT&T Uverse and their Motorola digital “STB” (set top box). I was curious, if the LAN port on the back of the STB is not being used to feed it connection and using a coax cable instead, would the LAN port (RJ-45) share its connection?

I grabbed a short Cat 5 cable and tried it. I went to the Menu > Setup > Network screen on the player and changed it from “Wireless” to “Cable.” The next thing I saw was, “There’s a firmware update would you like to download it?” Heck yes I would. I tried it, and it started downloading! My wife and I high-fived and will soon be watching movies from Netflix streaming.

Cheers!

Written by codeprostitute

February 27, 2010 at 9:49 pm

Posted in Uncategorized

YourTable.reset_column_information

leave a comment »

Rails Migration: Make Database Changes Take Place Before Inserting / Updating Records

Let’s say you have a table to create, and start using it right away, in the same script. If you try to use it right away, it will error out as the table doesn’t exist yet.

class CreateJobLevels type)
end
end

def self.down
drop_table :job_levels
end
end

You need to use: reset_column_information

class CreateJobLevels < ActiveRecord::Migration
def self.up
create_table :job_levels do |t|
t.integer :id
t.string :name

t.timestamps
end

JobLevel.reset_column_information
%w{assistant executive manager director}.each do |type|
JobLevel.create(:name => type)
end
end

def self.down
drop_table :job_levels
end
end

Written by codeprostitute

November 17, 2009 at 2:58 pm

Posted in Uncategorized

undefined method `set_cookie’ 2.3.3

leave a comment »

If you’re using “Tamper-proof cookies” like I am following this tutorial,
and recently moved to rails 2.3.3, you may be getting this error:

NoMethodError (undefined method `set_cookie’ for #):

It actually isn’t so much to do with Tamper-proof cookies, as it is that set_cookie has been deprecated in favor or http_only=.

So, if you’re having this issue, open lib/tamper_proof_cookie_jar.rb and search for “set_cookie” (should be line 38).

replace with this:

http_only=options

Or, anywhere you were using set_cookie, use http_only= instead.

Restart your app server (apache, mod_rails, mongrel…) and it should work for you now.

Written by codeprostitute

October 14, 2009 at 12:39 pm

Posted in Rails, Ruby

Tagged with , , ,

Snow Leopard Install, Ruby on Rails MySQL dev machine

leave a comment »

Here are some helpful notes if you’re upgrading to Snow Leopard (SL), and you do Ruby on Rails / MySQL development.

From a dev perspective, there are a number of things that changed with the update to Leopard.

On the Snow Leopard DVD, under “Optional Installs”, install “Xcode.mpkg”. Use all default options.

If you were using MacPorts,it will need to be updated.
Install the latest for SL (1.8.0): http://www.macports.org/install.php
Then, follow this guide to update MacPorts – I suggest doing the manual method to make sure you don’t install stuff you don’t really need. I installed coreutils, and it installed pretty much everything else I needed. If you’re running MySQL through MacPorts, don’t add it back. You’ll be guided by the Ruby on Rails guide to install the 64-bit version next.
The user will probably want wget… installing that gets you openssl, zlib.
http://trac.macports.org/wiki/Migration

Ruby on Rails__
This is an excellent guide, do follow this:
http://weblog.rubyonrails.org/2009/8/30/upgrading-to-snow-leopard Before you read this post and give up, look up your errors in the comments. I had 2 or 3 issues and what do you know? Others had the same issues, I followed a few of the comments where people address others’ issues and viola… working nicely now. Another tip for MySQL: When you install MySQL from mysql.org, be sure to pick the right one.. I kept getting the PowerPC one because it was at the end and had a “64″ on it… I realized I needed the other one.

This should get you through most of the changes for Ruby on Rails, and a good start on developer machines in general.

Post any questions you have.

Cheers,
Richard

Written by codeprostitute

September 26, 2009 at 12:19 am

64-bit OS X Snow Leopard defaults to 32-bit kernel

leave a comment »

Why?
It defaults to the 32-bit kernel on bootup because not all software you may have may be compiled / designed for 64-bit. Moving from 32 to 64 is a gradual process. 64-bit applications can still take advantage of being 64-bit and using multiple cores, but the kernel itself is still 32-bit by default. Only Snow Leopard Xserve boots into 64-bit kernel by default.

How do you change this?
If you have a machine capable of 64-bit processing, and you’re bold enough to go 64 only, hold down 6 and 4 on boot up. It will make the machine boot up in 64-bit kernel mode – but be ready for 32-bit applications to break.

Here’s how you find out if you’re machine is capable of 64-bit processing:
http://support.apple.com/kb/HT3696

Written by codeprostitute

September 11, 2009 at 11:15 am

Posted in Uncategorized

Tagged with , , , , ,

Snow Leopard upgrade, Exchange 2007, PlugSuit, VPN

with 2 comments

The main reason for me to upgrade is to start using Mail and iCal and leave the daily torture of using Entourage.

Mail and iCal work great. I had a little tweaking to do to make it check Exchange mail through our external URL (webmail). Just had to use the full UPN (UserPrincipalName) for the username, AD password, and the external URL for both internal and external servers.

The PlugSuit is incompatible (particularly with Quicktime I think). Here is how you disable it (you might have to enable and then disable it for the disabling to take).

When trying to start VPN, I got the horrible CiscoVPN Error 51 I complained and solved here.

But this time, I couldn’t fix it. It seems the CiscoVPN folder I referenced was removed. After some investigation, I found that Apple has included VPN capabilities into the OS. You just go to your System Preferences, Network, and hit the + to add a new network interface, select VPN. Then select whatever VPN parameters you need to – check with your pleasant and always helpful IT Admin for the params.

Cheers,
R

Written by codeprostitute

September 10, 2009 at 4:53 pm

“Bad CPU type in executable” MySQL upgrade for 64-bit following Snow Leopard install

leave a comment »

Recently, like many others, I upgraded to Snow Leopard on my MBP. I do lots of development on my machine (Ruby on Rails, MySQL, Java, .NET over VMWare + Vista Ultimate, etc.).

I’ll post my thoughts on the whole experience, but in this post, I want to highlight an issue I ran across.

I was previously running 32-bit MySQL 5.0 installed over Mac Ports. After I ran through this great post on upgrading to SL, I found I started getting this error in my RoR log:

Bad CPU type in executable…

As it turns out, I actually had installed “Mac OS X 10.5 (PowerPC, 64-bit)” from MySQL, instead of what I should have installed: Mac OS X 10.5 (x86_64).

The solution:
Just download the right one and install it. I have a 64-bit capable, Intel Core 2 Duo processor, so this was the right one for me. Here’s how you find out what you have.

Good luck!

Written by codeprostitute

September 10, 2009 at 4:35 pm

Posted in Uncategorized

Tagged with , , , ,

Ruby / Rails: Remove Extra Space

leave a comment »

…or anything else you want from a string.


" myemail @ address. co m ".gsub(/\s/, '')

gsub() substitutes all instances found (g = global), if you just want to substitute the first instance use sub()

Or, if you want to trim the whitespace from each end:


result = " myemail@address.com ".strip

To just trim the whitespace on the left or the right, use these (respectively):
lstrip()
rstrip()

Written by codeprostitute

May 1, 2009 at 12:16 pm

MySQL: Reset ID Auto-Increment

leave a comment »

ALTER TABLE tablename AUTO_INCREMENT = 1

Auto-increment is the thing that makes the primary key (integer) increment by 1 each time a record is inserted. Say you have 10 records (1..10). If you delete 9 and 10, the next ID is going to be 11, not 9. However, if you run the SQL command above, you can reset it to the last record ID, plus 1 – making the next record in this example, 9.

If you happen to want to do this in a migration file, just use “execute.”

def self.up
execute 'ALTER TABLE tablename AUTO_INCREMENT = 1'
# then go on to populate the right way
Skill.create(:id => 1, :name => 'Ajax')
...
end

def self.down
Skill.find(:all).each { |s| s.destroy }
end

Written by codeprostitute

February 13, 2009 at 4:10 pm

Mirroring script for SQL Server / Sharepoint

leave a comment »

http://spadmin.spaces.live.com/blog/cns!F030C52B8E5517C3!352.entry

I was working in one of my SharePoint test labs this weekend, and decided to write a script that would recycle, stop or start all of the SharePoint Key services. Copy the text and save it as ManageServices.bat

Enjoy

@ECHO OFF
:CHOICE
CLS
ECHO.
ECHO **********************************************************************
ECHO.
ECHO ** Recycle, Stop, Start SharePoint Key Services
ECHO.
ECHO ** Created April 23 2008
ECHO ** Gene Magerr
ECHO ** genemagerr@hotmail.com
ECHO ** Version 1.0 – April 23 2008
ECHO ** 1.1 -
ECHO ** 1.2 -
ECHO **
ECHO **
ECHO ** You have a royalty-free right to use, modify, reproduce, and
ECHO ** distribute this script file in any way you find useful, provided that
ECHO ** you agree that the creator, owner above has no warranty, obligations,
ECHO ** or liability for such use.
ECHO.
ECHO ** This batch file will Recycle, Stop or Start all of the key
ECHO ** SharePoint 2007 services. It will also do an IISRESET /NOFORCE
ECHO ** after each of the tasks.
ECHO.
ECHO **********************************************************************
ECHO.
ECHO Please choose a menu option.
ECHO.
ECHO Recycle all services …………………. 1
ECHO Stop all services ……………………. 2
ECHO Start all services …………………… 3
ECHO Quit (without affecting services) ……… 4
ECHO.
CHOICE /C:1234 /N /T:180 /D:4
ECHO.

IF ERRORLEVEL == 4 GOTO END
IF ERRORLEVEL == 3 GOTO START
IF ERRORLEVEL == 2 GOTO STOP
IF ERRORLEVEL == 1 GOTO RECYCLE

:RECYCLE
ECHO Stopping and restarting key services
ECHO.
net stop oSearch
net stop SPAdmin
net stop SPTimerv3
net stop SPTrace
net start oSearch
net start SPAdmin
net start SPTimerv3
net start SPTrace
PING 1.1.1.1 -n 1 -w 2000 >NUL
ECHO Recycling IIS
ECHO.
IISRESET /NOFORCE
PAUSE
GOTO CHOICE

:STOP
ECHO Stopping key services
ECHO.
net stop oSearch
net stop SPAdmin
net stop SPTimerv3
net stop SPTrace
PING 1.1.1.1 -n 1 -w 2000 >NUL
ECHO Stopping IIS
ECHO.
IISRESET /STOP
PAUSE
GOTO CHOICE

:START
ECHO Starting key services
net start oSearch
net start SPAdmin
net start SPTimerv3
net start SPTrace
PING 1.1.1.1 -n 1 -w 2000 >NUL
ECHO Starting IIS
ECHO.
IISRESET /START
PAUSE
GOTO CHOICE

:END

Written by codeprostitute

January 23, 2009 at 10:31 am