Deploying To Heroku using Git as a newbie

After preparing a simple node.js app, I deployed it to Heroku. by going through the following terminal commands (also see heroku guide)

git add .
git commit -msg "first commit"
heroku create stack --cedar
git push heroku master
heroku ps:scale web=1
heroku ps
heroku logs

Once deployed the app errored. So I rebulit and redeployed. When you do this several times in a short space of time it’s worth remembering the following…

Heroku locks on to a deployment environment using your git config. What I mean by this is when you do git commit and then git push heroku master, git is told about the url it is pushing to.

So when you do

git remote -v

This tells you what environments git has remote repositories stored at. I was mistakenly creating new cedar stacks and trying to deploy to them after destroying previous “erroring” stacks and kept getting a similar error to this: ! No such app as fierce-fog-63. What I should have done is kept the existing heroku stack (fierce-fog-63) and deployed to that instead.

So to remove the link between git and the remote repository and create a new link to a stack you have just created, you execute the following:

git remote rm heroku
git remote add heroku

where is the heroku url you are deploying to.

More info on this at


Sencha Touch 2 theming using Ruby gem Compass and Ubuntu 11.10

I am currently working on a Sencha application and now wish to do some styling /theming… To begin with I watched nelstrom’s tutorial. I then began my attempt at the same, placing a styles folder at root, adding config.rb and a default-theme.scss file. Theming involves getting your hands dirty with Ruby Gems again, as compass is a Ruby Gem.

So to compile with compass I required the compass ruby gem. I installed this by executing the following in a terminal window:

$ sudo gem install compass

This gave the following output:

Fetching: sass-3.1.18.gem (100%)
Fetching: chunky_png-1.2.5.gem (100%)
Fetching: fssm-0.2.9.gem (100%)
Fetching: compass-0.12.1.gem (100%)
Successfully installed sass-3.1.18
Successfully installed chunky_png-1.2.5
Successfully installed fssm-0.2.9
Successfully installed compass-0.12.1

To confirm you have the gem installed execute the following

$ gem list

This gives a list of gems installed, and compass is included.

*** LOCAL GEMS ***

chunky_png (1.2.5)
compass (0.12.1)
foreman (0.26.1)
fssm (0.2.9)
sass (3.1.18)
term-ansicolor (1.0.7)
thor (0.14.6)

That’s it… hopefully.

With compass installed I could then compile my default-theme.scss file by using the command $ compass compile, whilst in the styles directory. This produces the default-theme.css file, which you must place a reference to in your index.html file:

<link rel="stylesheet" href="default-theme.css" type="text/css">

The styling I wanted to achieve was fairly simple. I wanted the main colour for toolbars, etc. to be black and the secondary colour a shade of orange. I also wanted to reduce some of the text size for certain classes.I managed to do all this with the following .scss file:

$base-gradient: 'glossy';

@import ‘sencha-touch/default/all’;

// You may remove any of the following modules that you
// do not use in order to create a smaller css file.
@include sencha-panel;
@include sencha-buttons;
@include sencha-sheet;
//@include sencha-picker;
//@include sencha-tabs;
@include sencha-toolbar;
//@include sencha-toolbar-forms;
//@include sencha-indexbar;
@include sencha-list;
@include sencha-layout;
//@include sencha-carousel;
//@include sencha-form;
//@include sencha-msgbox;

.question {font-weight:bold;font-size:0.75em;};
.answer {font-size:0.75em;};

so black toolbars, etc. can be achieved with $base-color:#000;, secondary color as orange;$active-color:#FF8700; buttons with a glossy feel instead of the default matte; $base-gradient: ‘glossy’;. for shrinking down text size I’ve yet to find how to do this globally but using custom classes works by putting css direct into the .scss file, (styling for .question and .answer). You may have noticed, I am reducing the .css file by excluding many of the default @includes for the .scss file.

The only other issue was styling a button (xtype:button). I could not see how to apply styling globally to buttons, so used the style property for the button in the javascript:

items: [{
xtype: 'button',
text: 'Show me where this is',
align: 'right',
style: 'background: #FF8700',

This is messy as I’m not including all the styling in the css but will do for now.

Analyzing SQL Server Log Files

At work we have had issues with a SQL Server 2000 log file increasing its size and causing an error when trying to interact with the database:

[Microsoft][ODBC SQLServer Driver][SQL Server] The log file for database ‘db’ if full. Backup the transaction log for the database to free up some log space.

We had not had this error before so we ran some scripts to help work out what was going on.

The first thing we did was run DBCC SQLPERF(LOGSPACE). This gives you basic physical file size information. The example below puts the results into a table to query further.

CREATE TABLE #LogFileMonitor

[DatabaseName] varchar(100)
,[LogSize(MB)] real
,[LogSpaceUsed(%)] real
,[Status] int

INSERT INTO #LogFileMonitor

SELECT * FROM #LogFileMonitor ORDER BY [LogSpaceUsed(%)] DESC

DROP TABLE #LogFileMonitor

Running this confirmed the log file in question was up to 100% capacity. To shrink the log file, you need to execute these commands:

Use db
BACKUP LOG db with truncate_only

Once the log file was shrunk down, we explored the issues of why the log file was growing to the extent that it was causing a problem, as up until this point everything was ok. The only recent change to the database was a trigger, so I have dropped this. I will then use DBCC SQLPERF(LOGSPACE) to monitor the database as I execute SQL from the trigger to see what is causing the issue.

Some more useful commands:


use db

FROM dbo.sysfiles
WHERE name = 'db_Log'

-- CHECK RECOVERY MODEL FOR Database- simple, full, bulk logged

select databasepropertyex('db','Recovery')

Using DMO in SQL Server

At work we need to script out all the objects in a database on a regular basis. I wanted to do this automatically and have found DMO to be the solution.

The website linked to above comes with a useful scipt to do exactly what I wanted, which I have listed below in its entirety.

The author of the post recommends using DMO for anything that you find you are scripting on a regular basis. Its definitely proved useful for this job so will be looking to use it for other db admin stuff in the future.


/****** Object: Stored Procedure dbo.spScriptObjects Script Date: 23/11/2006 17:25:13 ******/

/****** Object: Stored Procedure dbo.spScriptObject Script Date: 07/11/2006 17:46:05 ******/
ALTER procedure spScriptObjects
/*scripts out one or more of the databases on the specified server in a number of ways
using the DMO to do so */
@SourceServer varchar(128) = 'MyServer' ,
@DatabaseWildcard varchar(128) = 'MyDatabase',
@SourceUID varchar(128) = null,
@SourcePWD varchar(128) = null,
@WorkDir varchar(500) = 'C:\temp',
@Workfile varchar(500) = null,
@ScriptFileMode int = 8--1 2 4 or 8 see below for the key
If you are using windows authentication then use DEFAULT instead of
the @SourceUID and @SourcePWD. If calling by parameter, then just
leave them out!

--write out the PUBS database to one file organised by object type
--and named MyServer_PUBS.SQL
spScriptObjects 'MyServer', 'PUBS', 'sa', 'secret', 'C:\database'

--write out the PUBS database to one file organised by object type
--and named MyNiceFilename.txt
spScriptObjects 'MyServer', 'PUBS', 'sa', 'secret', 'C:\database',

--write out all the databases on the server 'MYSERVER, each one in
a single file, organised by object type
spScriptObjects 'MyServer', '%', 'sa', 'secret', 'C:\database'

--write out all the databases on the server 'MYSERVER that begin with
the letter M, each one in a single file, organised by object type
spScriptObjects 'MyServer', 'M%', 'sa', 'secret', 'C:\database'

--write out the PUBS database to several files in a PUBS subdirectory
spScriptObjects 'BABBAGE', 'PUBS', 'sa','secret', 'C:\database','',4

--write out all database to several files in their own subdirectories
spScriptObjects 'BABBAGE', '%', 'sa', 'secret', 'C:\database','',4

--write out the PUBS database to several files in a PUBS subdirectory
--one file for tables, amother for triggers and so on
spScriptObjects 'BABBAGE', 'PUBS', 'sa','thumper', 'E:\database','',1

@ScriptFileMode is as follows:
1 Command batch is written to multiple files, one file for each kind of
object transferred. For example, generate a file for user-defined data
types and a separate file for tables. Specify a path using the ScriptFile
2 Command batch is written to one file. Specify the file name using the
ScriptFile argument.
4 Command batch is written to multiple files, one file for each
SQL Server component transferred. Specify a path using the ScriptFile
8 Command batch is written to one file. Command batch contents are organized
by object type. Specify the file name using the ScriptFile argument.

@hr int ,
@strErrorMessage Varchar(255) ,
@objErrorObject int ,
@objServer int ,
@objTransfer int ,
@strFilename varchar(255) ,
@strResult varchar(255) ,
@strCommand varchar(255) ,
@objDatabases int,
@objSpecificDB int,
@ii int,
@iiMax int,
@Command varchar(255),
@SourceDB varchar(255)

Set nocount on

create table #junk (line ntext)

SELECT @strErrorMessage = 'instantiating the DMO',@objErrorObject=@objTransfer
exec @hr= sp_OACreate 'SQLDMO.SQLServer', @objServer OUT

if @SourcePWD is null or @SourceUID is null
--use a trusted connection
if @hr=0 Select @strErrorMessage='Setting login to windows authentication on '+@SourceServer, @objErrorObject=@objServer
if @hr=0 exec @hr = sp_OASetProperty @objServer, 'LoginSecure', 1
if @hr=0 Select @strErrorMessage='logging in to the requested server using windows authentication on '+@SourceServer
if @SourceUID is null and @hr=0 exec @hr = sp_OAMethod @objServer, 'Connect', NULL, @SourceServer
if @SourceUID is not null and @hr=0 exec @hr = sp_OAMethod @objServer, 'Connect', NULL, @SourceServer ,@SourceUID
if @hr=0 SELECT @strErrorMessage = 'Connecting to '''+@SourceServer+
''' with user ID '''+@SourceUID+'''', @objErrorObject=@objServer
if @hr=0 exec @hr = sp_OAMethod @objServer, 'Connect', NULL, @SourceServer ,
@SourceUID , @SourcePWD
if @hr=0 Select @strErrorMessage='finding the number of databases in '+@SourceServer,
if @HR=0 EXEC @hr = sp_OAGetProperty @objServer, 'databases.Count',
@iimax OUT
Select @ii=1
while @hr=0 and @ii<=@iiMax
Select @strErrorMessage='Getting each item'
select @command='databases.item('+cast (@ii as varchar)+').name'
EXEC @hr = sp_OAGetProperty @objServer, @command,
@SourceDB OUT
if (@hr=0 and @SourceDB like @DatabaseWildcard)
begin /* then we script it out */
select @command='databases.item('+cast (@ii as varchar)+')'
EXEC @hr = sp_OAGetProperty @objServer, @command,
@objSpecificDB OUT
-- Create transfer object
if @hr=0 SELECT @strErrorMessage = 'Creating a DMO transfer object'
if @hr=0 exec sp_OACreate 'SQLDMO.Transfer', @objTransfer OUT -- Create Object

if @hr=0 SELECT @strErrorMessage =
'Selecting a property of the transfer',
if @hr=0 EXEC @hr= sp_OASetProperty @objTransfer, 'CopySchema',1
if @hr=0 EXEC @hr= sp_OASetProperty @objTransfer, 'CopyAllObjects',1
if @hr=0 EXEC @hr= sp_OASetProperty @objTransfer, 'CopyData',0

/*If a path is not included in the file name, the
file is created in the directory indicated by the client computer
environment variable TEMP. */
if @ScriptfileMode in (2,8)
Select @WorkDIR=rtrim(@WorkDIR)
select @strFilename=@WorkDIR+
case when right(@WorkDIR,1)'\' then '\' else '' end+
select @strFilename=@WorkDIR+
case when right(@WorkDIR,1)'\' then '\' else '' end+
select @command='MD '+@strFilename
execute master..xp_cmdshell @command
if @hr=0 SELECT @strErrorMessage =
'Assigning the transfer object to '+@SourceDB+' to script out to '+
if @hr=0
insert into #Junk(line)
EXEC @hr= sp_OAMethod @objSpecificDB,'ScriptTransfer',

EXEC sp_OADestroy @objTransfer --create it anew every time
Select @ii=@ii+1

if @hr0
@Source varchar(255),
@Description Varchar(255),
@Helpfile Varchar(255),
@HelpID int

EXECUTE sp_OAGetErrorInfo @objErrorObject,
@source output,@Description output,@Helpfile output,@HelpID output

Select @strErrorMessage='Error whilst '+@strErrorMessage+', '+@Description
raiserror (@strErrorMessage,16,1)
EXEC sp_OADestroy @objSpecificDB
EXEC sp_OADestroy @objDatabases
EXEC sp_OADestroy @objServer
return @hr