Monday, November 23, 2009

SQL SERVER – Shrinking Truncate Log File – Log Full

I always forget how to do this.  Here’s how it is done:

SQL SERVER – Shrinking Truncate Log File – Log Full « Journey to SQL Authority with Pinal Dave

Wednesday, October 14, 2009

GridView with ModalPopupExtender - Do not enclose in UpdatePanel

I will write this up later on. It took me a while to figure this out. Apparently there's a collision between UpdatePanel and ModalPopupExtender, they don't play nice together. I'll stub this for a moment and I will explain later.

Tuesday, October 13, 2009

CSS Code Snippet Green Dark Background

I like this CSS code snippet. I got it from here. Looks like a very good idea for distraction free writing.

body { font: 16px "Courier New"; color: #00ff00 !important; background: #000 !important; width: 800px; margin: 10px auto; }

Tuesday, September 29, 2009

How to Upgrade to the Latest Padre

Very simple!

perl -MCPAN -e "CPAN->upgrade('/^Padre/')"

Thursday, September 24, 2009

Insurance 411

http://www.insurance-411.org/

Fill this out, I will later. I think this is very important. From the website...

Welcome to Insurance 411, a Web tool which allows users to keep personal insurance information at their fingertips in the event of an emergency. By entering important policy and emergency contact information users can print out a credit card-sized information sheet to keep in their wallet.

Thursday, August 06, 2009

How to Install Aranight Color Theme (Style) for Padre

If you liked the Padre color theme from my previous posting. You can install it now by following this procedure. As a side note, in Padre lingo, code color theme is called a "Style". Aranight is still a work in progress and as you know Padre is also a work in progress, so there's a lot of changes that are happening, so be patient and check back for updates. I will be updating Aranight style here as I go. Enjoy!

  1. Locate the local Padre config folder by clicking Help > About. Create a styles folder in that location. Here's how the folder looks like in Win32: C:\Documents and Settings\username\Local Settings\Application Data\Perl\Padre\styles\
  2. Download Aranight style from here. Copy to the styles folder created earlier.
  3. Download Monaco font from here. Install.
  4. Restart Padre.
  5. In Padre, click View > Style, select Aranight.
  6. In Padre, click Edit > Preferences > Appearance. Now select the Monaco font. Change the "Editor Current Line Background Color" to R7, G65, B16. Click Save.

Here are some screenshots:
Padre IDE:

Perl file:

YAML file:

CSS file:

Tuesday, August 04, 2009

I discovered Padre, a new Perl IDE

This is really cool. Padre that is. I installed it alongside Strawberry Perl in my Win32 box. It is multi-platform, so I installed it in my Ubuntu box as well. It supports syntax highlighting for Perl 5 and Perl 6. There are plugins available now for Perl 6 as well as Catalyst, more to come. I think there's a lot of potential for Padre. The cool thing also about this IDE is it's built using no other than Perl language itself. So if you want to contribute or tweak it, you can.

Btw, I tried to customize the highlighting theme by creating a new style and here's what I came up with. You can get instructions from here.


Tuesday, June 30, 2009

ASP.NET Utility to create SQL Server Database for Membership and Roles Management

Ok, ok. I always forget so to save me some time, here it is...

Open up command line from Visual Studio, then run... cmd>aspnet_regsql.exe

Then execute the following...

-- Register Application
EXEC dbo.aspnet_Applications_CreateApplication 'AppName', NULL

-- Check if Application was registered
SELECT * FROM dbo.aspnet_Applications

-- Create a Role
EXEC dbo.aspnet_Roles_CreateRole 'AppName', 'Administrator'

-- Check if Role was created
SELECT * from dbo.aspnet_Roles

-- Add myself as Admin
DECLARE @Date AS DATETIME
SET @Date = (SELECT GETDATE())
EXEC aspnet_UsersInRoles_AddUsersToRoles 'AppName', 'DOMAIN\username', 'Administrator', @Date

-- Check if I got added as Admin
EXEC dbo.aspnet_UsersInRoles_GetUsersInRoles 'AppName', 'Administrator'

Sunday, June 28, 2009

Google App Engine Notes

Development console is here:
http://localhost:8080/_ah/admin/

Wednesday, June 24, 2009

Google App Engine Steps in Adding New Functionality

I sure want to take note. Just so that I don't forget. I got this from this book entitled Using Google App Engine.

In order to add a new functionality to our application, take the following steps:

  1. Decide on the URL that you want to use for the new feature.
  2. Write a new handler—the handler can initially be simple and just handle a GET request that renders a new template.
  3. Add a routing entry in main() to send the URL to a new handler.
  4. Add new templates as needed.
  5. Update the _base.htm to add any new navigation that is needed.
  6. Build the rest of the handler code and test your new functionality.

Thursday, June 04, 2009

CSS Blues

Ok, ok, I'm no designer so I don't know much about CSS. Whenever I needed to work on CSS, I google. Well I think working on CSS is both easy and difficult. Easy because it's mainly just formatting, difficult because it's frustrating at times especially when working on something that works in one browser but not on the other. Or something that works in one version but not on the other version.

Well, I just want to take note of what my CSS code looks like that works on 3 browsers, IE8, IE6 and Firefox3.

I commented the codes I added to make it work in IE6. I'm explaining this later on when I have time.

#container

{

    width: 100%;

    margin-top: 2em;

}

 

#content

{

    margin-right: 295px;

    overflow: hidden; /* IE6 cure */

    height: 100%; /* IE6 cure */

}

 

#nav

{

    float: right;

    width: 250px;

    padding: 1em;

    border: 1px silver solid;

}

 

table

{

    margin-left: 1px; /* IE6 cure */

    width: 99.9%; /* IE6 cure */

    border-collapse: collapse;

    border: 1px solid #7bb1db;

}

Monday, March 30, 2009

How to schedule a job that runs an SSIS Package in SQL Server

Again I just want to document how I did it. It's hard to remember sometimes the steps taken to make things work. Specially for things that are not done everyday. In this particular case, it is confusing which user accounts or login to specify to be used by the server agent. Anyway, here's a recipe on how to make this work, just follow along...

1. Create a credential.
2. Create a proxy under SSIS Package Execution using the above credential.
3. Create a job in SQL Server Agent, and this is the important part, specify "sa" as the owner of this job.
4. Now add a Step, select SQL Server Integration Services Package type. Again this is the crucial step: Go to the Run as dropdown, then select the proxy specified above.

Now test your package and let me know if it works for you.

How to import SSIS package protected by password to Integration Services

Ok, so that I can remember how to do this again. When importing SSIS package from development machine to server and the package protection level is "Encrypt sensitive data with password", this is for example, when you have a package that queries from an Oracle database, and you wanted to encrypt your credentials. I always forget to specify the package protection level. I don't know if it's because of me or the UI, the Protection level textbox is grayed out so one would normally assume that it's not needed. Then one would think that everything is ok until the package is executed, and you wonder why it errors out. So anyway, so I don't forget and to save me time in finding errors that traces back to not specifying passwords properly, I'm taking these notes on how to specify package protection level...

1. In Stored Packages, right click in MSDB then select Import Package...
2. For Package Location, select File System.
3. Specify Package path and Package name.
4. Then click the ellipsis button next to the Protection level textbox...

5. Now select "Encrypt sensitive data with password", then enter password...

Tuesday, March 24, 2009

The breakpoint will not currently be hit

This is so annoying. I'm using Visual Studio 2005, and for some reason I cannot set breakpoints to do my debugging. I tried several suggestions I can find from the net but still it doesn't work. Since I don't know the solution yet, but will expand this writeup once I figure out. But for me to debug on my ASP.NET Project right now, I added the following in my code. Important thing for me now is to debug my project.

System.Diagnostics.Debugger.Break(); // DEBUG

Wednesday, March 18, 2009

Constructor Dependency Injection Design Pattern

Note on Constructor Dependency Injection design pattern. This is how it is in C#.

private IContactManagerRepository _repository;

 

public ContactController()

    : this(new EntityContactManagerRepository())

{ }

 

public ContactController(IContactManagerRepository repository)

{

    _repository = repository;

}

Tuesday, March 17, 2009

Perl Design Patterns

Lookin' at Design Patterns for Perl. Here's the link.

Tuesday, March 03, 2009

Configuring Job Property Notifications for Sql Server 2005

I spent so much time figuring out how to configure Notifications in SQL Server 2005 job. One of the properties that can be enabled in a Job is "Notifications", when the job succeeds or fails or completes. I wanted to know when the Job I setup fails and so I set it to my E-mail as well as "When the job fails". But one thing about SQL Server Management Studio is that it doesn't tell you if you're lacking some more configurations. I wished it prompted me that I needed to do some other settings for it to work. Anyways, below I just wanted to outline what I did to make this work.

1. Setup Database Mail. Follow this.
2. Setup a Sql Server Agent Operator. Follow this.
3. Now Restart SQL Server Agent.

Thank you for those who wrote the posts I followed above.

Tuesday, February 10, 2009

Update table with data from another table in SQL Server

Ok, pretty much self explanatory

UPDATE table1 
    SET table1.col1 = table2.col1, 
        table1.col2 = table2.col2
FROM table1, table2
WHERE table2.col = table1.col

Or using alias:
UPDATE A1 
    SET A1.col1 = A2.col1, 
        A1.col2 = A2.col2
FROM table1 A1, table2 A2
WHERE A2.col = A1.col

Friday, February 06, 2009

Best Practices for Query Optimization

I'd like to take note of few tips from Pinal Dave. Certainly good reminders when creating queries.

Thursday, February 05, 2009

Configure Module::Starter::PBP in Windows XP

I decided to use Module::Starter::PBP when creating modules. But I got this error the first time:

C:\dev\perl\modules>module-starter --module=Dir::Walk
The Module::Starter::PBP template: t/C:./Documents isn't in the template directory (C:\Documents and Settings\user\.module-starter\PBP)
Some quirky stuffs in Windows when using this module. The initial configuration as outlined in cpan doesn't work. You need to tweak your config a little bit to accomodate this. It's not really the module's fault, but more on the way Windows handles directories, you know, spaces and backslashes, which is really a constant annoyance when you are programming perl in Windows. Anyway, here's what I did to make it work.

1. Move C:\Documents and Settings\user\.module-starter\PBP to another directory, in my case I moved it to C:\dev\perl\modules\templates\PBP.
(It's the spaces in 'Documents and Settings' that's causing the issue).

2. Modify C:\Documents and Settings\user\.module-starter\config as follows: (Note that I changed the backslashes to forwardslashes).

author: Sam Dela Cruz
email: myemail@address.com
builder: ExtUtils::MakeMaker Module::Build
plugins: Module::Starter::PBP
template_dir: C:/dev/perl/modules/templates/PBP

Tuesday, January 27, 2009

Plugin to Bookmark a Page in Your PDF files

Books in PDF formats are very popular nowadays. But annoying thing is that the Adobe Reader which is the standard PDF reader at work doesn't come with a bookmark functionality. I just need a simple bookmark like those good old paper bookmarks. Well I found one that does the job, a plugin from this post. Thank you very much.

Friday, January 23, 2009

How to make a quick copy of SQL Server database table

Here's how to create a quick copy of a database table including the data in SQL Server.

select * into [dbo].[TableName_Bak] from [dbo].[TableName]

Wednesday, January 07, 2009

My very first perl6 program

I know, I know, I promised to do some perl6 hacking over the holidays, but as it turned out, I didn't have the time to do it. Having 2 kids in the family and tons of activities lined up over the holidays didn't really gave me much room to doing other things like hacking with my computer. Anyways, another thing I did over the holidays was... tada I got a G1. And I really, really love it! Absolutely amazing piece of work. The downside is, it's going to hurt on our monthly utility bills. So my wife and I were thinking cutting down our cost. We are thinking of giving up our landline, since we both have wireless anyway. But of course wireless minutes aren't cheap either, so we gotta figure out who are actually calling us and who do we call from our landline.

Well, that can be done very easily. Since we are subscribed to comcast, incoming and outgoing phone calls are easily downloadable from their website. And so, this is a good opportunity for me to use the perfect tool for the job. Perl. But this time, I want to use Perl6. And here's what I came up with.

#!/usr/bin/perl6

my %number_of;

my $file = "CallRecords.txt";
if (my $fh = open $file, :r) {
    for =$fh -> $line {
        next if $line !~~ /Answered/ or $line ~~ /Private/;
        my ($name, $phone) = $line.split("\t")<2, 3>;
        %number_of{$name.uc} = $phone;
    }
else {
    say "Could not open $file";
}

for %number_of.sort.kv -> $name, $phone {
    say $name ~ ' ' ~ $phone;
}

Here's the output:

0 ABXXON ROLLY  (408) 386-XXXX
1 AGUXXAR R & J (408) 251-XXXX
2 AGUXXAR RONNIE        (408) 768-XXXX
3 ALMXXEN FAMILY        (408) 997-XXXX
4 XXER FRATERNAL        (408) 984-XXXX
5 AQXXNO GREG   (408) 297-XXXX
6 AQXXNO GREG R (408) 297-XXXX
7 ARGONCXXLO S  (408) 937-XXXX
8 ARGONCXXLO SUSA       (408) 937-XXXX
9 ASXXAS DAISY  (831) 240-XXXX
10 BALIXXIT VENTUR      (408) 251-XXXX
11 XXNK OF AMERICA      (866) 512-XXXX
12 BEXXER LIVING I      (408) 561-XXXX
13 BOUXXER      CO      (303) 786-XXXX
14 CALIFOXXIA EAR       (650) 494-XXXX
15 CAMXXHO GEMMA        (408) 849-XXXX
...

(I replaced some letters and numbers with X's in this post for security purposes.)

Oh my goodness! What an elegant piece of code that is. And it didn't take me a while to figure it out. I simply read tutorials from Gabor and Jonathan. I tell you, I can't believe the expressiveness of the latest and greatest perl. I have barely scratched the surface, it's got tons of other amazing stuffs! Try it for yourself.

Monday, January 05, 2009

Safari Login

My little secret Safari Login. Just for me to see if I can access Safari from my T-Mobile G1 with Google Phone, Black (T-Mobile).

Yey! It's working, now I can read books from my G1.

Sunday, January 04, 2009

Project setup using GitHub

Just taking notes on how to setup project in GitHub. These notes are from GitCasts and GitHub Guides.

1. Setup, Initialization and Cloning

Global setup, these apply to all projects on the system:

git config --global user.name 'User Name'
git config --global user.email username@gmail.com
git config --global color.status auto
git config --global color.branch auto
git config --global core.autocrlf true

To save project in git repository:
1. First, create the project.
2. cd to the project, then do the following:

git init
git add .
git ls-files --cache
git commit -m "Initial Commit"
git status
git log

To clone existing code in the git repo:

git clone git://github.com/sammydc/publictalkscheduler.git

If it's your own repo, use this instead:

git clone git@github.com:sammydc/publictalkscheduler.git 

2. Normal Workflow

Create .gitignore file, this is to specify which files we don't want to add to git, like as follows:

log/*.log
tmp/**/*

Editing files and commiting to repo:

git status
git add [filename]
git commit
OR:
git commit -a -m 'My Next Commit' #automatically add and commit all changed files
git ls-files --stage
git rm public/robots.txt #remove a file, git not to track the file anymore
git status
git commit -m 'robots file removed'

Now push to remote repo:

git remote add origin git@github.com:sammydc/publictalkscheduler.git
git push origin master

Take note that if you get the error message:

fatal: protocol error: expected sha/ref

You need to make sure that .git/config [remote "origin"] url entry is in the form of

git@github.com:sammydc/publictalkscheduler.git

When working on another machine, to get latest changes:

git pull