<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: send code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 16 May 2008 18:30:20 GMT</pubDate>
    <description>DZone Snippets: send code</description>
    <item>
      <title>Send custom UDP packets in Ruby</title>
      <link>http://snippets.dzone.com/posts/show/4541</link>
      <description>&lt;br /&gt;From: http://www.ruby-forum.com/topic/124159&lt;br /&gt;Author: Bill Kelly&lt;br /&gt;&lt;br /&gt;For yet another nifty UDP snippet see &lt;a href="http://www.rubyinside.com/skype-style-firewall-busting-with-ruby-and-udp-399.html"&gt;Skype-Style Firewall Busting with Ruby and UDP&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;require 'socket'&lt;br /&gt;&lt;br /&gt;#abort "Usage: server_addr, server_port, cmd_str" unless ARGV.length == 3&lt;br /&gt;&lt;br /&gt;UDP_RECV_TIMEOUT = 3  # seconds&lt;br /&gt;&lt;br /&gt;def q2cmd(server_addr, server_port, cmd_str)&lt;br /&gt;  resp, sock = nil, nil&lt;br /&gt;  begin&lt;br /&gt;   cmd = "\377\377\377\377#{cmd_str}\0"&lt;br /&gt;    sock = UDPSocket.open&lt;br /&gt;    sock.send(cmd, 0, server_addr, server_port)&lt;br /&gt;    resp = if select([sock], nil, nil, UDP_RECV_TIMEOUT)&lt;br /&gt;      sock.recvfrom(65536)&lt;br /&gt;    end&lt;br /&gt;    if resp&lt;br /&gt;      resp[0] = resp[0][4..-1]  # trim leading 0xffffffff&lt;br /&gt;    end&lt;br /&gt;  rescue IOError, SystemCallError&lt;br /&gt;  ensure&lt;br /&gt;    sock.close if sock&lt;br /&gt;  end&lt;br /&gt;  resp ? resp[0] : nil&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;# your firewall has to allow communication with IP address 67.19.248.74 (port 27912)&lt;br /&gt;#server, port, cmd = *ARGV&lt;br /&gt;server = "tastyspleen.net"&lt;br /&gt;port = 27912&lt;br /&gt;cmd = "status"&lt;br /&gt;&lt;br /&gt;result = q2cmd(server, port, cmd)&lt;br /&gt;puts result&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Fri, 14 Sep 2007 11:19:36 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4541</guid>
      <author>ntk ()</author>
    </item>
    <item>
      <title>Python - SendSMS over BT and AT</title>
      <link>http://snippets.dzone.com/posts/show/3041</link>
      <description>// Send SMS over Bluetooth (AT Command)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;import bluetooth&lt;br /&gt;&lt;br /&gt;sockfd = bluetooth.BluetoothSocket(bluetooth.RFCOMM)&lt;br /&gt;sockfd.connect(('00:00:00:00:00:00', 1)) # BT Address&lt;br /&gt;sockfd.send('ATZ\r')&lt;br /&gt;sockfd.send('AT+CMGF=1\r')&lt;br /&gt;sockfd.send('AT+CSCA="+393359609600"\r') # Client TIM ITA&lt;br /&gt;sockfd.send('AT+CMGS="+39xxxxxxxxxx"\r') # TO PhoneNumber&lt;br /&gt;sockfd.send('Messaggio da mandare...\n')&lt;br /&gt;sockfd.send(chr(26)) # CTRL+Z&lt;br /&gt;sockfd.close()&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 26 Nov 2006 21:31:03 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3041</guid>
      <author>whitetiger ()</author>
    </item>
    <item>
      <title>PyS60 - SendFile</title>
      <link>http://snippets.dzone.com/posts/show/3040</link>
      <description>// Send File over Bluetooth&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;from appuifw import *&lt;br /&gt;from e32socket import *&lt;br /&gt;&lt;br /&gt;try:&lt;br /&gt;    phone = bt_obex_discover()&lt;br /&gt;    file = query(u'File Selection', 'text')&lt;br /&gt;    bt_obex_send_file(phone[0], phone[1].values()[0], file)&lt;br /&gt;    note(u'File Sent')&lt;br /&gt;except Exception, error:&lt;br /&gt;    note(unicode(error), 'error')&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 26 Nov 2006 21:12:40 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3040</guid>
      <author>whitetiger ()</author>
    </item>
    <item>
      <title>Sending html mail</title>
      <link>http://snippets.dzone.com/posts/show/736</link>
      <description>Get the code for createhtmlmail(html, text, subject) &lt;a href=http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/67083&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;import smtplib&lt;br /&gt;html = open("newsletter.html").read()&lt;br /&gt;text = open("newsletter.txt").read()&lt;br /&gt;subject = "Today's Newsletter!"&lt;br /&gt;&lt;br /&gt;message = createhtmlmail(html, text, subject)&lt;br /&gt;&lt;br /&gt;server = smtplib.SMTP("localhost")&lt;br /&gt;server.sendmail('my@dress.com', 'your@dress.com', message)&lt;br /&gt;server.quit()&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 18 Sep 2005 13:31:52 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/736</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
    <item>
      <title>Send a file using FTP</title>
      <link>http://snippets.dzone.com/posts/show/711</link>
      <description>&lt;code&gt;&lt;br /&gt;import ftplib&lt;br /&gt;s = ftplib.FTP('myserver.com','login','password') # Connect&lt;br /&gt;&lt;br /&gt;f = open('todo.txt','rb')                # file to send&lt;br /&gt;s.storbinary('STOR todo.txt', f)         # Send the file&lt;br /&gt;&lt;br /&gt;f.close()                                # Close file and FTP&lt;br /&gt;s.quit()&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Taken (with some mod.) from &lt;a href=http://sebsauvage.net/python/snyppets/&gt;here&lt;/a&gt;</description>
      <pubDate>Thu, 15 Sep 2005 00:05:30 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/711</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
  </channel>
</rss>
