Monday, May 21, 2012

CSS for textarea make textarea height span the height of the first line?

How can I make the textarea height match the height of the textarea as if it only had one row. It would essentially look like a text field. The nonreuseable way is by playing with the height attribute and making the textarea look like it only spans one row, but is there a reuseable way?



When I use the CSS attribute height: auto, it spans two rows.





perl DBI recipes column array

Below is my sql query output



Company Col1    Col2    Col3
Comp1 1 2 3
Comp2 4 5 6
Comp3 7 8 9


Perl procedure to connect and retrive results



my $query1= qq(select * from database_table);
my $result1 = $dbh->selectall_arrayref($query1, {Slice => {}});

my %result1 =
map { shift @$_, [ @$_ ]}
@{$dbh->selectall_arrayref($query1)};
my @json_output = map { encode_json( { 'name' => $_, 'data'=> $result1{$_} } )
} sort keys %result1 ;
print Dumper %result1;

[{"name":"Comp1","data":[1,2,3]}, {"name":"Comp2","data":[4,5,6]}, {"name":"Comp3","data":[7,8,9]}]


I have been reading http://www.perlmonks.org/?node_id=284436#fetching but i could not figure out how to store columns values as array elements. (As shown below)



    [{"name":"Col1","data":[1,4,7]}, {"name":"col2","data":[2,5,8]}, {"name":"col3","data":[3,6,9]}]


Also, the value fields by default come as "string" in json, any recommendation on how to convert them as numbers?





COUNT query in MYSQL

Thanks for the help so far guys!!! I am really new to MySQL and database. But I am trying my best.



So I have these relations:



station (station_id, latitude, longitude)

station_control_manager (station_id, ctrl_unit_id)



Problem




Tabulate station names, ids and total numbers of control areas in the middle town area,
e.g., latitude between 40.750 and 40.760 and longitude between -74.000 and -73.95.




This is my query



SELECT DISTINCT s.station_name, s.station_id, count 
FROM station s,
(SELECT cm.station_id, COUNT(cm.station_id) as count
FROM stationcontrolmanager cm GROUP BY cm.station_id) sub_query
WHERE s.latitude >= 40.750
AND s.latitude <=40.760
AND s.longitude >= -74.000
AND s.longitude <= -73.95
GROUP BY s.station_id;


I count by grouping station_id and count how many times it repeats (by repating, we know how many control area it has).



Instead, I have this:
enter image description here



The count was supposed to be the number of ctrl_unit_id, which in this case, is also the number of station_id. But in DB I count 7 rows, not 2.



The station names are all correct, of course.



Is there something wrong with my SQL statements?





Code to retrieve the manager of the user from Active Directory throws an Exception

I have a requirement to retrieve all the user related information from the Active Directory.



My code retrieves username,useremail, Full Name of the user but when I try to retrieve the name of the manager, the code throws an exception.



The following is my code :



DataTable table = new DataTable();
table = dt;

DirectoryEntry dEntry = new DirectoryEntry("LDAP://" + domain);

DirectorySearcher dSearch = new DirectorySearcher(dEntry);
SearchResultCollection sResultcol;

try
{
dSearch.Filter = "(objectCategory=organizationalUnit)";
sResultcol = dSearch.FindAll();

foreach (SearchResult sResult in sResultcol)
{
DirectoryEntry dUserEntry = new DirectoryEntry();
DirectorySearcher dSearchUsers = new DirectorySearcher(dEntry);

SearchResultCollection sUserResults;
dSearchUsers.Filter = "(objectClass=User)";
dSearchUsers.SearchScope = SearchScope.Subtree;

sUserResults = dSearchUsers.FindAll();

foreach (SearchResult sUserResult in sUserResults)
{
DataRow dr = table.NewRow();
string empCode = sResult.Properties["pager"].ToString();

if (empCode.Length != 0)
{
dr["empcode"] = empCode;
string namee = sUserResult.Properties["samaccountname"][0].ToString();
dr["name"] = namee;
string disname = sResult.Properties["distinguishedName"][0].ToString();
dr["ou"] = disname;
string manager = sUserResult.Properties["manager"].Value.ToString();
dr["manager"] = manager;

dt.Rows.Add(dr);
}
}

dUserEntry.Close();
}

return dt;
}
catch (Exception ex)
{
throw new Exception("Error at retrieveUsers() : " + ex.Message.ToString());
}


I get the exception




Index was out of range. Must be non-negative and less than the size
of the collection. Parameter name: index




when I try to get the manager name.



As per the structure of the Active Directory, the manager's name is located in another tab.



Does anyone have any idea of retrieving the data from the tabs other than General from the Active Directory?



Please help me.



Thanks in advance.





Can not load UIImage on button

I want to add UIImage on button?but the del.png can't show on my button?
What can i do?



I try many load Image Method?but no effect?such as:



UIImage* delImage = [[UIImage alloc] initWithContentsOfFile:@"del.png"];

UIImage* delImage = [UIImage imageNamed:@"del.png"];

UIImage* delImage =[UIImage imageWithContentsOfFile:@"del.png"];

CalDelBtn *BookItem = [[CalDelBtn alloc] initWithFrame:CGRectMake(startPointX, startPointY, 75, 113) statuePicture:delImage];


Please give me some advice?thank you!!





Vector2 operator improvements

I recently asked a question about structs, and optimizing some overloaded operators.



The original question is here



Now, I have taken those improvements to heart (or some/most of them), and I return with the following functions (nonmember functions, as I wish for them to be C compliant if possible).



inline Vector2& operator+=(Vector2 &a, const Vector2 &b)
{
a.x += b.x;
a.y += b.y;
return a;
}

inline Vector2 operator+(Vector2 a, const Vector2 &b)
{
a += b;
return a;
}

inline Vector2& operator*=(Vector2 &a, const float &n)
{
a.x *= n;
a.y *= n;
return a;
}

inline Vector2 operator*(Vector2 a, const float &n)
{
a *= n;
return a;
}

inline float operator*(const Vector2 &a, const Vector2 &b)
{
return (a.x * b.x) + (a.y * b.y);
}

inline Vector2 rotate(const Vector2 &a, const float &angle)
{
Vector2 out = a;
out *= cos(angle);
out.x -= sin(angle) * a.y;
out.y += sin(angle) * a.x;
return out;
}


(Please note, I omitted subtraction, and another multiplication operator, as they were equivalent to other operators listed here).



I am currently unable to notice any other potential improvements.
Have I missed anything, that will (potentially) make these functions, as they currently stand, inefficient?





Gridview not updating all fields

I have a gridview that is filled correctly from 3 tables.
When I update it, it will only update one field (Kommentar) but only the first time.



    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID,Erledigt,Kommentar"
DataSourceID="ArtikelDataSource">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name"
ReadOnly="True" >
<ControlStyle Width="150px" />
</asp:BoundField>
<asp:BoundField DataField="Beschreibung" HeaderText="Beschreibung"
SortExpression="Beschreibung" ReadOnly="True" >
<ControlStyle Width="200px" />
</asp:BoundField>
<asp:BoundField DataField="Datum" HeaderText="Datum" SortExpression="Datum"
ReadOnly="True" >
<ControlStyle Width="100px" />
</asp:BoundField>
<asp:BoundField DataField="Erledigt" HeaderText="Erledigt"
SortExpression="Erledigt" >
<ControlStyle Width="50px" />
</asp:BoundField>
<asp:BoundField DataField="Kommentar" HeaderText="Kommentar"
SortExpression="Kommentar" >
<ControlStyle Width="200px" />
</asp:BoundField>
<asp:BoundField DataField="LastUpdate" HeaderText="LastUpdate"
SortExpression="LastUpdate" ReadOnly="True" />
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"
ReadOnly="True" SortExpression="ID" Visible="False" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="ArtikelDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"
SelectCommand="SELECT ci.Name, ci.Beschreibung, ca.ChkItemID, ca.ChkUserID, ca.Datum, ca.Erledigt, ca.Kommentar, ca.LastUpdate, ca.ID FROM ChecklistActions AS ca INNER JOIN ChecklistItems AS ci ON ca.ChkItemID = ci.ID INNER JOIN ChecklistUsers AS cu ON ca.ChkUserID = cu.ID WHERE (ca.Datum = @datum) AND (cu.Login = @userlogin)"
UpdateCommand="UPDATE ChecklistActions SET Kommentar = @Kommentar, LastUpdate = GETDATE() WHERE (ID = @ID)"
OnSelecting="_data_Selecting"
>
<SelectParameters>
<asp:Parameter Name="userlogin"/>
<asp:Parameter Name="datum"/>
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="Kommentar" Type="string"/>
<asp:Parameter Name="ID" />
</UpdateParameters>
</asp:SqlDataSource>


I have first an empty field "Kommentar", then it is filled, but when I try to change the value again, only the GETDATE() changes value, the content of Kommentar is the same as before.



When I try to change the value of "Erledigt" via SQL



UpdateCommand="UPDATE ChecklistActions SET Erledigt = @Erledigt Kommentar = @Kommentar, LastUpdate = GETDATE() WHERE (ID = @ID)" 
...
<asp:Parameter Name="Erledigt" Type="Int32"/>


nothing (except the Getdate()) is updated at all - not even the field Kommentar at the fist time



It seems that the gridview is sending the old values to the update command (only the first update will receive the new Kommentar-value) which is really irritating ?





Is there a simple way to code the strategy (or other) design pattern in ANSI C that would fit on the screen of an 11" MacBook Air?

It seems that OO in ANSI C is not the favored approach to OO today. Does anyone know of a way to code a simple design pattern using strict ANSI C so I can prove to a friend that it is possible?(Axel-Tobias Schreiners' book got me going on this!)





Oracle 11g: XQuery results concatenated in a single SQLXML type

When I run an XQuery query in PL-SQL using



 SELECT XQUERY('...' RETURNING CONTENT) FROM DUAL


the result is always returned concatenated in a single row single column holding a SQLXML field.



This is bad for queries returning sequences of elements and really nasty for queries returning sequences of text nodes.



Is there a way to avoid this concatenation and get a row per returned item?



Thanks,



Eric





OpenGL Multithreaded video rendering shows severe flickering issues [Mac specific]

I have a video player application, and use multiple threads in order to keep the user interaction still smooth.



The thread that decodes the video originally just wrote the resulting frames as BGRA into a RAM buffer, which got uploaded to VRAM by glTexSubImage2D which worked fine enough for normal videos, but -as expected- got slow for HD (esp 1920x1080).



In order to improve that I implemented a different kind of pool class which has its own GL context (NSOpenGLContext as I am on Mac), which shares the resources with the main context.
Furthermore I changed the code so that it uses



glTextureRangeAPPLE( GL_TEXTURE_RECTANGLE_ARB, m_mappedMemSize, m_mappedMem );


and



glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_SHARED_APPLE);


for the textures that I use, in order to improve the performance of uploading to VRAM.
Instead of uploading BGRA textures (which weigh in at about 8MB per frame for 1920x1080) I upload three individual textures for Y, U and V (each being GL_LUMINANCE, GL_UNSIGNED_BYTE, and the Y texture of original size, and the U and V at half the dimensions), thereby reducing the size being uploaded to about 3 MB, which already showed some improvement.



I created a pool of those YUV textures (depending on the size of the video it typically ranges between 3 and 8 surfaces (times three as it is Y, U and V components) - each of the textures mapped into its own area of the above m_mappedMem.



When I receive a newly decoded video frame I find a set of free YUV surfaces and update the three components each with this code:



glActiveTexture(m_textureUnits[texUnit]);
glEnable(GL_TEXTURE_RECTANGLE_ARB);

glBindTexture(GL_TEXTURE_RECTANGLE_ARB, planeInfo->m_texHandle);

glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_SHARED_APPLE);
glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);

memcpy( planeInfo->m_buffer, srcData, planeInfo->m_planeSize );

glTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB,
0,
0,
0,
planeInfo->m_width,
planeInfo->m_height,
GL_LUMINANCE,
GL_UNSIGNED_BYTE,
planeInfo->m_buffer );


(As a side question: I am not sure if for each of the textures I should use a different texture unit? [I am using unit 0 for Y, 1 for U and 2 for V btw])



Once this is done I put the textures that I used are marked as being used and a VideoFrame class is filled with their info (ie the texture number, and which area in the buffer they occupy etc) and put into a queue to be rendered. Once the minimum queue size is reached, the main application is notified that it can start to render the video.



The main rendering thread meanwhile (after ensuring correct state, etc) then accesses this queue (that queue class has its access internally protected by a mutex) and renders the top frame.



That main rendering thread has two framebuffers, and associated to them via glFramebufferTexture2D two textures, in order to implement some kind of double buffering.
In the main rendering loop it then checks which one is the front buffer, and then renders this front buffer to the screen using texture unit 0:



glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_RECTANGLE_ARB);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, frontTexHandle);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT );
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer);
glVertexPointer(4, GL_FLOAT, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, m_texCoordBuffer);
glTexCoordPointer(2, GL_FLOAT, 0, 0);
glDrawArrays(GL_QUADS, 0, 4);
glPopClientAttrib();


Before doing that rendering to the screen of the current frame (as the usual framerate is about 24 fps for videos, this frame might be rendered a few times before the next videoframe gets rendered - that's why I use this approach) I call the video decoder class to check if a new frame is available (ie it is responsible for syncing to the timeline and updating the backbuffer with a new frame), if a frame is available, then I am rendering to the backbuffer texture from inside the videodecoder class (this happens on the same thread as the main rendering thread):



glBindFramebuffer(GL_FRAMEBUFFER, backbufferFBOHandle);

glPushAttrib(GL_VIEWPORT_BIT); // need to set viewport all the time?
glViewport(0,0,m_surfaceWidth,m_surfaceHeight);

glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glLoadIdentity();
glScalef( (GLfloat)m_surfaceWidth, (GLfloat)m_surfaceHeight, 1.0f );

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texID_Y);

glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texID_U);

glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texID_V);

glUseProgram(m_yuv2rgbShader->GetProgram());

glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer);
glEnableVertexAttribArray(m_attributePos);
glVertexAttribPointer(m_attributePos, 4, GL_FLOAT, GL_FALSE, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, m_texCoordBuffer);
glEnableVertexAttribArray(m_attributeTexCoord);
glVertexAttribPointer(m_attributeTexCoord, 2, GL_FLOAT, GL_FALSE, 0, 0);
glDrawArrays(GL_QUADS, 0, 4);

glUseProgram(0);

glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);

glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);

glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();

glPopAttrib();
glBindFramebuffer(GL_FRAMEBUFFER, 0);


[Please note that I omitted certain safety checks and comments for brevity]



After the above calls the video decoder sets a flag that the buffer can be swapped, and after the mainthread rendering loop from above, it checks for that flag and sets the frontBuffer/backBuffer accordingly. Also the used surfaces are marked as being free and available again.



In my original code when I used BGRA and uploads by glTexSubImage2D and glBegin and glEnd, I didn't experience any problems, but once I started improving things, using a shader to convert the YUV components to BGRA, and those DMA transfers, and glDrawArrays those issues started showing up.



Basically it seems partially like a tearing effect (btw I set the GL swap interval to 1 to sync with refreshes), and partially like it is jumping back a few frames in between.



I expected that having a pool of surfaces which I render to, and which get freed after rendering to the target surface, and double buffering that target surface should be enough, but obviously there needs to be more synchronization done in other places - however I don't really know how to solve that.



I assume that because glTexSubImage2D is now handled by DMA (and the function according to the documents supposed to return immediately) that the uploading might not be finished yet (and the next frame is rendering over it), or that I forgot (or don't know) about some other synchronization mechanism which I need for OpenGL (Mac).



According to OpenGL profiler before I started optimizing the code:




  • almost 70% GLTime in glTexSubImage2D (ie uploading the 8MB BGRA to VRAM)

  • almost 30% in CGLFlushDrawable



and after I changed the code to the above it now says:




  • about 4% GLTime in glTexSubImage2D (so DMA seems to work well)

  • 16% in GLCFlushDrawable

  • almost 75% in glDrawArrays (which came as a big surprise to me)



Any comments on those results?



If you need any further info about how my code is set up, please let me know. Hints on how to solve this would be much appreciated.





How can I check if capslock is on without waiting for the user to type character using JavaScript?

Gmail shows an icon in Chrome when the user has capslock on and focuses on the password field, how are they able to do that?



There are many related question to this, but no one seem to know how to do it without user input, like:







Colour names of files

http://screenshots.en.sftcdn.net/en/scrn/39000/39972/xentient-labels-1.jpg



There is here such here a program: http://xentient-labels.en.softonic.com/
Tell, how it to realise (in Win7)? If that is possible on Delphi Xe2.





Does Thread lock on object ensures lock on member objects too?

Consider following class that I have wrote for testing the locking of non-primitive variable (myObject). My question is:



(Consider all threads are working on same object instance of SynchronizationTest)



I understand that if thread1 is executing set(...) method then any other thread (lets say thread2) is okay to execute either of the anotherSetWithSynchronized(...) or anotherSetWithoutSynchronized(...).



Question a : If thread1 has locked the object of SynchronizationTest while executing set(...), does it mean it has acquired lock on all member object variable ? like in this case myObject. If not then,



Question b: If thread1 is executing set(...) can thread2 execute anotherSetWithSynchronized(...) concurrently ?



Ouestion C: None of the two methods can execute simultaneously by thread?



Ouestion D: Design is wrong, I need to explicitly lock myObject in synchronized set(...) method. Like this:



  public synchronized void set(MyValue myValue)
{
synchronized (myObject)
{
myObject.put(myValue);
}
}


======================SynchronizationTest class======================



public class SynchronizationTest
{
private MyObject myObject = new MyObject();

public synchronized void set(MyValue myValue)
{
myObject.put(myValue);
}

public void anotherSetWithSynchronized(MyValue myValue)
{
synchronized (myObject)
{
myObject.put(myValue);
}
}

public void anotherSetWithoutSynchronized(MyValue myValue)
{
myObject.put(myValue);
}
}




How to disable E_STRICT

I need to turn off E_STRICT. I have error_reporting = E_ALL & ~E_STRICT in my php.ini but it seems to be ignored. I tried this in my code:



ini_set('error_reporting', E_NOTICE);


Nothing!



Please help.





Ajax vs Comet (not a chat application)

I've developed a web-based application in which a signed in user should send a message to the server telling he is still online every 3 seconds. The message is then processed by the server and a stored procedure is called in Mysql to set the user's status to online.
I've looked in to similar issues in which Comet and Ajax are compared (here or here) but considering that 3 second delay is acceptable and maximum users of 1000 are online in the system, is using Ajax a wise choice or Comet should be used?





pass a C++ object instance to python, but call C++ functions contain STL have exception in python

I am using SWIG to wrapper C++ dll. C++ call pyhon, but need to transfer a object instance to python. In python , it call some C++ function using this instance.



1 first, use:



 swig_type_info _swigt__p_CallFactory = 
{"_p_CallFactory", "CallFactory *", 0, 0, (void*)0, 0};

instance =
SWIG_NewPointerObj(SWIG_as_voidptr(callF), &(_swigt__p_CallFactory), 0);

pass a C++ object instance to python.


2 in python, it get SWIG_PyObject pointer. then I need to change it to CallFactory*.



in python: 
callFactory = example.Conver_to_callFactory (callF)


the Conver_to_callFactory fucntion is like this:



  CallFactory* c_ptr;

swig_type_info *ty = SWIG_TypeQuery("CallFactory *");

printf("CallFactory ty %p \n", ty);

if (SWIG_ConvertPtr(py_obj, (void **) &c_ptr, ty, 0) == -1)
{
c_ptr = 0;
}
else
{
Py_XINCREF(py_obj);
}


3 now I get CallFactory* in python which is newed in C++



4 now I call CallFactory method in python:



   callFactory.CreateStaticCall();

in C++ , the CallFactory::CreateStaticCall() contains STL operation :
intVec.push_back(2); intVec in a data member of CallFactory: std::vector<int>.

when pragram run here, it crash. I can't get anything useful.


And when call other fucntions without STL opreation, it is ok.



Could you help me, please? Thank you





Customized DevExpress LookupeditSettings

I write my customized lookupedit(derived from lookupedit)



I want to use it in lookupeditsettings instead of lookupedit
How can i do this?
(in Silverlight)





How to predict where segmentation fault occurs

How to predict where segmentation fault occurs if we are increasing a pointer in a infinite loop?



I have thought that we can use the alarm signal handler and it will be invoked after every 1 second and it will print the address pointed to by the pointer so that when the segmentation fault would occur we would get a very nearby address where it occurred.



Could there be more better solution? If there then please tell. Thanks in advance



Code :



#define SECOND 1

int *str;

void ALARMhandler(int sig)
{
signal(SIGALRM, SIG_IGN);


printf("ptr=%u \n",*str);

alarm(SECOND); /* set alarm for next run */
signal(SIGALRM, ALARMhandler); /* reinstall the handler */
}



int main()
{

int *ptr;
str=&ptr;
int a;
ptr=&a;
signal(SIGALRM,ALARMhandler);
alarm(SECOND);


for(;;)
{
ptr++;


}

return 0;

}




No line number found known for in gdb

I have compiled my own glibc, which produced libc.so. I loaded the libc.so file in gdb by doing gdb -q ./libc.so. However, when I try to find the location of a function by doing list function_name, I get the error message, No line number known for function_name. Note that I use the -g flag for compiling glibc. How can I solve this problem?





How to "wait" a Thread in Android

private void startGameTimeElapseThread(){
new Thread(new Runnable() {
Date d = new Date();
public void run() {
while (gameOn){
Log.d(TAG,""+d.getTime()+" "+gameStatus.getLastTimeUpdated());

postInvalidate(795, 150, 1024, 300);
try {
synchronized (this) {
wait(1000);
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block
Log.d(TAG, "Waiting didnt work!!");
e.printStackTrace();
}
}
}
}).start();
}


Here I wanted to make call the "Log.d" and "postInvalidate" every one second. But when i check it from LogCat it seems loop runs faster than i want it to be. Why doesnt this loop just wait for 1000ms ?



Following are the output in LogCat. So you can see its not sleeping for a 1 second at all. I used Thread.sleep as well ( after you suggesting )



05-27 11:40:10.060: DEBUG/NOPSA-P(4546): 1306496408950 1306496387535
05-27 11:40:10.070: DEBUG/NOPSA-P(4546): 1306496410037 1306496387535
05-27 11:40:10.232: DEBUG/NOPSA-P(4546): 1306496410201 1306496387535
05-27 11:40:10.250: DEBUG/NOPSA-P(4546): 1306496408214 1306496387535
05-27 11:40:10.310: DEBUG/NOPSA-P(4546): 1306496405988 1306496387535
05-27 11:40:10.361: DEBUG/NOPSA-P(4546): 1306496409327 1306496387535
05-27 11:40:10.431: DEBUG/NOPSA-P(4546): 1306496410398 1306496387535
05-27 11:40:10.521: DEBUG/NOPSA-P(4546): 1306496409478 1306496387535
05-27 11:40:10.593: DEBUG/NOPSA-P(4546): 1306496410566 1306496387535
05-27 11:40:11.230: DEBUG/NOPSA-P(4546): 1306496409678 1306496387535
05-27 11:40:11.230: DEBUG/NOPSA-P(4546): 1306496410201 1306496387535
05-27 11:40:11.241: DEBUG/NOPSA-P(4546): 1306496409878 1306496387535
05-27 11:40:11.241: DEBUG/NOPSA-P(4546): 1306496410037 1306496387535
05-27 11:40:11.241: DEBUG/NOPSA-P(4546): 1306496408950 1306496387535
05-27 11:40:11.260: DEBUG/NOPSA-P(4546): 1306496408214 1306496387535
05-27 11:40:11.314: DEBUG/NOPSA-P(4546): 1306496405988 1306496387535
05-27 11:40:11.314: DEBUG/NOPSA-P(4546): 1306496411254 1306496387535
05-27 11:40:11.361: DEBUG/NOPSA-P(4546): 1306496409327 1306496387535
05-27 11:40:11.431: DEBUG/NOPSA-P(4546): 1306496410398 1306496387535
05-27 11:40:11.520: DEBUG/NOPSA-P(4546): 1306496409478 1306496387535
05-27 11:40:11.551: DEBUG/NOPSA-P(4546): 1306496411508 1306496387535
05-27 11:40:11.712: DEBUG/NOPSA-P(4546): 1306496410566 1306496387535
05-27 11:40:11.881: DEBUG/NOPSA-P(4546): 1306496411865 1306496387535
05-27 11:40:12.051: DEBUG/NOPSA-P(4546): 1306496412025 1306496387535
05-27 11:40:12.211: DEBUG/NOPSA-P(4546): 1306496412198 1306496387535
05-27 11:40:12.231: DEBUG/NOPSA-P(4546): 1306496409678 1306496387535
05-27 11:40:12.242: DEBUG/NOPSA-P(4546): 1306496410201 1306496387535
05-27 11:40:12.251: DEBUG/NOPSA-P(4546): 1306496408950 1306496387535
05-27 11:40:12.251: DEBUG/NOPSA-P(4546): 1306496409878 1306496387535
05-27 11:40:12.251: DEBUG/NOPSA-P(4546): 1306496410037 1306496387535
05-27 11:40:12.261: DEBUG/NOPSA-P(4546): 1306496408214 1306496387535
05-27 11:40:12.311: DEBUG/NOPSA-P(4546): 1306496405988 1306496387535
05-27 11:40:12.341: DEBUG/NOPSA-P(4546): 1306496411254 1306496387535
05-27 11:40:12.371: DEBUG/NOPSA-P(4546): 1306496409327 1306496387535
05-27 11:40:12.442: DEBUG/NOPSA-P(4546): 1306496410398 1306496387535
05-27 11:40:12.471: DEBUG/NOPSA-P(4546): 1306496412431 1306496387535
05-27 11:40:12.521: DEBUG/NOPSA-P(4546): 1306496409478 1306496387535
05-27 11:40:12.553: DEBUG/NOPSA-P(4546): 1306496411508 1306496387535
05-27 11:40:12.671: DEBUG/NOPSA-P(4546): 1306496412639 1306496387535
05-27 11:40:12.711: DEBUG/NOPSA-P(4546): 1306496410566 1306496387535
05-27 11:40:12.841: DEBUG/NOPSA-P(4546): 1306496412813 1306496387535
05-27 11:40:12.891: DEBUG/NOPSA-P(4546): 1306496411865 1306496387535
05-27 11:40:13.001: DEBUG/NOPSA-P(4546): 1306496412983 1306496387535
05-27 11:40:13.051: DEBUG/NOPSA-P(4546): 1306496412025 1306496387535
05-27 11:40:13.193: DEBUG/NOPSA-P(4546): 1306496413166 1306496387535
05-27 11:40:13.231: DEBUG/NOPSA-P(4546): 1306496409678 1306496387535
05-27 11:40:13.251: DEBUG/NOPSA-P(4546): 1306496410201 1306496387535
05-27 11:40:13.251: DEBUG/NOPSA-P(4546): 1306496409878 1306496387535
05-27 11:40:13.251: DEBUG/NOPSA-P(4546): 1306496410037 1306496387535
05-27 11:40:13.251: DEBUG/NOPSA-P(4546): 1306496408950 1306496387535
05-27 11:40:13.261: DEBUG/NOPSA-P(4546): 1306496408214 1306496387535
05-27 11:40:13.271: DEBUG/NOPSA-P(4546): 1306496412198 1306496387535
05-27 11:40:13.321: DEBUG/NOPSA-P(4546): 1306496405988 1306496387535
05-27 11:40:13.341: DEBUG/NOPSA-P(4546): 1306496411254 1306496387535
05-27 11:40:13.371: DEBUG/NOPSA-P(4546): 1306496409327 1306496387535
05-27 11:40:13.431: DEBUG/NOPSA-P(4546): 1306496413405 1306496387535
05-27 11:40:13.441: DEBUG/NOPSA-P(4546): 1306496410398 1306496387535
05-27 11:40:13.481: DEBUG/NOPSA-P(4546): 1306496412431 1306496387535
05-27 11:40:13.532: DEBUG/NOPSA-P(4546): 1306496409478 1306496387535


This is the latest Code. gameOn is a boolean, for now it's true.



private void startGameTimeElapseThread(){
if (gameOn){
new Thread(new Runnable() {
Date d = new Date();
public void run() {

Log.d(TAG,""+d.getTime()+"ms "+d.getTime()/1000+"sec");
postInvalidate(795, 150, 1024, 300);
android.os.SystemClock.sleep(1000);
startGameTimeElapseThread();

}
}).start();
}
}


The output is



05-27 12:00:51.211: DEBUG/NOPSA-P(5098): 1306497650761ms  1306497650sec
05-27 12:00:51.211: DEBUG/NOPSA-P(5098): 1306497650786ms 1306497650sec
05-27 12:00:51.221: DEBUG/NOPSA-P(5098): 1306497650764ms 1306497650sec
05-27 12:00:51.221: DEBUG/NOPSA-P(5098): 1306497650763ms 1306497650sec
05-27 12:00:51.221: DEBUG/NOPSA-P(5098): 1306497650769ms 1306497650sec
05-27 12:00:51.231: DEBUG/NOPSA-P(5098): 1306497650749ms 1306497650sec
05-27 12:00:51.231: DEBUG/NOPSA-P(5098): 1306497650736ms 1306497650sec
05-27 12:00:51.231: DEBUG/NOPSA-P(5098): 1306497650742ms 1306497650sec
05-27 12:00:51.241: DEBUG/NOPSA-P(5098): 1306497650746ms 1306497650sec
05-27 12:00:51.241: DEBUG/NOPSA-P(5098): 1306497650848ms 1306497650sec
05-27 12:00:51.251: DEBUG/NOPSA-P(5098): 1306497650729ms 1306497650sec
05-27 12:00:51.271: DEBUG/NOPSA-P(5098): 1306497650739ms 1306497650sec
05-27 12:00:51.271: DEBUG/NOPSA-P(5098): 1306497650739ms 1306497650sec
05-27 12:00:51.271: DEBUG/NOPSA-P(5098): 1306497650868ms 1306497650sec
05-27 12:00:51.271: DEBUG/NOPSA-P(5098): 1306497650798ms 1306497650sec
05-27 12:00:51.281: DEBUG/NOPSA-P(5098): 1306497650870ms 1306497650sec
05-27 12:00:51.291: DEBUG/NOPSA-P(5098): 1306497651020ms 1306497651sec
05-27 12:00:51.551: DEBUG/NOPSA-P(5098): 1306497651498ms 1306497651sec
05-27 12:00:51.551: DEBUG/NOPSA-P(5098): 1306497651502ms 1306497651sec
05-27 12:00:51.642: DEBUG/NOPSA-P(5098): 1306497651523ms 1306497651sec
05-27 12:00:51.651: DEBUG/NOPSA-P(5098): 1306497651537ms 1306497651sec
05-27 12:00:51.691: DEBUG/NOPSA-P(5098): 1306497651529ms 1306497651sec
05-27 12:00:51.701: DEBUG/NOPSA-P(5098): 1306497651534ms 1306497651sec
05-27 12:00:51.784: DEBUG/NOPSA-P(5098): 1306497651527ms 1306497651sec
05-27 12:00:51.801: DEBUG/NOPSA-P(5098): 1306497651570ms 1306497651sec
05-27 12:00:51.801: DEBUG/NOPSA-P(5098): 1306497651564ms 1306497651sec
05-27 12:00:51.891: DEBUG/NOPSA-P(5098): 1306497651682ms 1306497651sec
05-27 12:00:51.891: DEBUG/NOPSA-P(5098): 1306497651690ms 1306497651sec
05-27 12:00:51.891: DEBUG/NOPSA-P(5098): 1306497651685ms 1306497651sec
05-27 12:00:51.901: DEBUG/NOPSA-P(5098): 1306497651693ms 1306497651sec
05-27 12:00:51.914: DEBUG/NOPSA-P(5098): 1306497651647ms 1306497651sec
05-27 12:00:51.914: DEBUG/NOPSA-P(5098): 1306497651667ms 1306497651sec
05-27 12:00:51.921: DEBUG/NOPSA-P(5098): 1306497651666ms 1306497651sec
05-27 12:00:51.921: DEBUG/NOPSA-P(5098): 1306497651658ms 1306497651sec
05-27 12:00:51.921: DEBUG/NOPSA-P(5098): 1306497651663ms 1306497651sec
05-27 12:00:51.932: DEBUG/NOPSA-P(5098): 1306497651688ms 1306497651sec
05-27 12:00:51.941: DEBUG/NOPSA-P(5098): 1306497651711ms 1306497651sec
05-27 12:00:51.961: DEBUG/NOPSA-P(5098): 1306497651792ms 1306497651sec
05-27 12:00:51.971: DEBUG/NOPSA-P(5098): 1306497651629ms 1306497651sec
05-27 12:00:51.981: DEBUG/NOPSA-P(5098): 1306497651714ms 1306497651sec
05-27 12:00:52.083: DEBUG/NOPSA-P(5098): 1306497652048ms 1306497652sec




css/jquery: Fixed when scrolling horizontally but not vertically

I have a large table with headers as the first column, and a jQuery slider plugin (from https://github.com/keesschepers/jquery-ui-content-slider) to scroll through the table horizontally while keeping the first column fixed.



However, if I try to scroll downwards (vertically) I cannot see the rest of first column (larger than the height of the screen) since it has the fixed property (css). Is there any css or jQuery trick to fix this?



CSS Code:



     table tr td:first-child { position: fixed; } 


HTML Code:



      <div id="#content-scroll">
<table>
<tr><td></td>...and many more cells</tr>
...and many more rows
</table></div>


jQuery Code:



             <script type="text/javascript">
$(document).ready(function() {
$("#content-slider").slider({
animate: true,
change : function (e, ui) {
var maxScroll = $("#content-scroll").prop("scrollWidth") -
$("#content-scroll").width();
$("#content-scroll").animate({
scrollLeft : ui.value * (maxScroll / 100)
}, 1000);
},
slide : function (e, ui)
{
var maxScroll = $("#content-scroll").prop("scrollWidth") -
$("#content-scroll").width();
$("#content-scroll").prop('scrollLeft' ,ui.value * (maxScroll / 100));
}
});
});
</script>




MYSQL WHERE condition depends upon SELECT column

Is it possible to reference back to the column you're selecting in the WHERE condition?



I'm not even sure how to ask this question without excessive verbage, so I'll just try to point you to the "rated_user = @2User" part and note that @2User is what I'm selecting.



SELECT id, user, minimum 
INTO @1ID, @1User, @minimum
FROM table1
WHERE a_or_b = 'a' AND item = itemName
ORDER BY number DESC LIMIT 1;

SELECT id, user
INTO @2ID, @2User
FROM table1
WHERE a_or_b = 'b' AND item = itemName
AND (SELECT IFNULL(AVG(rating),0) AS Rating
FROM table2
WHERE rated_user = @2User AND completed = 'y'
) >= @minimum_seller_rating
ORDER BY number ASC LIMIT 1;




Clickable links in UITableViewCell

I'm trying to add clickable text in a UITableViewCell, I tried some different approaches:




  • I've tried using 3rd party label such as fancyLabel etc, but the problem with those is that they don't support right to left languages (they always start the text from left to right)


  • I've tried using UIWebView as the text view but when I add a UIWebView to a UITableViewCell and scroll the table fast the text inside the webView is empty and when the scrolling decelerate the text reappears again, so it doesn't look good


  • I can't use UITextView because it doesn't support custom UIDataDetectionTypes and I need to detect # and @ for tweeter links




Any idea on how to approach the issue???





How to use two different analyze-strings for one node

In my XSLT transformation I have two analyze-strings that I need to use to process one node. They work fine one by one, but I don't know how to put them together.



XML document looks like this:



<article>
<title>Article 1</title>
<text><![CDATA[Lorem ipsum dolor sit amet, s consectetur adipiscing elit. Donec lorem diam, eleifend sed mollis id, condimentum in velit.

Sed sit amet erat ac mauris adipiscing elementum. Pellentesque eget quam augue, id faucibus magna.

Ut malesuada arcu eu elit sodales sodales. Morbi tristique porttitor tristique. Praesent eget vulputate dui. Cras ut tortor massa, at faucibus ligula.]]></text>
</article>


Here's my XSLT:



<xsl:template match="/">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Page title</title>
</head>
<body>
<xsl:for-each select="article">
<h1><xsl:value-of select="./title"/></h1>

<!-- This adds paragraphs tags instead of empty lines in the text -->
<xsl:analyze-string select="./text" regex=" ">
<xsl:non-matching-substring>
<p>
<xsl:value-of select="." disable-output-escaping="yes"/>
</p>
</xsl:non-matching-substring>
</xsl:analyze-string>

<!-- This is Czech language specific. It looks for ' s ' (or other letter) and changes second space for &nbsp;. So after that it is ' s&nbsp;'. -->
<xsl:analyze-string select="./text" regex="(\s[k/K/s/S/v/V/z/Z]\s)">
<xsl:matching-substring>
<xsl:text> </xsl:text>
<xsl:value-of select="replace(., ' ','')" disable-output-escaping="yes"/>
<xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;]]></xsl:text>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:for-each>
</body>
</html>
</xsl:template>


I need to apply both analyze-strings on the generated text so there are <p> tags for paragraphs and also added &nbsp; on the right places.



My desired output would look like this:



<h1>Article 1</h1>    
<p>Lorem ipsum dolor sit amet, s&nbsp;consectetur adipiscing elit. Donec lorem diam, eleifend sed mollis id, condimentum in velit.</p>
<p>Sed sit amet erat ac mauris adipiscing elementum. Pellentesque eget quam augue, id faucibus magna.</p>
<p>Ut malesuada arcu eu elit sodales sodales. Morbi tristique porttitor tristique. Praesent eget vulputate dui. Cras ut tortor massa, at faucibus ligula.</p>


Any idea how to do this? Thank you for taking your time and trying to help me.





`single-row subquery returns more than one row` error unclarity

I've got two tables.
The first one hold a type and the second one the value of this type.
In my example if there are more values 'john' as 'first_name' i get:single-row subquery returns more than one row



SELECT DISTINCT id FROM name WHERE id=(
SELECT id FROM name WHERE text1='first_name' INTERSECT
SELECT name_id FROM value WHERE text2='john');


I'm not very good with sql. I should use LEFT JOIN or something like that but it's not really clear to me how i should do this.





Class attribute in <HTML> tag?

Is class a leagal attribute of the HTML element?



<html class="...">


My Oracle ADF application does this - wounder why ..





jquery button using $.post()

I'm trying to use jquery to create a vote up, vote down button for my website. What i did was creating a form and have it processed in an external php script using $.post(). I thought this will allow the form to be processed in the quietly in the backend but when i click on the buttons, the jquery function doesn't seem to work and it just loads the whole script in the front-end.



Appreciate if anyone can provide some help here. Thanks. Following is my scripts.



Main PHP script



<div class="voting_class">

<?php
$user =& JFactory::getUser();
$ip = getenv('REMOTE_ADDR');
if($user->id == 185){
?>

<form method="post" action="../vote_plus.php">
<div class="form_element">
<label>user_id</label>
<input type="text" name="user_id" class="votetext" value="<?php echo $user->id;?>" />
</div>
<div class="element">
<label>ad_id</label>
<input type="text" name="ad_id" class="votetext" value="<?php echo $this->content->id;?>"/>
</div>
<div class="element">
<label>ip_address</label>
<input type="text" name="ip_address" class="votetext" value="<?php echo $ip;?>"/>
</div>
<div class="submit_element">
<input type="submit" class="button" id="submitadd" value="Recommend"/>
<div class="loading"></div>
</div>
<div class="submit_element">
<input type="submit" class="button" id="submitminus" value="Don't Recommend" />
<div class="loading"></div>
</div>
</form>
<p class="success_msg" style="display:none"></p>

<?php }?>

</div>


JAVASCRIPT SCRIPT



<script type = "text/javascript">
$(document).ready(function() {

$('#submitadd').click(function(event) {

//Get the data from all the fields
var user_id = $('input[name=user_id]');
var ad_id = $('input[name=ad_id]');
var ip_address = $('input[name=ip_address]');

$.post('../vote_plus.php', { user: "user_id.val()", ad: "ad_id.val()", ip: "ip_address.val()" }, function () {
$('.success_msg').append("Vote Successfully Recorded");
$('.success_msg').fadeOut();
});
event.preventDefault();
});
});
//if submit button is clicked
$('#submitminus').click(function(event) {

//Get the data from all the fields
var user_id = $('input[name=user_id]');
var ad_id = $('input[name=ad_id]');
var ip_address = $('input[name=ip_address]');

$.post('../vote_minus.php', { user: "user_id.val()", ad: "ad_id.val()", ip: "ip_address.val()" }, function () {
$('.success_msg').append("Vote Successfully Recorded");
$('.success_msg').fadeOut();
});
event.preventDefault();
});

});
</script>


I won't be posting the external script as i think the problem doesn't lie in the external php script as all mySQL updates can be loaded and properly and any info can be properly displayed. My problem lies where i can't get the button to work in jquery.





Relation between dimensions of a body and pixels in box2d iphone

Could anyone tell me about the relation between the dimensions of a body and number of pixels(in box2d). How many pixels contributes to one meter length?
To be more specific, I'm using the below line of code in my program



polygon_body.SetAsBox(1, 1);



In this code what are the parameters of SetASBox. I mean whether it is a pixel value or some other units.





Getting custom linear unique id in oracle in select statement based on Date

I have an oracle table such as this.



enter image description here



I want to get a custom unique id in the format Mon-YY/unique number in the select statement



The result would look like(see the column UNIQUEORDERID)



enter image description here



Is it possible to achieve the result in select statement?
Please help me write the query.



Thanks,
Sajad





how to send an object from jsp to servlet

I have an object that is being sent successfully from a servlet to a jsp.
In that jsp page I have a button and when user click on that button the same object should be sent from that jsp page to another servlet. how can I do that ??