Creating RSS feed for Rails website

Today, I worked on creating an RSS feed for news posts of amanzitel.com website. The procedure is simple:

Step 1:

Create a new method in a controller (like pages controller) called rss as follows:

def rss

@posts = NewsPost.find(:all, :limit => 10, :order => "updated_at DESC")

respond_to do |format|

format.rss { render :layout => false }

end

end

Step 2:

Create file called rss.rss.builder in the view folder as follows:

xml.instruct! :xml, :version=>"1.0"

xml.rss(:version=>"2.0"){

xml.channel{

xml.title("AmanziTel News")

xml.link("http://www.amanzitel.com/")

xml.description("Latest news from AmanziTel")

xml.language(‘en-us’)

for post in @posts

xml.item do

xml.title(post.title)

xml.description(post.short_news)

xml.author("AmanziTel.com")

xml.pubDate(post.publish_date.strftime("%Y-%m-%d"))

xml.link("/news_posts/#{post.id}")

xml.guid(post)

end

end

}

}

Step 3:

In the template head section of application.html.erb in layouts folder add the below code to allow browser to discover the RSS.

<%= auto_discovery_link_tag(:rss, :controller => "pages", :action => ‘rss’) %>

Now, the RSS url is /pages/rss

Create a Group Policy object to change power scheme settings

To create a Group Policy object to change the power scheme settings, follow these steps:

  1. On the domain controller, copy the Powercfg.exe file to the NETLOGON share.
    • By default, the Powercfg.exe file is located in the %systemroot%\System32 folder on a Windows 2003-based computer.
    • By default, the NETLOGON shared folder is located at%systemroot%\Sysvol\Sysvol\Domain_DNS_name\Scripts on a Windows Server 2003-based computer.
  2. Click Start, click Run, type dsa.msc, and then click OK. This starts the Active Directory Users and Computers snap-in.
  3. In the Active Directory Users and Computers dialog box, right-click the domain container, and then click Properties.
  4. On the Group Policy tab, click New.
  5. Type Power Configuration Policy, and then press ENTER.
  6. Click Edit.
  7. Under User Configuration, expand Windows Settings, and then click Scripts.
  8. In the right pane, double-click Logon, and then click Show Files. The user’s \Scripts\Logon folder appears.
  9. In the user’s Scripts\Logon folder, create a new batch file that sets the power scheme settings on the user’s computer. To do this, follow these steps:
    1. Click File, click New, and then click Text Document.
    2. Type PowerConfig.bat, and then press ENTER.
    3. In the Rename dialog box, click Yes.
    4. Right-click PowerConfig.bat, and then click Edit.
    5. If an Open File – Security Warning dialog box appears, click Run.
    6. Type the following commands in the batch file:
       @echo off net use x: \\domain_DNS_name\netlogon x: powercfg.exe /change "always on" /monitor-timeout-ac 20 powercfg.exe /SETACTIVE "always on" c: net use x: /delete 

      Note The domain_DNS_name term that is used in the batch file is a placeholder for the DNS name of the domain controller.

    7. Click File, click Exit, and then click Yes.
  10. Close the Scripts\Logon folder.
  11. In the Logon Properties dialog box, click Add, click Browse, double-click PowerConfig.bat, and then click OK two times.
  12. Under Computer Configuration, expand Windows Settings, expand Security Settings, and then expand Local Policies.
  13. Click User Rights Assignment, and then double-click Shut down the system.
  14. In the Shut down the system Properties dialog box, click Add User or Group, type the user’s domain name and account name in the User and group names box, and then click OK two times.
  15. Under Computer Configuration, expand Windows Settings, expand Security Settings, and then clickRegistry.
  16. In the Group Policy Object Editor dialog box, click Action, and then click Add Key.
  17. In the Selected key box, type the following entry, and then click OK:

    MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Controls Folder\PowerCfg

  18. Click Add, type the user’s account name in the Enter the object names to select box, and then clickOK two times.
  19. In the Add Object dialog box, click Configure this key then, click Propagate inheritable permissions to all subkeys, and then click OK.
  20. In the Group Policy Object Editor, click Action, and then click Add Key.
  21. In the Selected key box, type the following entry, and then click OK:
    USERS\.DEFAULT\Control Panel\PowerCfg
  22. Click Add, type the user’s account name into the Enter the object names to select box, and then clickOK two times.
  23. In the Add Object dialog box, click Configure this key then, click Propagate inheritable permissions to all subkeys, and then click OK.
  24. In the Group Policy Object Editor dialog box, click File, and then click Exit.
  25. In the domain container Properties dialog box, click OK.
  26. In the Active Directory Users and Computers dialog box, click File, and then click Exit.

* power-scheme must be set to “Portable/Laptop”
* plugged in monitor turn off – Never
* on battery monitor turn off – 15 min
* plugged in system standby – Never
* on battery system standby – 25 min
* plugged in hard disks turn off – Never

* on battery hard disks turn off – 45 min

To create script open notepad and type:

REM Set power-scheme to Portable/Laptop
powercfg /setactive “portable/laptop”
REM Set plugged in monitor timeout to Never
powercfg /change “portable/laptop” /monitor-timeout-ac 0

REM Set on battery monitor timeout to 15 minutes
powercfg /change “portable/laptop” /monitor-timeout-dc 15
REM Set plugged in system standby to Never
powercfg /change “portable/laptop” /standby-timeout-ac 0

REM Set on battery system standby to 25 minutes
powercfg /change “portable/laptop” /standby-timeout-dc 25
REM Set plugged in hard disks timeout to Never
powercfg /change “portable/laptop” /disk-timeout-ac 0

REM Set on battery hard disks timeout to 45 minutes
powercfg /change “portable/laptop” /disk-timeout-dc 45

Blue Screen at start of installation Windows Server 2003 on HP Pro 3010

You need to load the SATA ACHI drivers for the machine at the F6 prompt that comes up at the beginning of the Windows XP installation.

Below are the drivers. You probably don’t have floppy drives on the PC’s so just put these drivers on a USB flash drive and point the installation program to them when prompted to do so.

http://h20000.www2.hp.com/bizsupport/TechSupport/SoftwareIndex.jsp?lang=en&cc=nl&prodNameId=4047666&prodTypeId=12454&prodSeriesId=4047665&swLang=13&taskId=135&swEnvOID=1093#113100

The other alternative you have is to go into your BIOS and change the setting of your disk controller in the Computer Setup-Main menu from ACHI to IDE. Then you can load XP without installing the ACHI drivers beforehand.

See Chapter 3, page 15 of the maintenance guide below for where to find the BIOS settings:

http://bizsupport1.austin.hp.com/bc/docs/support/SupportManual/c01920721/c01920721.pdf

Once XP is installed you can then load the above drivers manually by following the instructions beginning on page 12 of this document. It is for notebooks but there would be no difference in the procedure for desktops.

http://bizsupport1.austin.hp.com/bc/docs/support/SupportManual/c01600726/c01600726.pdf

Ignore the reference to the setup folder because I gave you the drivers above. Just download them and put them in a folder you name and browse to that folder to install the drivers.

Before installing the ACHI drivers you will need to install the chipset driver first. You would want to do that anyway before installing any other drivers regardless.

http://h20000.www2.hp.com/bizsupport/TechSupport/SoftwareDescription.jsp?lang=en&cc=us&prodTypeId=12…

After you get the ACHI drivers loaded you can go back into your BIOS and select the ACHI option again for better disk performance.

Convert DTS sound tracks of Movies to AC3 format

When trying to watch some movies on LG LED TV, then a situation may happen that there is no Audio produced by the TV. The most probably reason for this, is that the movie is having sound with format called DTS (Digital Theater System). This format is not a free format and it should be licensed, and hence most TVs are not supporting this format. (Some rumors indicated it may be contained in new TVs due to a sort of agreement between LG and DTS producers).

However, to resolve the issue, the sound inside the movie is simply converted to another supported format, like AC3. To do this, here is the procedure:

Load tool from http://www.videohelp.com/tools/PopCorn-MKV-AudioConverter

the follownig utilities should be available, and pointed to by the above tool:

C:Program FilesMKVtoolnixmkvinfo.exe
C:Program FilesMKVtoolnixmkvextract.exe
C:Program FilesMKVtoolnixmkvmerge.exe

also, media info utility at: C:Program FilesMediaInfoMediaInfo.DLL

If the above utilities not existing, the AudioConveter allows you to download them.

Then specify the source movie, and the target location, and press RUN

Then, have fun 🙂

Annoying issue when replying emails from GMail on Galaxy Ace Android (with Solution)

Here is the situation:

I want to reply an email through Gmail android application on Galaxy Ace with Android 2.3. then clicking Reply button.

it usually takes about a second to respond and display the reply page.

During this second, the user may think that he missed the reply button and decides to re-press it again.

At the same moment, the application responds and displays the reply page, while the user is attempting to press reply button.

the surprise is, In the reply page, the SEND button is at the same place of reply button. At the same time, that user is thinking he is pressing REPLY button, but actually, he pressed SEND 😦

So, the user finds the message is sent !!! without writing the reply message 😦

I faced this problem multiple times when trying to respond to emails through Gmail android application

the solution is:

There is a check-box in the application settings under Confirm Actions, check Send check-box. By checking this box, the message will not be sent unless you pass the confirmation dialog that appears when press Send button. This gives the user an opportunity not to directly send the message (even by error).

Grid using CSS

CSS

<style type="text/css">
/* GRID */
.column { float: left; }
.grid2col, .grid2cola, .grid2colb, .grid2colc, .grid2cold, .grid2cole, .grid2colf, .grid3col, .grid3cola, .grid4col, .grid5col, .grid6col { width: 100%; }

.grid2col .column { width: 49%; }
.grid2col .grid2col .column { width: 47.8%; }
.grid3col .grid2col .column { width: 46%; }
.grid4col .grid2col .column { width: 45%; }

.grid2cola .column.first { width: 66%; }
.grid2cola .column.last { width: 32%; }

.grid2colb .column.first { width: 74.9%; }
.grid2colb .column.last { width: 23%; }

.grid2colc .column.first { width: 32%; }
.grid2colc .column.last { width: 66%; }

.grid2cold .column.first { width: 23%; }
.grid2cold .column.last { width: 74.9%; }

.grid2cole .column.first { width: 79%; }
.grid2cole .column.last { width: 19%; }

.grid2colf .column.first { width: 19%; }
.grid2colf .column.last { width: 79%; }

.grid3col .column { width: 32%; margin-left: 2%; }
.grid2col .grid3col .column { width: 31%; }

.grid3cola .column { width: 58%; margin-left: 2%; }
.grid3cola .column.first,
.grid3cola .column.last { width: 19%; }

.grid4col .column { width: 23%; margin-left: 3%; }

.grid5col .column { width: 18.4%; margin-left: 2%; }

.grid6col .column { width: 15%; margin-left: 2%; }

.column.first, .column.last { margin-left: 0 !important; }
.column.last { float: right !important; }

p.last, ul.last, ol.last, li.last { _width: auto !important; _float: none !important; }

#container:after, #content:after, .grid2col:after, .grid2cola:after, .grid2colb:after, .grid2colc:after, .grid2cold:after, .grid2cole:after, .grid2colf:after, .grid3col:after, .grid3cola:after, .grid4col:after, .grid5col:after, .grid6col:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
#container, #content, .grid2col, .grid2cola, .grid2colb, .grid2colc, .grid2cold, .grid2cole, .grid2colf, .grid3col, .grid3cola, .grid4col, .grid5col, .grid6col { zoom: 1; }
</style>

Usage

<div>
<div>
</div>

<div>
</div>

</div>

Nice look button – FrontPageBox

Button Code

Save the below code to _button.html.erb

<div>
<a href="<%= url %>" style="text-decoration:none;">
    <div>            
        <div style="width: 50px;">
            <img src="/images/<%= icon %>" alt=""/>
        </div>
        <div>
            <h2 style="font-size:18px;width:100px;margin-bottom:0px;"><%= lng title %></h2>
            <p style="margin-top:0px;">
                <%= lng description %>
            </p>
        </div>
    </div>
</a>
</div>

CSS

.frontpagebox {
    background-image: url(/images/bg-offer.png);
    height: 100px;
    width: 250px!important;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    margin-bottom: 10px;
}

.frontpagebox:hover {
    background-image: url(/images/bg-offer-n.png);
    height: 100px;
    width: 250px;
    border: 1px solid #bfbfbf;
    border-radius: 10px;
}

.frontpagebox p {
    width: 120px;
}

.frontpagebox img {
    width: 100px;
    height: 100px;
    padding-left: 5px;
}

.frontpagebox h2 {
    line-height: 20px;
    position: relative;
    left: 80px;
    top: 10px;
    text-decoration: none;
    color: #333;
    font-size: 18px;
}

.frontpagebox p {
    position: relative;
    left: 80px;
    top: 20px;
    font-size: 11px !important;
    text-decoration: none !important;
    color: #333;
}

Usage

<%= render :partial => 'pages/partials/button', :locals => 
                {    :title => category.name, 
                    :description => category.description,
                    :url => "/categories/#{category.to_param}",
                    :icon => "#{fileNameOnly}"} %>