Skip to content

Instantly share code, notes, and snippets.

@in_item = false #are we in channel or item?
@link = [] #current link. becuase links and texts go together
line = gets
while(line)
if line =~ /<item>/
puts "<h2><a href=#{@link[0]}>#{escape(@link[1])}<\/a><\/h2>"
@in_item = true
elsif line =~ /<\/item>/
def to_xml
rtn = "<task>"
instance_variables.each do |i|
rtn += "<#{i[1..-1]}>#{instance_variable_get(i)}</#{i[1..-1]}>"
end
rtn += "</task>"
rtn
#"<task><id>#{@id}</id><name>#{@name}</name><desc>#{@desc}</desc><priority>#{@priority}</priority></task>"
end
function AddLink(item)
{
if(item.linkageExportForAS)
{
fl.outputPanel.trace(item.name + "-> currently linked");
return;
}
// split the string at the . to remove .png
function AddLink(item)
{
if(item.linkageExportForAS)
{
fl.outputPanel.trace(item.name + "-> currently linked");
return;
}
// split the string at the . to remove .png
def foo(bar, baz)
blah
blah
blah
end
compare with c equivalent:
<?php
/**
* @version $Id: user.php 14401 2010-01-26 14:10:00Z louis $
* @package Joomla
* @subpackage User
* @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant to the
* GNU General Public License, and as distributed it includes or is derivative
* of works licensed under the GNU General Public License or other free or open
<?php //code to get a joomla user from the database
$query = 'SELECT * FROM #__user WHERE name == "' . $this->article->params->get('user_to_find') . '"';
$db = $mainframe->getDBObject;
$db->setQuery($query,0,0);
$rows = $db->getObjectList();
@max_size = 0
def is_palindrome(str)
# puts " checking string #{str}"
rtn = true
i = 0
j = str.size-1
while(rtn && i<str.length && j >= 0)
puts " i,j: #{i},#{j}"
require 'mathn'
@min = 227000
@primes = [2,3,5,7,11]
@fibs = [1,1,2,3,5,8,13]
#fills @fibs until @fibs[-1] contains the first pribe fib greater than @min
def gen_fibs
#this code borrowed from the internet
class Array
# Returns the "power set" for this Array. This means that an array with all
# subsets of the array's elements will be returned.
def power
# the power set line is stolen from http://johncarrino.net/blog/2006/08/11/powerset-in-ruby/
inject([[]]) do |c,y|
r=[]
c.each do |i|
r<<i