set text and navigate url property of hyperlink field using jacascript
var hyperlink = document.getElementById('<%= Hyperlink.ClientID %>'); hyp.innerHTML = 'My New Link'; hyp.href = 'http://snippets.dzone.com/'
5293 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
var hyperlink = document.getElementById('<%= Hyperlink.ClientID %>'); hyp.innerHTML = 'My New Link'; hyp.href = 'http://snippets.dzone.com/'
svn info | grep "URL" | cut -d" " -f2
function is_valid_email($email) { if(preg_match("/[a-zA-Z0-9_-.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+/", $email) > 0) return true; else return false; }
function mdy($mid = "month", $did = "day", $yid = "year", $mval, $dval, $yval) { if(empty($mval)) $mval = date("m"); if(empty($dval)) $dval = date("d"); if(empty($yval)) $yval = date("Y"); $months = array(1 => "January", 2 => "February", 3 => "March", 4 => "April", 5 => "May", 6 => "June", 7 => "July", 8 => "August", 9 => "September", 10 => "October", 11 => "November", 12 => "December"); $out = "<select name='$mid' id='$mid'>"; foreach($months as $val => $text) if($val == $mval) $out .= "<option value='$val' selected>$text</option>"; else $out .= "<option value='$val'>$text</option>"; $out .= "</select> "; $out .= "<select name='$did' id='$did'>"; for($i = 1; $i <= 31; $i++) if($i == $dval) $out .= "<option value='$i' selected>$i</option>"; else $out .= "<option value='$i'>$i</option>"; $out .= "</select> "; $out .= "<select name='$yid' id='$yid'>"; for($i = date("Y"); $i <= date("Y") + 2; $i++) if($i == $yval) $out.= "<option value='$i' selected>$i</option>"; else $out.= "<option value='$i'>$i</option>"; $out .= "</select>"; return $out; }
CSS /* set millions of background images */ .rbroundbox { background: url(nt.gif) repeat; } .rbtop div { background: url(tl.gif) no-repeat top left; } .rbtop { background: url(tr.gif) no-repeat top right; } .rbbot div { background: url(bl.gif) no-repeat bottom left; } .rbbot { background: url(br.gif) no-repeat bottom right; } /* height and width stuff, width not really nessisary. */ .rbtop div, .rbtop, .rbbot div, .rbbot { width: 100%; height: 7px; font-size: 1px; } .rbcontent { margin: 0 7px; } .rbroundbox { width: 50%; margin: 1em auto; } HTML <div class="rbroundbox"> <div class="rbtop"><div></div></div> <div class="rbcontent"> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis ornare ultricies libero. Donec fringilla, eros at dapibus fermentum, tellus tellus auctor erat, vitae porta magna libero sed libero. Mauris sed leo. Aliquam aliquam. Maecenas vestibulum.</p> </div><!-- /rbcontent --> <div class="rbbot"><div></div></div> </div><!-- /rbroundbox -->
************************************************************************ Example: ************************************************************************ $xml = new XML('artikel.xml'); $xml->print_nodes(); ?> *********************************************************************** Script *********************************************************************** <?php # This script formats a xml file according to some rules. These rules # are processed in the function that xml_set_character_data_handler # defines. We have to remember, in which element we are, and furthermore, # which ancestor elements the current element has. class Node { var $name; var $attributes; var $ancestors = "/" var $data; var $type; function Node($tree) { $this->name = array_pop($tree); $this->ancestors .= implode("/", $tree); } function add_data($value) { $this->data .= ' '.$value; } function get_type() { if (strlen($this->data) > 0) { return "with CDATA" } else { return "without CDATA" } } function level() { if ($this->ancestors == "/") return 0; if (preg_match_all("/(\/{1})/", $this->ancestors, $result,PREG_PATTERN_ORDER)) { return (count($result[0])); } else { return 0; } } function has_attributes() { return (is_array($this->attributes)); } function print_name() { return "$this->name"; } function is_child($node) { $result = preg_match("/^$ancestors/", $node->ancestors, $match); if ($node->ancestors == $this->ancestors) $result = false; return $result; } } class XML { var $file; var $tree = array(); var $nodes = array(); var $PIs; var $format_body = "font-family:Verdana;font-size:10pt;" var $format_bracket = "color:blue;" var $format_element = "font-family:Verdana;font-weight:bold;font-size:10pt;" var $format_attribute = "font-family:Courier;font-size:10pt;" var $format_data = "font-size:12pt;" var $format_attribute_name = "color:#444444;" var $format_attribute_value = "font-family:Courier;font-size:10pt;color:red;" var $format_blanks = " " function XML($filename) { $this->file = $filename; $xml_parser = xml_parser_create(); xml_set_object($xml_parser,&$this); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); xml_set_processing_instruction_handler ($xml_parser, "process_instruction"); # Why should one want to use case-folding with XML? XML is case-sensitiv, I think this is nonsense xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false); if (!($fp = @fopen($this->file, "r"))) { die(print("Couldn't open file: $this->file\n")); } while ($data = fread($fp, 4096)) { if (!xml_parse($xml_parser, $data, feof($fp))) { die(sprintf("XML error: %s at line %d\n", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); } } } function startElement($parser, $name, $attribs) { # Adding the additional element to the tree, including attributes $this->tree[] = $name; $node = new Node($this->tree); while (list($k, $v) = each($attribs)) { $node->attributes[$k] = $v; } $this->nodes[] = $node; } function endElement($parser, $name) { # Adding a new element, describing the end of the tag # But only, if the Tag has CDATA in it! # Check if (count($this->nodes) >= 1) { $prev_node = $this->nodes[count($this->nodes)-1]; if (strlen($prev_node->data) > 0 || $prev_node->name != $name) { $this->tree[count($this->tree)-1] = "/".$this->tree[count($this->tree)-1]; $this->nodes[] = new Node($this->tree, NULL); } else { # Adding a slash to the end of the prev_node $prev_node->name = $prev_node->name."/" $this->nodes[count($this->nodes)-1]->name = $this->nodes[count($this->nodes)-1]->name."/" } } # Removing the element from the tree array_pop($this->tree); } function characterData($parser, $data) { $data = ltrim($data); if ($data != "") $this->nodes[count($this->nodes)-1]->add_data($data); } function process_instruction($parser, $target, $data) { if (preg_match("/xml:stylesheet/", $target, $match) && preg_match("/type=\"text\/xsl\"/", $data, $match)) { preg_match("/href=\"(.+)\"/i", $data, $this->PIs); # print "<b>found xls pi: $PIs[1]</b><br>\n" } } function print_nodes() { # Printing the header print "<html><head><title>".$this->nodes[0]->name."</title></head>" print "<body style=\"".$this->format_body."\">\n" # Printing the XML Data for ($i = 0; $i < count($this->nodes); $i++) { $node = $this->nodes[$i]; # Checking: Empty element if ($node->name[strlen($node->name)-1] == "/") { $end_char = "/" $node->name = substr($node->name, 0, strlen($node->name)-1); } else { $end_char = "" } # Writing whitespaces, but only if it's _no_ closing element that follows # directly on it's opening element if (!("/".$this->nodes[$i-1]->name == $node->name)) { for ($j = 0; $j < $node->level(); $j++) echo $this->format_blanks; } echo "<span style=\"".$this->format_bracket."\"><</span><span style=\"".$this->format_element."\">".$node->name."</span>" if ($node->has_attributes()) { $keys = array_keys($node->attributes); for ($j = 0; $j < count($keys); $j++) { printf(" <span style=\"%s\">%s=\"</span><span style=\"%s\">%s</span><span style=\"%s\">\"</span>", $this->format_attribute_name, $keys[$j], $this->format_attribute_value, $node->attributes[$keys[$j]], $this->format_attribute_name); } echo " " } echo "<span style=\"".$this->format_element."\">$end_char</span><span style=\"".$this->format_bracket."\">></span>" if (strlen($node->data) > 0) echo "<span style=\"".$this->format_data."\">".ltrim($node->data)."</span>" else echo "<br>\n" } # Printing the footer print "</body></html>\n" } }
require 'rubygems' require 'rest-open-uri' def remote_file_exist?(url) open( url , :method => :head).status rescue false end
/** * $title = "Hello world! This is a title"; * echo Helpers_Html::titlelizeEncode($title); * echo "<br/>"; * echo Helpers_Html::titlelizeDecode(Helpers_Html::titlelizeEncode($title)); */ class Titlelize{ /** * Gera titulos que podem ser recuperados * @param string $string */ //return titlelizeEncode('ola mundo'):'ola-mundo' static function titlelizeEncode($string){ $slug=preg_replace('/[^A-Za-z0-9-]+/', '-', $string); return $slug; } //para usar em SQL algo como: '... title LIKE ?', titlelizeDencode('ola-mundo') //return 'ola?mundo' static function titlelizeDecode($string){ $slug=preg_replace('/-/', '?', $string); return $slug; } }
sudo gem1.9.1 install addressable
Successfully installed addressable-2.1.1
1 gem installed
Installing ri documentation for addressable-2.1.1...
Installing RDoc documentation for addressable-2.1.1...
sudo gem1.9.1 install alexrabarts-tld -s http://gems.github.com
Successfully installed alexrabarts-iso_country_codes-0.2.2
Successfully installed alexrabarts-tld-0.6.0
2 gems installed
Installing ri documentation for alexrabarts-iso_country_codes-0.2.2...
Installing ri documentation for alexrabarts-tld-0.6.0...
Updating class cache with 2187 classes...
Installing RDoc documentation for alexrabarts-iso_country_codes-0.2.2...
Installing RDoc documentation for alexrabarts-tld-0.6.0...
require 'tld' TLD.find('foo.com.au').name #=> "Australia" TLD.find('is.gd').name #=> "Grenada" TLD.find('deli.cio.us').name #=> "United States"
require 'open-uri' require 'net/http' def remote_file_exists?(url) url = URI.parse(url) Net::HTTP.start(url.host, url.port) do |http| return http.head(url.request_uri).code == "200" end end
remote_file_exists? 'http://www.www.www' #=> false remote_file_exists? 'http://www.wired.com/' #=> true remote_file_exists? 'http://www.wired.com/blogs/' #=> true remote_file_exists? 'http://www.wired.com/i-love-ruby/' #=> false