Wednesday, May 23, 2012

Translating SQL query to Doctrine2 DQL

I'm trying to translate this (My)SQL to DQL



SELECT content, created, AVG(rating)
FROM point
GROUP BY DAY(created)
ORDER BY created ASC


And I'm stuck at GROUP BY part, apparently DAY/WEEK/MONTH isn't recognized as valid "function".



[Semantical Error] line 0, col 80 near '(p.created) ORDER': Error: Cannot group by undefined identification variable.



$this->createQueryBuilder('p')
->select('p')
->groupBy('DAY(p.created)')
->orderBy('p.created', 'ASC')


Q: Is it possible to create this kind of query with query builder, or should I use native query?





ASP:CHART legend check box series control

I have a fully functioning Dynamic chart control( just the regular ASP.net Chart ) It works great but I've run into a problem trying to add check boxes to the legend. I'm trying to add them next to the series names so the user can hide or view the respective series data. The chart is plotting data for roughly 42 employees. So being able to select and hide data is very important. I've been researching this for a few days now and I've found examples for 3rd party chart tools but i need to do this in MSVS 2010 standard charting tool.



This is how I create the Chart.



 for (int emp = 1; emp < empRowList.Length; emp++)
{
chartB.Series.Add(empRowList[emp]);
chartB.Series[empRowList[emp]].ChartType = SeriesChartType.Point;
chartB.Series[empRowList[emp]].MarkerSize = 10;
chartB.Series[empRowList[emp]].MarkerStyle = MarkerStyle.Star4;

for (int month = 1; month < 12; month++)
{
chartB.Series[empRowList[emp]].Points.AddXY(mfi.GetMonthName(month), employeeStats[month, emp]);
chartB.Series[empRowList[emp]].Points[chartB.Series[empRowList[emp]].Points.Count - 1].ToolTip = empRowList[emp] + " - " + employeeStats[month, emp];
}
}


Here is how I format the chart



 chartB.DataSource = t.Tables["info"];
chartB.DataBind();
chartB.Legends.Add(new Legend("Legend"));
chartB.Legends["Legend"].Alignment = StringAlignment.Center;
chartB.Legends["Legend"].Docking = Docking.Top;


I looked through this post thinking it could be augmented to help but since his series aren't added dynamically i'm not sure if it is the right direction to pursue.



ASP .net 4 Chart Control Legend formatting is not displaying at all



I've also looked in to using custom legends but read that they aren't linked to the data so i thought that might also be that wrong direction.



If anyone could help it would be greatly appreciated i'm kind of at a stand still till I can figure this out.



Thanks in advance





How to parse bad html?

I am writing a search engine that goes to all my company affiliates websites parse html and stores them in database. These websites are really old and are not html compliant out of 100000 websites around 25% have bad html that makes it difficult to parse. I need to write a c# code that might fix bad html and then parse the contents or come up with a solution that will address above said issue. If you are sitting on idea, an actual hint or code snippet would help.





border-right not showing on first li

I have a specific issue with the following example:
http://jsfiddle.net/c7NyZ/8/



Open it in IE7 or do IE7 mode. The first LI (border-right) seems to have merged with the 2nd li.



I am using a jquery library for the rounded corners.



Can you help me show the border right again like the others?





Selecting stored in variable

Hi I'm trying to create a shopping cart for a college assignment, I'm trying to load a table from the contents of a variable but regardless of what I do it won't recognise its contents.



Here the code snippet



$sql = sprintf("SELECT name, description, price FROM %s WHERE id = %d;",$table, $product_id);
$result = mysql_query($sql);



The table variables contents is being missed out so its looking a nameless table, I've searched Google and found a couple of examples but are working for me.



Does anyone have any ideas?



Thanks Scott.





Tuesday, May 22, 2012

How secure are Cookies when set by an ASP.NET web application?

I want to know how secure a cookie is and if it can be read by other applications other than the one that set it.



I want to set a cookie that will store some sensitive data for my site to read at any time.



Can other applications read cookies that my application sets? If so, do I need to encrypt the data stored in the cookie?



NOTE: I do not have access to SSL.





Android ListView image resize

I have a lazy-loading ListView populated with images gotten over the network. The list rows are set to wrap_content, so once the image loads it resizes and the full scale image will be displayed. It looks great when scrolling down, but when scrolling up the rows resize and force the bottom rows off the screen. How can I prevent this jumpy scrolling while scrolling up?



----- EDIT:



The images are comics of varying sizes. Some are 2 or 3 frames where they aren't very tall. Others are single frame comics where they are much taller. The image needs to take up the full width and the height should not cut off any of the comic.