Wednesday, May 23, 2012

GWT - doesn't work correctly

There's a table with buttons on my page. There're so much buttons, that I have a scroller to scroll down my table.

Button "onClick" generates a dialog box with scrollpanel, content and a button to close this dialog box. I center it using When I press, let's say the first button in a table, dialog box appears strictly in the center.... but when I scroll down the page and press button in the bottom of my table, my DialogBox still appears in the "old" center...almost above my view. It simply doesn't move down according to my scrollbar position.
I tried to change setPopupPosition(), setPopupPositionAndShow() and so on, but it didn't help.

Is there any ideas what is wrong? Here is some code of my dialog box:

public class MyDialogBox extends DialogBox {

public MyDialogBox(final String caption, final String text) {
setText("Caption: " + caption);

VerticalPanel inner = new VerticalPanel();
Label msg = new Label(text);

Button ok = new Button("Close");
ok.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {

ScrollPanel scrollbar = new ScrollPanel(inner);
scrollbar.setSize("640", "480");
VerticalPanel outer = new VerticalPanel();

And here is how my button call it:

VerticalPanel mainPanel ... //MainPanel with a lot different elements, it contains panel with buttons
VerticalPanel panel ... //Panel with buttons
panel.setViewButtonHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
MyDialogBox dialogBox = new MyDialogBox("Caption", "Some text");;

How to add icon in button when slide down in jquery

enter image description hereI did some code for jquery sliding-toggle div but for now i want to adding icon in button when sliding down i want to show a small arrow icon bottom of the open content button. when i click again on open content button that icon want to remove.

go through the following path for see the code.
jsfiddle link

<div id="btn-div">Open content</div>
<div id="content-div">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
<br class="clear"/>

font:12px/18px Arial;

 $('#btn-div').live('click', function() {


Summing over lists in python - is there a better way?

Is there a more sensible way of doing this? I want to make a new list by summing over the indices of a lot of other lists. I'm fairly new to programming and this seems like a very clunky method!

list1 = [1,2,3,4,5]
list2 = [1,1,1,4,1]
list3 = [1,22,3,1,5]
list4 = [1,2,5,4,5]
list100 = [4,5,6,7,8]

i = 0
while i < len(list1):
mynewlist[i] = list1[i]+list2[i]+list3[i]+list4[i]+...list100[i]
i = i+1

How can I pass an int value as the LinkText for and ActionLink

@Html.ActionLink((string)item.NUM, "Building", "Property", new {id=item.STRAP, bldNum = item.NUM }, null)

This throws a Yellow screen of death.

Cannot convert type 'int' to 'string'

However, this works.

@Html.ActionLink("HI", "Building", "Property", new {id=item.STRAP, bldNum = item.NUM }, null)

How do UNIQUE indexes work on multiple columns?

just a quick question: how exactly does the unique index check the if the field(s) is(are) unique when added on multiple columns?

For example, if I add a UNIQUE index on the email,password columns, will the index check if:

  1. Is email unique AND is password unique, or

  2. The combination of email,password is unique, as in, it would allow, 123 and, 123

Apologies if my thoughts seem abrupt here, I'm having difficulty in expressing them today for some reason. Thanks in advance!

jenkins complains host key verification failure although the key was generated


Fetching upstream changes from
ERROR: Problem fetching from origin / origin - could be unavailable. Continuing anyway
hudson.plugins.git.GitException: Error performing command: git fetch -t +refs/heads/:refs/remotes/origin/
Command "git fetch -t +refs/heads/:refs/remotes/origin/" returned status code 128: Host key verification failed.
fatal: The remote end hung up unexpectedly

My comments:

1> I found that jenkins build fails when it executes ; git fetch -t +refs/heads/:refs/remotes/origin/

2> Executed the folleing to ensure the key works: -
ssh -T
Hi [username]! You've successfully authenticated, but GitHub does not provide shell access.

But when I pasted the same command on the command line it executes it successfully: weird!

Any help ASAP is much appreciated .

Backbone views design for standard menubar / detail pages mobile UI

I'm building a mobile web app and have been struggling with the design and wiring of my backbone views.

Let me illustrate what I would like to achieve.

enter image description here

As you can see, the image above identifies few UI components:

  • Toolbar view with back, search and menu button

  • Tabbed view with lists

  • Detail view

  • Menu view

Some notes on the behavior:

  • Tapping on the menu button overlays and animates the menu.

  • The list and detail views are permanently accessible with hashtags

For now I have created views for the toolbar, menu, list and detail. But obviously there has to be some interaction between views and I'm not sure how to handle it.

Problems to solve:

  1. Do I render all views when going to detail or list? If not, how to update the toolbar and handle that relationship

  2. How to remember which tab was shown when going to detail from say tab 2 and go back to list. Remembering the visible tab with hashtags is not an option because just switching between tabs should not be remembered.

I've been looking into tbranyen layoutmanager but it still seems to assume complete isolated views.

Single CSS file for all @media vs separate CSS file for each @media

If I have all media types in single CSS file, for example

the below is a content of style.css

@media only screen and (min-width: 480px) {
/* Style adjustments for viewports 480px and over go here */


@media only screen and (min-width: 768px) {
/* Style adjustments for viewports 768px and over go here */


@media print {
/* Style adjustments for Print go here */

Will browser download download the CSS part of @media only screen and (min-width: 480px) and @media print if I open the file on a device which has min-width: 768px?

or browser will download whole css on the device even if it will be never used on same device. For example the devices which has maximum width of 480px in both orientation will never need the CSS code of written for the device with greater then 480px width or height even if the CSS is cached. it will be no use?

Is using separate CSS file for each media best for performance?

Which can increase the performance, HTTP request or a separate and only required code needed for device?

CSS inline-block IE9

I currently have a search "button" that I made sit on the side of a textbox, as shown in the picture below, this renders fine in chrome and firefox.

enter image description here

In IE9 it renders like this.

IE Render

Has anyone ran into a similar problem? How can I get around this?

The CSS for the search button is:

display: inline-block;
width: 16px;
height: 16px;
position: relative;
left: -20px;
top: 5px;
cursor: hand;
cursor: pointer;
background-image: url(../Images/magnifier.png);

How to restart application at specefic time

I have a service and some activity for that , I want whole application will restart at specific time like (03:00 pm), do you know any way to to do this , so at 3AM , the whole app restart ?


ActionScript Vector casting inconsistency?

When a Vector is casted like this...

var v1:Vector.<String> = new Vector.<String>();

var v2:Vector.<Object> = Vector.<Object>(v1)


trace(v1); //foo,bar
trace(v2); //foo

... a copy of the Vector is created, as you can see in the trace output.

But when you change line 3 to...

var v2:Vector.<*> = Vector.<*>(v1)

... no copy is created, both v1 and v2 point to the same object, trace outputs will both be "foo,bar".

Why that? Shouldn't there somehow be a consistent behaviour?

ASP.NET: Get Value of Previous Page Controll's

My page consists of 4 tab(Using a Jquery Accordian).

Tab 1.) User selects Device Make and Model(Default.aspx)

Tab 2.)User Confirms Our Buyback price(GetPrice.aspx is loaded into Tab2)

Tab 3.)User Enters Contact information(Default.aspx)

Tab 4.)Confirmation Page Displaying Users Information(Conf.aspx is loaded into Tab3)

The problem arises because I need my CodeBehind(on Conf.aspx) to have access to the user's contact information. If I passed the value's through query string, it would enable users to tamper with it and insert erroneous information into my database. Keep in mind, all of this is done WITHOUT postback.

So I need:

1.)A way to tamper-proof the Query String(keep in my the query string would consist of a Phone number,email address,state,city,zip,etc)

2.)A simple way to grab the values of the previous field(Get the values of the contact page on Default.aspx, from the final page, conf.aspx)

Sorry for the long block of text, any help would be appreciated.

Core-Data willSave: method

I have an attribute modificationDate in my Entity A. I want to set it's value whenever NSManagedObject is saved. However, if i try to do that in NSManagedObject willSave: method, i get an error:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Failed to process pending changes before save.  The context is still dirty after 100 attempts.  Typically this recursive dirtying is caused by a bad validation method, -willSave, or notification handler.' ***

So, i'm wondering, what's the best way to set the value of modificationDate?

duplicated rows which have duplicated primary key in a view

i have i view and i mappe it like this

@Column(name = "IDBQ", precision = 5, scale = 0)
public Integer getIdbq() {
return this.idbq;

public void setIdbq(Integer idbq) {
this.idbq = idbq;

@Column(name = "ID", precision = 22, scale = 0)
public Integer getId() {

public void setId(Integer id) { = id;

@Column(name = "NOM_CLIENT", length = 100)
public String getNomClient() {
return this.nomClient;

public void setNomClient(String nomClient) {
this.nomClient = nomClient;

@Column(name = "PRENOM_CLIENT", length = 30)
public String getPrenomClient() {
return this.prenomClient;

and beacause it's a view the primary key IDBQ in many rows is duplicated.
the probleme when i make a request hql from hibernate it return : duplicated rows which have duplicated Id -> IDBQ

JSF page does not properly set object attributes

Simple question from a beginner at JSF:

I have very simple JSF form:

<h:inputText value="#{}" />

<h:inputSecret value="#{userServiceImpl.user.password}" />

<h:commandButton value="#{messages.loginButtonLogin}" action="#{userServiceImpl.authenticateUser}" />

The userServiceImpl class is:

public class UserServiceImpl implements UserService {

private UserSession userSession;
private User user;

public UserServiceImpl(UserSession userSession) {
this.userSession = userSession;

public void prepareService() {
user = new User();

public View authenticateUser() {
return View.MAIN;

public User getUser() {
return user;

public void setUser(User user) {
this.user = user;


My goal is pretty simple: when the user hits the login button, I want to authenticate the user.

The problem is:
When the authenticate method is called, the User attributes are null. I debugged the application and the getUser method is called and the values are properly set, but at some point (which I did not find [yet]) before the authenticateUser is called the User attributes are set to null...

I'm aware that this is a pretty basic question... but are you able to point out where my mistake is?


Using Qt with eclipse, #include <QSqlDatabase> leads to file not found

So I have started a new Qt console project;

everything so far has been working fine. I have eclipse set up with the integration, but i'm not actually using it, i have just included the relevant Qt directories so that my #include <QtGui> calls work.

These have all worked perfectly so far.

i can compile it either using eclipse's build option, or by doing

qmake -project

from the command line. Both work.

the include statements i have; are:

#include <QtGui>
#include <QApplication>

In two different files.

If i add anotherone though, i.e. #include <QSqldatabase> then eclipse recognises the include, and lets me initialise new variables, and use the QSqlDatabase classes. Everything seems fine - see here - eclipse screenshot

When i build the project though, it decides it can't see the files even though they are all there, see them here in the terminal too. And then eclipse puts red lines everywhere.

If i go into the directory, and attempt to do it all via the terminal, using the qmake -project; qmake; make then i get the same errors.

If however, I go into the .pro file created by qmake -project, and add the line QT += sql, and then do qmake; make, then all is fine and it works.

Why is qmake -project leaving out these files from the project file? I'd really rather not have to go in and manually add that line every time I build it...

Run .NET app that targets 3.0 on a machine that has only Frameworks 2.0 and 4.0

Could anyone advise on whether an app that targets .NET 3.0 will work on a users machine that has .NET 2.0 and 4.0 but not 3.0? The installers for 3.0 and 3.5 crash on this particular machine.

CSS Nesting Problem - Reading container information

This problem comes up from time to time when I work with CSS, here is the issue I face.

My current code is:

<div class="entry">
<blockquote><p>quoted text</p></blockquote>

In my css, I have:

.entry p {margin: 10px}
blockquote {stuff}
blockquote p {margin: 0px}

I would think the paragraph inside the blockquote would read from 'blockquote p', but instead it takes the margin: 10px from '.entry p'.

Why does it read from 'entry p' instead of 'blockquote p'?

How to center WPF CheckBox within GridViewColumn?

How to center WPF CheckBox within GridViewColumn?

<GridViewColumn   Width="60" Header="Success">
<CheckBox IsChecked="{Binding Path=IsSuccess}">


This solution works fine but it destroys Expression Dark theme for cells...
(I don't know for know how to fix it...)

<ListView Name="HistoryTable" Width="783" VerticalAlignment="Stretch"   VerticalContentAlignment="Top" Height="195">
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Style TargetType="{x:Type CheckBox}" x:Key="DataGridCheckBox">
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="IsEnabled" Value="False" />
<Setter Property="Margin" Value="4" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type GridViewColumn}},Path=ActualWidth}" />
<GridViewColumn DisplayMemberBinding="{Binding Filename}" Width="140" Header="{lex:LocTextExtension Key=Name, Dict=Resources, Assembly=PreShow.Player}" />
<GridViewColumn Width="60" Header="{lex:LocTextExtension Key=Success, Dict=Resources, Assembly=PreShow.Player}">
<DockPanel HorizontalAlignment="Center">
<CheckBox IsChecked="{Binding Path=IsSuccess}" Style="{StaticResource DataGridCheckBox}">

enter image description here

Forward requests coming into port 80, for a particular link, to port 8080 locally

I have 2 web forms, one coded using Java Servlets on glassfish (port 8080) and another using PHP on apache(port 80). But my office ITdept is refusing to open port 8080 to outside traffic.
How do I set up Apache such that requests coming in for the form with the servlets are directed to port 8080?
PS: Im using wamp

Which String method: "contains" or "indexOf > -1"?

Which of the following ways is an efficient way of determining substring containment?

if (str.indexOf("/") > -1)


if (str.contains("/")) 

Adding 2checkout to WordPress s2member Pro (PHP)

I am trying to enable the option of allowing my customers to make payments using 2checkout while taking care of the subscriptions and content protection using WordPress with s2member PRO.

Reading a few very basic guides ( ) and ( ) gives little clue as to how to actually create this integration.

I can most likely figure out most of it, but I need help with things like, what files do I need to create, edit, etc. What configuration changes do I need to make in s2member to allow the new gateway to show up in the control panel? Or is there an easier "behind the scenes" way of doing it? Basically I need help in getting it started. It seems like such a simple upgrade and I'm upset that the developers have not already created this option... please help.

Arabic characters issue

I have some problems with displaying some Arabic text in my iPhone application. When I am displaying it on a UILabel, it shows like ?????? ????? ?????? The string comes from server as XML, I parse it and display on a UILabel. I dont know this is due to a problem in iPhone or from Server side.

  • I want to know how can I determine the string coming from server is having correct encoding and is a valid Arabic characters.

  • Is it suffice to print value each character and check it lies between Arabic Unicode characters. (Like ASCII value of character A is 65 and that of Z is 90. So a value 70 must be a ASCII character).

  • In server the string is encoded with UTF8 encoding. And server program written in c#. What is the write encoding method to transfer Arabic text from server to iPhone?

  • Do I need to use other fonts to display Arabic characters correctly.

  • Is there any XML file with Arabic content in Internet, from where I can parse and display arabic text correctly?

Thanks in advance..


When I NSLogged XML data I got same ???? ???? ??? characters.


See a XML styled data that I got in console.

<SCA_LONG_NAME>???? ????? ?????????? ????? ?????????</SCA_LONG_NAME>
<SCA_SHORT_NAME>???? ????? ?????????</SCA_SHORT_NAME>

Javascript passing object as function parameter

I'm quite new to javascript, so maybe it's a silly error.
I created an object like the follwing:

function objA(){

I now have a function where I want to pass the object:

var foo=new objA;

function test(foo){....}

The problem is that when I call test(), I get the functions in objA (objA.func1 and objA.func2) executed.
I would like just to get the properties value of objA.
I have to use another function and an array, fill the array with the properties of objA and then pass the array:

var arrayA={}

function fillArray(data){

function test(arrayA){....}

Is it the only way or I'm doing something wrong ?

android merging 2 images

i'm working on this for hours and can't solve it.
i want to merge 2 images in an XML file - so this will be the basic xml file for my shape.
i want this shape to include a png which is the frame, and a png which is a picture inside a frame. that picture will change dynamically.

i've tried to use tag and to build my shape, but when i'm including it to my main xml file it fails because i can use merge only as root.
try to did the same with , and still didn't get what i wanted...

what can i do to be able to merge these 2 pngs, and to be able to set the inner png position inside the frame png??

Tuesday, May 22, 2012

PDO get the last ID had inserted

I have a query and i want to get the last ID had inserted , the filed ID is primary key and auto increment

i know that i have to use this statement


That statement works with me when the query like this

$query = "INSERT INTO `cell-place` (ID) VALUES (LAST_INSERT_ID())";

But if i want to get that ID using this statement


I have got this error

Fatal error: Call to undefined function LAST_INSERT_ID()

What am i doing wrong please

A program worked fine on my computer but when I sent it on another one with a Dutch Windows it has problems with the DateTimePicker

The program is with C# WinForms and SQL Server 2008. When I want to enter data that includes the value from a DateTimePicker I can see that the wording is in Dutch and then I get an error about converting of the value. Is there any way to pre-program it to get around this? I've caught the error and here it is.


SqlConnection connect = new SqlConnection("Data Source=Localhost\\SQLExpress;Initial Catalog=DataBase;Integrated Security=True");
SqlDataAdapter da = new SqlDataAdapter();

/******************** Inserting ********************/
string query = "INSERT INTO spending VALUES (";
query += "'" + date_dateTimePicker.Value + "', "; // Date
query += "'" + Convert.ToDecimal(amount_spent_textBox.Text) + "', "; // Amount spent
query += "'" + spent_on_textBox.Text + "')"; // Spent on
da.InsertCommand = new SqlCommand(query, connect);


catch (Exception error)

Things are getting thick.. I got this error while trying to insert a dateTimePicker value into the database the same way I did with the code above. It worked perfectly fine on my computer but it won't work here. Can someone explain? Here is the error:


Code used:

string update = "UPDATE table SET the_date = '" + the_date_dateTimePicker.Value + "' WHERE instance_ID = 1";
da.InsertCommand = new SqlCommand(update, connect);

Set focus to UI element using XAMl or MVVM

I want to set focus to the ui elemt when i press any key in the text box. i wnt it purely on XAML sid or by using mvvm.

Inserting a List<> in SQL Table

I have an entity "report" whose values i want to insert in a Database table. Following attributes of the Report have to be inserted -

reportID - int
RoleID - int
Created_BY = SYSTEM(default)

Now the problem is with the 2nd attribute. I have a report with the LIST<ROLES> attributes. ROLES is a well defined entity which has an ID and a NAME. From this list I have to extract every role and insert each role's ID into the table.

So my query presently looks as below :


The C# code from where I am parsing these values is as follows :

StringBuilder _objSQL = new StringBuilder();
_objSQL.AppendFormat(Queries.Report.ReportQueries.ADD_NEW_ROLES, report.ID, "report.MarjorieRoles.Add(MarjorieRole"));
_IsRolesAdded = true;

So please guide me how to add roles from C# function

plupload Codeigniter file upload issue-IO error 2032

i am using plupload script with codeigniter to upload files.I included all required files to make it work but now the issue is if i am trying to upload a image file large than 20 Kb than it will uploaded to the specific folder successfully but if you go and check the image file than only around 25% part of the image is visible other part is shown as a grey color.

and sometimes plupload shows IO error 2032 also.

I check my max post size and file upload size both are large enough to upload a 20 kb image file.

my script is:

    <script type="text/javascript">
// Convert divs to queue widgets when the DOM is ready
$(function() {
var cct = $.cookie("<?php echo $this->config->item("csrf_cookie_name"); ?>");
// General settings
runtimes : 'gears,flash,silverlight,browserplus,html5',
url : '<?php echo base_url();?>index.php/uploadphoto',
max_file_size : '5mb',
chunk_size : '1mb',
unique_names : true,
multipart_params:{'<?php echo $this->security->get_csrf_token_name(); ?>': cct},

// Specify what files to browse for
filters : [
{title : "Image files", extensions : "jpg,gif,png,bmp,jpeg"}

// Flash settings
flash_swf_url : '<?php echo base_url();?>js/plupload.flash.swf',

// Silverlight settings
silverlight_xap_url : '<?php echo base_url();?>js/plupload.silverlight.xap'


and my controller upload photo is like this:

    $upload_path_url = './uploads/';

$config['upload_path'] =$upload_path_url;
$config['allowed_types'] = 'gif|jpg|png|bmp|jpeg';
$config['max_size'] = '5500';

$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('file'))
$error = array('error' => $this->upload->display_errors());
//$this->load->view('upload', $error);
$data = $this->upload->data();

so give me any suggestion to solve this issue.

-Thanks in advance

Error while loading the data from server to core data model using restkit

i am using restkit in my project. i can sucessfully load data using the restkit and can store to data base by manually passing the loaded data to the coredata objects. Later i modified it to the restkit coredata model then i am getting the error like this. when run first time

reason = "The model used to open the store is incompatible with the one used to create the store";

my core data was set correctly and its working fine when i pass the data to keys manually.

i got a solution to delete the app or delete the app data from simulator file,
so i deleated the app from the simulator and again run it.this time i got the this error

 2012-05-18 17:38:45.610 MAW[85942:15203] W Unable to find parser for MIME Type 'text/html'
2012-05-18 17:38:45.612 MAW[85942:15203] W Encountered unexpected response with status code: 200 (MIME Type: text/html -> URL: -- -- --
2012-05-18 17:38:45.614 MAW[85942:15203] Encountered an error: Error Domain=org.restkit.RestKit.ErrorDomain Code=4 "The operation couldn't be completed. (org.restkit.RestKit.ErrorDomain error 4.)"

Hear is my code

// Initialize RestKit
RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURLString:@""];
objectManager.client.requestQueue.showsNetworkActivityIndicatorWhenBusy = YES;

RKManagedObjectStore* objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:@"MAW.sqlite"];

RKManagedObjectMapping* customerMapping = [RKManagedObjectMapping mappingForClass:[Customer class]inManagedObjectStore:objectStore];
[customerMapping mapKeyPath:@"phone" toAttribute:@"phone"];
[customerMapping mapKeyPath:@"organization" toAttribute:@"organization"];
[customerMapping mapKeyPath:@"siteAdministrator" toAttribute:@"siteAdministrator"];
[customerMapping mapKeyPath:@"customerType" toAttribute:@"customerType"];
[customerMapping mapKeyPath:@"id" toAttribute:@"id"];

RKManagedObjectMapping* articleMapping = [RKManagedObjectMapping mappingForClass:[User class]inManagedObjectStore:objectStore];
[articleMapping mapKeyPath:@"email" toAttribute:@"email"];
[articleMapping mapKeyPath:@"fullname" toAttribute:@"fullname"];
[articleMapping mapKeyPath:@"id" toAttribute:@"id"];

// relationship mapping
[articleMapping mapKeyPath:@"customer" toRelationship:@"customer" withMapping:customerMapping];

[[RKObjectManager sharedManager].mappingProvider addObjectMapping:articleMapping] ;

[self loadData];

my delegate methods

// fetch your mapping
RKObjectMapping *customerMapping = [[RKObjectManager sharedManager].mappingProvider objectMappingForClass:[Customer class]];
//request data
[[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"auth?password=1234&" objectMapping:customerMapping delegate:self];
- (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects {
RKLogInfo(@"Load collection of: %@", objects);

- (void)objectLoader:(RKObjectLoader*)objectLoader didFailWithError:(NSError*)error {
NSLog(@"Encountered an error: %@", error);

- (void)request:(RKRequest*)request didLoadResponse:
(RKResponse*)response {
if ([request isGET]) {
if ([response isOK]) {
NSLog(@"Retrieved JSON: %@", [response bodyAsString]);
} else if ([request isPOST]) {
if ([response isJSON]) {
NSLog(@"Got a JSON response back from our POST!");

can any one help me how can i solve this. and also suggest me in using restkit. As i am new to iphone feeling little bit difficult to with rest kit. Shall i continue with this or suggest any other alternatives i will go them. if not suggest me a good resorce to follow restkit. now i am going through this restkit in github

I have tried by running the example twiter code provided in the restkit . It is also giving the same error, what might be the problem????(either ios / restkit) i have found an issue here any ideas? thank you...

Spinlock Versus Semaphore!

What is the basic differences between Semaphores & Spinlock? & In what best situations or conditions, we can use these.

static content not working on virtual directories in IIS on XP

I have a strange problem with IIS on XP.

I have a ASP.MVC web application with a virtual directory pointing to it.

The application works OK, I see the generated html pages.
The problem is that I get 404 errors for all the static content files (css,js and image files).

The really strange thing is that if I create an application directly on the directory the static content is served, but I can't get the static content from a virtual directory pointing to the same directory!.

BTW, the static content is served OK from the virtual directory created by VS2010 for the application.

I can't find any differences in the configuration in the IIS between the virtual directory created by VS2010 (that works) and the one that does not work.

I anybody got any ideas, I would be VERY gratefull...



Delete this from a javascript object in a jQuery .each()

I am having trouble deleting this from the following javascript object, when this is from a jquery .each() loop.


"Move Out Day":{
"type":"One Time",

This is a shrunken version of the .each() loop:

$.each(, function(i){
if(this.type == "One Time"){

Transfer Focus From One Component To Other In JFrame

I am working on a JFrame with few Text Fields and JTables and have defined the Focus order of components with the tab Key using the example!

I have also inhereted the jtable Class with following changes
The problem is that on reaching the jtable and when i press the Tab key the focus is not transfered to the other Component.

public class FocusTransferableJTable extends JTable {
public boolean isFocusTraversable() {
return false;

And also using the following code for jtable and jtxtArea

public static void patch(Component c) {
strokes = new HashSet<KeyStroke>(Arrays.asList(KeyStroke.getKeyStroke("pressed TAB")));
c.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, strokes);
strokes = new HashSet<KeyStroke>(Arrays.asList(KeyStroke.getKeyStroke("shift pressed TAB")));
c.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, strokes);

Now it is working fine for jtable and jtxtArea i now need help in jTabPane and it's sub tabs and the component inside them.
Question edited with SSCCE!

Best Facebook Library for Android

I have checked the official Facebook Library, I do not want to use it, I want to know if there are any alternatives or rather the best alternatives.

AttributeError: 'WSGIRequest' object has no attribute 'session'

I keep getting this error at random times and whenever I touch the django.wsgi file, it gets fixed only to happen again after a few hours. I'm lost as to what to do. my middleware_classes is as follows:


The error always occurs in the facebook middleware when i do an "if request.session" statement.

Watchdog fires on high interrupt rate

I am working on a customized/proprietary RTOS provided by my client.

The RTOS uses round robin scheduling with priority preemption.

Scenario is -

  1. The Renesas H8S controller is running at 20 MHz

  2. I have configured interrupt for ethernet interrupt (A LAN9221 chip is interrupting)

  3. A task which reads the data from LAN controller is running at highest priority in OS

  4. Another task TCP which is second highest priority task in system

I have generated network traffic to simulate bombarding condition on the network.
Problem is at high data rates (more than 500 packets/second) on ethernet ISR watchdog is getting fired which is configured for 1 second.

Watchdog is configured to be serviced by a lower priority task of OS to detect any problem in OS functionality.

I doubt the frequency of ISR and higher priority tasks are not letting the watchdog task to be scheduled. To confirm my doubt i have serviced the watchdog in ISR itself and found working till 2000 packets/second.

Could you please suggest how can handle the situation so the watchdog should not fire even on higher data/interrupt rate.


Dialog that returns an Object

Is it possible to create a JDialog in swing that would return an object when OK button is clicked?

For example the Dialog box has text fields that have components that make up an adress ( street name, country etc.)

When the OK button is clicked an Address object is returned.

Why I thought this to be possible was because of this. But what I want is something like I mentioned above.

Any pointers on how to get this done would be very helpful.

Creating a lock screen dialog for an app

I want to create a dialog on an app that is the same as the android pattern lock screen you see when you try to enter the phone.

I've read around and i'm trying to view the android code for this section, but I cant seem to find it nor find out how to implement what I'm trying to do.

Any tips?

What's the theoretical complexity of this algorithm?

fun(double x, int y){
if (int == 0){
return 1.0;
} else {
return fun(x, y/2) * fun(x, y/2);

How can I find the theoretical complexity?
+ What's the difference between the big O and the theta-notation?


High-Order ScalaCheck

Consider the following definition of a category:

trait Category[~>[_, _]] {
def id[A]: A ~> A
def compose[A, B, C](f: A ~> B)(g: B ~> C): A ~> C

Here's an instance for unary functions:

object Category {
implicit def fCat = new Category[Function1] {
def id[A] = identity
def compose[A, B, C](f: A => B)(g: B => C) = g.compose(f)

Now, categories are subject to some laws. Relating composition (.) and identity (id):

forall f: categoryArrow -> id . f == f . id == f

I want to test this with ScalaCheck. Let's try for functions over integers:

"Categories" should {
import Category._

val intG = { (_ : Int) - 5 }

"left identity" ! check {
forAll { (a: Int) => fCat.compose([Int])(intG)(a) == intG(a) }

"right identity" ! check {
forAll { (a: Int) => fCat.compose(intG)( == intG(a) }

But these are quantified over (i) a specific type (Int), and (ii) a specific function (intG). So here's my question: how far can I go in terms of generalizing the above tests, and how? Or, in other words, would it be possible to create a generator of arbitrary A => B functions, and provide those to ScalaCheck?

jquery shows wrong page

This is the jquery

$(document).on('change', '.ui-slider-switch', function () {

if ($(this).val() == 'on') {

} else {



<div id="switch" data-role="fieldcontain">      
<select name="slider" id="flip-a" data-role="slider">
<option value="off"></option>
<option value="on"></option>

In my site I sometimes use a custom URL (And get data out of it with $ _GET).
When the page reload I'm always getting $("#content2").show(); instead of $("#content1").show();

How to change gallery's scrollview

MyGallery gallery = (MyGallery)findViewById(;
PhonePhotoViewerAdapter = new PhonePhotoViewerAdapter(this, FilePath);

Above is my code to show photo with scrollview.

But if I want to focus on next, I have to move finger on screen with a larger distance.

I want to let it change focus while a smaller distance moved

How can I do it?

I had modify class Gallery as below:

public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (e1.getX() - e2.getX() > 50 && Math.abs(velocityX) > 100) {
// Fling left
} else if (e2.getX() - e1.getX() > 50 && Math.abs(velocityX) > 100) {
// Fling right
return false;

Below code is my modify:

gallery.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
int action = event.getAction();
if((action == MotionEvent.ACTION_DOWN) && !Clicking) {
StartX = event.getX();
StartIndex = gallery.getSelectedItemPosition();
Clicking = true;
else if((action == MotionEvent.ACTION_UP) && Clicking) {
EndX = event.getX();
EndIndex = gallery.getSelectedItemPosition();
Clicking = false;
if(((EndX - StartX) > 50) && (StartIndex == EndIndex)) {
if(EndIndex > 0) {
gallery.setSelection(EndIndex - 1);
else if(((StartX - EndX) > 50) && (StartIndex == EndIndex)) {
if(EndIndex < count - 1) {
gallery.setSelection(EndIndex + 1);
return false;

But there are some abnormal in showing.

Upload external file to AWS S3 bucket using PHP SDK

I want to upload a file from an external URL directly to an Amazon S3 bucket using the PHP SDK. I managed to do this with the following code:

$s3 = new AmazonS3();
$response = $s3->create_object($bucket, $destination, array(
'fileUpload' => $source,
'length' => remote_filesize($source),
'contentType' => 'image/jpeg'

Where the function remote_filesize is the following:

function remote_filesize($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
$ok = curl_exec($ch);
$head = ob_get_contents();
$regex = '/Content-Length:\s([0-9].+?)\s/';
$count = preg_match($regex, $head, $matches);
return isset($matches[1]) ? $matches[1] : "unknown";

However, it would be nice if I could skip setting the filesize when uploading to Amazon since this would save me a trip to my own server. But if I remove setting the 'length' property in the $s3->create_object function, I get an error saying that the 'The stream size for the streaming upload cannot be determined.' Any ideas how to solve this problem?

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 @$_, [ @$_ ]}
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 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)


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;

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;



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"
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name"
ReadOnly="True" >
<ControlStyle Width="150px" />
<asp:BoundField DataField="Beschreibung" HeaderText="Beschreibung"
SortExpression="Beschreibung" ReadOnly="True" >
<ControlStyle Width="200px" />
<asp:BoundField DataField="Datum" HeaderText="Datum" SortExpression="Datum"
ReadOnly="True" >
<ControlStyle Width="100px" />
<asp:BoundField DataField="Erledigt" HeaderText="Erledigt"
SortExpression="Erledigt" >
<ControlStyle Width="50px" />
<asp:BoundField DataField="Kommentar" HeaderText="Kommentar"
SortExpression="Kommentar" >
<ControlStyle Width="200px" />
<asp:BoundField DataField="LastUpdate" HeaderText="LastUpdate"
SortExpression="LastUpdate" ReadOnly="True" />
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"
ReadOnly="True" SortExpression="ID" Visible="False" />
<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)"
<asp:Parameter Name="userlogin"/>
<asp:Parameter Name="datum"/>
<asp:Parameter Name="Kommentar" Type="string"/>
<asp:Parameter Name="ID" />

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


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?



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 );



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:


glBindTexture(GL_TEXTURE_RECTANGLE_ARB, planeInfo->m_texHandle);


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

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:

glBindTexture(GL_TEXTURE_RECTANGLE_ARB, frontTexHandle);

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);

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?

glScalef( (GLfloat)m_surfaceWidth, (GLfloat)m_surfaceHeight, 1.0f );





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






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

There is here such here a program:
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)

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

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

public synchronized void set(MyValue myValue)

public void anotherSetWithSynchronized(MyValue myValue)
synchronized (myObject)

public void anotherSetWithoutSynchronized(MyValue 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);


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;

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

4 now I call CallFactory method in python:


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)

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

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

int main()

int *ptr;
int a;



return 0;


No line number found known for in gdb

I have compiled my own glibc, which produced I loaded the file in gdb by doing gdb -q ./ 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) {
} catch (InterruptedException e) {
// TODO Auto-generated catch block
Log.d(TAG, "Waiting didnt work!!");

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);


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 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">
<tr><td></td>...and many more cells</tr>
...and many more rows

jQuery Code:

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

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

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