‘Code’ Category

 

How to Hide Android WebView Highlight Border (or change it’s color)

Here's one that had me at a loss for a long time that I just figured out. You can easily remove the highlight border (the border that comes up when an element is focused) or change it's color in a WebView with CSS! The WebKit-specific property "-webkit-tap-highlight-color" is what you're looking for.

The following line will disable it on a page completely:

1
2
3
* {
	-webkit-tap-highlight-color: rgba(0, 0, 0, 0);	
}

rgba() is just like rgb(), but it takes a 4th parameter for opacity. It's my belief that this would probably work for iPhone WebView's as well, since both Chrome and Safari are based off of WebKit.

Bookmark this page
[del.icio.us] [Digg] [Facebook] [Google] [Reddit] [Slashdot] [StumbleUpon]
 
 
 

PHP RSS Parser – RSS Reader Class for PHP

Just had to create a quick RSS parser for PHP and thought I'd post my solution. The implementation and class follows.

<?php
$rss = new RSSReader('http://news.google.com/?output=rss');
while ($rss -> hasNext())
	print_r($rss -> next());
?>
<?php
class RSSReader {
	var $xml = null;
	var $pos = 0;
	var $count = 0;

	function __construct($feed_url) {
		$this -> load_url($feed_url);
	}

	function load_url($feed_url) {
		$this -> load_string(file_get_contents($feed_url));
	}

	function load_string($feed_string) {
		$this -> xml = simplexml_load_string(str_replace('content:encoded', 'content_encoded', $feed_string));
		$this -> pos = 0;
		$this -> count = count($this -> xml -> channel -> item);
	}

	function get_title() {
		return $this -> xml -> channel -> title;
	}

	function get_link() {
		return $this -> xml -> channel -> link;
	}

	function get_pubdate() {
		return $this -> xml -> channel -> pubdate;
	}

	function hasNext() {
		return $this -> count > $this -> pos;
	}

	function next() {
		$obj = $this -> xml -> channel -> item[$this -> pos++];
		return array(
			'title' => (string) $obj -> title,
			'link' => (string) $obj -> link,
			'description' => (string) $obj -> description,
			'content' => (string) $obj -> content_encoded,
			'pubDate' => strtotime($obj -> pubDate),
		);
	}
}
?>
Bookmark this page
[del.icio.us] [Digg] [Facebook] [Google] [Reddit] [Slashdot] [StumbleUpon]
 
 
 

How To Convert Large XML Files to CSV

 I usually struggle with convert very large XML files to other formats just because they are in a dynamic format and most programs you find run out of memory before properly parsing them. Well, I'm happy to say, I found a FAST and EASY solution. Of course this will work for small files as well as big files.

You'll want to grab a copy of the msxsl command line utility from Microsoft.

After you've got that, you'll need to setup a XSL file to tell the program how to format your file. If you're unfamiliar with XSL, you can familiarize yourself here.

After you've got your XSL file created, it's a simple command line entry:

msxsl xml_file.xml xsl_file.xsl -o output_file.csv

The following is a sample XML and XSL file that I used.

XML File:


	
		772500
		Tue, 20 Jan 2009 16:28:08 CST
		Tue, 20 Jan 2009 16:51:01 CST

		
		
			61951
			The Hills Season 1
		
	
	
		773000
		Tue, 20 Jan 2009 16:28:08 CST
		Tue, 20 Jan 2009 16:53:54 CST

		
		
			61926
			Hogan Knows Best Season 2
		
	
	
		775500
		Thu, 22 Jan 2009 14:49:12 CST
		Thu, 22 Jan 2009 14:51:35 CST

		
		
			62068
			Carlos Mencia 2007
		
		
			1402
			Comedy Central
		
	

XSL File (Creates tab-delimited file)


	
		
				

		
	
Bookmark this page
[del.icio.us] [Digg] [Facebook] [Google] [Reddit] [Slashdot] [StumbleUpon]
 
 
 

» Recent Comments

  • Dan: I knew that the browser ...
  • Dan: Roni, you would just ite...
  • Roni: But that script is only ...

» Meta