Tuesday, December 7, 2010

Per user tags and recent tags display

TODO: need per-user tags table
that will have uid -> array tag => count
update on every question user posts

===============================

How to find all questions AND answers per user per tag?

If we have tags in answers then it's easy just search for tag $in + $uid
then the same in QUESTIONS

So we really must have tags in ANSWERS!

===================================

Every time a user posts an answer we must also update PER_USER_TAGS collection

=====================================

It would be cool to have PER_USER_VIEWS table

question_id, uid, hts (i_ts not necessary because we can just sort by _id)

Can also collect "interesting tags" based on user views, questions, answers!

======================

Handling "save draft": best is to save draft into USER object under 'q_draft' as array
of title, body, tags

And for answer is a_draft and alo draft_c for comment!

Then after submit answer/question/comment but delete the value from user object

====================================

TODO: when showing "recent tags" Stack does sneaky thing:
it ALWAYS show "YOUR INTERESTING" tags first, even if they are not most recent
and THEN append block with recent tags.

In order to do this we cannot cache recent tags, actually we can for guests
and those who does not yet have "interesting tags"

Then we do 2 selects from RECENT_TAGS: first one with $in => "Interesting tags"
and the second one we get the usual 'recent tags' but remove "my tags" from result
OR specifically in find() pass $not and specify array of "interesting" tags.

It's probably easier to do the usual select, then array_diff
and then append one array to another or merge then so that "MY TAGS" are
always on top!

It actually goes one step beyond this: it also uses per-user tags stats, looks like it
picks some tags from there as well.

So 3 arrays: "My tags", "My stats tags" and "recent tags"
then filters out duplicates and uses them in order of "My tags", "Stat tags", "Recent tags"

Also, how are recent tags updated? Does the new answer trigger update or only new question?
In other words, recent activity for the tag, meaning answer/question/edit/comment (maybe?)
OR just new question?

==========================================

Monday, December 6, 2010

Processing of question

Handling Processing of QForm

Title, body, tags run through utf-8 string first

Run title, tags, body through htmlspecialchars or htmlentities()
or even through string_tags!

In the future if we allow tags then...we will run through safe_html instead!

Make intro
Parse markdown
store [html], [plain]
or just body?

We need something like messageAdapter that will accept
submittedQuestion object

SubmittedQuestion will have:
getBody (UTF8 object is fine, it's even better because we will be able to get num-lines, num-words)
getTitle Utf8String
getTags array
getUser <- UserObject
getIP string

////

tokenize title

record:
PER_USER_TAGS
TITLE_TAGS
QUESTION_TAGS
USER_STATS... not sure what it is but we need to update count_questions of user, right?
Ideally this will be in mongo USER collection
We can have separate collection USER_STATS, it's fine and it's small...


We can also keep reputation there? Maybe but it's really inconvenient because we
need reputation in clsUserObject of oViewer.


Also... we still want similar elist items!

We also want a way to get similar questions (later)
Also need a way to check for duplicate using q_hash uid + body

Need a way to test for floodcheck per uid, per ip

so we need a flood check class that would act as a filter via observer?

It's cool

The similar creation should be done as post-echo call.
also some emailing to subscribers will be done via post-echo thingy

///

Need a way to validate and set form errors.
validate title, validateBody, validateTags

If there are errors in validation we will return the same form.

Otherwise do redirect via meta tag with 2 seconds delay
How to do meta redirect? Basically we need to still show result page
with link to view new question and will say 'you will be redirected in 3 seconds"

Monday, November 15, 2010

Some notes about installing lighttpd and php

copy php-fpm.conf to /usr/local/cgiphp/etc
chmod src/php-5.3.3/sapi/fpm/init.d*

make /usr/local/cgiphp/var writable to user 'nobody' or just make it writable
both log and run dirs must be writable so that default log
and pid files can be created

//
lighttpd server
after ./configure
make
make install

// need to manually create
/etc/lighttpd
and copy from src/lighttpd-XXX/doc/config/lighttpd.conf
//
and also copy modules.conf there too

manually create dir /var/log/lighttpd/
and create files access.log and error.log in there
and make them writable
if files don't exist server will not be able to start

manually create /tmp/lighttpd/cache
for compression

change ipv6 to "disabled" otherwise the SERVER["REMOVE_HOST"]
shows weird looking ip stat starts with hex:$ip

Sunday, July 18, 2010

How to work around “sorry, you must have a tty to run sudo” without sacrificing security

Edit the /etc/sudoers file and comment out this line:

Defaults requiretty

Done!

Tuesday, July 13, 2010

Notes for Twitter image aggregator

Need per-twitter-user stats

in order to show other pics by the same user.
==================================================

Image rate up/down
favorites

comments

/reply

===========

most commented
most liked
most favorited

============

By tags....

How to best display other thumbs? In carousel or just on side block?


The idea is to auto retweet every new one

User may "Retweet", "Favorite", "Like", "Hate"

and "Comment" and "Reply"

Also may "Follow"

===================\\

Home page will have thumbs of new images + hash tag + tweet...
+ 'minutes' ago.... use JS for that?
+ javascript will auto-insert new images to top

==============

Nav column will have just recent tweets with auto-update

=============

Will also have tabs with most viewed, most commented, most liked, most favorited....


And will also have a per/tag pages...
=========

Settings to not include the user in 'viewed' image
Setting to not auto tweet the "Like" action

========

Keep tab on Next/Prev per image

========

store image paths like 23/54.jpg
then can easily create mini thumbs, thumbs, orig


===========

Sunday, May 30, 2010

Cannot start XAMPP on Windows 7?

If you having problem starting apache server on Windows 7 after installing the XAMPP, the problem is most likely that you already have a web server running.

Windows 7 comes with the IIS server and it's started up by default on many Windows 7 installations.

This is usually a very bad security risk, mainly because you should never have any server running that you don't need. Even more important, you should never have any server running that you are not aware of.

Anyway, on Windows 7 you should check if IIS is running and stop it if it is running.
Do this:
Start -> Control Panel -> System and security -> Internet Information service.

You then look in the right panel to see if Start button is grey and stop button is green. This would indicate that IIS service is running. Just click on Stop button to stop it.

Then you should be able to start the Apache server from the XAMPP control panel