Vertical Marquee Banner

I was supposed to create randomize rotated ads banner with javascript. But it's not quite alright and not have enough performance to all browsers. That's why I considered to do this small function with old-fashioned coding which is marquee tag. Because we shouldn't stick in attemption for serveral times when we're solving and finding bugs. That's why I decided to do with marquee tag and save my time. It's quite easy and flexiable to all browser but it's awful that before page is completely loaded by browser if banners images are more than 10 images.

view plain print about
1<marquee direction="up" onmouseover="this.stop()" onmouseout="this.start()" scrollDelay="200" width="200">
2<a href="advfile.cfm/adv/flexanew" target="_blank"><img src="misspeople_sponsors/platinum_1.jpg" /></a>
3<a href="advfile.cfm/adv/alpine" target="_blank"><img src="misspeople_sponsors/platinum_2.jpg" /></a>
4<a href="advfile.cfm/adv/silk-n-shine" target="_blank"><img src="misspeople_sponsors/platinum_3.jpg" /></a>
5<a href="advfile.cfm/adv/perfectil" target="_blank"><img src="misspeople_sponsors/platinum_4.jpg" /></a>
6<a href="advfile.cfm/adv/smooth-e" target="_blank"><img src="misspeople_sponsors/platinum_5.jpg" /></a>
7<a href="advfile.cfm/adv/lily" target="_blank"><img src="misspeople_sponsors/platinum_6.jpg" /></a>
8<a href="advfile.cfm/adv/ogawa" target="_blank"><img src="misspeople_sponsors/platinum_7.jpg" /></a>
9<a href="advfile.cfm/adv/dodokoko" target="_blank"><img src="misspeople_sponsors/platinum_8.jpg" /></a>
10<a href="advfile.cfm/adv/vista" target="_blank"><img src="misspeople_sponsors/platinum_9.jpg" /></a>
11<a href="advfile.cfm/adv/tri" target="_blank"><img src="misspeople_sponsors/platinum_10.jpg" /></a>
12</marquee>

How to Embed MP3 Audio Files In Web Pages

I'm not kinda happy in these days. Because my server is spontaneously crushed whenever visiting users are building up. I feel it might be because of stream section of our website called "Music Portal". As we all know, all of over people away from mother land miss the sounds of our native land such as music, movies, articles and so on. That's why 70% of our customers are listening songs from our websites make our server to be in crush. Being developers of site, I gotta solve this problem and prevent not to crush our server again.

I embed window media player for listening songs from our site. How about flash media player instead of window media player? Embed flash media player in website can reduce bandwidth? I'm in delimma in such questions. So, I try seeking embed flash media player in Google. Fortunately, I've found this website providing developers to putting flash media player in their websites. It's kinda cool and I've embed it in our website already. The one I need is to compare server load is going as usual or gradually decreased.

Best Credit to : http://www.labnol.org/internet/design/html-embed-mp3-songs-podcasts-music-in-blogs-websites/2232/

Coldfusion Captcha

In these days, sending spam messages programs are building up and they are now the big challenge for website developers. That's why some websites prevent this bots by the way of installing captcha program in their site. For coldfusion developer, I'll describe how to prevent spam bots. Here is coding:

Captcha.cfc

view plain print about
1<cfcomponent name="Captcha" hint="Writes the captcha to a file">
2    <cfscript>
3        instance = StructNew();
4    
</cfscript>
5    <!--- PUBLIC --->
6    <cffunction name="init" hint="Constructor" access="public" returntype="Captcha" output="false">
7        <cfscript>
8        return this;
9        
</cfscript>
10    </cffunction>
11    <cffunction name="captchaToFile" hint="Writes the captcha to the designated file path" access="public" returntype="void" output="false">
12        <cfargument name="filePath" hint="The absolute path to the file the CAPTCHA is to be written to" type="string" required="Yes">
13        <cfargument name="text" hint="The text to display" type="string" required="Yes">
14        <cfargument name="width" hint="The width of the image" type="numeric" required="true">
15        <cfargument name="height" hint="The height of the image" type="numeric" required="true">
16        <cfargument name="fontsize" hint="The font size the text" type="numeric" required="true">
17        <cfargument name="leftOffset" hint="The number of pixels of padding to put to the left of the text" type="numeric" required="true">
18        <cfargument name="topOffset" hint="The number of pixels of padding to put to the top of the text" type="numeric" required="true">
19        <cfargument name="shearXRange" hint="The amount to shear the font on the X axis" type="numeric" required="true">
20        <cfargument name="shearYRange" hint="The amount to shear the font on the Y axis" type="numeric" required="true">
21        <cfscript>
22            var fileOutputStream = createObject("java", "java.io.FileOutputStream").init(arguments.filePath);
23            writeToStream(fileOutputStream,
24             arguments.text,
25             arguments.width,
26             arguments.height,
27             arguments.fontsize,
28             arguments.leftOffset,
29             arguments.topOffset,
30             arguments.shearXRange,
31             arguments.shearYRange);
32         fileOutputStream.flush();
33         fileOutputStream.close();
34        
</cfscript>
35    </cffunction>
36    <cffunction name="captchaToBinary" hint="Returns the captcha as binary data for use in the cfcontent 'variable' attribute" access="public" returntype="any" output="false">
37        <cfargument name="text" hint="The text to display" type="string" required="Yes">
38        <cfargument name="width" hint="The width of the image" type="numeric" required="true">
39        <cfargument name="height" hint="The height of the image" type="numeric" required="true">
40        <cfargument name="fontsize" hint="The font size the text" type="numeric" required="true">
41        <cfargument name="leftOffset" hint="The number of pixels of padding to put to the left of the text" type="numeric" required="true">
42        <cfargument name="topOffset" hint="The number of pixels of padding to put to the top of the text" type="numeric" required="true">
43        <cfargument name="shearXRange" hint="The amount to shear the font on the X axis" type="numeric" required="true">
44        <cfargument name="shearYRange" hint="The amount to shear the font on the Y axis" type="numeric" required="true">
45            <cfscript>
46            var byteOutputstream = createObject("java", "java.io.ByteArrayOutputStream").init();
47            writeToStream(byteOutputstream,
48             arguments.text,
49             arguments.width,
50             arguments.height,
51             arguments.fontsize,
52             arguments.leftOffset,
53             arguments.topOffset,
54             arguments.shearXRange,
55             arguments.shearYRange);
56                return byteOutputstream.toByteArray();
57            
</cfscript>
58    </cffunction>
59    
60    <cffunction name="writeToStream" hint="Writes to a outputStream" access="private" returntype="void" output="false">
61        <cfargument name="outputStream" hint="Gimme a java.io.OutputStream" type="any" required="Yes">
62        <cfargument name="text" hint="The text to display" type="string" required="Yes">
63        <cfargument name="width" hint="The width of the image" type="numeric" required="true">
64        <cfargument name="height" hint="The height of the image" type="numeric" required="true">
65        <cfargument name="fontsize" hint="The font size the text" type="numeric" required="true">
66        <cfargument name="LeftOffset" hint="The number of pixels of padding to put to the left of the text" type="numeric" required="true">
67        <cfargument name="TopOffset" hint="The number of pixels of padding to put to the top of the text" type="numeric" required="true">
68        <cfargument name="shearXRange" hint="The amount to shear the font on the X axis" type="numeric" required="true">
69        <cfargument name="shearYRange" hint="The amount to shear the font on the Y axis" type="numeric" required="true">
70        <cfscript>
71            /* variables */
72            var counter = 0;var characters = 0;var top = 0;
73            var len = 0;var size = 0;var left = 0;
74            var response = 0;var char = 0;var encoder = 0;
75            var encoderParam = 0;
76            /* utils */
77            var staticArrays = createObject("java", "java.util.Arrays");
78            var staticCollections = createObject("java", "java.util.Collections");
79            /* prep image */
80            var dimension = createObject("java", "java.awt.Dimension").init(width, height);
81            var imageType = createObject("java", "java.awt.image.BufferedImage").TYPE_INT_RGB;
82            var bufferedImage = createObject("java", "java.awt.image.BufferedImage").init(JavaCast("int", dimension.getWidth()), JavaCast("int", dimension.getHeight()), imageType);
83            var graphics = bufferedImage.createGraphics();
84            /* get the fonts */
85            var allFonts = staticArrays.asList(createObject("java", "java.awt.GraphicsEnvironment").getLocalGraphicsEnvironment().getAllFonts());
86            /* drawing graphics here */
87            /* background */
88            var startColor = createRandomLightGreyScaleColor();
89            var endColor = createRandomLightGreyScaleColor();
90            var gradientPaint = createObject("java", "java.awt.GradientPaint").init(getRandomPointOnBorder(dimension),
91            startColor,
92            getRandomPointOnBorder(dimension),
93            endColor);
94            var background = createObject("java", "java.awt.Rectangle").init(dimension);
95            graphics.setPaint(gradientPaint);
96            graphics.fill(background);
97            /* draw some lines */
98            len = randRange(10, 20);
99            for(counter = 1; counter lte len; counter = counter + 1)
100            {
101                drawRandomLine(graphics, dimension);
102            }
103            /* draw the text in random font characters */
104            characters = text.toCharArray();
105            len = ArrayLen(characters);
106            size = fontsize;
107            top = topOffset;
108            left = Leftoffset;
109            staticCollections.shuffle(allFonts);
110            for(counter = 1; counter lte len; counter = counter + 1)
111            {
112                char = characters[counter];
113                setNewFont(graphics, allFonts, size, arguments.shearXRange, arguments.shearYRange);
114                graphics.setColor(createRandomDarkGreyScaleColor());
115                //if cannot display, find a font that can
116
                while(NOT graphics.getFont().canDisplay(char))
117                {
118                    setNewFont(graphics, allFonts, size, arguments.shearXRange, arguments.shearYRange);
119                }
120                graphics.drawString(JavaCast("string", char), JavaCast("int", left), JavaCast("int", top));
121                left = left + (2 * graphics.getFontMetrics().charWidth(char));
122            }
123                len = randRange(2, round(max(min(width, height) / 20, 3))); //draw more lines the bigger it is.
124
            for(counter = 1; counter lte len; counter = counter + 1)
125            {
126                drawRandomLine(graphics, dimension);
127            }
128             encoder = createObject("java", "com.sun.image.codec.jpeg.JPEGCodec").createJPEGEncoder(arguments.outputstream);
129             encoderParam = encoder.getDefaultJPEGEncodeParam(bufferedImage);
130             encoderParam.setQuality(JavaCast("float", 0.80), false);
131         encoder.setJPEGEncodeParam(encoderParam);
132         encoder.encode(bufferedImage);
133        
</cfscript>
134    </cffunction>
135
136    <cffunction name="createRandomLightGreyScaleColor" hint="Creates a random greyscale java.awt.colour" access="private" returntype="any" output="false">
137        <cfscript>
138            var shade = JavaCast("int", RandRange(255, 160));
139            var color = createObject("java", "java.awt.Color").init(shade, shade, shade);
140            return color;
141        
</cfscript>
142    </cffunction>
143    
144    <cffunction name="createRandomDarkGreyScaleColor" hint="Returns a dark greyscale java.awt.color" access="private" returntype="any" output="false">
145        <cfscript>
146            var shade = JavaCast("int", RandRange(0, 100));
147            var color = createObject("java", "java.awt.Color").init(shade, shade, shade);
148            return color;
149        
</cfscript>
150    </cffunction>
151    
152    <cffunction name="getRandomPointOnBorder" hint="Gets a random java.awt.Point on the border" access="private" returntype="any" output="false">
153        <cfargument name="dimension" hint="The dimension object" type="any" required="Yes">
154        <cfscript>
155            var point = createObject("java", "java.awt.Point");
156            var height = Javacast("int", arguments.dimension.getHeight());
157            var width = JavaCast("int", arguments.dimension.getWidth());
158            var choice = randrange(1,4);
159            switch (choice)
160            {
161            case 1: //left side
162
            point.setLocation(JavaCast("int", 0), JavaCast("int", RandRange(0, height)));
163            break;
164            case 2: //top side
165
            point.setLocation(JavaCast("int", RandRange(0, width)), JavaCast("int", 0));
166            break;
167            case 3: //right side
168
            point.setLocation(width, RandRange(0, height));
169            break;
170            case 4://bottom side
171
            point.setLocation(RandRange(0, width), height);
172            break;
173            }
174            return point;
175        
</cfscript>
176    </cffunction>
177
178
179    <cffunction name="setNewFont" hint="Sets a new font in the graphics lib" access="private" returntype="void" output="false">
180        <cfargument name="graphics" hint="The graphics" type="any" required="Yes">
181        <cfargument name="fontCollection" hint="The current font collection" type="any" required="Yes">
182        <cfargument name="size" hint="The size of the font" type="numeric" required="Yes">
183        <cfargument name="shearXRange" hint="The shear x range" type="numeric" required="Yes">
184        <cfargument name="shearYRange" hint="The shear y range" type="numeric" required="Yes">
185        <cfscript>
186            var font = 0;
187            var staticCollections = createObject("java", "java.util.Collections");
188            
189            staticCollections.rotate(arguments.fontCollection, 1);
190            //apply transform twice, just for fun
191
            font = arguments.fontCollection[1].deriveFont(JavaCast("float", arguments.size)).deriveFont(getRandomTransformation(arguments.shearXRange, arguments.shearYRange)).deriveFont(getRandomTransformation(arguments.shearXRange, arguments.shearYRange));
192            arguments.graphics.setFont(font);
193        
</cfscript>
194    </cffunction>
195
196    <cffunction name="getRandomTransformation" hint="Gets a random transformation" access="private" returntype="any" output="false">
197        <cfargument name="shearXRange" hint="The shear x range" type="numeric" required="Yes">
198        <cfargument name="shearYRange" hint="The shear y range" type="numeric" required="Yes">
199        <cfscript>
200            //create a slightly random affine transform
201
            var transformation = createObject("java", "java.awt.geom.AffineTransform").init();
202            var shearx = RandRange(-1 * arguments.shearXRange, arguments.shearXRange) / 100;
203            var sheary = RandRange(-1 * arguments.shearYRange, arguments.shearYRange) / 100;
204            transformation.shear(shearx, sheary);
205            return transformation;
206        
</cfscript>
207    </cffunction>
208
209    <cffunction name="drawRandomLine" hint="draws a random line" access="private" returntype="void" output="false">
210        <cfargument name="graphics" hint="The graphics" type="any" required="Yes">
211        <cfargument name="dimension" hint="The dimension object" type="any" required="Yes">
212        <cfscript>
213            var point1 = getRandomPointOnBorder(arguments.dimension);
214            var point2 = getRandomPointOnBorder(arguments.dimension);
215            var staticColor = createObject("java", "java.awt.Color");
216            arguments.graphics.setColor(staticColor.white);
217            arguments.graphics.drawLine(
218            JavaCast("int", point1.getX()),
219            JavaCast("int", point1.getY()),
220            JavaCast("int", point2.getX()),
221            JavaCast("int", point2.getY()));
222        
</cfscript>
223    </cffunction>
224</cfcomponent>

To include your CFM file in like that: It make "random text and print it onto Captcha Image"

view plain print about
1<cfset ststring=structNew()>
2<cfloop index="i" from="1" to="6" step="1">
3 <cfset a = randrange(48,122)>
4 <cfif (#a# gt 57 and #a# lt 65) or (#a# gt 90 and #a# lt 97)>
5 <cfset ststring["#i#"]="E">
6 <cfelse>
7 <cfset ststring["#i#"]=#chr(a)#>
8 </cfif>
9</cfloop>
10<cfset randtext_captcha="#ststring[1]##ststring[2]##ststring[3]##ststring[4]##ststring[5]##ststring[6]#">
11<cfscript>
12    captcha = createObject("component", "Captcha").init();
13    captcha.captchaToFile(expandPath("captcha.jpg"),"#randtext_captcha#",400,50,30,10,35,45,60);
14
</cfscript>
15<img src="captcha.jpg">

How? It's kinda easy, isn't it?

Big Credit: http://www.compoundtheory.com/

passed to log scan mssql 2000

I was dilemma last weekend. Now that our server has faced such error message "passed to log scan" while attaching database with MS.SQL 2000 enterprise manager. For this case, I was stack on this error and trying to get data from *.mdf file on anyway like seeking in Google. Fortunately, I've found www.ureader.com pointing out these kinda error message, how to solve it.

I did the instruction of this blog. But, it was not fine and showed my database is marked as Emergency mode. At that time, I have had an idea to retrieve the included datas from *.mdf with by the way of using SQL Query Analyzer. Thanks God. Cause I can retrieve all included data by Query Analyzer but one left is how to migrate the data from the database marked as Suspend mode to another new database. I was supposed to set all data into text output with Query Analyzer or something else. But, anything would be ok. Finally, I've create black database and using follow query string to migrate new database as to recover my database.

view plain print about
1SELECT * INTO NewTable FROM existingdb.dbo.existingtable

Best Credit to :http://www.ureader.com/msg/1145136.aspx http://snippets.dzone.com/posts/show/372

Planet Valentine2009 and Academy 2007

I've implemented two featured sites on Planet Myanmar Website in these days. One is Valentine2009 and another one is Academy2007. As my style, I've implemented these two as database-less as much as it could be. As we all know, it's so complicated to do guestbook function with database-less knowledge. I didn't tell that we cannot do guestbook application as database-less knowledge.

Planet Academy

Planet Valentine

File upload with ColdFusion Flash Form

I was thinking about the benefit of uploading files with flash form can reduce bandwidth than using HTML file upload tag. Because upload files with flash form may have risk about the users which don't have flash player. Anyhow, I can say that uploading flash form is more faster than others like ajaxupload, java applet and so on. In this function, we can dynamically check the size of uploaded file and file type as soon as users browse. And, we can show dynamically uploading progress to user how much his/her file is being uploaded on our server. I can say uploading file with flash form have less risk than using html form upload tag.

Big Credit to : http://www.asfusion.com/blog/entry/file-upload-with-coldfusion-flash-forms

MissPeople2008 is launched

We have launched misspeople2008. In this page, I've created it with database less, except Forum. For this page, I've tried my best and added new features even thought these are not included in Planet.com.mm. These are Image Captcha, to generate randomize words and so on.

 

Miss People 2008

 

Go and visit MissPeople2008 official site http://www.people.com.mm/misspeople2008/

Top of Page