Archive for the 'Programming' Category
Sunday, May 27th, 2007
I was working on a module for an application of mine, and I’ve been struggling and searching in order to come up with a Google PageRank detector. I came up with a cool and accurate solution and I would love to share it with you.
I uploaded a Java Web Start small application! Check it out here
Btw, Java Runtime Environment is required, get it from java.com
Edit: The source code is available here.
Stay tuned!
Wednesday, February 7th, 2007
Every now and then, I keep hearing people discussing the power of AJAX. First, let me explain in brief for those who don’t know about this technique:
What does AJAX stand for is Asynchronous Javascript And XML. This technique is being used frequently by WEB 2.0 designers to make cross browser website; the client can submit information without refreshing the whole page. But, is it really asynchronous? Well, for an application to be asynchronous, there should be replies without requests (you’ll get this idea better in a bit). In AJAX, there is no reply without request! It should be called SJAX (Synchronous JavaScript And XML). For the Javascript part, it’s simple! it is the only way to have a light weight client side (instead of Flash, Java Applets or ActiveX Apps). XML (Extended Markup Language) should not be a big deal since the functions used for AJAX do not require XML.
Is AJAX really powerful? (more…)
Monday, January 15th, 2007
Hello there,
Have you ever tried to upload a file with php on IIS? or maybe just copy or create a file on a certain folder? Well, I’ve been trying to do that for a while, but it was returning:
Warning: [function] - Permission denied in [my code].
On Windows Server 2003, it’s not an issue and the user can figure out the solution easily by opening the properties of the folder and working with the security tab which I’ll explain later on.
On the other hand, Windows XP users have that security tab hidden. I kept on unchecking the Read-Only, but it was rechecked automatically! The trick is to show the Security Tab in the properties window of the folder. (more…)
Friday, October 6th, 2006
Hello Geek Friends,
Google Inc. is introducing a new search service that only a geek could love.
The Web search leader said late on Wednesday it is introducing Google Code Search, a site that simplifies how software developers search for programming code to improve existing software or create new programs.
Google product manager Tom Stocky said the Mountain View, California-based company is set to help programmers sift through billions of lines of computer source code using its familiar search box to uncover snippets of reusable software.
Give it a shot: http://www.google.com/codesearch
Thursday, September 7th, 2006
As usual I want to share the solutions for my coding problems! I’m sure many of you tried to resize images with Java to make thumbnails for example or to fit some images and logos in a game or just to create an animation…
Anyway, while I was working on a project of mine “DPMagnifier” (Display Picture Magnifier), I had to resize images to a fixed size of 96×96 the same way MSN Messenger does. I checked the Java Documentation, and found out that have implemented some Rendering algorithms. The best algorithm to resize a large image into a small one is the Bicubic! So there was some rendering hints like RenderingHints.VALUE_INTERPOLATION_BICUBIC. but too bad, Java people did not implement this resizing algorithm well! I tried it and it was just the same like the Bilinear algorithm. So enough talking about the issue… here’s the solution:
BufferedImage temp = javax.imageio.ImageIO.read(new File(imagefile));
/* determine thumbnail size from WIDTH and HEIGHT */
int thumbWidth = width;
int thumbHeight = height;
int imageWidth = temp.getWidth(null);
int imageHeight = temp.getHeight(null);
int tempWidth;
int tempHeight;
int x = 0;
int y = 0;
if (imageWidth < imageHeight) {
tempWidth = width;
tempHeight = (int)(((double)imageHeight*width)/imageWidth);
y = -(tempHeight - tempWidth)/2;
}
else {
tempHeight = height;
tempWidth = (int)(((double)imageWidth*height)/imageHeight);
x = -(tempWidth - tempHeight)/2;
}
Image temp1 = temp.getScaledInstance(tempWidth, tempHeight, Image.SCALE_SMOOTH);
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
image.getGraphics().drawImage(temp1, x, y, null);
try {
javax.imageio.ImageIO.write(image, "png", new File("output.png"));
} catch (IOException e) {
e.printStackTrace();
}
If you have a better solution… or maybe you have implemented a better resizing function, write a comment and share it with us!
Cheers…
Thursday, June 29th, 2006
When I was developing phpLiveTalk, I wanted to send some URL encoded text in the AJAX response. I encoded the text using urlencode() php function, but the decoding on the client side (JavaScript) was an issue!
Why?
The JavaScript unescape() function does not understand the ‘+’ (Plus) in the encoding of ‘ ‘ (Space). Actually, it should be %20. So why not replacing all the + with %20 then unescape()!!!
Bingo… Solved.
Here’s the code you may use:
message = unescape(replaceAll(message,'+‘,’%20‘));
function replaceAll( str, from, to ) {
var idx = str.indexOf( from );
while ( idx > -1 ) {
str = str.replace( from, to );
idx = str.indexOf( from );
}
return str;
}
Good Luck!
Friday, June 23rd, 2006
When I was working on phpLiveTalk, I decided to have a background for the text inputs in forms. I couldn’t find a decent hack to make it work on both IE and Mozilla! So I came out with a solution! Here it is:
input[type="text"], input[type="password"], input[type="file"] {border: solid 1px #336699;
color: #336699;
background-image: url('images/input-text-bg.png');
}
/* this is for IE */
input {
border: expression(this.type=="text" || this.type=="password" || this.type=="file" ? "solid 1px #336699" : "this.border");
color: expression(this.type=="text" || this.type=="password" || this.type=="file" ? "#336699" : "this.color");
_background-image: none;
_background-image: expression(this.type=="text" || this.type=="password" || this.type=="file" ? "url('theme/default/images/input-text-bg.png')" : "this.background-image");
}
Working perfectly…
Friday, June 9th, 2006
As a java developer, I’ve been using Intellij IDEA IDE for about 3 years to manage my java projects. I was quite happy and satisfied with this environment. As a web developer, I’ve been using Macromedia Dreamweaver and it wasn’t bad at all!!!
Suddenly I decided to try Eclipse IDE! WoW is the least I can say. My java and php projects were scrambled… I needed a common environment for all my projects, from web to desktop java applications. Eclipse did the job! PHPEclipse plugin is really great…
If you’re a Java, C++, C#, php, etc… developer make sure you try Eclipse… IT REALLY ROCKS!!
I’m in the middle of my exams, See you soon guys!!
Saturday, April 22nd, 2006
Since there isn’t actually a vb.net addin implementation available out there, i decided to give you a commented sample, here we go :
Imports System
Imports Microsoft.Messenger
Public Class MAR Implements IMessengerAddIn
Private WithEvents Mess As MessengerClient
Public Sub Initialize(ByVal messenger As Microsoft.Messenger.MessengerClient) Implements Microsoft.Messenger.IMessengerAddIn.Initialize
Mess = messenger ‘Set The Object
messenger.AddInProperties.Creator = “Mario Achkarâ€
messenger.AddInProperties.Description = “MAR UNofficial Messenger Addinâ€
messenger.AddInProperties.FriendlyName = “Mario’s Addin Beta 1.0″
End Sub
Private Sub Mess_IncomingTextMessage(ByVal sender As Object, ByVal e As Microsoft.Messenger.IncomingTextMessageEventArgs) Handles Mess.IncomingTextMessage
If (Mess.LocalUser.Status = UserStatus.Away) then
Mess.SendTextMessage(String.Format(â€I’m Away {0} ({1}) - Please Leave A Message!â€, e.UserFrom.Email, e.UserFrom.FriendlyName), e.UserFrom)
End if
End Sub
Quite Easy Huh? Enjoy! Wanna Try An Already Made Addin? Click Here
Friday, April 21st, 2006
Many of you tried, searched or just thought about making a pluggin for MSN Messenger… The good news is that MSN Messenger team has made life easier for Add-ins developpers.
MessengerClient.dll API was added to the MSN Messenger folder since the version 8.0.0683.00, you can download it from here. Before starting to develop anything, you have to enable the Add-ins options with this messenger version because microsoft were trying to hide it. So here’s how you show the option:
Start / Run / “regedit”, in the registery browse to HKEY_CURRENT_USER/Software/Microsoft/MSN Messenger/ then add a DWORD (name: AddInFeatureEnabled and value: 1)…
Restart MSN Messenger, and sign in… now the Add-ins option has been enabled in the options…
The next step to do is start developping the add-in… Since I’m a java developer, C# is a good language to program with! I recommend it so bad!
Have you got your IDE? Visual Studio? Here’s SharpDevelop a free software for developing in C# and VB.Net : Click here to download.
Is it time to start coding? hell yea!!
1st of all you have to add reference to the MessengerClient.dll which is found in the new MSN Messenger folder! (Notice for java freaks: Adding reference to a .dll with .Net is like mounting a .jar file to your java project and importing it)
Let’s Start Coding…
The following code a small add-in which sends an Away message to everyone who’s trying to message you while you’re Away…
using System;
using Microsoft.Messenger;
public class EPLUGIN : IMessengerAddIn
{
private MessengerClient messenger;
public void Initialize(MessengerClient messenger)
{
this.messenger = messenger;
messenger.AddInProperties.Creator = “ElectroSoft”;
messenger.AddInProperties.Description = “Away Messenger”;
messenger.IncomingTextMessage += new EventHandler(this.OnIncomingMSG);
}
private void OnIncomingMSG(object sender, IncomingTextMessageEventArgs args)
{
if (messenger.LocalUser.Status == UserStatus.Away)
{
this.messenger.SendTextMessage(”I’m away… Leave a message… [Plugin by Elie Khoury]”, args.UserFrom);
}
}
}
As you noticed: you have to implement the IMessengerAddIn Interface… which requires you to implement the “public void Initialize(MessengerClient messenger)” function…Happy Coding… send comments guys… I’m sure there are enough things to add!
|
|