JavaScript: Convert String to Integer (int)

To convert strings (text) to integer (number) in JavaScript use the parseInt function.

For example:

document.write(parseInt("23 years"));

Will return the number 23, the function ignores the string “years” and return the integer 23 only.

Another common example is:





 

If you enter 4 and 5, the script will return “45”  instead of 9.  To fix use the parseInt function as follows:






 

 

PHP: Check If Two Strings Are Similar

In php, to check the similarity between to strings (text) use the similar_text for example:

Here’s a PHP function that’ll help you check if two strings (texts) are similar. If the strings are 50% similar then the function will output “Duplicate Entries”.

 0) {
	if (count($result)>(count($array1)/2)){
		echo "Duplicate Entries";
	};

};
}

issimilar ( "Hello World Foo Bar Baz", "Hello Foo Bar Baz");

?>

Free Online Website Performance Testings Tools

Here is a list of 10 of my favorite website / web page performance testing tools. The tools test things such as load time, load speed and web server stress, many of them provide helpful tips on how to increases website performance.

GTmetrix | Website Speed and Performance Optimization
http://gtmetrix.com/

 

Broswer Mob Website Performance Test
https://browsermob.com/free-website-performance-test/

 

WebPageTest.org Web Page Performance Test
http://www.webpagetest.org/

 

Pingdom Tools – Test the load time of a web page
http://tools.pingdom.com/

 

Load Impact
http://loadimpact.com/

 

Gomez Web Site Performance Test
http://www.gomeznetworks.com/custom/instant_test.html

 

Web Page Analyzer – 0.98 – from Website Optimization
http://www.websiteoptimization.com/services/analyze/

 

Benchmark your website or test the speed of your web connection.
http://webwait.com/

 

Gomez Instant Test Center
http://www.gomez.com/resources/instant-test-center/

 

Webserver Stress Tool – 30 Day Free Trial Software
http://www.paessler.com/webstress

 


 

Disable Auto Zoom in Internet Explorer or Safari Using HTML

To disable page auto zoom (auto scale)  in Internet Explorer, Safari or any other browsers, place the following META tag in the head section of your page:

<meta name="viewport" content="width=device-width, user-scalable=no" />



Mr. Speaker: Debating Business Issues in Less than 200 Words

The third of three debates that I wrote for a business class a few years ago. The purpose of the assignment was to debate a business issue in less 200 words. I hope some Business Administration students will find this helpful.

Debate 3: Should the House Bail Out Big Businesses

Mr. Speaker, we are here today to debate the resolution that the House should bail out big business. As side government, we support this resolution and believe strongly that it must stand.

When the failure of a major corporation would reverberate through not only its own sectors but across several sectors, causing wide-spread unemployment, the government should intervene, buying shares in the company and monitoring its operations. Moreover, as a condition of its investment in a troubled corporation, the government should conduct a thorough investigation and audit to ascertain whether the company’s financial shortfalls result from criminal fraud or negligence, prosecuting managers and executives as evidence against them warrants.

“We used to say, ‘As GM goes, so goes the nation,’” North American GM President Mark Reuss quoted the old adage as he spoke with reporters in January. In General Motors, we see a compelling example of a government bail-out’s benefit. Within eighteen months of the government’s investment in GM, the company streamlined its operations, sold-off its unsuccessful ventures, won wage and benefit concessions from the unions, and returned both to profitability and market leadership. Emerging from bankruptcy and bailout as an industry leader, the “new” General Motors repaid its debt to American taxpayers with substantial interest. Timely government intervention in a large corporation’s troubled finances has exactly the remedial effects workers and shareholders want.

Side government, Mr. Speaker, would like to thank the House for its time and, for the reasons stated, reiterate that we believe strongly this resolution must stand.

Thank you, Mr. Speaker.

References:

Calello, P. & Wilson, E. (2010). From bailout to bail-in. Economist, 394(8667).
Retrieved from http://search.ebscohost.com/login.aspx?direct=true&db=bth&AN=47815765&login.asp&site=bsi-live

Morley, R. (2011, January 24). The Subprime Nation. The Trumpet.
Retrieved from http://www.thetrumpet.com/?q=7246.5799.0.0

Ruggles, D. (2010). How, Why We Saved Detroit?. Ward’s Dealer Business, 44(7). Retrieved from
http://search.ebscohost.com/login.aspx?direct=true&db=bth&AN=52593968&login.asp&site=bsi-live.

Regular Expressions: Remove Links Hashes & Mentions from Tweet

Use this regular expresion to remove URLs (http://…) hashes (#ahash) and mentions (@amention) from Tweets or any other block of text for that matter.

For PHP code use:

/(@|#|http\:\/\/)([a-zA-z0-9\.\/])+/

 

For JavaScript:

^(@|#|http\:\/\/)([a-zA-z0-9\.\/])+$