This is a conversion of my original .Net No SPAM email trick where an email address get retreived via an AJAX call.
This sample uses PHP 5 OOP with the JQuery library written using Netbeans 6.5 IDE.
Get it here.
Saturday, March 28, 2009
Monday, March 23, 2009
Weekly Source Code: The Art Of Debugging In MS Visual Studio.Net
Bruno Terkaly wrote 11 lessons (more to come) on the art of debugging in MS Visual Studio.Net 2008. Very interesting and a must read to catch some tips! Did you know that MS Visual Studio.Net can debug Javascript? :-)
Visit his blog for the 11 lessons or this list that list the first 10 lessons.
Have fun!
Visit his blog for the 11 lessons or this list that list the first 10 lessons.
Have fun!
Saturday, March 14, 2009
Weekly Source Code: Ruby Setting Utility Class
Its a general task to store application settings so I wrote my own for the Ruby programming language
How to use:
Save the SettingUtil.rb file so that your application code can find it.
Add:
require 'SettingsUtil'
include SettingUtil
Save Example:
require 'SettingsUtil'
include SettingUtil
setting = Settings.new # create the settings object
setting.values = {"jabber_notifyme" => "true", "jabber_jid" => "lenniedg@gmail.com", "jabber_password" => "", "jabber_to" => "lenniedg@gmail.com"}
setting.save
puts setting.jabber_to
to save you need to set the values accessor which is a hashset then call the save method.
Load Example:
require 'SettingsUtil'
include SettingUtil
setting = Settings.new
puts setting.values["jabber_to"]
when creating a new object of Settings (remember its in the SettingUtil module) it will load the previous saved settings else you can just call load method directly.
Note:
There are 2x ways to get the settings value:
puts setting.jabber_to
OR
puts setting.values["jabber_to"]
in both cases it reads the setting of "jabber_to" from the values hashset.
If it can't find the setting the first option will return "none" by default where the second option will return a nil reference.
By default it save settings into a settings.config file, you might want to change that if you wish.
The source:
#
# Store application settings
# Settings get marchalled to a file and then loaded, you can refer to settings
# by getting them from the values accessor directly or calling a method
#
# Author: Lennie De Villiers
# Created: 12/03/2009
module SettingUtil
SettingsFileName = "settings.conf" # constant with the file name
attr_accessor :values
class Settings
def initialize()
values = {}
load()
end
def load()
if File.exists?(SettingsFileName)
f = open(SettingsFileName)
temp = Marshal.load(f)
self.values = temp.values
end
end
def save()
open(SettingsFileName, "w") { |f| Marshal.dump(self, f) }
end
def method_missing(method_name, *args)
if values != nil && values.key?(method_name.to_s)
return values[method_name.to_s]
else
return "none"
end
end
end
end
How to use:
Save the SettingUtil.rb file so that your application code can find it.
Add:
require 'SettingsUtil'
include SettingUtil
Save Example:
require 'SettingsUtil'
include SettingUtil
setting = Settings.new # create the settings object
setting.values = {"jabber_notifyme" => "true", "jabber_jid" => "lenniedg@gmail.com", "jabber_password" => "", "jabber_to" => "lenniedg@gmail.com"}
setting.save
puts setting.jabber_to
to save you need to set the values accessor which is a hashset then call the save method.
Load Example:
require 'SettingsUtil'
include SettingUtil
setting = Settings.new
puts setting.values["jabber_to"]
when creating a new object of Settings (remember its in the SettingUtil module) it will load the previous saved settings else you can just call load method directly.
Note:
There are 2x ways to get the settings value:
puts setting.jabber_to
OR
puts setting.values["jabber_to"]
in both cases it reads the setting of "jabber_to" from the values hashset.
If it can't find the setting the first option will return "none" by default where the second option will return a nil reference.
By default it save settings into a settings.config file, you might want to change that if you wish.
The source:
#
# Store application settings
# Settings get marchalled to a file and then loaded, you can refer to settings
# by getting them from the values accessor directly or calling a method
#
# Author: Lennie De Villiers
# Created: 12/03/2009
module SettingUtil
SettingsFileName = "settings.conf" # constant with the file name
attr_accessor :values
class Settings
def initialize()
values = {}
load()
end
def load()
if File.exists?(SettingsFileName)
f = open(SettingsFileName)
temp = Marshal.load(f)
self.values = temp.values
end
end
def save()
open(SettingsFileName, "w") { |f| Marshal.dump(self, f) }
end
def method_missing(method_name, *args)
if values != nil && values.key?(method_name.to_s)
return values[method_name.to_s]
else
return "none"
end
end
end
end
Tuesday, March 10, 2009
Weekly Source Code: Twitter IM Notification
Twitter has become a very populare social website where you tell the world what your doing in 140 characters.
You can always follow me on Twitter
Since I've started to teach myself the Ruby dynamic programming language you can use this Ruby script to send yourself notification to Google Talk when a friend post a message to Twitter.
Steps:
1) Download Ruby
2) Install Ruby and setup a path to C:\Ruby\bin
3) Install the twitter gem: gem install twitter
4) Install the Jabber gem: gem install xmpp4r
5) Update the script by adding your Twitter username and password, Google Talk username (like lenniedg@gmail.com), password and notification address (like lenniedg@gmail.com)
6) run the script: ruby TwitterIMNotify_share.rb
I love Ruby! :)
You can always follow me on Twitter
Since I've started to teach myself the Ruby dynamic programming language you can use this Ruby script to send yourself notification to Google Talk when a friend post a message to Twitter.
Steps:
1) Download Ruby
2) Install Ruby and setup a path to C:\Ruby\bin
3) Install the twitter gem: gem install twitter
4) Install the Jabber gem: gem install xmpp4r
5) Update the script by adding your Twitter username and password, Google Talk username (like lenniedg@gmail.com), password and notification address (like lenniedg@gmail.com)
6) run the script: ruby TwitterIMNotify_share.rb
I love Ruby! :)
Friday, March 6, 2009
Write a Share Trading Bot Challenge
Programming can also be fun :-)
David Bolton from C/C++/C# About.com started a challenge where you must write a bot in C, C++ or C# where the bot must do share trading.
Visit the challenge webpage for more information.
David Bolton from C/C++/C# About.com started a challenge where you must write a bot in C, C++ or C# where the bot must do share trading.
Visit the challenge webpage for more information.
Thursday, March 5, 2009
Weekly Source Code: PHP - Email Address Images
Sorry ladies & gents that there wasn't a weekly source code last week, work was crazy.
On beds.co.za which is one of the websites I'm working on, you will notice that the email address for an accommodation is actually an image and that there is in the HTML no "mailto:" tag. This is one way to prevent spammers from grabbing your email address from a website by converting the email address to an image and then use my No SPAM email link functionality (that I must still port over from .Net to PHP)
Here's the code that create the image
the email address get stored in $emailAddressEntity, for example "lenniedg@gmail.com"
@imagecreate is the PHP method that create the image.
After this you can refer to the image
Resources:
@imagecreate
On beds.co.za which is one of the websites I'm working on, you will notice that the email address for an accommodation is actually an image and that there is in the HTML no "mailto:" tag. This is one way to prevent spammers from grabbing your email address from a website by converting the email address to an image and then use my No SPAM email link functionality (that I must still port over from .Net to PHP)
Here's the code that create the image
the email address get stored in $emailAddressEntity, for example "lenniedg@gmail.com"
@imagecreate is the PHP method that create the image.
After this you can refer to the image
Resources:
@imagecreate
Subscribe to:
Posts (Atom)