Never been to DZone Snippets before?

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

« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS 

Unicode words from online dictionary

// list words from unicode dictionary
// you need to add this line in the head section
// <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

for ( $i = 1; $i <= 45; $i++) {
$url="http://dsal.uchicago.edu/cgi-bin/romadict.pl?page=$i&table=molesworth&display=utf8";
$text=file_get_contents($url);
$myarray = preg_match_all('#<font size="\+1">(.*?)</font>#i', $text, $matches);
echo implode(' ',$matches[1]); 
}

can i implement voice support for gaim

// description of your code here

// insert code here..

Csharp format integer as hex string

// Using the built in ability to print a byte as a hex value
// this set of methods gives the ability to print shorts
// and longs as hex using the spacing that is customary.

using System;

namespace testApp
{
	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	class Class1
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{
			Class1 t = new Class1();
			long i = 12; // 
			Console.WriteLine(t.int32ToHexString(i));
		}

		private string int32ToHexString(long i)
		{
			byte[] int32Bytes;
			int32Bytes = BitConverter.GetBytes(i);
			return String.Format("{0}{1}{2}{3}",
				padString(int32Bytes[0].ToString("X")),
				padString(int32Bytes[1].ToString("X")),
				padString(int32Bytes[2].ToString("X")),
				padString(int32Bytes[3].ToString("X")));
		}

		private string int16ToHexString(short i)
		{
			byte[] int32Bytes;
			int32Bytes = BitConverter.GetBytes(i);
			return String.Format("{0}{1}",
				padString(int32Bytes[0].ToString("X")),
				padString(int32Bytes[1].ToString("X")));
		}

		private string byteToHexString(byte b)
		{
			return padString(String.Format("{0}", b.ToString("X")));
		}

		private string padString(string s)
		{
			while (s.Length < 2) s = "0" + s;
			while (s.Length < 3) s = " " + s;
			return s;
		}
	}
}



produces this output:
0C 00 00 00

ForLoop: a simple for loop in xslt

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
### begin_: file metadata
    ### <region-file_info>
    ### main:
    ###   - name : ForLoop: a simple for loop in xslt
    ###     desc : |
    ###         Do a simple for loop in xslt displaying hello world.
    ###         Call this from any source xml file.
    ###         It works independently of the data in the xml.
    ###     date : created="Thu 2005-12-01 11:30:52"
    ###     last : lastmod="Thu 2005-12-01 11:30:57"
    ###     lang    : xslt
    ###     tags    : xml xslt loop for hello_world
    ### </region-file_info>
    -->
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html"/>

<xsl:template match="/">

<html>
<head><title>Say Hello Ten Times!</title></head>
<body>
    <b>I am going to say hello Ten Times!</b>
<!-- begin_: Send_Loop_To_HTML -->
    <xsl:call-template name="for.loop">
     <xsl:with-param name="i">1</xsl:with-param>
     <xsl:with-param name="count">10</xsl:with-param>
    </xsl:call-template>
</body>
</html>

</xsl:template>


<!--begin_: Define_The_Output_Loop -->
  <xsl:template name="for.loop">

   <xsl:param name="i"      />
   <xsl:param name="count"  />

   <!--begin_: Line_by_Line_Output -->
   <xsl:if test="$i &lt;= $count">
      <br /> <b><xsl:value-of select="$i" />.</b>Hello world!
   </xsl:if>

   <!--begin_: RepeatTheLoopUntilFinished-->
   <xsl:if test="$i &lt;= $count">
      <xsl:call-template name="for.loop">
          <xsl:with-param name="i">
              <xsl:value-of select="$i + 1"/>
          </xsl:with-param>
          <xsl:with-param name="count">
              <xsl:value-of select="$count"/>
          </xsl:with-param>
      </xsl:call-template>
   </xsl:if>

  </xsl:template>
</xsl:stylesheet>
« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS