<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: basic code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 05:06:07 GMT</pubDate>
    <description>DZone Snippets: basic code</description>
    <item>
      <title>VBScript Basic</title>
      <link>http://snippets.dzone.com/posts/show/5172</link>
      <description>Make A Error Message.&lt;br /&gt;Save As .vbs&lt;br /&gt;&lt;code&gt;&lt;br /&gt;x = msgbox("message Here" , 16, "title here")&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 25 Feb 2008 02:11:59 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5172</guid>
      <author>jmprogrammer (Jonathan Moore)</author>
    </item>
    <item>
      <title>Set a Field Equal to Something</title>
      <link>http://snippets.dzone.com/posts/show/2982</link>
      <description>A basic code sample for tcm_write_macros. It sets a custom field to a value&lt;br /&gt;&lt;code&gt;&lt;br /&gt;/* also - custom-1, custom-2, custom-3, custom-4, custom-5, etc for custom fields. */&lt;br /&gt;var obj = document.getElementById('custom-3');&lt;br /&gt;obj.value = "VALUE";&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 10 Nov 2006 05:55:58 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2982</guid>
      <author>tmcw ()</author>
    </item>
    <item>
      <title>Acceder a la fecha en la que una foto fue tomada en VB .NET</title>
      <link>http://snippets.dzone.com/posts/show/2931</link>
      <description>//Funci&#243;n a la que se le pasa el archivo jpg o jpge y devuelve la fecha en la que fue tomada&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;    Public Function ObtieneFecha(ByVal RutaArchivo As String) As Date&lt;br /&gt;&lt;br /&gt;        Dim image As New Bitmap(RutaArchivo)&lt;br /&gt;        Dim propItems As System.Drawing.Imaging.PropertyItem() = image.PropertyItems&lt;br /&gt;&lt;br /&gt;        Dim encoding As New System.Text.ASCIIEncoding&lt;br /&gt;&lt;br /&gt;        For i As Integer = propItems.GetLowerBound(0) To propItems.GetUpperBound(0)&lt;br /&gt;            If propItems(i).Id.ToString = "36868" Then&lt;br /&gt;                Dim strAux1() As String = Split(encoding.GetString(propItems(i).Value), " ")&lt;br /&gt;                Dim strAux2() As String = Split(strAux1(0), ":")&lt;br /&gt;                Dim strAux3() As String = Split(strAux1(1), ":")&lt;br /&gt;                Return CDate(strAux2(0) &amp; "/" &amp; strAux2(1) &amp; "/" &amp; strAux2(2) &amp; " " &amp; strAux3(0) &amp; ":" &amp; strAux3(1) &amp; ":" &amp; strAux3(2))&lt;br /&gt;            End If&lt;br /&gt;        Next&lt;br /&gt;        image.Dispose()&lt;br /&gt;    End Function&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 30 Oct 2006 22:16:11 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2931</guid>
      <author>ceronegativo (Pablo)</author>
    </item>
    <item>
      <title>Format strings like PRINT USING, for Ruby</title>
      <link>http://snippets.dzone.com/posts/show/2472</link>
      <description>This is an extension to Ruby's String class. Just put this code in a file and include it. This basically takes a string and adds literals and padding to it. For example, you can format a phone number like this:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;"5445556747".using('(###) ###-####', '', true)&lt;br /&gt;   =&gt; (544) 555-6747&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;require 'strscan'&lt;br /&gt;&lt;br /&gt;class String&lt;br /&gt;&lt;br /&gt;  # Returns the string formatted according to a pattern.&lt;br /&gt;  #&lt;br /&gt;  # The pattern consists of placeholders and literals. The string is placed in&lt;br /&gt;  # the placeholders, leaving the literals as they are. The result may be&lt;br /&gt;  # truncated or padded if there are more placeholders than strings.&lt;br /&gt;  #&lt;br /&gt;  # Placeholders are '#' or '&amp;'. Each '#' is replaced by one character from&lt;br /&gt;  # the string, or the filler character if the string has no characters left.&lt;br /&gt;  # The '&amp;' is replaced by any remaining characters, or left out of the result&lt;br /&gt;  # if there are no remaining characters. There can only be one '&amp;' in the&lt;br /&gt;  # pattern. If there is no '&amp;', remaining characters are discarded.&lt;br /&gt;  # &lt;br /&gt;  # '#' or '&amp;' may be replaced by other characters if they are needed as&lt;br /&gt;  # literals.&lt;br /&gt;  #&lt;br /&gt;  # Examples:&lt;br /&gt;  # "123456789".using('###-##-####')&lt;br /&gt;  #    =&gt; "123-45-6789"&lt;br /&gt;  # "12345".using('###-##-####')&lt;br /&gt;  #    =&gt; "123-45"&lt;br /&gt;  # "12345".using('###-##-####', nil)&lt;br /&gt;  #    =&gt; "12345"&lt;br /&gt;  # "12345".using('###-##-####', ' ')&lt;br /&gt;  #    =&gt; "123-45-    "&lt;br /&gt;  # "5551212".using ('(###) ###-####', '', true)&lt;br /&gt;  #    =&gt; "555-1212"&lt;br /&gt;  # "873555121276668".using ('(###) ###-#### ext &amp;', '', true)&lt;br /&gt;  #    =&gt; "(873) 555-1212 ext 76668"&lt;br /&gt;  # "KB5774X".using ('##-&amp;-#')&lt;br /&gt;  #    =&gt; "KB-5774-X"&lt;br /&gt;  #&lt;br /&gt;  # Parameters:&lt;br /&gt;  # pattern -- The format string, see above.&lt;br /&gt;  # fill    -- A string for padding. If the empty string, then the pattern is&lt;br /&gt;  #            filled as much as possible, and the rest of the pattern is&lt;br /&gt;  #            truncated. If nil, and the string does not fill the pattern,&lt;br /&gt;  #            the string is returned unchanged.  Otherwise, the string is&lt;br /&gt;  #            padded to fill the pattern, which is not truncated. Defaults to&lt;br /&gt;  #            the empty string.&lt;br /&gt;  # right   -- If true, the pattern is filled from right-to-left instead of&lt;br /&gt;  #            from left-to-right, and truncated on the left instead of the&lt;br /&gt;  #            right if needed. Default is false.&lt;br /&gt;  # fixchar -- The single-character placeholder. Default is '#'.&lt;br /&gt;  # remchar -- The remaining-character placeholder. Default is '&amp;'.&lt;br /&gt;  #&lt;br /&gt;  def using(pattern, fill='', right=false, fixchar='#', remchar='&amp;')&lt;br /&gt;&lt;br /&gt;    remCount = pattern.count(remchar)&lt;br /&gt;    raise ArgumentError.new("Too many #{remchar}") if remCount &gt; 1&lt;br /&gt;    raise ArgumentError.new("#{fixchar} too long") if fixchar.length &gt; 1&lt;br /&gt;    raise ArgumentError.new("#{remchar} too long") if remchar.length &gt; 1&lt;br /&gt;    raise ArgumentError.new("#{fill} too long")    if fill.length &gt; 1&lt;br /&gt;    remaining = remCount != 0&lt;br /&gt;    slots = pattern.count(fixchar)&lt;br /&gt;&lt;br /&gt;    # Return the string if it doesn't fit and we shouldn't even try,&lt;br /&gt;    if fill.nil?&lt;br /&gt;      return self if self.length &lt; slots&lt;br /&gt;      return self if self.length &gt; slots and !remaining&lt;br /&gt;    end&lt;br /&gt;&lt;br /&gt;    # Pad and clone the string if necessary.&lt;br /&gt;    source =  if fill.nil? || fill.empty? then&lt;br /&gt;                self&lt;br /&gt;              elsif right then&lt;br /&gt;                self.rjust(slots, fill)&lt;br /&gt;              else&lt;br /&gt;                self.ljust(slots, fill)&lt;br /&gt;              end&lt;br /&gt;    &lt;br /&gt;    # Truncate the string if necessary.&lt;br /&gt;    if source.length &gt; slots &amp;&amp; !remaining then&lt;br /&gt;      source = right ? source[-source.length, source.length] :&lt;br /&gt;                       source[0, source.length]&lt;br /&gt;    end&lt;br /&gt;&lt;br /&gt;    # Truncate pattern if needed.&lt;br /&gt;    if !fill.nil? &amp;&amp; fill.empty? then&lt;br /&gt;      &lt;br /&gt;      if source.length &lt; slots  # implies '&amp;' can be ignored&lt;br /&gt;        keepCount = source.length # Number of placeholders we are keeping&lt;br /&gt;        leftmost, rightmost = 0, pattern.length - 1&lt;br /&gt;        if right then&lt;br /&gt;          # Look right-to-left until we find the last '#' to keep.&lt;br /&gt;          # Loop starts at 1 because 0th placeholder is in the inject param.&lt;br /&gt;          leftmost = (1...keepCount).inject(pattern.rindex(fixchar)) {&lt;br /&gt;            |leftmost, n| pattern.rindex(fixchar, leftmost - 1) }&lt;br /&gt;        else&lt;br /&gt;          # Look left-to-right until we find the last '#' to keep.&lt;br /&gt;          rightmost = (1...keepCount).inject(pattern.index(fixchar)) {&lt;br /&gt;            |rightmost, n| pattern.index(fixchar, rightmost + 1) }&lt;br /&gt;        end&lt;br /&gt;        pattern = pattern[leftmost..rightmost]&lt;br /&gt;        slots = pattern.count(fixchar)&lt;br /&gt;      end&lt;br /&gt;    &lt;br /&gt;      # Trim empty '&amp;' up to nearest placeholder. If a '&amp;' goes empty, the&lt;br /&gt;      # literals between it and the nearest '#' are probably also unnecessary.&lt;br /&gt;      if source.length == slots then&lt;br /&gt;        if pattern.match("^#{Regexp.escape(remchar)}") then&lt;br /&gt;          pattern = pattern[pattern.index(fixchar) || 0 ... pattern.length]&lt;br /&gt;        elsif pattern.match("#{Regexp.escape(remchar)}$") then&lt;br /&gt;          pattern = pattern[0 ... (pattern.rindex(fixchar) + fixchar.length) || pattern.length]&lt;br /&gt;        end&lt;br /&gt;      end&lt;br /&gt;&lt;br /&gt;    end&lt;br /&gt;      &lt;br /&gt;    # Figure out how long the remainder will be when we get to it.&lt;br /&gt;    remSize = source.length - slots&lt;br /&gt;    if remSize &lt; 0 then remSize = 0; end&lt;br /&gt;    &lt;br /&gt;    # Make the result.&lt;br /&gt;    scanner = ::StringScanner.new(pattern)&lt;br /&gt;    sourceIndex = 0&lt;br /&gt;    result = ''&lt;br /&gt;    fixRegexp = Regexp.new(Regexp.escape(fixchar))&lt;br /&gt;    remRegexp = Regexp.new(Regexp.escape(remchar))&lt;br /&gt;    while not scanner.eos?&lt;br /&gt;      if scanner.scan(fixRegexp) then&lt;br /&gt;        result += source[sourceIndex].chr&lt;br /&gt;        sourceIndex += 1&lt;br /&gt;      elsif scanner.scan(remRegexp) then&lt;br /&gt;        result += source[sourceIndex, remSize]&lt;br /&gt;        sourceIndex += remSize&lt;br /&gt;      else&lt;br /&gt;        result += scanner.getch&lt;br /&gt;      end&lt;br /&gt;    end&lt;br /&gt;    &lt;br /&gt;    result&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 26 Aug 2006 19:21:53 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2472</guid>
      <author>Agent (Dustin Voss)</author>
    </item>
    <item>
      <title>fuck with the tsr-80s at radioshack</title>
      <link>http://snippets.dzone.com/posts/show/1547</link>
      <description>&lt;code&gt;&lt;br /&gt;10 print "i am so awesome"&lt;br /&gt;20 goto 10&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 22 Feb 2006 07:56:39 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1547</guid>
      <author>bezo ()</author>
    </item>
  </channel>
</rss>
