<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: remove code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 17 May 2008 00:25:37 GMT</pubDate>
    <description>DZone Snippets: remove code</description>
    <item>
      <title>HTML/JavaScript - Select list - Add/Remove Options (DOM)</title>
      <link>http://snippets.dzone.com/posts/show/4442</link>
      <description>from http://www.mredkj.com/tutorials/tutorial005.html&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Overview&lt;br /&gt;&lt;br /&gt;    * Insert Before Selected - A new option is created and added above the selected option (as determined by selectedIndex). If none are selected, then no option is added.&lt;br /&gt;    * Remove Selected - Deletes the selected option (or options) from the list. If no options are selected, no options are deleted.&lt;br /&gt;    * Append Last - No matter what is selected, a new option is added at the end.&lt;br /&gt;    * Remove Last - No matter what is selected, the last option is deleted from the list.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Explanation&lt;br /&gt;&lt;br /&gt;According to DOM Level 1, the following is the syntax for the add and remove methods in HTMLSelectElement:&lt;br /&gt;&lt;br /&gt;void add(in HTMLElement element, in HTMLElement before) raises(DOMException);&lt;br /&gt;void remove(in long index);&lt;br /&gt;&lt;br /&gt;The add method takes two arguments: the element to add, and the element to insert before. The spec also says you can add to the end of the list by passing null as the second argument.&lt;br /&gt;&lt;br /&gt;The remove method just takes a number: the index of the option to be removed. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The JavaScript&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;script language="JavaScript" type="text/javascript"&gt;&lt;br /&gt;&lt;!--&lt;br /&gt;var count1 = 0;&lt;br /&gt;var count2 = 0;&lt;br /&gt;&lt;br /&gt;function insertOptionBefore(num)&lt;br /&gt;{&lt;br /&gt;  var elSel = document.getElementById('selectX');&lt;br /&gt;  if (elSel.selectedIndex &gt;= 0) {&lt;br /&gt;    var elOptNew = document.createElement('option');&lt;br /&gt;    elOptNew.text = 'Insert' + num;&lt;br /&gt;    elOptNew.value = 'insert' + num;&lt;br /&gt;    var elOptOld = elSel.options[elSel.selectedIndex];  &lt;br /&gt;    try {&lt;br /&gt;      elSel.add(elOptNew, elOptOld); // standards compliant; doesn't work in IE&lt;br /&gt;    }&lt;br /&gt;    catch(ex) {&lt;br /&gt;      elSel.add(elOptNew, elSel.selectedIndex); // IE only&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function removeOptionSelected()&lt;br /&gt;{&lt;br /&gt;  var elSel = document.getElementById('selectX');&lt;br /&gt;  var i;&lt;br /&gt;  for (i = elSel.length - 1; i&gt;=0; i--) {&lt;br /&gt;    if (elSel.options[i].selected) {&lt;br /&gt;      elSel.remove(i);&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function appendOptionLast(num)&lt;br /&gt;{&lt;br /&gt;  var elOptNew = document.createElement('option');&lt;br /&gt;  elOptNew.text = 'Append' + num;&lt;br /&gt;  elOptNew.value = 'append' + num;&lt;br /&gt;  var elSel = document.getElementById('selectX');&lt;br /&gt;&lt;br /&gt;  try {&lt;br /&gt;    elSel.add(elOptNew, null); // standards compliant; doesn't work in IE&lt;br /&gt;  }&lt;br /&gt;  catch(ex) {&lt;br /&gt;    elSel.add(elOptNew); // IE only&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function removeOptionLast()&lt;br /&gt;{&lt;br /&gt;  var elSel = document.getElementById('selectX');&lt;br /&gt;  if (elSel.length &gt; 0)&lt;br /&gt;  {&lt;br /&gt;    elSel.remove(elSel.length - 1);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;//--&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The HTML&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;form&gt;&lt;br /&gt;&lt;input type="button" value="o" onclick="insertOptionBefore(count1++);" /&gt;&lt;br /&gt;Insert Before Selected&lt;br /&gt;&lt;br /&gt;&lt;input type="button" value="o" onclick="removeOptionSelected();" /&gt;&lt;br /&gt;Remove Selected&lt;br /&gt;&lt;br /&gt;&lt;select id="selectX" size="10" multiple="multiple"&gt;&lt;br /&gt;&lt;option value="original1" selected="selected"&gt;Orig1&lt;/option&gt;&lt;br /&gt;&lt;option value="original2"&gt;Orig2&lt;/option&gt;&lt;br /&gt;&lt;/select&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;input type="button" value="o" onclick="appendOptionLast(count2++);" /&gt;&lt;br /&gt;Append Last&lt;br /&gt;&lt;br /&gt;&lt;input type="button" value="o" onclick="removeOptionLast();" /&gt;&lt;br /&gt;Remove Last&lt;br /&gt;&lt;/form&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Wed, 22 Aug 2007 12:39:41 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4442</guid>
      <author>bradalyst (brad)</author>
    </item>
    <item>
      <title>Remove comments from a file</title>
      <link>http://snippets.dzone.com/posts/show/4174</link>
      <description>Remove all comment lines from a file.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;sed -e '/^#/d' $1 | more&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;or to output it to a new file&lt;br /&gt;&lt;code&gt;&lt;br /&gt;sed -e '/^#/d' $1 &gt; $1.nocomments&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 20 Jun 2007 18:24:22 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4174</guid>
      <author>fak3r (fak3r)</author>
    </item>
    <item>
      <title>remove dublicate lines form</title>
      <link>http://snippets.dzone.com/posts/show/4124</link>
      <description>111111&lt;br /&gt;1111&lt;br /&gt;11&lt;br /&gt;222&lt;br /&gt;222&lt;br /&gt;33333&lt;br /&gt;4444&lt;br /&gt;1111&lt;br /&gt;22&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;textarea name="lines" cols="70" rows="30"&gt;&lt;br /&gt;&lt;?php &lt;br /&gt;$a=array_unique(explode("\n", $_POST['lines']));&lt;br /&gt;#natsort($a);&lt;br /&gt;echo implode("\n",$a);&lt;br /&gt;?&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;result:&lt;br /&gt;111111&lt;br /&gt;1111&lt;br /&gt;11&lt;br /&gt;222&lt;br /&gt;33333&lt;br /&gt;4444&lt;br /&gt;22</description>
      <pubDate>Sat, 09 Jun 2007 01:08:56 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4124</guid>
      <author>BlackHalt (BlackHalt)</author>
    </item>
    <item>
      <title>BlockFlash-Revisited.user.js</title>
      <link>http://snippets.dzone.com/posts/show/3054</link>
      <description>&lt;code&gt;&lt;br /&gt;// ==UserScript==&lt;br /&gt;// @name		BlockFlash-Revisited&lt;br /&gt;// @namespace		http://snippets.dzone.com/posts/show/3054&lt;br /&gt;// @description	Do not start Flash animation until you click on them.&lt;br /&gt;// @include		*&lt;br /&gt;// @exclude		http://www.macromedia.com/*&lt;br /&gt;// @exclude		http://www.atomfilms.com/*&lt;br /&gt;// @exclude		http://uploads.ungrounded.net/*&lt;br /&gt;// @exclude		http://www.albinoblacksheep.com/*&lt;br /&gt;// ==/UserScript==&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;	Revised by Andrew Pennebaker (andrew.pennebaker@gmail.com)&lt;br /&gt;&lt;br /&gt;	Author: Jos van den Oever (jos@vandenoever.info)&lt;br /&gt;&lt;br /&gt;	License: GPL&lt;br /&gt;&lt;br /&gt;	Version history:&lt;br /&gt;		2006-02-12: initial version&lt;br /&gt;		2006-11-28: changed appearance&lt;br /&gt;&lt;br /&gt;Inspiration for this script comes from the removeFlash script and the FlashBlock firefox extension.&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;(function () {&lt;br /&gt;	var objects=document.getElementsByTagName("object");&lt;br /&gt;&lt;br /&gt;	for (i=0; i&lt;objects.length; i++) {&lt;br /&gt;		var flash=objects[i];&lt;br /&gt;&lt;br /&gt;		if (flash.innerHTML.match(/.swf|shockwave|flash/)) {&lt;br /&gt;			var placeholder=document.createElement("div");&lt;br /&gt;&lt;br /&gt;			placeholder.style.cursor='pointer';&lt;br /&gt;			placeholder.style.background='orange'; // 'gray '&lt;br /&gt;			placeholder.style.textAlign='center';&lt;br /&gt;			placeholder.style.color='black';&lt;br /&gt;			placeholder.innerHTML="[Play Flash]";&lt;br /&gt;&lt;br /&gt;			flash.parentNode.insertBefore(placeholder, flash);&lt;br /&gt;			flash.on=false;&lt;br /&gt;&lt;br /&gt;			placeholder.addEventListener(&lt;br /&gt;				'click',&lt;br /&gt;				function() {&lt;br /&gt;					if (flash.on) {&lt;br /&gt;						flash.style.display='none';&lt;br /&gt;						placeholder.innerHTML="[Play Flash]";&lt;br /&gt;						flash.on=false;&lt;br /&gt;					}&lt;br /&gt;					else {&lt;br /&gt;						flash.style.display='';&lt;br /&gt;						placeholder.innerHTML="[Stop Flash]";&lt;br /&gt;						flash.on=true;&lt;br /&gt;					}&lt;br /&gt;				},&lt;br /&gt;				true&lt;br /&gt;			);&lt;br /&gt;&lt;br /&gt;			flash.style.display='none';&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;})();&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 29 Nov 2006 01:03:18 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3054</guid>
      <author>mcandre (Andrew Pennebaker)</author>
    </item>
    <item>
      <title>Delete empty directories (UNIX)</title>
      <link>http://snippets.dzone.com/posts/show/3012</link>
      <description>// Shell command to delete empty directories. May have to run several times to get everything.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;find . -type d -empty | xargs rmdir -&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 18 Nov 2006 03:21:34 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3012</guid>
      <author>jasonbentley (Jason Bentley)</author>
    </item>
    <item>
      <title>drop-highest - remove the highest value from a series</title>
      <link>http://snippets.dzone.com/posts/show/2730</link>
      <description>&lt;code&gt;&lt;br /&gt;drop-highest: func [block] [head remove maximum-of block]&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 29 Sep 2006 18:31:03 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2730</guid>
      <author>gregg.irwin (Gregg Irwin)</author>
    </item>
    <item>
      <title>drop-lowest - remove the lowest value from a series</title>
      <link>http://snippets.dzone.com/posts/show/2729</link>
      <description>&lt;code&gt;&lt;br /&gt;drop-lowest:  func [block] [head remove minimum-of block]&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 29 Sep 2006 18:30:17 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2729</guid>
      <author>gregg.irwin (Gregg Irwin)</author>
    </item>
    <item>
      <title>Javascript Manipulate Class Names</title>
      <link>http://snippets.dzone.com/posts/show/2630</link>
      <description>I often have to manipulate class names of objects in javascript.&lt;br /&gt;But className can have multiple classes in it.&lt;br /&gt;These functions deal with that.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;// ----------------------------------------------------------------------------&lt;br /&gt;// HasClassName&lt;br /&gt;//&lt;br /&gt;// Description : returns boolean indicating whether the object has the class name&lt;br /&gt;//    built with the understanding that there may be multiple classes&lt;br /&gt;//&lt;br /&gt;// Arguments:&lt;br /&gt;//    objElement              - element to manipulate&lt;br /&gt;//    strClass                - class name to add&lt;br /&gt;//&lt;br /&gt;function HasClassName(objElement, strClass)&lt;br /&gt;   {&lt;br /&gt;&lt;br /&gt;   // if there is a class&lt;br /&gt;   if ( objElement.className )&lt;br /&gt;      {&lt;br /&gt;&lt;br /&gt;      // the classes are just a space separated list, so first get the list&lt;br /&gt;      var arrList = objElement.className.split(' ');&lt;br /&gt;&lt;br /&gt;      // get uppercase class for comparison purposes&lt;br /&gt;      var strClassUpper = strClass.toUpperCase();&lt;br /&gt;&lt;br /&gt;      // find all instances and remove them&lt;br /&gt;      for ( var i = 0; i &lt; arrList.length; i++ )&lt;br /&gt;         {&lt;br /&gt;&lt;br /&gt;         // if class found&lt;br /&gt;         if ( arrList[i].toUpperCase() == strClassUpper )&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;            // we found it&lt;br /&gt;            return true;&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;         }&lt;br /&gt;&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;   // if we got here then the class name is not there&lt;br /&gt;   return false;&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;// &lt;br /&gt;// HasClassName&lt;br /&gt;// ----------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// ----------------------------------------------------------------------------&lt;br /&gt;// AddClassName&lt;br /&gt;//&lt;br /&gt;// Description : adds a class to the class attribute of a DOM element&lt;br /&gt;//    built with the understanding that there may be multiple classes&lt;br /&gt;//&lt;br /&gt;// Arguments:&lt;br /&gt;//    objElement              - element to manipulate&lt;br /&gt;//    strClass                - class name to add&lt;br /&gt;//&lt;br /&gt;function AddClassName(objElement, strClass, blnMayAlreadyExist)&lt;br /&gt;   {&lt;br /&gt;&lt;br /&gt;   // if there is a class&lt;br /&gt;   if ( objElement.className )&lt;br /&gt;      {&lt;br /&gt;&lt;br /&gt;      // the classes are just a space separated list, so first get the list&lt;br /&gt;      var arrList = objElement.className.split(' ');&lt;br /&gt;&lt;br /&gt;      // if the new class name may already exist in list&lt;br /&gt;      if ( blnMayAlreadyExist )&lt;br /&gt;         {&lt;br /&gt;&lt;br /&gt;         // get uppercase class for comparison purposes&lt;br /&gt;         var strClassUpper = strClass.toUpperCase();&lt;br /&gt;&lt;br /&gt;         // find all instances and remove them&lt;br /&gt;         for ( var i = 0; i &lt; arrList.length; i++ )&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;            // if class found&lt;br /&gt;            if ( arrList[i].toUpperCase() == strClassUpper )&lt;br /&gt;               {&lt;br /&gt;&lt;br /&gt;               // remove array item&lt;br /&gt;               arrList.splice(i, 1);&lt;br /&gt;&lt;br /&gt;               // decrement loop counter as we have adjusted the array's contents&lt;br /&gt;               i--;&lt;br /&gt;&lt;br /&gt;               }&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;         }&lt;br /&gt;&lt;br /&gt;      // add the new class to end of list&lt;br /&gt;      arrList[arrList.length] = strClass;&lt;br /&gt;&lt;br /&gt;      // add the new class to beginning of list&lt;br /&gt;      //arrList.splice(0, 0, strClass);&lt;br /&gt;      &lt;br /&gt;      // assign modified class name attribute&lt;br /&gt;      objElement.className = arrList.join(' ');&lt;br /&gt;&lt;br /&gt;      }&lt;br /&gt;   // if there was no class&lt;br /&gt;   else&lt;br /&gt;      {&lt;br /&gt;&lt;br /&gt;      // assign modified class name attribute      &lt;br /&gt;      objElement.className = strClass;&lt;br /&gt;   &lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;// &lt;br /&gt;// AddClassName&lt;br /&gt;// ----------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// ----------------------------------------------------------------------------&lt;br /&gt;// RemoveClassName&lt;br /&gt;//&lt;br /&gt;// Description : removes a class from the class attribute of a DOM element&lt;br /&gt;//    built with the understanding that there may be multiple classes&lt;br /&gt;//&lt;br /&gt;// Arguments:&lt;br /&gt;//    objElement              - element to manipulate&lt;br /&gt;//    strClass                - class name to remove&lt;br /&gt;//&lt;br /&gt;function RemoveClassName(objElement, strClass)&lt;br /&gt;   {&lt;br /&gt;&lt;br /&gt;   // if there is a class&lt;br /&gt;   if ( objElement.className )&lt;br /&gt;      {&lt;br /&gt;&lt;br /&gt;      // the classes are just a space separated list, so first get the list&lt;br /&gt;      var arrList = objElement.className.split(' ');&lt;br /&gt;&lt;br /&gt;      // get uppercase class for comparison purposes&lt;br /&gt;      var strClassUpper = strClass.toUpperCase();&lt;br /&gt;&lt;br /&gt;      // find all instances and remove them&lt;br /&gt;      for ( var i = 0; i &lt; arrList.length; i++ )&lt;br /&gt;         {&lt;br /&gt;&lt;br /&gt;         // if class found&lt;br /&gt;         if ( arrList[i].toUpperCase() == strClassUpper )&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;            // remove array item&lt;br /&gt;            arrList.splice(i, 1);&lt;br /&gt;&lt;br /&gt;            // decrement loop counter as we have adjusted the array's contents&lt;br /&gt;            i--;&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;         }&lt;br /&gt;&lt;br /&gt;      // assign modified class name attribute&lt;br /&gt;      objElement.className = arrList.join(' ');&lt;br /&gt;&lt;br /&gt;      }&lt;br /&gt;   // if there was no class&lt;br /&gt;   // there is nothing to remove&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;// &lt;br /&gt;// RemoveClassName&lt;br /&gt;// ----------------------------------------------------------------------------&lt;br /&gt;  &lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 20 Sep 2006 21:34:35 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2630</guid>
      <author>Will_Rickards (Will Rickards)</author>
    </item>
    <item>
      <title>removeDir //PHP Function</title>
      <link>http://snippets.dzone.com/posts/show/2448</link>
      <description>Removes a folder, including its subfolders and files in a efficient way without recursion, returns Boolean.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;//+ Jonas Raoni Soares Silva&lt;br /&gt;//@ http://jsfromhell.com&lt;br /&gt;&lt;br /&gt;function removeFolder($dir){&lt;br /&gt;	if(!is_dir($dir))&lt;br /&gt;		return false;&lt;br /&gt;	for($s = DIRECTORY_SEPARATOR, $stack = array($dir), $emptyDirs = array($dir); $dir = array_pop($stack);){&lt;br /&gt;		if(!($handle = @dir($dir)))&lt;br /&gt;			continue;&lt;br /&gt;		while(false !== $item = $handle-&gt;read())&lt;br /&gt;			$item != '.' &amp;&amp; $item != '..' &amp;&amp; (is_dir($path = $handle-&gt;path . $s . $item) ?&lt;br /&gt;			array_push($stack, $path) &amp;&amp; array_push($emptyDirs, $path) : unlink($path));&lt;br /&gt;		$handle-&gt;close();&lt;br /&gt;	}&lt;br /&gt;	for($i = count($emptyDirs); $i--; rmdir($emptyDirs[$i]));&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 20 Aug 2006 21:26:33 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2448</guid>
      <author>jonasraoni (Jonas Raoni Soares Silva)</author>
    </item>
    <item>
      <title>remove-all - remove all values matching the value arg from the series</title>
      <link>http://snippets.dzone.com/posts/show/2097</link>
      <description>&lt;code&gt;&lt;br /&gt;remove-all: func [series value] [remove-each val series [val = value]]&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 25 May 2006 03:07:40 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2097</guid>
      <author>gregg.irwin (Gregg Irwin)</author>
    </item>
  </channel>
</rss>
