Archive for the ‘mysql’ Category

Sentiment Analytics in Django

April 27th, 2010

Been busy with lots of stuff – especially with work. Thus, unable to update as frequently as I would like. Sorry ya.

Anyway, been catching up with some backlogs. I did a simple conversion of part of my FYP into python (django). And have hosted in here: http://analytics.weeyoung.com/sa/analysis.

Well, what it does is you submit some words and it breaks them up and see the overall sentiment of your words.

Still lots of parts not done. lots of breakages. still figuring out which is better – drawing with matplotlib or jquery. Analysis of the words are still immature (e.g. no spelling checks)

But its a start! Looking into consolidating with rss feed. Found this site useful and will try it out.

All in all. If there’s anything u like to see, or any ideas. Feel free to let me know @ weiyang13@gmail.com..

Cheers. ;)

VN:F [1.9.6_1107]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.6_1107]
Rating: +1 (from 1 vote)
DiggTwitterTechnorati FavoritesRedditNewsVineFacebookShare

PHP convert date to timestamp

April 21st, 2009

Instead of finding a way to manipulate 2 date pickers and find the range of dates and use each date.

why not convert each date produced by the date picker into unix timestamp and find the range

<?

//begindate/enddate has a format of  “m d Y”

$splitbegindate = explode(‘ ‘, $begindate);
$splitenddate = explode(‘ ‘, $enddate);
$timestamp = mktime(’00′, ’00′, ’00′, $splitbegindate[0], $splitbegindate[1], $splitbegindate[2]);
$timestampend = mktime(’23′, ’59′, ’59′, $splitenddate[0], $splitenddate[1], $splitenddate[2]);

// and then do the query
$query = “Select count(*),username, SUM(time_duration),… from $table where timestamp BETWEEN $timestamp AND $timestampend group by …. “;

?>

much easier right?

VN:F [1.9.6_1107]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.6_1107]
Rating: 0 (from 0 votes)
DiggTwitterTechnorati FavoritesRedditNewsVineFacebookShare

Import and Export Mysql Database

April 16th, 2009

Found this pretty useful

For exporting DB:

mysqldump -u username -ppassword database_name > FILE.sql

while importing DB:

mysql -u username -ppassword database_name < FILE.sql

 easy but useful.. =) oh.. and got it on this site: Clockwatchers thanks. =)

Finally seeing the light.. =)

VN:F [1.9.6_1107]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.6_1107]
Rating: 0 (from 0 votes)
DiggTwitterTechnorati FavoritesRedditNewsVineFacebookShare

Unable to connect to the database:The MySQL adapter “mysql” is not available.

April 3rd, 2009

was trying to use PHP, mysql, IIS and joomla.

somehow, i keep getting this error

Unable to connect to the database:The MySQL adapter “mysql” is not available.

well. most forum says its my php not having the extension and php.ini not having the extension as follows:

extension=php_mysql.dll

I install and uninstall countless times, removed the ini in the process too to make sure things are properly installed. and i check my php.ini and the extension is there.. the dll file is there too.

I dunt understand whats wrong.. zzz. maybe its the lack of sleep…

on the sidenote.. im trying out symfony. hopefully it’ll be good. =) and learning cron jobs and some bash scripts.. =)

VN:F [1.9.6_1107]
Rating: 6.8/10 (4 votes cast)
VN:F [1.9.6_1107]
Rating: -1 (from 3 votes)
DiggTwitterTechnorati FavoritesRedditNewsVineFacebookShare

Importing CSV to mysql

March 17th, 2009

Something pretty straight forward..

if i have a csv as shown below

to import to mysql
1) go to the directory of the csv file. e.g. words.csv

“airy”
“amused”
“animated”
“beatific”
“blissful”
“blithe”
“bright”
“brisk”
“buoyant”
“cheerful”

3) go into mysql admin

mysql -u root -p

4) run command

>LOAD DATA INFILE “./words.csv” INTO TABLE happy FIELDS TERMINATED BY “,” OPTIONALLY ENCLOSED BY “”"” TERMINATED BY ‘\n’;

the words.csv is saved under /var/lib/mysql.

5) and its done.

mysql> select * from happy;

+—————-+
| name            |
+—————-+
| airy                |
| amused        |
| animated      |
| beatific          |
| blissful           |
| blithe             |
| bright            |

VN:F [1.9.6_1107]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.6_1107]
Rating: 0 (from 0 votes)
DiggTwitterTechnorati FavoritesRedditNewsVineFacebookShare
Get Adobe Flash playerPlugin by wpburn.com wordpress themes