Crop center and resize paperclip image attachment
has_attached_file :profile_image,
storage: :s3,
s3_credentials: {
bucket: Settings.s3_bucket_name,
access_key_id: Settings.aws_access_key_id,
secret_access_key: Settings.aws_secret_access_key
},
default_url: '/assets/default_profile_pic.png',
styles: { square_50: '', square_100: '', square_193: '' },
convert_options: {
square_50: '-gravity center -resize 50x50^ -crop 50x50+0+0',
square_100: '-gravity center -resize 100x100^ -crop 100x100+0+0',
square_193: '-gravity center -resize 193x193^ -crop 193x193+0+0'
}
Date Time Format In RUBY
Format meaning:
%a – The abbreviated weekday name (“Sun”)
%A – The full weekday name (“Sunday”)
%b – The abbreviated month name (“Jan”)
%B – The full month name (“January”)
%c – The preferred local date and time representation
%d – Day of the month (01..31)
%H – Hour of the day, 24-hour clock (00..23)
%I – Hour of the day, 12-hour clock (01..12)
%j – Day of the year (001..366)
%m – Month of the year (01..12)
%M – Minute of the hour (00..59)
%p – Meridian indicator (“AM” or “PM”)
%S – Second of the minute (00..60)
%U – Week number of the current year,
starting with the first Sunday as the first
day of the first week (00..53)
%W – Week number of the current year,
starting with the first Monday as the first
day of the first week (00..53)
%w – Day of the week (Sunday is 0, 0..6)
%x – Preferred representation for the date alone, no time
%X – Preferred representation for the time alone, no date
%y – Year without a century (00..99)
%Y – Year with century
%Z – Time zone name
%% – Literal “%” character
t = Time.now
t.strftime(“Printed on %m/%d/%Y”) #=> “Printed on 27/11/2012”
t.strftime(“at %I:%M%p”) #=> “at 11:06AM”
Disable Firewall CentOS / RHEL / RedHat
First login as the root user.
Next enter the following three commands to disable firewall.
# service iptables save
# service iptables stop
# chkconfig iptables off
If you are using IPv6 firewall, enter:
# service ip6tables save
# service ip6tables stop
# chkconfig ip6tables off
Selenium Webdriver with Ruby Unit Example of Google Search
Copy the code and save as google_search.rb and run “ruby google_search.rb”
require “selenium-webdriver”require “test/unit”class GoogleSearch < Test::Unit::TestCasedef setup@driver = Selenium::WebDriver.for :firefox@base_url = “http://www.google.com/”@driver.manage.timeouts.implicit_wait = 30@verification_errors = []enddef teardown@driver.quitassert_equal [], @verification_errorsenddef test_google_search@driver.get(@base_url)@driver.find_element(:name, “q”).clear@driver.find_element(:name, “q”).send_keys “Thiyagarajan Veluchamy”@driver.find_element(:name, “btnK”).clickenddef element_present?(how, what)@driver.find_element(how, what)truerescue Selenium::WebDriver::Error::NoSuchElementErrorfalseenddef verify(&blk)yieldrescue Test::Unit::AssertionFailedError => ex@verification_errors << exendend
sendmail settings in rails 3 application
Open “application.rb” file in “config” folder of your application and add the following data to it.
*************************************************************
config.action_mailer.delivery_method = :sendmail
config.action_mailer.sendmail_settings = {
:location => ‘/usr/sbin/sendmail’,
:arguments => ‘-i -t’
}
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
*************************************************************
Taskbar missing in ubuntu
- Press Alt+F2, in text fild type ‘gnome-terminal’ (without quots) and click on ‘Run’.
- In terminal submit the commands below one by one. Select one line at a time and press ‘Enter’.
gconftool –recursive-unset /apps/panel
rm -rf ~/.gconf/apps/panel
pkill gnome-panel
Preload site before displaying
We can easiest can do this,
<html> <head> <script language="javascript" type="text/javascript"> function showpage() { document.getElementById('loader').style.display = "none"; document.getElementById('main').style.display = "block"; } </script> </head> <body onload="showpage();"> <div style="height:100%; width:100%; display:block;" id="loader"> Some preloading content here </div> <div style="height:100%; width:100%; display:none;" id="main"> Main Content Here </div> </body> </html>
assert vs verify in selenium
Assert –
When test case fail immediately test get aborted.
Verify –
Will generate failure log after complete the test execution.
Assert Commands –
- assertAlert(pattern)
Verify Commands –
- verifyAlert(pattern)
Web apps Functional Testing Checklist
1.1 LINKS
1.1.1 Check that the link takes you to the page it said it would.
1.1.2 Ensure to have no orphan pages (a page that has no links to it)
1.1.3 Check all of your links to other websites
1.1.4 Are all referenced web sites or email addresses hyperlinked?
1.1.5 If we have removed some of the pages from our own site, set up a custom 404 page that redirects your visitors to your home page (or a search page) when the user try to access a page that no longer exists.
1.1.6 Check all mailto links and whether it reaches properly
1.2 FORMS
1.2.1 Acceptance of invalid input
1.2.2 Optional versus mandatory fields
1.2.3 Input longer than field allows
1.2.4 Radio buttons
1.2.5 Default values on page load/reload(Also terms and conditions should be disabled)
1.2.6 Is Command Button can be used for HyperLinks and Continue Links ?
1.2.6 Is all the datas inside combo/list box are arranged in chronolgical order?
1.2.7 Are all of the parts of a table or form present? Correctly laid out? Can you confirm that selected texts are in the “right place?
1.2.8 Does a scrollbar appear if required?
1.3 DATA VERIFICATION AND VALIDATION
1.3.1 Is the Privacy Policy clearly defined and available for user access?
1.3.2 At no point of time the system should behave awkwardly when an invalid data is fed
1.3.3 Check to see what happens if a user deletes cookies while in site
1.3.4 Check to see what happens if a user deletes cookies after visiting a site
2. APPLICATION SPECIFIC FUNCTIONAL REQUIREMENTS
2.1 DATA INTEGRATION
2.1.1 Check the maximum field lengths to ensure that there are no truncated characters?
2.1.2 If numeric fields accept negative values can these be stored correctly on the database and does it make sense for the field to accept negative numbers?
2.1.3 If a particular set of data is saved to the database check that each value gets saved fully to the database. (i.e.) Beware of truncation (of strings) and rounding of numeric values.
2.2 DATE FIELD CHECKS
2.2.1 Assure that leap years are validated correctly & do not cause errors/miscalculations.
2.2.2 Assure that Feb. 28, 29, 30 are validated correctly & do not cause errors/ miscalculations.
2.2.3 Is copyright for all the sites includes Yahoo co-branded sites are updated
2.3 NUMERIC FIELDS
2.3.1 Assure that lowest and highest values are handled correctly.
2.3.2 Assure that numeric fields with a blank in position 1 are processed or reported as an error.
2.3.3 Assure that fields with a blank in the last position are processed or reported as an error an error.
2.3.4 Assure that both + and – values are correctly processed.
2.3.5 Assure that division by zero does not occur.
2.3.6 Include value zero in all calculations.
2.3.7 Assure that upper and lower values in ranges are handled correctly. (Using BVA)
2.4 ALPHANUMERIC FIELD CHECKS
2.4.1 Use blank and non-blank data.
2.4.2 Include lowest and highest values.
2.4.3 Include invalid characters & symbols.
2.4.4 Include valid characters.
2.4.5 Include data items with first position blank.
2.4.6 Include data items with last position blank.
Selenium ( web application testing system )
The selenium is one off the most popular free web based automation tool. The following steps will help to install(firefox),
1. go to “http://seleniumhq.org/download/”
2. download “Selenium IDE”
3. execute the downloaded file
4. click install now
Now ready after restart the FireFox browser.
First Name, Last Name Validation
It should be
– first and last character must be alphabet
– accepts single character input
– it wont allow any special character and white space at start and end
Priority Testing
Generally Priority is Business for the projects. And this will be set by the team lead or the project lead, based on the severity and the time constraint that the module has the priority will be set.
- Must fix the bug as soon as possible. Because bug is blocking further progress in this area.
- Should fix the all issues, before release the product or project.
- fix the issues within time period.
Available Browsers for Linux, Windows, Mac for Testing
A Web browser is a software application, user to display and interact with text, images, music, videos, games & etc typically located on a Web page at a Web site on the World Wide Web or a local area network. A web browser is importing for web application testing … The great number of browsers in the internet,
Web browsers listing for Windows
How To Access Blocked Web Sites
i given blow more proxy sites:
- http://www.hidemyass.com
- http://www.anonymizer.com
- http://www.wujie.net
- http://www.ultrareach.net
- http://surfshield.net
- http://www.guardster.com/subscription/proxy_free.php
- http://anonymouse.ws/anonwww.html
- http://www.browser-x.com
- http://www.spysurfing.com
- http://www.xerohour.org/hideme
- http://www.proxyz.be
- http://www.sc0rian.com/prox
- https://www.proxify.us
- http://kproxy.com/index.jsp
- http://www.brawl-hall.com/pages/proxy.php
- http://www.proxify.net
- http://proxy.computersteroids.com/index0.php
- http://www.unipeak.com
- http://flyproxy.com
- http://alienproxy.com
- http://proxify.com/
- http://www.unfilter.net
- http://www.proxymouse.com
- http://www.surfonym.com/cgi-bin/nph-proxy
- http://www.superproxy.be/browse.pl
- http://www.websiteguru.com/mrnewguy
- http://www.letsproxy.com
- http://www.fsurf.com
- http://indianproxy.com
- http://www.letmeby.com
- http://Boredatschool.net
- http://www.ibypass.org
- http://www.ipzap.com/
- https://proxify.biz
- http://kproxy.com/index.jsp
- http://www.attackcensorship.com/attack-censorship.html
- http://mrnewguy.com
- http://www.evilsprouts.co.uk/defilter
- http://www.proxify.info
- http://www.torify.com
- http://www.switchproxy.com
- http://www.proxifree.com
- http://www.secure-tunnel.com/
- http://www.proxify.cn
- http://www.arnit.net/utilities/webproxy/new
- http://www.proxify.co.uk
- http://www.betaproxy.com
- http://www.proxify.org
- http://www.proxychoice.com
- http://www.proxysnail.com
- http://www.anonypost.com
- http://www.thestrongestlinks.com
- http://www.hujiko.com
- http://www.anonproxy.info
- http://www.peoplesproxy.com
- http://www.freeproxy.us
- http://www.proxyweb.net
- http://www.nopath.com
- http://urlencoded.com
- http://www.pole.ws
- http://www.browseany.com
- http://www.spiderproxy.com
- http://www.clickcop.com
- http://www.sneakysurf.com
- http://www.mywebtunnel.com
- http://www.thewebtunnel.com
- http://www.3proxy.com
- http://www.yourfreeproxy.com
- http://www.proxy7.com
- http://www.fireprox.com
- http://www.stupidcensorship.com
- http://www.letsproxy.com
- http://www.sneak2.com
- http://www.cecid.com
- http://www.freeproxy.ca
- http://www.ibypass.org
- http://www.goproxing.com
- http://www.projectbypass.com/
- http://www.ipsecret.com
- http://www.nomorelimits.net
- http://www.proxify.de
- http://www.bywhat.com
- http://www.snoopblocker.com
- http://www.anonymizer.ru
- http://www.proxyking.net/
- http://www.perlproxy.com
- http://www.proxylord.com
- http://tntproxy.com
- http://satanproxy.com
- http://zombieinvasion.info
- http://demonproxy.com
- http://www.myfreeproxy.com
- http://www.gezcem.com/nph-proxy.pl.old
- http://mpleger.de
- http://www.the-cloak.com/login.html
Top 25 common programming bugs
Insecure Interaction between Components
- Improper Input Validation
- Improper Encoding or Escaping of Output
- Failure to Preserve SQL Query Structure (‘SQL Injection’)
- Failure to Preserve Web Page Structure (‘Cross-site Scripting’)
- Failure to Preserve OS Command Structure (‘OS Command Injection’)
- Clear text Transmission of Sensitive Information
- Cross-Site Request Forgery (CSRF) 8. Race Condition
- Error Message Information Leak
Risky Resource Management
- Failure to Constrain Operations within the Bounds of a Memory Buffer
- External Control of Critical State Data
- External Control of File Name or Path
- Un trusted Search Path
- Failure to Control Generation of Code (‘Code Injection’)
- Download of Code Without Integrity Check
- Improper Resource Shutdown or Release
- Improper Initialization
- Incorrect Calculation
Porous Defenses
- Improper Access Control (Authorization)
- Use of a Broken or Risky Cryptographic Algorithm
- Hard-Coded Password
- Insecure Permission Assignment for Critical Resource
- Use of Insufficiently Random Values
- Execution with Unnecessary Privileges
- Client-Side Enforcement of Server-Side Security