Burak Ozdemir 's Blog
Computer Science & Softwares - Latest Technology


Where people meet new technology !


Simple Text Editor with Java Swing

Programming 4 Comments »

Hi again, for this post I decided to demonstrate JAVA’s Swing library.With this library it is easy to create applications with GUI.Anyway I never prefer to write Windows applications in JAVA, however if you need cross-platform stuff, Swing may be a choice.Unlike awt, Swing looks like same in the all platforms. This simple Editor program, uses JMenuBar (Standard Menubar) , JToolBar (Standard Toolbar) , JDesktop (MDI) , Images for buttons , also Editor is capable of inserting images to the text. (StyledDocument).

Here is the source code:
Read the rest of this entry »

Perl and Regular Expressions

Programming No Comments »

perl-at-work-sign.png

Perl is one of the most rooted scripting languages, and has wide range of libraries for any purpose.Nowadays I’m studying it, and exploring its great usage and ease of use.Perl has powerful string processing ability, and also when you have confidence in using regular expressions, you may achieve anything on parsing.Here I want to demonstrate its simple syntax.

\t : Tab Character
\n : New Line
\r : Carriage Return
\f : Form Feed Character
\cX : Control Character CTRL-X.  : Match any one character
| : Alternation
( ) : Group  / Also returns the values for $1 , $2 , $3 after proper matches.
[ ] : Define Character class^ : Match the beginning       $ : Match the end
\b : Match at a ”word” boundary  \B : Match at not a ‘word’ boundary

* : Match 0 or more times
+ : Match at least 1 or more times
? : Match 0 or 1 times

\d : [0-9] A digit            \D : A non-digit
\s : Whitespace char       \S : A non-whitespace char.

/i : ignore case    /g : Match globally (all matches)      /s : Substitute, Replace

=~ True If the regex matches        !~ True If the regex doesn’t match

The above information will be helpful if you have just started to learn Regular Expressions.

Technorati Tags: , , , , ,

C# and Inline Assembly

Programming 1 Comment »

Inline assembly was a technique to use I386 assembly language directives in a C++ code. Programmers often use this technique to gain speed at intense calculations. However C# is far away from this concept, being lack of such a need, C# stands as a limited programming language against C++. According to some gossip, they are considering to add this in Whidbey.

However you may not want to wait for Whidbey, yes it is said to be there exist some solutions, (I heard this from one my programmer friend). Surprisingly the idea seems very interesting to me. The point is that you call assembly functions from a DLL, so the only thing that differs is coding, you just call some functions to make your calculations in machine language, and as a result. you acquire the indispensable augmentation in performance.

Never tried this method, but I will definitely try, in the following posts I may expose it with some code samples. Another important point that you may use this method in VB.NET also, as you can use the DLL in a same manner. Goodbye until to next post!

Technorati Tags: , , , , , , ,

.NET & MySQL - F(r)iends?

Programming No Comments »

Hi, in my previous post I discussed and compared IIS and ASP against PHP and Apache. In this post I’ll be discussing diffuculties about communicating with a MySQL database in ASP.NET on a shared hosting. As you know if you have a direct access to your web server, nothing is impossible but in most cases you can not.

For example, I am using GoDaddy’s shared hosting plans and I’m really happy with.However I am discovering the limits lately, and I am understanding what are you capable of to do with shared hosting using ASP.NET.Chances are that if you are using PHP, you have greater freedom and everything becomes possible.

Yesterday I was trying to connect to a MySQL database with .NET, I accomplished this on Windows very smoothly without having any problems.(I used ByteFX .NET library to connect MySQL).On the other hand, on Web, this is nearly impossible, you can not use external dlls on many of the shared hostings (security issue).I tried to use ODBC to connect MySQL, I didn’t use any DLLs and again I couldn’t connect to MySQL database (By the way this MySQL database is not on my shared hosting, on a completely different host), because thanks to GoDaddy, they have blocked outgoing connections to other database hosts.So I was only able to connect an inner MySQL database.You may ask why MySQL? Because you may not find free database hosts that give MSSql (there are lots of hosts that provides free MySQL databases), and also you may not have any other options other than MySQL, so in such a case your all hands are tied.

Briefly I am really considering to use PHP rather ASP.NET, day by day I discover something that is possible in all the way with PHP and not possible with ASP.NET.
This is really driving me nuts.As you see PHP gains another +1 against ASP.NET.See you next time…

Technorati Tags: , , , , , , , , ,

ASP.NET Url Rewrite - ASP.NET/IIS VS PHP/Apache

Programming No Comments »

Have you ever realized how difficult url rewrite can be in ASP.NET which is hosted in IIS?
If you are coding php and hosting it on an apache server, your job is pretty easy. You may just write appropriate
matchings for your urls ( this is typically done by regular expressions ) in htaccess file. However this is not just that easy on IIS. You may ask, why the subject contains “ASP.NET”, this is because IIS is just used to host ASP.NET in usual. You may host ASP.NET on your apache, but the hosting firms in the market do not use apache servers for ASP.NET. They use IIS.

Url rewriting can be made in few ways, with ISAPI modules, or you may configure IIS to direct .html or anyother extensions to ASP.NET dll. However you need to access your IIS server.If you are using a shared hosting like me :) , you may be disappointed but you should accept that you can only do url rewrites which ends in .aspx extension, because IIS directs .aspx extensions to asp.net dll, and your custom rewrites in your global.asax will run before IIS gives an “404 Not Found Error”.

Yes I hate .aspx/.php or any other extensions different than .html. Not only me prefer .html , but also Google prefers .html extensions, and most likely to index that pages.Briefly the same situation can happen if you host php on IIS (which is pretty a dumb action to do), as a result this is not related but .NET, but again If we consider php/apache bros. they gain +1 against asp.net/IIS .

Technorati Tags: , , , ,

Win32 API Introduction

Programming No Comments »

A small win32 application code that was taken from http://www.winprog.org/tutorial/ . Great win32 tutorial for beginners, nowadays I am interested in win32 api programming and found this site from google, here the code piece:

#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
MessageBox(NULL, “Goodbye, cruel world!”, “Note”, MB_OK);
return 0;
}

Yes, this is a way of saying “Hello World” in win32 api :)
Maybe I’ll add some small tools in the future if I can learn, it is pretty hard and complicated.

Tags: ,

MPI - Parallel Bubble Sort

Programming 2 Comments »

Below I am giving VC++ project file (utilizing MPI) of a parallelized bubble sort algorithm, you may find it useful, there are message passings between master and slave tasks, also there are some functions like merge, bubblesort and swap.

Download 9 KB

First Order Logic Parser

Programming, Computer Science No Comments »

Finally after a week or so, I am ready to put the parser for download. I want to clarify some points, actually I used the word “parser” to intend syntax checking, it is not a complete parser, it just checks first order logic syntax, so not a big deal ! Be aware that code may contains error(s), I am not saying it is perfect, it is just a piece of code that I wrote for my Automata Lecture project. So the code gives just a simple idea about how syntax checking done iteratively. The rar archive contains a fol.txt besides main.cpp (single source file) , all predicates, functions, variables, constants, simply all our language defined in this text file.You may change some values while some must remain as it is. After compiling the source file, put fol.txt in the same directory with compiled .exe.

Download Source File(2.80 KB)

Sorting Algorithms

Programming No Comments »

In this post, I am here to give you pseudo codes of basic sorting algorithms, I gathered all of them in one place, there are 8 different sorting algorithms, some of them may perform than the others, if you are interested in sorting algorithms, you should search for complexity analysis of each one to understand the differences between them.

Threading in C#

Programming No Comments »

What is Threading?
-Parallel execution of code pieces on CPU, commonly compiled codes started in a single thread but it is possible to create multi-threads within a program.

Why Threading?
-Because threading is really useful, and it is used in nearly all kind of serious softwares, threads enables us to do independent jobs simultaneously, and it is sometimes hard to handle, if it is done with experienced hands, it enhances the software greatly. I want to give a simple example, consider you want your program to check for available updates and install them without interrupting the user’s work. This is only done with threads, while user working with your software, another thread connects to Internet and checks available updates without blocking the current execution of the software.

A simple threading example with C# :

Thread test_thread;

public void Thread_Task()
{
for(int i=0;i<100:++i)
TextBox1.Text=Convert.ToString(i);
}
private void button1_Click(object sender, EventArgs e)
{
test_thread=new Thread(new ThreadStart(this.Thread_Task));
test_thread.IsBackground = true;
test_thread.Start();
}

In the above simple code piece, we created a thread object and a thread task function, then we assigned task function to thread object in a button_click function, then we started the thread, as you notice, if user clicks the button a new thread starts and show the value of i in the TextBox1 without blocking the program, user may continue working and at the same time values of i are showed in the TextBox1. This was a sample example to demonstrate threads created and used, besides there is a vast usage and restrictions for threads, for example there will be a problem what if two threads wants to access the same resource and wants to edit, there are lots of synchronization problems and techniques.

Copyright Protected ©2007 http://www.buraak.com
Contact info : <burak [at] buraak [dot] com>
Entries RSS Comments RSS Login
eXTReMe Tracker

Privacy Policy