<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: blog code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 17 May 2008 10:26:53 GMT</pubDate>
    <description>DZone Snippets: blog code</description>
    <item>
      <title>firefox not showing vertical scrollbars in blog</title>
      <link>http://snippets.dzone.com/posts/show/5161</link>
      <description>hey everyone,&lt;br /&gt;&lt;br /&gt;I'm new here and wondering if someone can help me out.  i have a couple wordpress blogs i've built for clients, and i'm occasionally getting a wierd behavior in Firefox Win/Mac:  sometimes even though there is plenty of content below the fold, no vertical scrollbar will show at all.  it only does this on firefox.&lt;br /&gt;&lt;br /&gt;here's an example  (must view in firefox):&lt;br /&gt;&lt;br /&gt;http://www.lorihedrickphotography.com/blog/&lt;br /&gt;&lt;br /&gt;and i've tried adding this:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;html {&lt;br /&gt;height:101%;&lt;br /&gt;overflow-y:scroll;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;i looked at it with firebug, it validates.  i'm stumped!  any help would be greatly appreciated.&lt;br /&gt;&lt;br /&gt;-jared</description>
      <pubDate>Thu, 21 Feb 2008 20:40:24 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5161</guid>
      <author>jaredh123 (Jared Henderson)</author>
    </item>
    <item>
      <title>MetaWeblog API in PHP</title>
      <link>http://snippets.dzone.com/posts/show/4816</link>
      <description>Implementation of the MetaWeblog API http://www.xmlrpc.com/metaWeblogApi in PHP.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;/**&lt;br /&gt; * Skeleton file for MetaWeblog API http://www.xmlrpc.com/metaWeblogApi in PHP&lt;br /&gt; * Requires Keith Deven's XML-RPC Library http://keithdevens.com/software/xmlrpc and store it as xmlrpc.php in the same folder&lt;br /&gt; * Written by Daniel Lorch, based heavily on Keith Deven's examples on the Blogger API.&lt;br /&gt; */&lt;br /&gt;&lt;br /&gt;require_once dirname(__FILE__) . '/xmlrpc.php';&lt;br /&gt;&lt;br /&gt;function metaWeblog_newPost($params) {&lt;br /&gt;  list($blogid, $username, $password, $struct, $publish) = $params;&lt;br /&gt;  $title = $struct['title'];&lt;br /&gt;  $description = $struct['description'];&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  // YOUR CODE:&lt;br /&gt;  $post_id = 0; // id of the post you just created&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  XMLRPC_response(XMLRPC_prepare((string)$post_id), WEBLOG_XMLRPC_USERAGENT);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function metaWeblog_editPost($params) {&lt;br /&gt;  list($postid, $username, $password, $struct, $publish) = $params;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  // YOUR CODE:&lt;br /&gt;  $result = false; // whether or not the action succeeded&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  XMLRPC_response(XMLRPC_prepare((boolean)$result), WEBLOG_XMLRPC_USERAGENT);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function metaWeblog_getPost($params) {&lt;br /&gt;  list($postid, $username, $password) = $params;&lt;br /&gt;  $post = array();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  // YOUR CODE:&lt;br /&gt;  $post['userId'] = '1';&lt;br /&gt;  $post['dateCreated'] = XMLRPC_convert_timestamp_to_iso8601(time());&lt;br /&gt;  $post['title'] = 'Replace me';&lt;br /&gt;  $post['content'] = 'Replace me, too';&lt;br /&gt;  $post['postid'] = '1';&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  XMLRPC_response(XMLRPC_prepare($post), WEBLOG_XMLRPC_USERAGENT);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function XMLRPC_method_not_found($methodName) {&lt;br /&gt;  XMLRPC_error("2", "The method you requested, '$methodName', was not found.", WEBLOG_XMLRPC_USERAGENT);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$xmlrpc_methods = array(&lt;br /&gt;  'metaWeblog.newPost'  =&gt; 'metaWeblog_newPost',&lt;br /&gt;  'metaWeblog.editPost' =&gt; 'metaWeblog_editPost',&lt;br /&gt;  'metaWeblog.getPost'  =&gt; 'metaWeblog_getPost'&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;$xmlrpc_request = XMLRPC_parse($HTTP_RAW_POST_DATA);&lt;br /&gt;$methodName = XMLRPC_getMethodName($xmlrpc_request);&lt;br /&gt;$params = XMLRPC_getParams($xmlrpc_request);&lt;br /&gt;&lt;br /&gt;if(!isset($xmlrpc_methods[$methodName])) {&lt;br /&gt;  XMLRPC_method_not_found($methodName);&lt;br /&gt;} else {&lt;br /&gt;  $xmlrpc_methods[$methodName]($params);&lt;br /&gt;}&lt;br /&gt;?&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 25 Nov 2007 18:34:43 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4816</guid>
      <author>danielsanII (Daniel Lorch)</author>
    </item>
    <item>
      <title>Test Trackback using cURL</title>
      <link>http://snippets.dzone.com/posts/show/4540</link>
      <description>I've Googled this about 20 times - documenting it here for convenience.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;curl -d url=TRACKBACK_URL -d title=TRACKBACK_TITLE -d blog_name=TRACKBACK_BLOG_NAME -d excerpt=TRACKBACK_EXCERPT URL&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;A correct response:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;br /&gt;&lt;response&gt;&lt;br /&gt;&lt;error&gt;0&lt;/error&gt;&lt;br /&gt;&lt;/response&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 14 Sep 2007 01:31:16 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4540</guid>
      <author>jnewland (Jesse Newland)</author>
    </item>
    <item>
      <title>Latex2wiki</title>
      <link>http://snippets.dzone.com/posts/show/2847</link>
      <description>Translate a subset of LaTeX into MoinMoin wiki syntax.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/env python&lt;br /&gt;&lt;br /&gt;#    Copyright (C) 2003, Maxime Biais &lt;maxime@biais.org&gt;&lt;br /&gt;#&lt;br /&gt;#    This program is free software; you can redistribute it and/or modify&lt;br /&gt;#    it under the terms of the GNU General Public License as published by&lt;br /&gt;#    the Free Software Foundation; either version 2 of the License, or&lt;br /&gt;#    (at your option) any later version.&lt;br /&gt;#&lt;br /&gt;#    This program is distributed in the hope that it will be useful,&lt;br /&gt;#    but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&lt;br /&gt;#    GNU General Public License for more details.&lt;br /&gt;#&lt;br /&gt;#    You should have received a copy of the GNU General Public License&lt;br /&gt;#    along with this program; if not, write to the Free Software&lt;br /&gt;#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA&lt;br /&gt;#&lt;br /&gt;# $Id: latex2wiki.py,v 1.1.1.1 2004/03/14 18:31:50 max Exp $&lt;br /&gt;&lt;br /&gt;import sys, re&lt;br /&gt;&lt;br /&gt;def dummy(d):&lt;br /&gt;    pass&lt;br /&gt;&lt;br /&gt;NONE = "__@NONE@__"&lt;br /&gt;&lt;br /&gt;tr_list = [&lt;br /&gt;    (r"\\includegraphics.*{(.*)\.eps}", "attachment::%s.png", dummy),&lt;br /&gt;    (r"\\caption{.*}", "", dummy),&lt;br /&gt;    (r"\\label{.*}", "", dummy),&lt;br /&gt;    (r"(.*)\\emph{(.*)}(.*)", """%s'''%s'''%s""", dummy),&lt;br /&gt;    (r"\\item (.*)", " * %s", dummy),&lt;br /&gt;    (r"\\begin{.*}", "", dummy),&lt;br /&gt;    (r"\\end{.*}", "", dummy),&lt;br /&gt;    (r"(.*)``(.*)''(.*)", "%s\"%s\"%s", dummy),&lt;br /&gt;    (r"\\chapter{(.*)}", NONE, dummy),&lt;br /&gt;    (r"\\paragraph{(.*)}", "==== %s ====", dummy),&lt;br /&gt;    (r"\\subsubsection{(.*)}", "==== %s ====", dummy),&lt;br /&gt;    (r"\\subsection{(.*)}", "=== %s ===", dummy),&lt;br /&gt;    (r"\\section{(.*)}", "== %s ==", dummy),&lt;br /&gt;    (r"(.*)\\fig{.*}(.*)", "%s suivant %s", dummy)&lt;br /&gt;    ]&lt;br /&gt;&lt;br /&gt;in_stream  = open(sys.argv[1], "r")&lt;br /&gt;if len(sys.argv) &lt; 3:&lt;br /&gt;    out_stream = sys.stdout&lt;br /&gt;else:&lt;br /&gt;    out_stream = open(sys.argv[2], "w")&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;for i in in_stream.readlines():&lt;br /&gt;    cur_write = 0&lt;br /&gt;    for reg in tr_list:&lt;br /&gt;        m = re.search(reg[0], i)&lt;br /&gt;        if m:&lt;br /&gt;            reg[2](i)&lt;br /&gt;            cur_write = 1&lt;br /&gt;            if reg[1] == NONE:&lt;br /&gt;                break&lt;br /&gt;            print &gt;&gt; out_stream, reg[1] % m.groups()&lt;br /&gt;            break&lt;br /&gt;    if not cur_write:&lt;br /&gt;        out_stream.write(i)&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 17 Oct 2006 12:10:39 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2847</guid>
      <author>bugmenot (BugMeNot)</author>
    </item>
    <item>
      <title>Use the contents of a WordPress database in your Rails app</title>
      <link>http://snippets.dzone.com/posts/show/1314</link>
      <description>These two models can be used to access the posts and associated comments of a WordPress database.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class WpBlogComment &lt; ActiveRecord::Base&lt;br /&gt;&lt;br /&gt;  # if wordpress tables live in a different database (i.e. 'wordpress') change the following&lt;br /&gt;  # line to set_table_name "wordpress.wp_comments"&lt;br /&gt;  # don't forget to give the db user permissions to access the wordpress db&lt;br /&gt;  set_table_name "wp_comments"&lt;br /&gt;  set_primary_key "comment_ID"&lt;br /&gt;&lt;br /&gt;  belongs_to :post , :class_name =&gt; "WpBlogPost", :foreign_key =&gt; "comment_post_ID"&lt;br /&gt;&lt;br /&gt;  validates_presence_of :comment_post_ID, :comment_author, :comment_content, :comment_author_email&lt;br /&gt;  &lt;br /&gt;  def validate_on_create&lt;br /&gt;    if WpBlogPost.find(comment_post_ID).comment_status != 'open'&lt;br /&gt;      errors.add_to_base('Sorry, comments are closed for this post')&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;end &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class WpBlogPost &lt; ActiveRecord::Base&lt;br /&gt;&lt;br /&gt;  set_table_name "wp_posts"&lt;br /&gt;  set_primary_key "ID"&lt;br /&gt;&lt;br /&gt;  has_many :comments, :class_name =&gt; "WpBlogComment", :foreign_key =&gt; "comment_post_ID"&lt;br /&gt;&lt;br /&gt;  def self.find_by_permalink(year, month, day, title)&lt;br /&gt;    find(:first, &lt;br /&gt;         :conditions =&gt; ["YEAR(post_date) = ? AND MONTH(post_date) = ? AND DAYOFMONTH(post_date) = ? AND post_name = ?", year.to_i, month.to_i, day.to_i, title])&lt;br /&gt;  end&lt;br /&gt;end &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;</description>
      <pubDate>Mon, 30 Jan 2006 04:10:02 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1314</guid>
      <author>jazzido (Manuel Aristar&#225;n)</author>
    </item>
  </channel>
</rss>
