Online computer courses, code, programming tutorial and sidebar information for monitoring Canadian S&P/TSX index. Build friendship and networking. Welcome to visit my blogs often!!! I also have two other sites: YouTube Channel and Google site.
Adsense
Popular Posts
- PHPWind-- A PHP forum script applcaition in China
- PHP: add a download as pdf file button in report page
- How to blend adsense inside your post?
- Formatting my post
- Notepad++ - Add C++ compiler
- PHP connect IBM db2 database in XAMPP
- Datatable export excel wraptext and newline
- phpexcel toggle expand and hide column in EXCEL and summary
- Sweet Alert JS library - beautiful replacement of JavaScript Alert
- Set up a child account and set screen time limit in Windows 8
Saturday, December 31, 2011
Global variables for CSS
Purpose: Create a CSS template file demo.txt with global variables, after processed by a PHP file convert_to_css.php, a CSS file demo.css is produced. So we can easily manage complicated CSS files.
demo.txt:
$colour2 = '#363';
body{
text-align:center;
background:$colour2;
}
#boundary{
background:$colour2;
}
convert_to_css.php
<?PHP
ini_set('display_errors', 1);
error_reporting(E_ALL);
// grab the c parameter and ensure that it contains .txt is no slashes
// this is a safety measure to prevent XSS
//http://icant.co.uk/articles/cssconstants/
$c=$_GET['file'];
if(preg_match('/\//',$c) or !preg_match('/.txt/',$c))
{
die('only local CSS files allowed!');
exit;
}
// load the content of the CSS file into the variable css, end if the
// file wasn't found.
$css=load($c);
if($css=='')
{
die('File not Found, sorry!');
exit;
}
// grab all constants and store them in the array constants
preg_match_all("/\\$(\w+).*=.*\'(.*)\'/",$css,$constants);
for($i=0;$i<sizeof($constants[1]);$i++)
{
// replace all occurrences of the contants with their values
$css=preg_replace('/\\$'.$constants[1][$i].'/',$constants[2][$i],$css);
}
// delete all constant definitions
$css=preg_replace("/\\#.*=.*?;\s+/s",'',$css);
$newfile=str_replace(".txt",".css",$c);
// save the style sheet
save($newfile, $css);
echo 'convert to '.$newfile;
function load($filelocation)
{
if (file_exists($filelocation))
{
$newfile = fopen($filelocation,"r");
$file_content = fread($newfile, filesize($filelocation));
fclose($newfile);
return $file_content;
}
}
function save($newfile, $filecontent)
{
$file = fopen ($newfile, "w");
fwrite($file, $filecontent);
fclose ($file);
}
?>
After run convert_to_css.php?file=demo.txt
demo.css is produced:
body{
text-align:center;
background:#363;
}
#boundary{
background:#363;
}
Reference:
http://icant.co.uk/articles/cssconstants/
Friday, December 30, 2011
Open Port 1935 for Flash Media Server in Windows 7
For remote connect to Flash Media Server, we need to open port 1935 (default) for Flash Media Server. There are three ways in Windows 7.
1) One way is to click add port in Firewall after Control panel->System and Security->Windows Firewall, following the instruction from the link below:
http://windows.microsoft.com/en-CA/windows-vista/Open-a-port-in-Windows-Firewall
2) I did not find "add port" property in firewall in Windows 7 home edition. My way is to click "Allow a program or feature through Windows Firewall" after clicking
Control panel->System and Security->Windows Firewall. I allowed following 4 programs in FireWall.
C:\Program Files\Adobe\Flash Media Server 4.5\FMSMaster.exe
C:\Program Files\Adobe\Flash Media Server 4.5\FMSEdge.exe
C:\Program Files\Adobe\Flash Media Server 4.5\FMSCore.exe
C:\Program Files\Adobe\Flash Media Server 4.5\FMSAdmin.exe
3) One simple way is to select turn off firewall after clicking
Control panel->System and Security->Windows Firewall.
This is not recommended due to putting your computer at risk.
Wednesday, December 7, 2011
Click to display message box, Javascript
Click "Show message text box" below to show message box, click again to hide message box. So this will save a lot of content space.
Show message text box
Welcome to Jiansen Lu blogs
<style type="text/css">
<!--
.hidden { display: none; }
.displayed {
background-color: #F4F4F4;
border: 1px solid #CCC;
height: 200px;
width: 300px;
padding: 5px;
display: block;
}
-->
</style>
<script type="text/javascript">
function display2(divID) {
var item = document.getElementById(divID);
if (item) {
document.getElementById('toggletext2').innerHTML =(item.className=='hidden')?'Hide quoted text box':'Show quoted text box';
item.className=(item.className=='hidden')?'displayed':'hidden';
}
}
</script>
<a href="javascript:display2('testcode2');" id="toggletext2">Show quoted text box</a>
<div class="hidden" id="testcode2">
<h1>
Welcome to Jiansen Lu blogs</h1>
</div>
Make a dynamic table using hide content in JavaScript
When you click row 1, cell 1 in the following table, the column 2 content shows.
Same for row 2. So you can make a dynamic table to show and hide row and column contents
Show | Hide/Show |
row 1, cell 1 | row 1, cell 2 |
row 2, cell 1 | row 2, cell 2 |
Source code:
<style type="text/css">
.hidden { display: none; }
.displayed { display: block; }
</style>
<script type="text/javascript">
function display(divID) {
var item = document.getElementById(divID);
if (item) {
item.className=(item.className=='hidden')?'displayed':'hidden';
}
}
</script>
<table border="1", width="100%">
<tr> <td width="50%"> Show </td> <td width="50%">Show/Hide </td>
<tr>
<tr> <td><a id='toggletext' href="javascript:display('row1');">row 1, cell 1</a></td> <td id="row1" class="hidden">row 1, cell 2</td> </tr>
<tr> <td><a id='toggletext' href="javascript:display('row2');">row 2, cell 1</a></td> <td id="row2" class="hidden">row 2, cell 2</td> </tr>
</table>
Tuesday, December 6, 2011
Prezi - Make you presentation dynamic and alive
You can sing up prezi free account on:
http://prezi.com/
Using prezi, you can visualize your ideas. You can insert images, videos,PDF. zoom and pan region. You can present the result online or offline. You can also use prezi online meeting to work with others for colloborative document.
My Example using prezi CV template:
Saturday, November 26, 2011
PHP content management systems using subMerged
subMerged is a theme or template for various content management systems.
Detail can be found:
http://submerged.sourceforge.net/
There are subMerged for phpBB3, Coppermine Photo gallery, phpWebSite, and phpNuke
Below is the demo for Coppermine Photo gallery.
Friday, November 25, 2011
JavaScript, set focus on document.form
Purpose: when the web page is loaded, set the focus on the subject of the form,
i.e. the input field of the subject in the form is blinking and ready to accept the text input.
<form name="testform"> <input type="text" name="subject"> </form>
Modify the body tag to:
<body OnLoad="document.testform.subject.focus();">
Tuesday, November 22, 2011
Online vector graphics editor - SVG editor
You can download SVG-editor for free from
http://code.google.com/p/svg-edit/
You just need to copy the download folder to your web server and run svg-editor.html.
You can have free-hand drawing, lines, polylines, ellipses, square and much more features online.
One of the website used SVG editor for clipart is: http://www.clker.com/
I do find a lot of nice drawings there using SVG editor.
SVG editor demo can be found below as embed:
Monday, November 21, 2011
Flash CS5 actionscript editor and Code Snippets
This video tutorial from Adobe TV shows how to use custom class code hint and completion in Flash CS5 ActionScript editor.
You may not remember all the ActionScript libraries and functions. The video below from Adobe TV show you how to use and modify existing snippets to quickly add functionality to your project, as well as creating and saving your own snippets for later use.
Show quoted text and hide quoted text in JavaScript
In GMail, we can see "show quoted text" and "hide quoted text"
in the mail body. We can apply the same functionality in blog posts
use JavaScript.
1) First, we need to define two CSS classes: hidden and displayed
<style type="text/css">
.hidden { display: none; }
.displayed { display: block; }
</style>
2) Second, we need to define a Javascript function display to toggle
between hide and display
<script type="text/javascript">
function display(divID) {
var item = document.getElementById(divID);
if (item) {
document.getElementById('toggletext').innerHTML =(item.className=='hidden')?'Hide quoted text':'Show quoted text';
item.className=(item.className=='hidden')?'displayed':'hidden';
}
}
</script>
3) Create a hide and display link
<a id='toggletext' href="javascript:display('testcode');">Show quoted text</a>
<div id="testcode" class="hidden">
<h3>Welcome to Jiansen Lu blogs</h3>
</div>
Result (click to see the hidden text)
Show quoted text
Welcome to Jiansen Lu blogs
Thursday, November 17, 2011
ActionScript 3.0: produce an online voice recorder in flash
Following the instruction on active tuts website:
http://active.tutsplus.com/tutorials/actionscript/create-a-useful-audio-recorder-app-in-actionscript-3/
I designed an online voice recorder as below. The design used the MicRecorder class from google code library. When you click the button, the sound around is recorded by your microphone. When you click stop, the sound is saved in your local computer.
Another good flash tutorial can be found:
http://www.webzo.org/tutorials/flash.php?page=1
Result of my sound recorder.
Wednesday, November 16, 2011
Difference between Actionscript 3.0 and ActionScript 2.0 video tutorial
This one hour video tutorial from Adobe TV is presented by renowned Flash developer R Blank. He explains the basics of getting things done in ActionScript 3.0 and the difference between ActionScript 3.0 and ActionScript 2.0.
Actionscript 3.0 design a flash loader using progress bar and UILoader
Purpose: To design a container to load external flash and show loading progress bar
1. Open flash CS5, new ActionScript 3.0 flash document
2. Set document Class as "Loader" in the Properties panel.
3. Drag the ProgressBar component and UILoader component from the Components panel to the library.
4. Save this files as Loader.fla.
5. In the same folder of Loader.fla, enter following ActionScript 3.0 in Loader.as:
package
{
import flash.display.MovieClip;
import flash.display.Sprite;
import fl.containers.UILoader;
import fl.controls.Label;
import fl.controls.ProgressBar
import fl.controls.ProgressBarMode;
import flash.events.*;
import flash.text.*;
//For Security.allowDomain
import flash.external.ExternalInterface;
import flash.system.Security;
public class Loader extends Sprite
{
private var UI_intro_loader:UILoader;
private var progressText:TextField;
private var bar_pb:ProgressBar;
private var introURL:String = 'http://www3.telus.net/jianlu58/resizebutton.swf';
public function Loader()
{
init();
}
private function init():void
{
//Load the Room Builder
var now:Date = new Date();
var queryString = this.loaderInfo.parameters;
var domain = "http://www3.telus.net/";
// allow domain www3.telus.net to access this flash
Security.allowDomain(domain);
UI_intro_loader = new UILoader();
UI_intro_loader.autoLoad = false;
UI_intro_loader.source = introURL;
UI_intro_loader.scaleContent = false;
UI_intro_loader.load();
bar_pb = new ProgressBar();
bar_pb.mode = ProgressBarMode.EVENT;
bar_pb.source = UI_intro_loader;
bar_pb.move(stage.stageWidth / 2 - bar_pb.width / 2, stage.stageHeight / 2);
bar_pb.addEventListener(ProgressEvent.PROGRESS, onProgress);
bar_pb.addEventListener(Event.COMPLETE, onComplete);
addChildAt(bar_pb,0);
progressText = new TextField();
progressText.x = bar_pb.x;
progressText.y = bar_pb.y + bar_pb.height;
progressText.textColor = 0xffffff;
progressText.autoSize = TextFieldAutoSize.LEFT;
addChildAt(progressText, 1);
//trace(UI_loader.source);
}
private function onProgress(e:ProgressEvent):void
{
//trace(e);
progressText.text = int(e.currentTarget.percentComplete) + '%';
}
private function onComplete(e:Event):void
{
//trace(e);
addChildAt(UI_intro_loader, 1);
var intro:MovieClip = UI_intro_loader.content as MovieClip;
intro.play();
//remove progress bar when it is done!
bar_pb.removeEventListener(ProgressEvent.PROGRESS, onProgress);
bar_pb.removeEventListener(Event.COMPLETE, onComplete);
removeChild(bar_pb);
removeChild(progressText);
}
}
}
6. Result:7. Reference:
A.Use the ProgressBar component
http://help.adobe.com/en_US/as3/components/WS5b3ccc516d4fbf351e63e3d118a9c65b32-7fa4.html
B.Customize the ProgressBar component
http://help.adobe.com/en_US/as3/components/WS5b3ccc516d4fbf351e63e3d118a9c65b32-7f43.html
Wednesday, November 9, 2011
ActionScript 3.0: play and play again buttons
To design a game in flash using ActionScript 3.0, click play button to start a game. After the game over, click "Play Again" button to restart the game.
1) Start Flash CS5, click new-> actionscript 3.0, name your fla fileas myGame.fla, set class: myGame in property menu.
2) Create 3 frames, the first frame name: "start", second frame name: "play", the third frame name: "gameover"
3) In "start" frame, create a button instance name: startButton
Press F9, enter following actionscript:
//stop at first frame
stop();
//When mouse click startButton, call function clickStart
startButton.addEventListener(MouseEvent.CLICK,clickStart);
function clickStart(event:MouseEvent) {
//go to "play" frame
gotoAndStop("play");
}
4) In "play" frame, create your game. for example, you can create a MovieClip and you can call a function from myGame.as actionscript file.5) In "gameover" frame, create a button called "playAgainButton". Press F9 to enter following actionscript:
//When mouse click "playAgainButton" button, call clickPlayAgain function
playAgainButton.addEventListener(MouseEvent.CLICK,clickPlayAgain);
function clickPlayAgain(event:MouseEvent) {
//go to "play" frame
gotoAndStop("play");
}
Friday, November 4, 2011
The RSA Animate series of video clips
The RSA Animate series of video clips used animation to present some very sophisticated ideas to learners. You can find all RSA animate video series here:
http://comment.rsablogs.org.uk/videos/
Example video: RSA Animate - Smile or Die
Acclaimed journalist, author and political activist Barbara Ehrenreich explores the darker side of positive thinking.
Maximum number of MySQL connection
Use MySQL query browser to check maximum number of MySQL connection:
1) Click Tools at the top manual
2) Select MySQL Administrator
3) Click Start Variables at the left Panel
4) Click "Advanced Networking", under Advanced, you can change Max connection, the default for old MySQL database is 100, for MySQL 5.5 is 151.
Some flash code and ActioScript Resources
Flash Game University is the companion site for the book ActionScript 3.0 game programming university. You can finsh video tutorials for flash game design from Flash Game University on:
http://flashgameu.com/list_all_posts.html
The source code can be downloaded from:
http://flashgameu.com/book_source_files_2.html
There are alos some great articles from http://www.learningactionscript3.com/
For how to compile ActionScript, you can find it from:
http://edutechwiki.unige.ch/en/AS3_Compiling_a_program
There are also some detail explanation of ActionScript:
http://edutechwiki.unige.ch/en/AS3_example_Positioning
Wednesday, November 2, 2011
Clear file history in Acrobat Reader, Word document and Firefox
In Acrobat Reader:
1) Click Edit in the top menu
2) Select Preferences
3) Click Documents (the first row)
4) Right side under open setting, change the "Documents in recently used list" to 1. You can select from 1 to 10.
In Word document:
- Click the File tab
- Click Recent, you can see a list of your recent files
- Right click the file you want to remove from the list and select Remove from the list
1) Click Firefox tab and click options
2) Click options
3) Click Privacy tab,
4) Click clear your recent history
Tuesday, November 1, 2011
PHP, compress and extract files using PclZip library
PclZip library offers PHP compression and extraction functions for Zip formatted archives. PclZip library can be downloaded from:
http://old.phpconcept.net/pclzip/index.en.php
The user menu can be found HERE.
To include pclzip library:
include_once('pclzip.lib.php');
To add or extract very large file, "memory_limit" value in php.ini needs to be increased. "memory_limit" can also set in the PHP code:
ini_set('memory_limit', '180M');
To initialize a zip instance:
$myzipfile = new PclZip('myzfile.zip');
To create a zip file from image1.jpg and image2.jpg:
$mylist = $archive->create('mydata/image1.jpg,mydata/image2.jpg',
PCLZIP_OPT_REMOVE_PATH, 'data',
PCLZIP_OPT_ADD_TEMP_FILE_ON);
Sunday, October 30, 2011
Create flash website using Adobe Rome
Adobe Rome is an online and desktop content creation and publishing application. Finished projects can be exported in PDF, JPG, Flash, and HTML file formats. You can easily combine graphics, photos, text, video, audio and animation into your website projects. You can download Adobe Rome for free from:
http://rome.adobe.com/download.html
Video: Make A Flash Website With Adobe Rome (Free Version Of Flash)
Convert flash to HTML5 using Adobe Wallaby
Adobe Wallaby converts flash file (fla) to HTML5. This conversion is a good news to ipad as ipad doses not support flash. This also allows you to reuse and extend the reach of your content. Adobe wallaby is a free software. You can download it from
http://labs.adobe.com/technologies/wallaby/
Video: Adobe Wallaby- How to convert Flash Fla Files into HTML5
3D printer
Think about printing 3D object using printer. Yes it is possible, three dimensional object can be created by laying down successive layers of material. There are several different techniques, some used molten polymer and the other used metal.
Below is the video for how 3D metal printer work.
Video: 3D metal printing
Reference: http://www.canadaka.net/news/topic/9-science
Friday, October 28, 2011
Adobe Flash Tutorial- Design a Cartoon using drawing tools
This video showes you how to create an outside cartoon environment. For more tutorials check out: http://www.incredibletutorials.com.
There is no actionscript related, mainly learn how to use Adobe flash drawing tool and design cartoon.
Thursday, October 27, 2011
Create an online survey for free
You can create an online survey via:
http://www.surveymonkey.com
The basic is for free. 10 questions per survey. 100 responses per survey.
You can copy the survey embed code in your blogs. There are also a lot of templates
to select. You can also create an online survey using Google docs. Below is the survey for my blog. Fill and send:
Create your free online surveys with SurveyMonkey, the world's leading questionnaire tool.
Wednesday, October 26, 2011
Telus Optiktv TV show remote recording
You not only can schedule and manage your Telus Optik TV HD PVR recordings* at home, but also at a smartphone† or any Internet-connected computer.
The following is the step for setting Telus Optiktv TV show remote recording.
1)Press record button in your Telus Optik TV HD PVR box or remote
control, select create account and type your email address.
2)You will receive an email from telus. Follow the instruction and register
your account to setup password. Go to
http://telus.com/content/tv/optik/applications/remote-record.jsp
Update:
https://webservices.tv.telus.net/RdvrSilverlight/RDVR.html
3) Click launch application, type your email and password. Done! you can record
your favorite TV shows fro any computer with network connection.
4) The Remote Recording application is for free.
Monday, October 24, 2011
PHP, text after apostrophe or hyphen cutoff
In some scenarios when a piece of text is pasted from Word to online visual editor, if the text contains an apostrophe or hyphen, all text that comes after the apostrophe or hyphen will not cutoff in MYSQL database. mb_convert_encoding function can be used to solve this problem:
$sql_subject =mb_convert_encoding($_POST['subject'], 'HTML-ENTITIES', 'OLD-ENCODING');
$sql_subject =ereg_replace("’", "'", $sql_subject);
$sql_subject=$addslashes(html_entity_decode($sql_subject));
’ is for ', mb_convert_encoding will automatically solve hyphen cutoff problem.
For using function mb_convert_encoding:
In C:/php5.3.1/php.ini, line 960, un-comment
extension=php_mbstring.dll
Thursday, October 20, 2011
Schedule backup MySQL database in Windows Server
I tried to use MySQL query browser to backup MySQL database in Windows 2003 server, but failed.
Step 1:
1) Start MySQL query browser.
2) Go to Tools ->MySQL administration, click backup, move the database you want to backup to right column
3)new project->project name: gnsh_backup, save project.
4) click Schedule: Error message: "A schedule backup requires a stored connection"
click Schedule: Error message: "A schedule backup requires a stored connection"
Step 2:
Switch using Scheduled Tasks in Windows:
1)Control Pane -> Scheduled Tasks.
2) Click "Add Scheduled Task", select backup, daily, set name gnsh_backup,
10:10 pm every day, start date 10/20/2011, enter: user name and
password.
3) Select "open advanced window"
In Run column, enter:
"C:\Program Files\MySQL\MySQL Tools for 5.0\MySQLAdministrator.exe" "-UDC:\Documents and Settings\Administrator\Application Data\MySQL\" "-cRoot" "-bpgnsh_backup" "-btC:\sql_dumps\mysql_admin\" "-bxgnsh_
In Start Column in:
"C:\Documents and Settings\Administrator\Application Data\MySQL\
Note: Explanation of MySQLAdministrator.exe command line:
C:\Program Files\MySQL\MySQL Tools for 5.0\MySQLAdministrator.exe" -cServer -bpProject-Name -btC:\SQLDUMP -bxDump-Name
Note Project-Name is defined in step 1.
MySQL database is successfully backuped daily automatically.
Friday, October 14, 2011
GIMP - free photo and graphics tool
GIMP is a free photo and graphics tool. You can download GIMP from:
http://www.gimp.org/.
GIMP has full suite of paiting tools, advanced manupilation including full alpha support, layers and channels, foreground extracting tools, transformation tools including rotate, scale, shear and flip, frame navigator for animation. GIMP supports file format including bmp , gif, jpeg, mng, pcx, pdf, png, ps, psd, svg, tiff, tga, xpm, and many others, and also file formate converting. If you can not afford PhotoShop, using GIMP may be an alternative choice.
Wednesday, October 12, 2011
Remove facemoods
facemoods is a Facebook add-on for Facebook Chat that gives you a huge collection of smiley. I set google as my default homepage settings. It it is often changed to http://start.facemoods.com/.
To remove facemoods in Windows 7, go to Control Panel, then click Program, then click uninstall a program under Programs and Features, right click Facemoods Toolbar and uninstall.
Tuesday, October 11, 2011
Transfer variables from Javascript in SWFobject to actionscript in a flash file
I am designing a flash swf file, which is used to test video connection setting in Flash Media Server. The IP address of the Flash Media Server should be passed from Javascript in SWFobject to the actionscript in the flash file. My Javascript for SWFobject:
<div id="flashContent" class="flashContainer"></div>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
var so = new SWFObject("/_swf/fms_connection/settings.swf", "connection_settings", "640", "360","7");
so.addParam("wmode", "transparent");
so.addParam("flashvars", "fms_server=192.168.1.61&room_id='.$_SESSION['member_id'].'");
so.write("flashContent");
//--><!]]>
</script>
Pass variables room_id and fms_server to the actionscript in the flash file.
import flash.external.
function onMouseDown():Void {
focusManager.enabled = false;
}
function onMouseUp():Void {
focusManager.enabled = true;
}
attachMovie("
var flash_id = "connection_settings"; //could retrive this dynamically with the _url param
function whereAmI(myLocation:String):
cs.myTrace("whereAmI: " + myLocation);
cs.connect(room_id,myLocation,
}
//don't put the swf in a form IE will crap out on ExternalInterface.addCallback
ExternalInterface.addCallback(
getURL("javascript:var me=document."+flash_id+";me.
room_id and fms_serve are also passed to connetionSettings class, which is defined in another actionscript file.
Monday, October 10, 2011
New tags in HTML 5
1. <canvas>: This is used for rendering dynamic bitmap graphics or games.
2. <command>: This is used for a command button, like a radiobutton, a checkbox, or a button, only visible if it is inside a menu element.
3. <audio> is used to define sound stream
4. <datalist> defines a list of options for input, only supported by Firefox and Opera, not Chrome and IE
5. Other new tags
<details>
<embed>
<figure>
<footer>
<header>
<hgroup>
<keygen>
<mark>
<meter>
<nav>
<output>
<progress>
<ruby>
<section>
<time>
<video>
<wbr>
Friday, October 7, 2011
Confirmation Email sent when user submitting a Google Form
1. Go to your Google docs
2. Click the form you produced, which will be shown as EXCEL format
3. Click tools in the top menu bar, select Notification Rule
4. Check the box "A user subits a form" and check "Email-right away". Click Save.
5. An email will be sent to me when users submit the form.
I try to setup the email notification to other collaborators when users submit the form. But I still can not find the way.
Wednesday, October 5, 2011
How well does your bowser support HTML5?
HTML 5 is the fifth revision of the HTML standard. The best browser to support HTML5 is Google Chrome (Score 341 out of 450 for version 13). The second is Mozilla Firefox (Score 313 out of 450 for version 6). Even though the specification isn't finalized yet, all major browser manufacturers are making sure their browser is ready for the future.
To find out which parts of HTML5 are already supported by your browser today and compare the results with other browsers, click http://html5test.com/index.html.
Sunday, October 2, 2011
Upgrade Flash Media Server from 2.0 to 4.5
Backup Flash Media Server (FMS) 2.0 as upgrade will remove the old version first. As I already install Apache 2.2, I do not choose install Apache 2.2 during upgrade. I only choose port 1935, but not port 80 for FMS as it is for my web server.
After upgrade, copy application directory in FMS 2.0 to Flash Media Server 4.5. I have one extra file domainList.asc under directory scriptlib to copy. I also modify conf/_defaultRoot_/_defaultVhost_/Vhost.xml. Copy these two files to FMS 4.5. You do not need to copy these two files. Restart FMS 4.5. (In Windows, go to control panel, then click administration tools, then service and select Flash Media Server)
Server license, port and user administration information can be found in coif/fms.ini. The administration password is stored in conf/fms.ini in FMS 2.0, but not in FMS 4.5.
Flash Media Development Server 4.5
Flash Media Server can be downloaded from http://www.adobe.com/downloads/ via selecting Flash Media Server and click Go.
If you do not buy the flash media server, you still can use it. During installation, you do not input license number and the installation will be changed to Flash Media Development Server. Flash Media Development Server has the same functionality of Flash Media Server but with limited of streaming time and number of connection. It is ideal for developers. The restriction of video delivery on Flash Media Server is:
1) HTTP streaming session length is not more than 30 minutes
2) IP multicast streaming for no more than 10 minutes
3) Your server multicast plug-in will be limited to 50 multicast connections
4) Server support for RTMFP is limited to 50 connections.
The difference between Flash Media Development Server, Flash Media Streaming Server, Flash Media Interactive Server, Flash Media Enterprise Server, Flash Media Server on Amazon Web Services can be found:
http://www.adobe.com/products/flashmediaserver/helpmechoose.html
Friday, September 30, 2011
Network file sharing in Windows 7 using password protection
I have a laptop and a desktop, both of them are Windows 7.
I want to share files in these two computers with password protection during sharing.
1. To choose home network and password protection
start->Control panel->Network and Internet->Network and Sharing center
Under "View your active networks" click and choose "Home network"
Under left panel to choose Advanced sharing settings, under home or work:
all select Turn on. Under HomeGroup connections,
select Use user accounts and passwords to connect to other computers.
2. Select the file or folder to share
Right click mouse to select properties, select share with everyone
3. View the network file
Under My Computer, click network in left panel, you can select another computer. Click that icon,
enter your user name and password in that remote computer, you can see the network file to share.
I am able to my file in my laptop to desktop via network file share. It is much fast than using USB
stick to copy twice in two computers.
Sunday, September 25, 2011
Design a editable webpage and keep ten revisions using PHP MySQL
Purpose
Design a editable webpage and keep ten revisions.
Procedure using PHP/MySQL
1) Create two tables.
First table web_content store current content of webpage
CREATE TABLE web_content (
`content_id` mediumint(8) unsigned NOT NULL auto_increment,
`revision` mediumint(8) unsigned NOT NULL default '0',
`title` varchar(255) NOT NULL,
`text` text NOT NULL,
PRIMARY KEY (`content_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Another table web_content_rev to store 10 revison
CREATE TABLE web_content_rev (
`content_id` mediumint(8) unsigned NOT NULL auto_increment,
`revision` mediumint(8) unsigned NOT NULL default '0',
`title` varchar(255) NOT NULL,
`text` text NOT NULL,
PRIMARY KEY (`content_id`, `revision`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
2) page_id as a dynamic varable, create save, cancel, restore revision buttons, load external editor, display page content and the content in the editor at the same time.
<?php
//page_id from web site for example index.php?page_id=1
if(isset($_GET['content_id'])){
$content_id=$_GET['content_id'];}
else {
// The "i" after the pattern delimiter indicates a case-insensitive search
if (preg_match("/index.php/i",$_SERVER['PHP_SELF'])) $content_id=1;
}
?>
<?php
//Jiansen Lu, Sept 23, 2011
global $db;
$sql = "SELECT text, revision FROM web_content WHERE content_id=$content_id";
$result = mysql_query($sql, $db);
while ($row = mysql_fetch_assoc($result)) {
$content = $row['text'];
$revision = $row['revision'];
}
$sql_3 = "SELECT revision FROM web_content_rev WHERE content_id=$content_id";
$result_3 = mysql_query($sql_3, $db);
$i=0;
while ($row = mysql_fetch_assoc($result_3)) {
$revision_1[$i] = $row['revision'];
$i=$i+1;
}
//if you are admin and the page editable ie edit=1, index.php?edit=1&page_id=1
if($_GET['edit']==1&&isset($_SESSION['portal_status']) && $_SESSION['portal_status']['admin'] == STATUS_ADMIN){
if ($_POST['save']=="Save") {
$sql_1 = "INSERT INTO web_content_rev SELECT * FROM web_content WHERE content_id=$content_id";
$result0 = mysql_query($sql_1, $db);
//delete revisions,investigaor and references older than 10 ago
$sql_2 = "DELETE FROM web_content_rev WHERE content_id=$content_id AND revision < ($revision-9)";
@mysql_query($sql_2,$db);
//prevent MySQL injection using mysql_real_escape_string
$sql0 = "UPDATE web_content set text='".mysql_real_escape_string($_POST['doc_body'])." ', revision=revision+1 WHERE content_id=1";
$result0 = mysql_query($sql0, $db);
}
else if ($_POST['cancel']=="Cancel") {
if($content_id==1)
header('Location: /index.php');
exit();
}
}
if ($_POST['restore']=="Restore Revision") {
if(!isset($_POST['rid'])){
$msg->addError('You must select a revision first.');
}else{
$sql_5 = "SELECT text FROM web_content_rev WHERE content_id=1 AND revision=".$_POST['rid'];
$result_5 = mysql_query($sql_5, $db);
while ($row = mysql_fetch_assoc($result_5)) {
$content = $row['text'];
}
}
}
echo ($content);
if($_GET['edit']==1&&isset($_SESSION['portal_status']) && $_SESSION['portal_status']['cesei'] == STATUS_ADMIN){
?>
<form action="<?php echo $_SERVER['PHP_SELF'].'?edit=1&content_id='.$content_id; ?>" method="post" name="form_1_global">
<input type="submit" class="input-button" value="Save" name="save" class="input-button"/>
<input type="submit" name="cancel" value="Cancel" class="input-button" />
<input type="submit" name="restore" value="Restore Revision" class="input-button" />
<table>
<tbody>
<?php foreach($revision_1 as $revision1): ?>
<tr valign="middle"><input type="radio" name="rid" value="<?php echo $revision1; ?>" id="p_<?php echo $revision1; ?>" /></tr>
<tr><?php echo $revision1."    "; ?></tr>
<?php endforeach; ?>
</tbody>
</table>
<textarea name="doc_body" id="doc_body" rows="5" class="mce-editor" style="width:100%; height:700px;"><?php echo (htmlspecialchars($content)); ?></textarea>
<?php
//local external mce editor
load_editor();
?>
</form>
<?php
}
?>
Wednesday, September 21, 2011
Encrypt and decrypt data in PHP
The class to encrypt and decrypt a string or password: (save in file EncrptClass.php)
<?php
class Encryption {
var $skey = "yourSecretKey"; // you can change it
public function safe_b64encode($string) {
$data = base64_encode($string);
$data = str_replace(array('+','/','='),array('-','_',''),$data);
return $data;
}
public function safe_b64decode($string) {
$data = str_replace(array('-','_'),array('+','/'),$string);
$mod4 = strlen($data) % 4;
if ($mod4) {
$data .= substr('====', $mod4);
}
return base64_decode($data);
}
public function encode($value){
if(!$value){return false;}
$text = $value;
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->skey, $text, MCRYPT_MODE_ECB, $iv);
return trim($this->safe_b64encode($crypttext));
}
public function decode($value){
if(!$value){return false;}
$crypttext = $this->safe_b64decode($value);
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$decrypttext = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->skey, $crypttext, MCRYPT_MODE_ECB, $iv);
return trim($decrypttext);
}
}
?>
In myencrypt.php, encrypt the string "mypassword" ad decrypt it.
<?php
require("EncrptClass.php");
$password = "mypassword";
$converter = new Encryption;
$encoded = $converter->encode($password);
$decoded = $converter->decode($encoded);
echo "Encoded password: $encoded <br />";
echo "Decoded password: $decoded";
?>
Sunday, September 18, 2011
Switch blue characters in HP laptop
To go to blue character mode, press ctrl + Shift. To go back to the normal keys, click ctrl + shift twice.
Thursday, September 15, 2011
Resize image using button in actionscript 3
The steps to design a "+" and "-" button to increase an image in actionscript 3.0
Here the button is not real button in AS3, it is a Movie Clip.
1) Click Adobe Flash CS3 Professional:
2) File->New ->ActionScript 3
3) In layer 1, import an image, draw a button using rectangular tool and duplicate it.
4) Create a new layer "text", type "+" and "-" in each button
5) Using selection tool (v), convert image and two buttons as "Movie Clip", and set
image instance name m_whale (click property), "+"button as m_plus, "-" button as m_minus
6) Create new layer " action",
press F9 to import following actionscript
m_plus.addEventListener(MouseEvent.CLICK, IncreaseSize);
m_minus.addEventListener(MouseEvent.CLICK, DecreaseSize);
function DecreaseSize(evt:MouseEvent){
m_whale.scaleX -= 0.1;
m_whale.scaleY -= 0.1;
}
function IncreaseSize(evt:MouseEvent){
m_whale.scaleX += 0.1;
m_whale.scaleY += 0.1;
}
4) Control + Test Movie (ctrl+enter) to test movie. Export movie to swf file.
5. The swf is below
Note:
onRelease in As2 should be changed to ddEventListener(MouseEvent.CLICK, myfunc) in AS3, or you will get Flash Warning #1090.
In AS2:
m_plus.onRelease = function () {
//Do Something
}
In AS3:
m_plus.addEventListener(MouseEvent.CLICK, IncreaseSize);
function IncreaseSize(evt:MouseEvent){
//do something
}
Wednesday, September 14, 2011
Display microphone volume level in actionscript 3
The steps to design a circle, whose size increases as microphone volume increases in actionscript 3.0
1) Click Adobe Flash CS3 Professional:
2) File->New ->ActionScript 3
3) In “layer 1, press F9 to import following actionscript
var myMic:Microphone = Microphone.getMicrophone();
Security.showSettings(SecurityPanel.MICROPHONE);
myMic.setLoopBack(true);
myMic.setUseEchoSuppression(true);
stage.addEventListener(Event.ENTER_FRAME, stage_EnterFrame);
var zw:Number = stage.stageWidth/2;
var zh:Number = stage.stageHeight/2.;
function stage_EnterFrame(e:Event)
{
var num:Number = myMic.activityLevel*5;
graphics.clear();
graphics.beginFill(0x555555);
graphics.drawCircle(zw, zh, num);
}
4) Control + Test Movie (ctrl+enter) to test movie. Export movie to swf file.
5. The swf is below: you can not see the circle until you turn on microphone and speak
(Reference: http://www.youtube.com/watch?v=IYmdkvLVRgc
http://www.gotoandlearn.com/
http://www.brendandawes.com/project/source/ )
Tuesday, September 13, 2011
Access Webcam in actionscript 3.0
The steps to access webcam in actionscript 3.0
1) Click Adobe Flash CS3 Professional:
2) File->New ->ActionScript 3
3) In “layer 1, press F9 to import following actionscript
var camera = Camera.getCamera();
var video = new Video(camera.width*2,camera.height*2);
video.attachCamera(camera);
addChild(video);
4) Control + Test Movie (ctrl+enter) to test movie. Export movie to swf file.
5. The swf file is below:
(Reference: http://www.youtube.com/watch?v=3hHedyl7Wls&feature=related)
Subscribe to:
Posts (Atom)