- So I was developing some PHP using netbeans 6.9.1 on my i3 ubuntu 10.10 laptop
- Then I realize the CPU process is too high causing my laptop to easily get hot
- I have been using netbeans 6.9 for a long time and no problem before
- This problem just occured and I not really sure the reason (either netbean update or ubuntu update?)
- Do some google and asking few friend, they said yes there is a report for this problem
- Anyway, the problem is solve once I install netbeans 7.2.1
Showing posts with label developer. Show all posts
Showing posts with label developer. Show all posts
Sunday, November 25, 2012
Net beans high CPU process
net bean high cpu process
Labels :
developer,
netbeans,
software,
Troubleshoot,
ubuntu
Tuesday, November 22, 2011
google email phone mobile verification contact requirement
Problem
If you want to create a new Google email. They will ask for your mobile phone number.
This is Google security feature to prevent bot
Reason
Once, I read a blog (cant remember URL) about the phone verification only appear because of username you put. They will search for number or any repetitive name. If have, they will ask for phone verification
Solution
Thus the solution you need is simply putting a unique name. This is difficult since most of any name you try might already been taken.
So the solution for the solution is, "Elf name generator". Yes, Elf name is less frequently use in gmail so you will have high chance to get register new email without phone number verification
Here is some list of website that generate Elf name for you (You can find many website by simply searching "elf name generator"). Good luck in creating your new email... legolas
That is all, your sincerely
Eärendur Fëfalas
If you want to create a new Google email. They will ask for your mobile phone number.
This is Google security feature to prevent bot
Reason
Once, I read a blog (cant remember URL) about the phone verification only appear because of username you put. They will search for number or any repetitive name. If have, they will ask for phone verification
Solution
Thus the solution you need is simply putting a unique name. This is difficult since most of any name you try might already been taken.
So the solution for the solution is, "Elf name generator". Yes, Elf name is less frequently use in gmail so you will have high chance to get register new email without phone number verification
Here is some list of website that generate Elf name for you (You can find many website by simply searching "elf name generator"). Good luck in creating your new email... legolas
- http://elf.namegeneratorfun.com/
- http://online-generator.com/name-generator/elf-name-generator.php
- http://chriswetherell.com/elf/index.php
That is all, your sincerely
Eärendur Fëfalas
Labels :
developer,
DIY,
internet,
Troubleshoot,
window tricks
Thursday, October 27, 2011
Netbean chinese character problem
Probably happen in my pc (Window XP Home)
Create a new .php file, then when I paste the chinese character it show all right
Problem rises when the display (like export into PDF)
This is because the character encoding for the netbeans (NetBeans IDE 6.9.1) is not UTF-8
So simply fix this problem by changing the file type. As for me, I'm using notepad2 to change to file type into UTF-8. Below is the example
http://localhost/search/
Create a new .php file, then when I paste the chinese character it show all right
Problem rises when the display (like export into PDF)
This is because the character encoding for the netbeans (NetBeans IDE 6.9.1) is not UTF-8
So simply fix this problem by changing the file type. As for me, I'm using notepad2 to change to file type into UTF-8. Below is the example
http://localhost/search/
Labels :
developer,
developer html,
developer php,
FPDF,
html,
netbeans,
phpexcel,
word
Tuesday, September 6, 2011
cakephp check database configuration exist and connection alive valid
Keyword
Check cakephp database configuration exist
Check cakephp database can be connect
In cakephp you need to configure the connection
The configuration file was in app/config/database.php
Inside the file, you can see 2 variable which is 'default' and 'test'
By default is 'default' but if you want to use 'test' in the controller for example, you need to call it like this
Problem arise is, can we connect to 'test' without problem?
So, here is the code I made. Been googling it and quite hard to found the solution, thus I'm putting this in my blog. lol...
This code will check
- Does the configuration 'test' exist
- If the configuration exist, does the database connection valid
If these 2 condition is pass, you can only have SQL Syntax Error like selecting table that does not exist
So here is the code (its free)
Reference
http://bakery.cakephp.org/articles/T0aD/2009/07/08/handle-database-connection-errors
http://debuggable.com/posts/handling-database-connection-errors-in-cakephp:480f4dd5-9570-421a-a04d-43cdcbdd56cb
Check cakephp database configuration exist
Check cakephp database can be connect
In cakephp you need to configure the connection
The configuration file was in app/config/database.php
Inside the file, you can see 2 variable which is 'default' and 'test'
By default is 'default' but if you want to use 'test' in the controller for example, you need to call it like this
$this->Mmodel->useDbConfig = 'test';
Problem arise is, can we connect to 'test' without problem?
So, here is the code I made. Been googling it and quite hard to found the solution, thus I'm putting this in my blog. lol...
This code will check
- Does the configuration 'test' exist
- If the configuration exist, does the database connection valid
If these 2 condition is pass, you can only have SQL Syntax Error like selecting table that does not exist
So here is the code (its free)
//Checking is done by connecting with the database
if (class_exists('DATABASE_CONFIG')){
$dbConfigName1 = 'test'; //<-- PUT YOUR DATABASE CONFIG VARIABLE NAME HERE
$dbConfig1 = new DATABASE_CONFIG();
//pr( $dbConfig1);
if( isset( $dbConfig1->$dbConfigName1)){
//Now check wether the database configuration, its alive!
//pr( $dbConfig1->$dbConfigName1);
$dbTemp1 =& ConnectionManager::getDataSource($dbConfigName1);
if( $dbTemp1->isConnected() == true){
//Means database exist and you can use it
echo "DATABASE CONFIG '$dbConfigName1' EXIST AND MANAGE TO CONNECT";
}
else{
//Database configuration exist, but cannot connect to the database
echo "DATABASE CONFIG '$dbConfigName1' EXIST BUT FAILED TO CONNECT";
}
}
else{
//The database configuration does not exist
echo "HAS NO DATABASE CONFIGURATION WITH NAME '$dbConfigName1'";
}
}
else{
//The database.php file not even exist. How can this be? IMPOSIBIEBERBEL!
echo "CANNOT FIND THE 'database.php' CONFIGURATION FILE";
}
Reference
http://bakery.cakephp.org/articles/T0aD/2009/07/08/handle-database-connection-errors
http://debuggable.com/posts/handling-database-connection-errors-in-cakephp:480f4dd5-9570-421a-a04d-43cdcbdd56cb
Labels :
developer,
developer cakephp,
developer mysql,
developer php
Wednesday, July 13, 2011
javascript slider for div simple
This is to make a javascript slider
The main concept was taken from here and modify it alot http://www.sitepoint.com/forums/javascript-15/slide-div-horizontally-449624.html
Below will be the code, if you want to see the demo, refer to this page http://legendarytesting.zymichost.com/codemo/sliderfinal.html
Note to remember
If you wandering how I convert these code into HTML syntax, refer it here http://puzzleware.net/CodeHTMLer/default.aspx
The main concept was taken from here and modify it alot http://www.sitepoint.com/forums/javascript-15/slide-div-horizontally-449624.html
Below will be the code, if you want to see the demo, refer to this page http://legendarytesting.zymichost.com/codemo/sliderfinal.html
Note to remember
- I have test and work well on these browser (except for different browser slide with different speed)
- Google Chrome (v10.0.648.205)
- Firefox (v5.0)
- Opera (v11.11)
- Safari (v5.0.5)
- Internet Explorer (v8.0.6001)
- Using these script, it will store value on element (not store inside the javascript which I think much better method). You may change these code for your own needs
- Note the padding must be inside the 3rd div, else it will run out of alignment (depend on your browser)
- The 2nd div (with 999px width) must be put and always put additional width (browser compability purpose also)
- Variable "Column width" is important, you need to add the padding value also (300px actual + 10px padding = 310px)
<html>
<head>
<title>Simple Slider</title>
<script type="text/javascript" language="javascript">
//<![CDATA[
function snapColumn( snapToCol)
{
slidingDiv = document.getElementById("d1");
divWidth = document.getElementById("columnwidth").innerHTML;
currentCol = document.getElementById("currentcolumn").innerHTML;
slidingDiv.style.left = -1 * (snapToCol-1) * divWidth;
document.getElementById("currentcolumn").innerHTML = snapToCol;
document.getElementById("poswatch").innerHTML = slidingDiv.style.left;
}
function slideLeft( stopPos)
{
slidingDiv = document.getElementById("d1");
document.getElementById("functiondebug").innerHTML = parseInt(document.getElementById("functiondebug").innerHTML) + 1;
if( parseInt(slidingDiv.style.left) > stopPos){
slidingDiv.style.left = parseInt(slidingDiv.style.left) - 2 + "px";
document.getElementById("poswatch").innerHTML = slidingDiv.style.left;
setTimeout(function(){slideLeft(stopPos)}, 2);
}
else{
document.getElementById("slidestatus").innerHTML = 0;
}
}
function nextColumn()
{
if( document.getElementById("slidestatus").innerHTML == 1){
return false;
}
document.getElementById("slidestatus").innerHTML = 1;
slidingDiv = document.getElementById("d1");
divWidth = document.getElementById("columnwidth").innerHTML;
currentCol = document.getElementById("currentcolumn").innerHTML;
currentCol = parseInt(currentCol) + 1;
stopPos = -1 * (currentCol-1) * divWidth;
if( currentCol > parseInt(document.getElementById("columntotal").innerHTML)){
document.getElementById("slidestatus").innerHTML = 0;
return false;
}
//alert(stopPos);
//slidingDiv.style.left = stopPos; //Snap to the position immidietely
slideLeft( stopPos);
document.getElementById("currentcolumn").innerHTML = currentCol;
}
function slideRight( stopPos)
{
slidingDiv = document.getElementById("d1");
document.getElementById("functiondebug").innerHTML = parseInt(document.getElementById("functiondebug").innerHTML) + 1;
if( parseInt(slidingDiv.style.left) < stopPos){
slidingDiv.style.left = parseInt(slidingDiv.style.left) + 2 + "px";
document.getElementById("poswatch").innerHTML = slidingDiv.style.left;
setTimeout(function(){slideRight(stopPos)}, 2);
}
else{
document.getElementById("slidestatus").innerHTML = 0;
}
}
function previousColumn()
{
if( document.getElementById("slidestatus").innerHTML == 1){
return false;
}
document.getElementById("slidestatus").innerHTML = 1;
slidingDiv = document.getElementById("d1");
divWidth = document.getElementById("columnwidth").innerHTML;
currentCol = document.getElementById("currentcolumn").innerHTML;
currentCol = parseInt(currentCol) - 1;
stopPos = -1 * (currentCol-1) * divWidth;
if( currentCol < 1){
document.getElementById("slidestatus").innerHTML = 0;
return false;
}
//alert(stopPos);
//slidingDiv.style.left = stopPos; //Snap to the position immidietely
slideRight( stopPos);
document.getElementById("currentcolumn").innerHTML = currentCol;
return true;
}
//]]>
</script>
</head>
<body>
<label>Variable</label>
<table border="1">
<tr>
<td>DIV current style.left</td>
<td><div id="poswatch">0</div></td>
</tr>
<tr>
<td>Check function executed</td>
<td><div id="functiondebug">0</div></td>
</tr>
<tr>
<td>Current column</td>
<td><div id="currentcolumn">1</div></td>
</tr>
<tr>
<td>Max no of column</td>
<td><div id="columntotal">3</div></td>
</tr>
<tr>
<td>Column width</td>
<td><div id="columnwidth">310</div></td>
</tr>
<tr>
<td>Slide Status</td>
<td><div id="slidestatus">0</div></td>
</tr>
</table>
<div style="height: 50px;"></div>
<label>Use this to slide</label><br/>
<b onclick="previousColumn()">< BACK</b> | <b onclick="nextColumn()">NEXT ></b>
<div style="height: 50px;"></div>
<label>Use this to snap to specific column</label><br/>
<a onclick="snapColumn(1)">[1]</a> | <a onclick="snapColumn(2)">[2]</a> | <a onclick="snapColumn(3)">[3]</a>
<div style="height: 50px;"></div>
<!-- 1st div -->
<div style="width: 310px; overflow: hidden; border: 1px dashed black;">
<!-- 2nd div -->
<div id="d1" style="width: 999px; position: relative; left: 0px;">
<!-- 3rd div (a) -->
<div style="width: 310px; height: 100px; background-color: plum; float: left;" align="right">
<div style="padding: 5px;">
<b>SPARTA !!!!!!!!!!!!!!!!!!!!!</b>
</div>
</div>
<!-- 3rd div (b) -->
<div style="width: 310px; height: 100px; background-color: bisque; float: left;" align="right">
<div style="padding: 5px;">
<b>IS !!!!!!!!!!!!!!!!!!!!!</b>
</div>
</div>
<!-- 3rd div (c) -->
<div style="width: 310px; height: 100px; background-color: powderblue; float: left;" align="right">
<div style="padding: 5px;">
<b>THIS !!!!!!!!!!!!!!!!!!!!!</b>
</div>
</div>
</div>
</div>
</body>
</html>If you wandering how I convert these code into HTML syntax, refer it here http://puzzleware.net/CodeHTMLer/default.aspx
Tuesday, June 7, 2011
Get web server application folder name WAMP LAMP
Let say you have a web application like wordpress in your localhost web server (WAMP)
The wordpress name is 'wordpressasipo'
Thus, the path to these is
C:\wamp\www\wordpressasipo
While in localhost it will be
http://localhost:80/wordpressasipo
The problem here is how the get the 'application name' (which is wordpressasipo) dynamically
Means even after you change the folder name (into wordpressasipo1 for example) it will still work
Here is the solution, quite usefull and I cant get this in quick googling
Thus, if your application was in C:\wamp\www\wordpressasipo will return string wordpressasipo
The wordpress name is 'wordpressasipo'
Thus, the path to these is
C:\wamp\www\wordpressasipo
While in localhost it will be
http://localhost:80/wordpressasipo
The problem here is how the get the 'application name' (which is wordpressasipo) dynamically
Means even after you change the folder name (into wordpressasipo1 for example) it will still work
Here is the solution, quite usefull and I cant get this in quick googling
basename( realpath('.'));
Thus, if your application was in C:\wamp\www\wordpressasipo will return string wordpressasipo
Friday, May 6, 2011
phpmyadmin too many table in database cause pagination
![]() |
| Too many table will automatically create a page pagination |
If you are using phpmyadmin version 3.3.9, and your table in the database is alot (about 600 table)
then the page number will appear (these called pagination in web term, I think)
These page number is quite annoying since I remember some important table name from the database and having a page number slow me down cause I search the table name by using "Ctrl + F" from Google Chrome
Thus, when I Ctrl+F and type the table name, it does not appear...
Note that phpmyadmin work best when using Google Chrome (because of its "Ctrl +F" function) compared to Firefox, Opera and Safari (I have test them all and these in only an opinion)
So, the reason behind all my problem lies in the default config @global integer $cfg['MaxTableList'] where it will do a pagination for database table (set default into display 250 table in a page)
![]() |
| The reason, change this and all problem solved! |
So, regarding on which IDE did you use in programming, search globally (in whole project) for string name @global integer $cfg['MaxTableList']
If you are using windows with WampServer Version 2.1, the phpmyadmin program is located at C:\wamp5\apps\phpmyadmin3.3.9
If you are lazy or not have a capability to find the whole project, here is the location
C:\wamp5\apps\phpmyadmin3.3.9\libraries\config.default.php (on line 501)
thats all, hope its usefull
Labels :
developer,
developer mysql,
developer php,
phpmyadmin
Thursday, March 24, 2011
Disable history back if pressing backspace
If you press backspace on the website page (but not on textbox) it will go to its previous page
This is to disable them
Taken from here, then I modified
http://www.sitepoint.com/forums/javascript-15/disable-back-javascript-168890.html
These is javascript coding
This is to disable them
Taken from here, then I modified
http://www.sitepoint.com/forums/javascript-15/disable-back-javascript-168890.html
These is javascript coding
//DISABLE "GO BACK TO PREVIOUS HISTORY" IF PRESSING "BACKSPACE"
if (typeof window.event != 'undefined')
document.onkeydown = function()
{
if( event.keyCode == 8){
theEvent = event.srcElement.tagName.toUpperCase();
if( theEvent == 'HTML'){
return false;
}
else if( theEvent == 'INPUT'){
theType = event.srcElement.getAttribute('type').toUpperCase();
//alert(theType);
switch(theType){
case 'TEXT':
return true;
break;
default:
return false;
}
return false;
}
else{
switch( theEvent){
case 'TEXTAREA':
return true;
break;
default:
//alert('Backspace pressed on ' + theEvent + ', return false');
return false;
}
return false;
}
}
}
else
document.onkeypress = function(e)
{
if( e.keyCode == 8){
theEvent = e.target.nodeName.toUpperCase();
if( theEvent == 'HTML'){
return false;
}
else if( theEvent == 'INPUT'){
theType = e.target.getAttribute('type').toUpperCase();
//alert(theType);
switch(theType){
case 'TEXT':
return true;
break;
default:
return false;
}
return false;
}
else{
switch( theEvent){
case 'TEXTAREA':
return true;
break;
default:
//alert('Backspace pressed on ' + theEvent + ', return false');
return false;
}
return false;
}
}
}
Labels :
developer,
developer html,
developer php,
html,
javascript
Saturday, March 19, 2011
javascript detect and capture keyboard keycode
These is how to capture what user have type in their keyboard
The captured data is the "keycode" which is an integer
Like 'enter' key, the code is 13
Some data that I have discover and might be usefull to others and myself
These was tested and the same for IE, Firefox, Google Chrome and Safari
Lets get to the code
Type something here :
The captured data is the "keycode" which is an integer
Like 'enter' key, the code is 13
Some data that I have discover and might be usefull to others and myself
These was tested and the same for IE, Firefox, Google Chrome and Safari
| a until z | keycode 97 until 122 |
| A until Z | keycode 65 until 90 |
| 0 until 9 | keycode 48 until 57 |
Lets get to the code
function whatKeyCodeHaveIType( theEvent)
{
charCode = (theEvent.which) ? theEvent.which : theEvent.keyCode
theTempoElement = document.getElementById('thisiswhatyouhavetpye');
theTempoElement.innerHTML = theTempoElement.innerHTML + ', ' + charCode;
//This is to ignore "ENTER" key. Its usefull to prevent a form from autosubmit if you press enter
return (charCode != 13);
}
//Later in HTML, use these
<input id="whatyouhavetype" style="width: 500px;" onkeypress="return whatKeyCodeHaveIType(event);"/>
<textarea id="thisiswhatyouhavetpye" cols="70" rows="5"></textarea>
Type something here :
Labels :
developer,
developer html,
developer php,
html,
javascript
javascript detect finish typing keystroke delay autocomplete
Okay, the title might be confusing but here is what these about
You want to execute certain function, right after the user has finish its typing
These is different from normal 'keypress' or 'keyup' or 'keydown' event detection because these will execute a function every key is press. Right now you want to give certain delay so that the function only execute at the right time
These is important if you developing an autocomplete (AJAX) because you dont want to execute the script too much. Typing "HELLO" means you do the SQL statement 5 times
H
HE
HEL
HELL
HELLO
But if you do a proper keystroke delay (detect user finish typing) you will only execute the SQL statement once
HELLO
Cut to the story, hopefully understand what I was trying to explain at the top
Here is the function
Type something here : (These input id is 'typesomethinghere')
The script will only execute after you finish typing. By assuming when you have stop typing for 0.7 seconds, means you have finish typing
Type something here :
These is what happen if you dont use the script
You want to execute certain function, right after the user has finish its typing
These is different from normal 'keypress' or 'keyup' or 'keydown' event detection because these will execute a function every key is press. Right now you want to give certain delay so that the function only execute at the right time
These is important if you developing an autocomplete (AJAX) because you dont want to execute the script too much. Typing "HELLO" means you do the SQL statement 5 times
H
HE
HEL
HELL
HELLO
But if you do a proper keystroke delay (detect user finish typing) you will only execute the SQL statement once
HELLO
Cut to the story, hopefully understand what I was trying to explain at the top
Here is the function
var typingTimer;
var doneTypingInterval = 700;
//Detect keystroke and only execute after the user has finish typing
function delayExecute()
{
clearTimeout(typingTimer);
typingTimer = setTimeout(
function(){somethingExecuted('typesomethinghere')},
doneTypingInterval
);
return true;
}
function somethingExecuted( theInputName)
{
alert( "You have type '" + document.getElementById(theInputName).value + "'");
}
//Later in the HTML code, put these
<input onkeypress="return delayExecute();" id="typesomethinghere">
Type something here : (These input id is 'typesomethinghere')
The script will only execute after you finish typing. By assuming when you have stop typing for 0.7 seconds, means you have finish typing
Type something here :
These is what happen if you dont use the script
Labels :
developer,
developer html,
developer php,
html,
javascript
Monday, March 14, 2011
Install LAMP on Ubuntu
These is a double posting, the original was from here http://asipi.blogspot.com/2009/10/haih.html
I write it back here because the title and here will be the latest updated place
(Yes I do update these post again if got any changes)
1
Install apache & mysql & phpmyadmin : http://www.howtoforge.com/ubuntu_lamp_for_newbies
*Update 23 Jan 2010
My Software source was from Malaysia and it has problem!. So it set my source to "Main Server" (Software source download from Main Server)
2
Enable the www folder
This will make your be able to add new folder into the localhost
using terminal :
/var/www/smellynomore means http://localhost/smellynomore
3
You will realize that u cant open the phpmyadmin on http://localhost/phpmyadmin
This is because when you see inside /var/www there is no "phpmyadmin" folder
Solve it by referring here http://ubuntuforums.org/showthread.php?t=1036836
Solve by doing this in terminal :
4
Additional configuration for the mysql
When you first time install the mySQL, everything is working fine.
But then, after you reboot the PC, the mySQL server cant start.
The mySQL configuration file will be missing after boot
After some haih...checking, you will realize that file inside "/var/run/mysqld" is missing
I solve it by this link, http://ubuntuforums.org/showthread.php?t=386056
Try to chown to "mysql.mysql" if owned by root, and give it a 755
It is because of the folder write permission
How to chown and chmod, please note that I dont know what happen to security issue when I done this, just want to 'make it work!'
5
Load the mod_rewrite module
I google here to solve it http://ubuntuforums.org/showthread.php?t=255556&page=2
Using terminal :
After that change AllowOverride None to AllowOverride All
Then, restart Apache
6
Additional, command to mySQL server (check, start, restart and stop)
http://abbysays.wordpress.com/2008/05/20/how-to-startstop-mysql-server-on-ubuntu-804/
Setting up the cakePHP 1.2.5
There will be 2 problem
1. Warning (512): /var/www/cakemake/app/tmp/cache/ is not writable [CORE/cake/libs/cache/file.php, line 262]
2. Your tmp directory is NOT writable.
Solve by : Once again chmod 777 is not secure, yeah!
7
Install x-debug
http://ubuntuforums.org/showthread.php?t=525257
EDITED #2 (Feb 2011)
I dont know why lately my xdebug does not working. So I edit the php.ini file
I make the all to be "Deleopment mode" because its defaulted to "Production mode"
So I guess that is the reson, plus use this on ERROR Report
8
After that, it will read index.html
I dont know how to change it for the thing to refer into index.php
However, this is the index.php code (simple version of mine)
Thus when you open your http://localhost/index.php will get something like this
9
phpMyAdmin login might be annoying, solve it from here http://asipi.blogspot.com/2011/02/disable-phpmyadmin-login.html
10 Edit 28 Nov 2012
To install CURL. I follow this website http://buzznol.blogspot.com/2008/12/install-curl-extension-for-php-in.html
Basically, in terminal type : sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
Then restart the LAMP server, then test it using var_dump(curl_version()); make sure to put -pre- html tag around it
Note that to restart the server. Using this command seems to be even better. Feel like it was relly restarting... sudo /etc/init.d/apache2 restart
Thats all
good luck, kupo!
I write it back here because the title and here will be the latest updated place
(Yes I do update these post again if got any changes)
1
Install apache & mysql & phpmyadmin : http://www.howtoforge.com/ubuntu_lamp_for_newbies
*Update 23 Jan 2010
My Software source was from Malaysia and it has problem!. So it set my source to "Main Server" (Software source download from Main Server)
2
Enable the www folder
This will make your be able to add new folder into the localhost
using terminal :
Please note that /var/www is your root for the website
sudo chmod -R 777 '/var/www'
/var/www/smellynomore means http://localhost/smellynomore
3
You will realize that u cant open the phpmyadmin on http://localhost/phpmyadmin
This is because when you see inside /var/www there is no "phpmyadmin" folder
Solve it by referring here http://ubuntuforums.org/showthread.php?t=1036836
Solve by doing this in terminal :
sudo ln -s '/usr/share/phpmyadmin' '/var/www'
4
Additional configuration for the mysql
When you first time install the mySQL, everything is working fine.
But then, after you reboot the PC, the mySQL server cant start.
The mySQL configuration file will be missing after boot
After some haih...checking, you will realize that file inside "/var/run/mysqld" is missing
I solve it by this link, http://ubuntuforums.org/showthread.php?t=386056
Try to chown to "mysql.mysql" if owned by root, and give it a 755
It is because of the folder write permission
How to chown and chmod, please note that I dont know what happen to security issue when I done this, just want to 'make it work!'
sudo chown -R asipo '/var/run/mysqld'
sudo chmod -R 777 '/var/run/mysqld'
5
Load the mod_rewrite module
I google here to solve it http://ubuntuforums.org/showthread.php?t=255556&page=2
Using terminal :
sudo a2enmod rewrite
sudo gedit /etc/apache2/sites-enabled/000-default
After that change AllowOverride None to AllowOverride All
Then, restart Apache
sudo /etc/init.d/apache2 force-reload
6
Additional, command to mySQL server (check, start, restart and stop)
http://abbysays.wordpress.com/2008/05/20/how-to-startstop-mysql-server-on-ubuntu-804/
Setting up the cakePHP 1.2.5
There will be 2 problem
1. Warning (512): /var/www/cakemake/app/tmp/cache/ is not writable [CORE/cake/libs/cache/file.php, line 262]
2. Your tmp directory is NOT writable.
Solve by : Once again chmod 777 is not secure, yeah!
sudo chown -R asipo '/var/www/smellynomore/app/tmp'
sudo chmod -R 777 '/var/www/smellynomore/app/tmp'
7
Install x-debug
http://ubuntuforums.org/showthread.php?t=525257
EDITED #2 (Feb 2011)
I dont know why lately my xdebug does not working. So I edit the php.ini file
I make the all to be "Deleopment mode" because its defaulted to "Production mode"
So I guess that is the reson, plus use this on ERROR Report
error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE
8
After that, it will read index.html
I dont know how to change it for the thing to refer into index.php
However, this is the index.php code (simple version of mine)
<p><b>Localhost</b></p>If you have been wandering how I put this code into this blog. This is the place http://asipi.blogspot.com/2011/01/write-blog-post-using-tinymce.html
<p>Select folder or file to navigate</p>
<?php
echo "<ul>";
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo "<li><a href='$file'>$file<a></li>";
}
}
closedir($handle);
}
echo "</ul>";
?>
Thus when you open your http://localhost/index.php will get something like this
9
phpMyAdmin login might be annoying, solve it from here http://asipi.blogspot.com/2011/02/disable-phpmyadmin-login.html
10 Edit 28 Nov 2012
To install CURL. I follow this website http://buzznol.blogspot.com/2008/12/install-curl-extension-for-php-in.html
Basically, in terminal type : sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
Then restart the LAMP server, then test it using var_dump(curl_version()); make sure to put -pre- html tag around it
Note that to restart the server. Using this command seems to be even better. Feel like it was relly restarting... sudo /etc/init.d/apache2 restart
Thats all
good luck, kupo!
Labels :
developer,
developer mysql,
developer php,
DIY,
Troubleshoot,
ubuntu
Thursday, February 17, 2011
Disable phpmyadmin login
PhpMyAdmin is a webbased database management application and it is a very good tool for developer.
But there is one problem if you want to install it localhost which is annoying login after AFK for a while
I have google for these solution and the result wasnt good enough so I post this so I can refer it back
Manage to work it out by referring the manual http://www.phpmyadmin.net/documentation/#servers_user
Nows lets disable the annoying login
Advantage: no annoying
Disadvantage: Less secure, password stored in a file without encrypted
These was tested on Ubuntu machine version 10.10 so I'm not sure about windows
The version of phpmyadmin is 3.3.7deb3build0.10.10.1
1st open the configuration of the phpmyadmin file
Search for string "/* Authentication type */" (its at line no 35)
Disable the "cookie" auth_type and put these code. It should look like these
So you eventually change the auth_type into 'config' and you required to put the username and password for that
To test the annoying login is now disabled, restart your FireFox (reset the cache) and try to direct to the phpmyadmin (In my case I type "http://localhost/phpmyadmin/" in my FireFox URL)
It work when you are not asked for login. KUPO!
p/s: I know the file was /etc/phpmyadmin/config.ini.php is from file /var/www/phpmyadmin/config.inc.php
Edit 29 Nov 2012
For phpMyAdmin 3.4.11 the configuration file for windows was in libraries/config.default.php
here is my setting, for localhost development
$cfg['Servers'][$i]['auth_type'] = 'config'; //Default is cookie
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['nopassword'] = true; //Default is false
$cfg['Servers'][$i]['AllowNoPassword'] = true; //Default is false
But there is one problem if you want to install it localhost which is annoying login after AFK for a while
I have google for these solution and the result wasnt good enough so I post this so I can refer it back
Manage to work it out by referring the manual http://www.phpmyadmin.net/documentation/#servers_user
Nows lets disable the annoying login
Advantage: no annoying
Disadvantage: Less secure, password stored in a file without encrypted
These was tested on Ubuntu machine version 10.10 so I'm not sure about windows
The version of phpmyadmin is 3.3.7deb3build0.10.10.1
1st open the configuration of the phpmyadmin file
sudo gedit /etc/phpmyadmin/config.inc.php
Search for string "/* Authentication type */" (its at line no 35)
Disable the "cookie" auth_type and put these code. It should look like these
/* Authentication type */
//$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'mypasswordissecret';
So you eventually change the auth_type into 'config' and you required to put the username and password for that
To test the annoying login is now disabled, restart your FireFox (reset the cache) and try to direct to the phpmyadmin (In my case I type "http://localhost/phpmyadmin/" in my FireFox URL)
It work when you are not asked for login. KUPO!
p/s: I know the file was /etc/phpmyadmin/config.ini.php is from file /var/www/phpmyadmin/config.inc.php
Edit 29 Nov 2012
For phpMyAdmin 3.4.11 the configuration file for windows was in libraries/config.default.php
here is my setting, for localhost development
$cfg['Servers'][$i]['auth_type'] = 'config'; //Default is cookie
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['nopassword'] = true; //Default is false
$cfg['Servers'][$i]['AllowNoPassword'] = true; //Default is false
Labels :
developer,
developer mysql,
developer php,
Troubleshoot,
ubuntu
Tuesday, February 8, 2011
Javascript numeric input
This is my cheatsheet while playing with the javascript, always forgot about them so I job it down here
Easy to find, one of them is in here
http://javascript.internet.com/forms/validate-numeric-only.html
Round a number into 2 decimal place
Convert string to Integer
http://www.keyboardface.com/archives/2006/04/04/javascript-string-to-int/
Another alternative for number format
http://www.pageresource.com/jscript/j_a_03.htm
Check is numeric
http://andrewpeace.com/javascript-is-numeric.html AND http://bytes.com/topic/javascript/answers/526119-convert-double-cdbl-javascript
Adding and removing 'readonly' attribute to element
http://bytes.com/topic/javascript/answers/655784-change-textbox-readonly
Change the element background
http://www.codeproject.com/KB/scripting/focusBGColor.aspx
Select all the text in textbox
http://javascript-array.com/scripts/onclick_select_all_text_in_field/
p/s: Remember not to use 'onclick' function because just in case the user dont want to select all (they made typo mistake and want to remove only 1 character)
Check the element has what attribute
There is a source, but I forget whare I take it from
p/s: The attribute can be anything actually, typically is 'readonly' for textbox
Easy to find, one of them is in here
http://javascript.internet.com/forms/validate-numeric-only.html
Round a number into 2 decimal place
var result = Math.round(annualPremium*100)/100
Convert string to Integer
http://www.keyboardface.com/archives/2006/04/04/javascript-string-to-int/
parseInt(10.10) //Return 10
Another alternative for number format
http://www.pageresource.com/jscript/j_a_03.htm
profits.toFixed(2) //returns 2489.82
profits.toPrecision(4) //returns 123.5 (round up)
Check is numeric
http://andrewpeace.com/javascript-is-numeric.html AND http://bytes.com/topic/javascript/answers/526119-convert-double-cdbl-javascript
valueCredit = document.getElementById('thisIsSparrta').value;
if( valueCredit != '' && !isNaN(valueCredit)){
totalCredit += parseFloat(valueCredit);
}Adding and removing 'readonly' attribute to element
http://bytes.com/topic/javascript/answers/655784-change-textbox-readonly
document.getElementById('helloworld').setAttribute('readonly', true);
document.getElementById('helloworld').removeAttribute('readonly');
Change the element background
http://www.codeproject.com/KB/scripting/focusBGColor.aspx
document.getElementById('helloworld').style.backgroundColor = '#EBEBE4';
Select all the text in textbox
http://javascript-array.com/scripts/onclick_select_all_text_in_field/
document.getElementById(id).focus();
document.getElementById(id).select();
p/s: Remember not to use 'onclick' function because just in case the user dont want to select all (they made typo mistake and want to remove only 1 character)
Check the element has what attribute
There is a source, but I forget whare I take it from
document.getElementById.hasAttribute('acinput')
p/s: The attribute can be anything actually, typically is 'readonly' for textbox
Sunday, January 30, 2011
Prevent mail from spam or junk by encryption from crawler
If you write a blog and put your email on it. There is a chance for you to get Spam/Junk mail
This can be cause of many reason but I'm focus on crawler method
How this spam works?
Basically this is the procedure
1. They find your email
2. They write email to you
Spam usually include 1000 email or more and of course it is done by using a bot (a system) and not just people manually type in
To find your email
They using web-crawler, spam-crawler or anything-crawler. These crawler will browse slowly through the internet (from blog to blog, website to website until forever). If your blog put an hyperlink of your friend blog (blogroll they called) these crawler will go into it
Thus in, programming these crawler detect 2 things
1st detection
Detect "http://" text. If they found and word, URL or string match. They will retrieve the link and put in on the "Next going to be crawl list"
2nd detection
Since they want to spam to your mail, they simply find any string or word with "@" symbol. Thus your email will be captured in these process
Write email to you (spam)
These is a process of producing mass email and of course they use the list they got from the first step and use a bot (system) to mass mail it
Prevention
There is 2 type of prevention
1. Email filter (thats why you have spam/junk mail categories)
2. Prevent your email from being on the spammer list
1st prevention - Filter your mailbox
This is already common and build in feature for almost all email system like gmail and others. So no need discussing much
2nd prevention - Prevent from listed
This is what I want to discussed about
Usually people will make their email not in easy format or encryption.
Using different email format like (let say your email is ajskdhqjeakjbdia@gmail.com)
Email: ajskdhqjeakjbdia (@gmail)
Email: ajskdhqjeakjbdia at gmail dot com
Or they use encryption like these
ajskdhqjeakjbdia@gmail.com
(It looks normal but it is actually encrpted)
So these encryption can be easily google. But I'm suggesting you the simplest one which taken from these website http://www.web-designz.com/tools/email_encoder.shtml
Note: The simplest method might also means it is easily detectable by the crawler
If you are a programmer and wandering how did the website do the answer is they are using convertToUnicode(...) function
If you view the page source. It wont show and "@" or your email at all because it is encrypted and of course the crawler is a system, they read the page source and not reading like you did (using web browser)
-End-
This can be cause of many reason but I'm focus on crawler method
How this spam works?
Basically this is the procedure
1. They find your email
2. They write email to you
Spam usually include 1000 email or more and of course it is done by using a bot (a system) and not just people manually type in
To find your email
They using web-crawler, spam-crawler or anything-crawler. These crawler will browse slowly through the internet (from blog to blog, website to website until forever). If your blog put an hyperlink of your friend blog (blogroll they called) these crawler will go into it
Thus in, programming these crawler detect 2 things
1st detection
Detect "http://" text. If they found and word, URL or string match. They will retrieve the link and put in on the "Next going to be crawl list"
2nd detection
Since they want to spam to your mail, they simply find any string or word with "@" symbol. Thus your email will be captured in these process
Write email to you (spam)
These is a process of producing mass email and of course they use the list they got from the first step and use a bot (system) to mass mail it
Prevention
There is 2 type of prevention
1. Email filter (thats why you have spam/junk mail categories)
2. Prevent your email from being on the spammer list
1st prevention - Filter your mailbox
This is already common and build in feature for almost all email system like gmail and others. So no need discussing much
2nd prevention - Prevent from listed
This is what I want to discussed about
Usually people will make their email not in easy format or encryption.
Using different email format like (let say your email is ajskdhqjeakjbdia@gmail.com)
Email: ajskdhqjeakjbdia (@gmail)
Email: ajskdhqjeakjbdia at gmail dot com
Or they use encryption like these
ajskdhqjeakjbdia@gmail.com
(It looks normal but it is actually encrpted)
So these encryption can be easily google. But I'm suggesting you the simplest one which taken from these website http://www.web-designz.com/tools/email_encoder.shtml
Note: The simplest method might also means it is easily detectable by the crawler
If you are a programmer and wandering how did the website do the answer is they are using convertToUnicode(...) function
If you view the page source. It wont show and "@" or your email at all because it is encrypted and of course the crawler is a system, they read the page source and not reading like you did (using web browser)
-End-
Labels :
developer,
developer cakephp,
developer html,
developer php,
DIY,
html
Saturday, January 29, 2011
Make a horizontal list
This is more like HTML & CSS tutorial to make ordered list to go vertical
This is order list (normal)
- Hello
- This is
- Testing
This is order list (horizontal)
I actually copy the code from this guy http://leandrovieira.com/projects/jquery/lightbox/
<style type="text/css">
/* jQuery lightBox plugin - Gallery style */
#gallery {
background-color: #444;
padding: 10px;
width: 520px;
}
#gallery ul { list-style: none; }
#gallery ul li { display: inline; }
#gallery ul img {
border: 5px solid #3e3e3e;
border-width: 5px 5px 20px;
}
#gallery ul a:hover img {
border: 5px solid #fff;
border-width: 5px 5px 20px;
color: #fff;
}
#gallery ul a:hover { color: #fff; }
</style>
<div id="gallery">
<ul>
<li>Hello</li>
<li>This is</li>
<li>Testing</li>
</ul>
</div>
The result
- Hello
- This is
- Testing
Tuesday, January 25, 2011
HTML UTF encoding entities
I was doing some project require math symbol. The key was not exist in keyboard
The website that I use as reference is
http://www.fileformat.info/info/unicode/char/b1/index.htmThe link is a plus minus symbol (±). You can search fur further symbol at the top left
Or also here
http://www.danshort.com/HTMLentities/index.php?w=hertz
Labels :
developer,
developer cakephp,
developer html,
developer php,
html
Thursday, January 20, 2011
PHP generate document PDF, ODT, Excel (XLS)
Just to record down any PHP library that can help in generate document
PDF
FPDF = http://www.fpdf.org/
ODT
odtPHP = http://www.odtphp.com/
XLS (Excel)
PHPExcel = http://phpexcel.codeplex.com/
odtPHP is from Anaska. Who / what is Anaska?
Not sure for myself but I do belive they produce something really useful. Check out your WAMP it is from Anaska too :D
FPDF = http://www.fpdf.org/
ODT
odtPHP = http://www.odtphp.com/
XLS (Excel)
PHPExcel = http://phpexcel.codeplex.com/
odtPHP is from Anaska. Who / what is Anaska?
Not sure for myself but I do belive they produce something really useful. Check out your WAMP it is from Anaska too :D
Tuesday, January 11, 2011
PHPExcel
PHPExcel make a nice looking table header
Actually is not really nice looking. Just a proper presentation...
There is too many code and I got no time to upload...
Sources from here
http://phpexcel.codeplex.com/Thread/View.aspx?ThreadId=32427
Actually is not really nice looking. Just a proper presentation...
There is too many code and I got no time to upload...
Sources from here
http://phpexcel.codeplex.com/Thread/View.aspx?ThreadId=32427
$headerStart = 22; //Start row
foreach( array( 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'M', 'N', 'O', 'Q', 'R', 'S', 'T') as $alphabet){
$objPHPExcel->getActiveSheet()->getStyle($alphabet.$headerStart)->getAlignment()->setWrapText(true);
$objPHPExcel->getActiveSheet()->mergeCells( $alphabet.$headerStart.":".$alphabet.($headerStart+1));
$objPHPExcel->getActiveSheet()->getStyle($alphabet.$headerStart)->getAlignment()->setVertical( PHPExcel_Style_Alignment::VERTICAL_CENTER);
}
Wednesday, January 5, 2011
CakePHP connect 2, many, multiple database
Tag
CakePHP connect with more than 1 database
CakePHP connect multiple database
CakePHP connect more database
CakePHP connect 2 database
CakePHP connect with 2 database. 1 is CakePHP structured and another 1 is not
The main source is from here
http://blog.4webby.com/posts/view/6/cakephp_models_using_multiple_db_connections
Repeat the same thing
Here is some additional
1. I can connect even without make it persistance.
Note that tbl_lecturer is another non cakePHP database. It used MySQL database and query does take the data nicely
If you want to check the database connection. Refer here http://asipi.blogspot.com/2011/09/cakephp-check-database-configuration.html
CakePHP connect with more than 1 database
CakePHP connect multiple database
CakePHP connect more database
CakePHP connect 2 database
CakePHP connect with 2 database. 1 is CakePHP structured and another 1 is not
The main source is from here
http://blog.4webby.com/posts/view/6/cakephp_models_using_multiple_db_connections
Repeat the same thing
class DATABASE_CONFIG {
var $default = array(
'driver' => 'mysql',
'persistent' => false,
'host' => 'your_host',
'login' => 'your_login_1',
'password' => 'your_password_1',
'database' => 'DB_1',
'prefix' => ''
);
var $general_syst = array(
'driver' => 'mysql',
'persistent' => false,
'host' => 'your_host',
'login' => 'your_login_2',
'password' => 'your_password_2',
'database' => 'DB_2',
'prefix' => ''
);
}
?>
class User extends AppModel {
var $name = 'User';
var $useDbConfig = 'general_syst';
//your code here
//....
}
class Post extends AppModel {
var $name = 'Post';
var $useDbConfig = 'default';
//your code here
//....
}
$this->Post->bla_bla_bla : data will be retrieved/inserted/updated from DB_1
$this->User->bla_bla_bla : data will be retrieved/inserted/updated from DB_2
Here is some additional
1. I can connect even without make it persistance.
pr($this->Student->useDbConfig);
$this->Student->useDbConfig = 'general_syst';
$ret = $this->Student->query("SELECT * FROM tbl_lecturer");
Note that tbl_lecturer is another non cakePHP database. It used MySQL database and query does take the data nicely
If you want to check the database connection. Refer here http://asipi.blogspot.com/2011/09/cakephp-check-database-configuration.html
Labels :
developer,
developer cakephp,
developer mysql,
developer php
Subscribe to:
Posts (Atom)





