ruby

old ruby code for working with sugarcrm

Login and show basic info require 'soap/wsdlDriver' require 'digest/md5' u = "user" p = Digest::MD5.hexdigest("password") ua = {"user_name" => u,"password" => p} wsdl = "http://yoursite.com/soap.php?wsdl" #create soap s = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver #uncomment this line for debugging. saves xml packets to files #s.wiredump_file_base = "soapresult" #create session ss = s.login(ua,nil) #check for login errors if ss.error.number.to_i != 0 #status message puts "failed to login - #{ss.error.description}" #exit program exit else #get id sid = ss['id'] #get current user id uid = s.get_user_id(sid) #status message puts "logged in to session #{sid} as #{u} (#{uid}) " #logout s.logout(sid) #status message puts "logged out" end Adding an account After login, you can create new accounts using the code : module_name = "Accounts" ...

posted @ Sunday, March 15, 2009 8:01 PM | Feedback (1)

replacing carriage return

nothing fancy here, we're just doing a regex replace on \r and replacing it with nothing. this is a different way of doing the same thing dennis already posted here. =Pusing System.IO;using System.Text.RegularExpressions;namespace StripCR{     class Program    {         static void Main(string[] args)        {            nocr(args[0]);        }         public static void nocr(string f)        {             string t; ...

posted @ Tuesday, October 31, 2006 12:08 PM | Feedback (0)

parsing eml files with ruby

This is essentially the same thing, just with ruby code. Again, note that you can change that URL regular expression to match what you want to find in the email. i also split the file in half after the header and only searched the header for from/to/subject and the body for urls in this one. a slightly different approach. The point of this is really just to show how simple it is to setup the logic and where you can easily configure your regular expressions to tweak your results. As with most ruby code I write, there is probably a...

posted @ Thursday, October 26, 2006 11:18 AM | Feedback (1)