Thursday, August 22, 2013

Adobe Illustrator [AI]

A project in collaboration with my classmate Catherine F. Palarca. Our instructor ask us to make our own monster create using AI, so we'd end up as shown in the picture. The names were based to surname or to type of animals (e.g Palcamon - Palca from Palarca and mon from digimon) (e.g Spidocs - Spid from spider and ocs from octopus). Please do rate our works. Thanks !

AI 1.0: Palcamon

AI 2.0: Spidocs

Upload File using move_uploaded_file() function in Php and MySQL as Db

Uploading file and save it directly to your database is okay but not advisable (in my opinion) because the more you upload your file and save to your db, the higher the risk your database will get an error or any up to the peak that your db might give up. So, I advise to use the file's location only and be save to your database. Where will your file be save? Simple, your file will be save inside the htdocs (e.g /htdocs/myuploaded/file.txt  <-- complete path to your file).

The logic is that, you use the upload form in html, once you select a file and click the button upload, you must get the tmp_name of the file, the designated folder where you want your file be save and perform the  move_uploaded_file() function. The code below is the sample:

1. Create an html tags and etc. and paste this code inside the body tags (save this as uploadfile.php inside you htdocs folder):

<form action="uploadfile.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" value=""/><br/>
<input type="submit" name="submit" value="Upload"/>
</form>

<?php

require('connect.php');  // note that you already established your connection in MySQL and to your database

session_start();

$path = "files\\";
$fname = $_FILES["file"]["name"];
$ftmp = $_FILES["file"]["tmp_name"];
$fsize = $_FILES["file"]["size"];
$file_fullpath = $path.$fname;


$path = stripslashes($path);
$fname = stripslashes($fname);
$fsize = stripslashes($fsize);

$path = mysql_real_escape_string($path);
$fname = mysql_real_escape_string($fname);
$fsize = mysql_real_escape_string($fsize);


if($fname == ""){
echo "Please complete selection.";
}
else{
move_uploaded_file($ftmp, 'files/'.$fname);

mysql_query("INSERT INTO myfiles(filetitle, filedir, filesize) values( '$fname' , '$path' , '$fsize' )");
echo "File uploaded successfully.";
}
?>

2. Create a folder and name it as files inside your htdocs folder together with the uploadfile.php.

3. In your mysql, create a table and name it as myfiles and put the following as your fieldnames:

  • filetitle  varchar(25)
  • filedir   varchar(25)
  • filesize  varchar(25)

Saturday, February 9, 2013

Print only selected div content selected using @media print css

THIS WILL PRINT THE ENTIRE PAGE DUE TO THE DEFAULT HTML CODE OF THIS BLOG.
BETTER TO ZOOM IN THE PREVIEW TO SEE THAT THE "DEMO HERE" BUTTON WILL HIDE ONCE YOU PRINT OR TRY IT THROUGH COPYING THE PROVIDED CODES BELOW.


If you need to print only selected content in div and not include button print, this is simple solution help you to solve it.

<html>
<head>
<style type="text/css" media="print">
@media print
{
#non-printable { display: none; }
#printable {
display: block;
width: 100%;
height: 100%;
}
}
</style>
</head>
<body>
<div id="printable" >
Your content to print
</div>
<input type="button" id="non-printable" class=normaltext onclick="JavaScript:window.print();" value="print" />
</body>
</html>

Tuesday, January 29, 2013

Pop- up Window with Dim Background (OnFocus)



Close




You can put anything here :)

Try this by copying the codes below.





+--- This code must place inside the head tags

<script src="http://code.jquery.com/jquery-latest.js"></script>

<script type="text/javascript">

//This is the function that closes the pop-up
function endBlackout(){
$(".blackout").css("display", "none");
$(".msgbox").css("display", "none");
}

//This is the function that starts the pop-up
function strtBlackout(){
$(".msgbox").css("display", "block");
$(".blackout").css("display", "block");
}

//Sets the buttons to trigger the blackout on clicks
$(document).ready(function(){
$("#btn1").click(strtBlackout); // open if btn is pressed
$(".blackout").click(endBlackout); // close if click outside of popup
$(".closeBox").click(endBlackout); // close if close btn clicked

// Automatically trigger the pop-up after 10 seconds
setTimeout( strtBlackout, 10000);
});
</script>

<style type="text/css">

.blackout {
background-color:#000;
opacity:.7;
filter:alpha(opacity=70);
height:100%;
width:100%;
position:fixed;
top:0;
left:0;
z-index:100;
display:none;
cursor:pointer;
}
.msgbox {
background-color:#ccc;
border:1px solid #ccc;
color:#000;
width:30%;
height:30%;
position:fixed;
top:20%;
left:15%;
border-radius:20px;
padding:10px;
z-index:101;
display:none;
margin-left: 20%;
}
.closeBox {
background-color:#CC0000;
color:#FFFFFF;
padding:8px;
float:right;
border-radius:3px;
cursor:pointer;
text-transform:uppercase;

}
</style>


+--- This must place inside the body tags

<input id="btn1" name="submit" type="submit" value="Demo here" />
<div class="blackout">
</div>
<div class="msgbox">
<div class="closeBox">
Close</div>
<br /><br /><br /><br />
<center>
<form action="#" method="post">You can put anything here :)<br />
<label><a href="#">CLICK HERE</a> to add me on FB.</label>
</form>
</center>
</div>

Friday, January 25, 2013

Assembly Code Using 10h for Graphical Display (American Flag)


'just copy the code and paste it on your notepad or command prompt editor (must be inside the directory wherein tasm and tlink IDE located then type this command --->  edit <filename>.asm ) . You can modify it because I think the number of stars on the flag was wrong.

+----------------SAMPLE OUTPUT----------------+

+------------------------------------------------------+


.model small
.stack 100h
.data
        newl db,0ah,0dh,"$"
        line1 db " * * * * * * * * $"
        color1 db "                                       $"
        line2 db " * * * * * * * * $"
        color2 db "                                       $"
        line3 db " * * * * * * * * $"
        color3 db "                                       $"
        line4 db " * * * * * * * * $"
        color4 db "                                       $"
        line5 db " * * * * * * * * $"
        color5 db "                                       $"
        line6 db " * * * * * * * * $"
        color6 db "                                       $"
        line7 db " * * * * * * * * $"
        color7 db "                                       $"
        line8 db " * * * * * * * * $"
        color8 db "                                       $"
        stripes1 db "                                                                        $"
        stripes2 db "                                                                        $"
       

.code
        mov ax,@data
        mov ds,ax

mov ah,9

mov bl,00011111b
mov cx,30
int 10h
mov dx,offset line1
int 21h
mov bl,11110000b
mov cx,40
int 10h
mov dx,offset color1
int 21h
mov dx,offset newl
int 21h

mov bl,00011111b
mov cx,30
int 10h
mov dx,offset line2
int 21h
mov bl,41h
mov cx,40
int 10h
mov dx,offset color2
int 21h
mov dx,offset newl
int 21h

mov bl,00011111b
mov cx,30
int 10h
mov dx,offset line3
int 21h
mov bl,11110000b
mov cx,40
int 10h
mov dx,offset color3
int 21h
mov dx,offset newl
int 21h

mov bl,00011111b
mov cx,30
int 10h
mov dx,offset line4
int 21h
mov bl,41h
mov cx,40
int 10h
mov dx,offset color4
int 21h
mov dx,offset newl
int 21h

mov bl,00011111b
mov cx,30
int 10h
mov dx,offset line5
int 21h
mov bl,11110000b
mov cx,40
int 10h
mov dx,offset color5
int 21h
mov dx,offset newl
int 21h

mov bl,00011111b
mov cx,30
int 10h
mov dx,offset line6
int 21h
mov bl,41h
mov cx,40
int 10h
mov dx,offset color6
int 21h
mov dx,offset newl
int 21h

mov bl,00011111b
mov cx,30
int 10h
mov dx,offset line7
int 21h
mov bl,11110000b
mov cx,40
int 10h
mov dx,offset color7
int 21h
mov dx,offset newl
int 21h

mov bl,00011111b
mov cx,30
int 10h
mov dx,offset line8
int 21h
mov bl,41h
mov cx,40
int 10h
mov dx,offset color8
int 21h
mov dx,offset newl
int 21h

mov cx,8

meme:
push cx
mov bl,11110000b
mov cx,57
int 10h
mov dx,offset stripes1
int 21h
mov dx,offset newl
int 21h
mov bl,41h
mov cx,57
int 10h
mov dx,offset stripes2
int 21h
mov dx,offset newl
int 21h
pop cx
dec cx
cmp cx,0
je exit
loop meme

exit:
mov ax,4c00h
int 21h
end

ID Generator Using Random (Rnd) in Vb6


'To be placed on the command button

Private Sub GenerateID_Click()
Text2.Text = GenerateCode() '<--- Call by Function
End Sub

'Function code that will do the random pick of numbers to be generated.

Public Function GenerateCode()
    strInputString = "123456789012345678901234567890"
 
    intLength = Len(strInputString)
 
    intNameLength = 5
 
    Randomize
 
    strName = ""
 
    For intStep = 1 To intNameLength
        intRnd = Int((intLength * Rnd) + 1)
 
        strName = strName & Mid(strInputString, intRnd, 1)
    Next
 
    GenerateCode = strName
End Function