PostId
int64 4
11.8M
| PostCreationDate
stringlengths 19
19
| OwnerUserId
int64 1
1.57M
| OwnerCreationDate
stringlengths 10
19
| ReputationAtPostCreation
int64 -55
461k
| OwnerUndeletedAnswerCountAtPostTime
int64 0
21.5k
| Title
stringlengths 3
250
| BodyMarkdown
stringlengths 5
30k
⌀ | Tag1
stringlengths 1
25
⌀ | Tag2
stringlengths 1
25
⌀ | Tag3
stringlengths 1
25
⌀ | Tag4
stringlengths 1
25
⌀ | Tag5
stringlengths 1
25
⌀ | PostClosedDate
stringlengths 19
19
⌀ | OpenStatus
stringclasses 5
values | unified_texts
stringlengths 32
30.1k
| OpenStatus_id
int64 0
4
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
11,382,614 | 07/08/2012 11:03:25 | 1,176,480 | 01/29/2012 13:15:55 | 69 | 1 | Qt Mac Store Famous Library/Preferences/com.trolltech.plist rejection | My Qt Mac OS App has been rejected from Apple Mac Store for this reason:
2.30
The application accesses the following location(s):
'~/Library/Preferences/com.trolltech.plist'
'/Users/mac'
The application may be
* creating files
* writing files
* opening files for Read/Write access (instead of Read-Only access)
in the above location(s). | osx | qt | store | null | null | null | open | Qt Mac Store Famous Library/Preferences/com.trolltech.plist rejection
===
My Qt Mac OS App has been rejected from Apple Mac Store for this reason:
2.30
The application accesses the following location(s):
'~/Library/Preferences/com.trolltech.plist'
'/Users/mac'
The application may be
* creating files
* writing files
* opening files for Read/Write access (instead of Read-Only access)
in the above location(s). | 0 |
11,382,615 | 07/08/2012 11:03:42 | 1,071,136 | 11/29/2011 11:04:25 | 1,378 | 48 | Floating point formatting in LLDB (debugging C++) | Given a `double d`, I can print it,
(lldb) expr d
(double) $2 = 3.05658e-08
Is there a way to print more digits of d, such as
printf("%.15f", d) ? | lldb | null | null | null | null | null | open | Floating point formatting in LLDB (debugging C++)
===
Given a `double d`, I can print it,
(lldb) expr d
(double) $2 = 3.05658e-08
Is there a way to print more digits of d, such as
printf("%.15f", d) ? | 0 |
11,410,794 | 07/10/2012 09:56:15 | 367,949 | 06/16/2010 06:31:12 | 315 | 62 | Packing Inner Boxes inside outer boxes |
I am working on a project where i have to pack inner boxes which contain car parts inside a outer box for exporting .
There are three type of Inner boxes(Form of Cuboid) .If volume of outer box is V then volume of Inner boxes are V/20,v/40,V/80 . Height of each inner box is same.
I want to fill the inner boxes most efficiently in outer box:
Outerbox weight should not exceed 1 ton
Outerbox should be filled with 100% efficiency
Which algorithm should I use?
| algorithm | null | null | null | null | null | open | Packing Inner Boxes inside outer boxes
===
I am working on a project where i have to pack inner boxes which contain car parts inside a outer box for exporting .
There are three type of Inner boxes(Form of Cuboid) .If volume of outer box is V then volume of Inner boxes are V/20,v/40,V/80 . Height of each inner box is same.
I want to fill the inner boxes most efficiently in outer box:
Outerbox weight should not exceed 1 ton
Outerbox should be filled with 100% efficiency
Which algorithm should I use?
| 0 |
11,410,690 | 07/10/2012 09:50:00 | 1,006,821 | 10/21/2011 09:39:26 | 58 | 1 | Using Curl wiith IIS to upload files using HTTP | I have an application built using C++ using libcurl (C# for the GUI) which uploads files to a remote webserver through HTTP.
The problem is the previous developer who built it tested it on an Apache webserver using his local server and it works perfect (I have tested it myself) now the remote server is actually an IIS server. After modifying curl file to accept username and password. I have managed to connect to the IIS web server but it does not upload any files. The error returned is "Failed to Write" but all the permission is set to complete control (read write and execute).
The upload handler is a PHP file on the server. I have set up PHP on the IIS server.
I am not understanding what the problem may be? Is it because Curl has some problems with IIS or is there something which I have forgotten to include in the IIS configuration.
Any suggestion would be really helpful and if any information any of you need please do ask.
Thanks in advance. | c++ | http | iis | webserver | libcurl | null | open | Using Curl wiith IIS to upload files using HTTP
===
I have an application built using C++ using libcurl (C# for the GUI) which uploads files to a remote webserver through HTTP.
The problem is the previous developer who built it tested it on an Apache webserver using his local server and it works perfect (I have tested it myself) now the remote server is actually an IIS server. After modifying curl file to accept username and password. I have managed to connect to the IIS web server but it does not upload any files. The error returned is "Failed to Write" but all the permission is set to complete control (read write and execute).
The upload handler is a PHP file on the server. I have set up PHP on the IIS server.
I am not understanding what the problem may be? Is it because Curl has some problems with IIS or is there something which I have forgotten to include in the IIS configuration.
Any suggestion would be really helpful and if any information any of you need please do ask.
Thanks in advance. | 0 |
11,410,691 | 07/10/2012 09:50:06 | 1,346,402 | 04/20/2012 11:23:47 | 20 | 0 | Preventing java class unload? | I have a test class extending `junit.framework.TestCase` with several test methods.Each method opens a HTTP connection to server and exchange request and response json strings.One method gets a response with a string called UID(similar to sessionId) which i need to use in subsequent requests to the server.
I was previously writing that string to a file and my next requests read that file for string.I am running one method at a time.Now I am trying to use that string without file operations.I maintained a hastable(because there are many UIDs to keep track of) in my test class as instance variable for the purpose , but eventually found that class is getting loaded for my each method invocation as my static block is executing everytime.This is causing the loss of those UIDs.
How do I achieve this without writing to file and reading from it?
I doubt whether my heading matches my requirement.Someone please edit it accordingly. | java | junit | null | null | null | null | open | Preventing java class unload?
===
I have a test class extending `junit.framework.TestCase` with several test methods.Each method opens a HTTP connection to server and exchange request and response json strings.One method gets a response with a string called UID(similar to sessionId) which i need to use in subsequent requests to the server.
I was previously writing that string to a file and my next requests read that file for string.I am running one method at a time.Now I am trying to use that string without file operations.I maintained a hastable(because there are many UIDs to keep track of) in my test class as instance variable for the purpose , but eventually found that class is getting loaded for my each method invocation as my static block is executing everytime.This is causing the loss of those UIDs.
How do I achieve this without writing to file and reading from it?
I doubt whether my heading matches my requirement.Someone please edit it accordingly. | 0 |
11,410,796 | 07/10/2012 09:56:20 | 1,040,752 | 11/10/2011 23:14:02 | 397 | 0 | How to turn off the ticks on the upper/right axis of a numpy plot? | Basically, I want to make the ticks on the right and upper axis invisible, and not sure what the third line should be:
import matplotlib.pyplot as plt
plt.plot(X,Y)
#plt.upper_right_axis_ticks_off()
| python | numpy | matplotlib | null | null | null | open | How to turn off the ticks on the upper/right axis of a numpy plot?
===
Basically, I want to make the ticks on the right and upper axis invisible, and not sure what the third line should be:
import matplotlib.pyplot as plt
plt.plot(X,Y)
#plt.upper_right_axis_ticks_off()
| 0 |
11,410,798 | 07/10/2012 09:56:30 | 522,058 | 11/27/2010 06:19:25 | 766 | 13 | Finding Hardy Ramanujan Numbers | Find the first n Hardy-Ramanujan numbers. Given a value n. I would like to find the first n Hardy Ramanujan Numbers.
A Hardy Ramanujan Number being a number that can be expressed as sum of two perfect cubes in two different ways:
example
cube(1)+cube(12) = 1729 = cube(9)+cube(10)
I would like a rough overview of the algorithm or the c snippet of how to approach the problem. | c | algorithm | homework | numbers | null | null | open | Finding Hardy Ramanujan Numbers
===
Find the first n Hardy-Ramanujan numbers. Given a value n. I would like to find the first n Hardy Ramanujan Numbers.
A Hardy Ramanujan Number being a number that can be expressed as sum of two perfect cubes in two different ways:
example
cube(1)+cube(12) = 1729 = cube(9)+cube(10)
I would like a rough overview of the algorithm or the c snippet of how to approach the problem. | 0 |
11,410,768 | 07/10/2012 09:54:23 | 1,514,360 | 07/10/2012 09:43:24 | 1 | 0 | How to call specific action on drop down selected change event in rails3.1 | I have on select_tag on my page and this drop down have language collection. now i want to change all the messages according to language selected in the drop down. For that i need to call action on the selection change. So how i will call the same.
Thanks,
Lalit | ruby-on-rails | ruby | null | null | null | null | open | How to call specific action on drop down selected change event in rails3.1
===
I have on select_tag on my page and this drop down have language collection. now i want to change all the messages according to language selected in the drop down. For that i need to call action on the selection change. So how i will call the same.
Thanks,
Lalit | 0 |
11,373,282 | 07/07/2012 07:49:31 | 1,479,105 | 06/25/2012 05:32:18 | 1 | 0 | fetch count values from sqlite database | i'm new to android, i don know how to do the following please help me
i have a table named "attendence", in which i will store students status as present or absent,..
now i want to display the final report as
user selects branch name, semester and subject,, as soon as he selects these i want a list view of students with total number of classes present
output resembles some what like this
branch: ECE
semester: 1
Subject: Basic Electronics
Total Classes: 10
//(listview)
ABC 4
DEF 7
GHI 5
KLM 2
please help me
thank u in advance
| android | null | null | null | null | 07/08/2012 23:02:40 | not a real question | fetch count values from sqlite database
===
i'm new to android, i don know how to do the following please help me
i have a table named "attendence", in which i will store students status as present or absent,..
now i want to display the final report as
user selects branch name, semester and subject,, as soon as he selects these i want a list view of students with total number of classes present
output resembles some what like this
branch: ECE
semester: 1
Subject: Basic Electronics
Total Classes: 10
//(listview)
ABC 4
DEF 7
GHI 5
KLM 2
please help me
thank u in advance
| 1 |
11,373,291 | 07/07/2012 07:51:03 | 1,508,405 | 07/07/2012 07:30:19 | 1 | 0 | reference variable AS3 | I am trying to create a simple AS3 code in Flash Professional CS6 which references a variable.
Example:
var1:int = 1;
varref = "var1"; (this is the "reference" variable, but ofcourse this is not how it's done in as3)
if (var1 == 1)
{
varref = 50
}
If this is run, it would try to make the string from the variable varref which is currently "var1" into an int of "1'. I want it to **reference** the variable, not be a variable of it's own.
A simple example of how to do this would be great. (From what I know, an object may be needed, so a simple object example of this situation would be great.) | actionscript-3 | flash | null | null | null | null | open | reference variable AS3
===
I am trying to create a simple AS3 code in Flash Professional CS6 which references a variable.
Example:
var1:int = 1;
varref = "var1"; (this is the "reference" variable, but ofcourse this is not how it's done in as3)
if (var1 == 1)
{
varref = 50
}
If this is run, it would try to make the string from the variable varref which is currently "var1" into an int of "1'. I want it to **reference** the variable, not be a variable of it's own.
A simple example of how to do this would be great. (From what I know, an object may be needed, so a simple object example of this situation would be great.) | 0 |
11,373,296 | 07/07/2012 07:51:56 | 905,911 | 08/22/2011 13:07:25 | 1 | 0 | ""Duplicate Entry" while inserting in a Composite primary keyed table | CREATE TABLE IF NOT EXISTS `mytable` (
`machine_no` varchar(50) CHARACTER SET ascii NOT NULL,
`date` datetime NOT NULL,
`nature` int(11) DEFAULT NULL,
`start` time NOT NULL,
PRIMARY KEY (`machine_no`,`date`),
UNIQUE KEY `date` (`date`),
UNIQUE KEY `start` (`start`),
UNIQUE KEY `start_2` (`start`),
UNIQUE KEY `nature` (`nature`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
This table has a composite key.
When I try to insert 2 records with same date/time but different value of machine_no. It says duplicate entry for Date. I dont understand the reason for it. As it a composite key, it should only look for duplicate entry for in both the attributes.
| mysql | database | primary-key | null | null | null | open | ""Duplicate Entry" while inserting in a Composite primary keyed table
===
CREATE TABLE IF NOT EXISTS `mytable` (
`machine_no` varchar(50) CHARACTER SET ascii NOT NULL,
`date` datetime NOT NULL,
`nature` int(11) DEFAULT NULL,
`start` time NOT NULL,
PRIMARY KEY (`machine_no`,`date`),
UNIQUE KEY `date` (`date`),
UNIQUE KEY `start` (`start`),
UNIQUE KEY `start_2` (`start`),
UNIQUE KEY `nature` (`nature`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
This table has a composite key.
When I try to insert 2 records with same date/time but different value of machine_no. It says duplicate entry for Date. I dont understand the reason for it. As it a composite key, it should only look for duplicate entry for in both the attributes.
| 0 |
11,373,298 | 07/07/2012 07:52:04 | 1,075,846 | 12/01/2011 16:17:04 | 10 | 0 | SQL Syntax Error. Looks like i miss something | Here is my sql code combined with php
$query = sprintf("SELECT SUM( value ) AS totalvalue
FROM (
SELECT *
FROM answers
WHERE user_id='%s'
AND test_id ='%s'
ORDER BY answers.id DESC
LIMIT '%s'
)
AS subquery",
$user_id,
mysql_real_escape_string($test_id),
$num_of_q);
And there is god damn error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''40' ) AS subquery' at line 8
My friends what is the problem here. | php | mysql | sql | query | mysql-error-1064 | null | open | SQL Syntax Error. Looks like i miss something
===
Here is my sql code combined with php
$query = sprintf("SELECT SUM( value ) AS totalvalue
FROM (
SELECT *
FROM answers
WHERE user_id='%s'
AND test_id ='%s'
ORDER BY answers.id DESC
LIMIT '%s'
)
AS subquery",
$user_id,
mysql_real_escape_string($test_id),
$num_of_q);
And there is god damn error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''40' ) AS subquery' at line 8
My friends what is the problem here. | 0 |
11,373,304 | 07/07/2012 07:52:57 | 1,403,154 | 05/18/2012 10:49:36 | 3 | 1 | How can i parse data from .swf file? | I'm trying to develop an application that will parse the data from a .swf (i want to be able to read some fields from the flash file) How can i achieve this? or is it impossible ?
Ty | flash | parsing | data | null | null | null | open | How can i parse data from .swf file?
===
I'm trying to develop an application that will parse the data from a .swf (i want to be able to read some fields from the flash file) How can i achieve this? or is it impossible ?
Ty | 0 |
11,373,306 | 07/07/2012 07:53:09 | 1,349,928 | 04/22/2012 18:50:14 | 158 | 0 | How to work in Netbeans with an already maximized form | I don't want to maximize the frame after the launch, using setExtendedState(), but rather I want to edit the frame in its maximum size, so that when its maximized, the size of jbuttons and other components do not change, or their position.
Let me explain more since my english isn't that good, when I create a new JFrame Form, it is created with an original size of 400,300; means when I maximize it later, the look will be different, some positions might change, some components might grow bigger, all I want to do, is to edit the jframe in its maximized state, of course I can check my screen resolution and give that width and height to the jframe, but thats not very....precise, cause some pixels are gone because of the border or whatever. | netbeans | jframe | null | null | null | null | open | How to work in Netbeans with an already maximized form
===
I don't want to maximize the frame after the launch, using setExtendedState(), but rather I want to edit the frame in its maximum size, so that when its maximized, the size of jbuttons and other components do not change, or their position.
Let me explain more since my english isn't that good, when I create a new JFrame Form, it is created with an original size of 400,300; means when I maximize it later, the look will be different, some positions might change, some components might grow bigger, all I want to do, is to edit the jframe in its maximized state, of course I can check my screen resolution and give that width and height to the jframe, but thats not very....precise, cause some pixels are gone because of the border or whatever. | 0 |
11,373,307 | 07/07/2012 07:53:11 | 1,400,353 | 05/17/2012 07:06:58 | 84 | 10 | POST FROM immediately | I have a Paypal class and I would like to echo the form and then submit it after the user click pay. I've tried the javascript but it didn't work with me.
if(isset($_SESSION['user_id']))
{
include('includes/class_paypal.php');
include 'includes/class_order.php';
include 'includes/class_user.php';
include 'includes/class_permission.php';
include('includes/adminfunctions_status.php');
$invoice = new paypal();
$order = new order($_GET['pay']);
$invoice->custom = $_GET['pay'];
$invoice->amount = $order->price;
$invoice->item_name = 'Order #'.$order->id.'';
$invoice->item_number = $order->id;
$invoice->init();
}
?>
<script type="text/javascript">
$(document).ready(myfunc () {
var frm = document.getElementById("order");
frm.submit();
}
</script>
PayPal Class
var $cmd = "_xclick";
var $business = "**";
var $item_name;
var $item_number;
var $amount;
var $no_shipping = 1;
var $no_note = 1;
var $currency_code = "USD";
var $lc = 'US';
var $bn = "PP-BuyNowBF";
var $return;
var $cancel_return;
var $rm = 2;
var $notify_url;
var $custom;
function init()
{
echo '
<form id="order" target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="'.$this->business.'">
<input type="hidden" name="item_name" value="'.$this->item_name.'">
<input type="hidden" name="item_number" value="'.$this->item_number.'">
<input type="hidden" name="amount" value="'.$this->amount.'">
</form>
';
}
as you can see I want to post the form after initialize the order information. So when the user go to index.php?pay=45 (45 is the order number ) I want the file to show the form and everything, and then post the form to Paypal.
| php | javascript | jquery | html | null | null | open | POST FROM immediately
===
I have a Paypal class and I would like to echo the form and then submit it after the user click pay. I've tried the javascript but it didn't work with me.
if(isset($_SESSION['user_id']))
{
include('includes/class_paypal.php');
include 'includes/class_order.php';
include 'includes/class_user.php';
include 'includes/class_permission.php';
include('includes/adminfunctions_status.php');
$invoice = new paypal();
$order = new order($_GET['pay']);
$invoice->custom = $_GET['pay'];
$invoice->amount = $order->price;
$invoice->item_name = 'Order #'.$order->id.'';
$invoice->item_number = $order->id;
$invoice->init();
}
?>
<script type="text/javascript">
$(document).ready(myfunc () {
var frm = document.getElementById("order");
frm.submit();
}
</script>
PayPal Class
var $cmd = "_xclick";
var $business = "**";
var $item_name;
var $item_number;
var $amount;
var $no_shipping = 1;
var $no_note = 1;
var $currency_code = "USD";
var $lc = 'US';
var $bn = "PP-BuyNowBF";
var $return;
var $cancel_return;
var $rm = 2;
var $notify_url;
var $custom;
function init()
{
echo '
<form id="order" target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="'.$this->business.'">
<input type="hidden" name="item_name" value="'.$this->item_name.'">
<input type="hidden" name="item_number" value="'.$this->item_number.'">
<input type="hidden" name="amount" value="'.$this->amount.'">
</form>
';
}
as you can see I want to post the form after initialize the order information. So when the user go to index.php?pay=45 (45 is the order number ) I want the file to show the form and everything, and then post the form to Paypal.
| 0 |
11,373,310 | 07/07/2012 07:53:25 | 1,225,603 | 02/22/2012 10:57:03 | 135 | 8 | Django-nonrel: Syntax to Reset an App | To reset my app, I ran this:
./manage.py reset node
It is giving me this error output:
WARNING:root:The rdbms API is not available because the MySQLdb library could not be loaded.
Traceback (most recent call last):
File "./manage.py", line 11, in <module>
execute_manager(settings)
File "/home/a/mywebsites/django/seperolinux/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/home/a/mywebsites/django/seperolinux/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/a/mywebsites/django/seperolinux/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/a/mywebsites/django/seperolinux/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/home/a/mywebsites/django/seperolinux/django/core/management/base.py", line 286, in handle
app_output = self.handle_app(app, **options)
File "/home/a/mywebsites/django/seperolinux/django/core/management/commands/reset.py", line 35, in handle_app
sql_list = sql_reset(app, self.style, connection)
File "/home/a/mywebsites/django/seperolinux/django/core/management/sql.py", line 107, in sql_reset
return sql_delete(app, style, connection) + sql_all(app, style, connection)
File "/home/a/mywebsites/django/seperolinux/django/core/management/sql.py", line 66, in sql_delete
table_names = connection.introspection.get_table_list(cursor)
AttributeError: 'DatabaseIntrospection' object has no attribute 'get_table_list'
How do I reset a Model in Django-nonrel? | django | django-models | django-nonrel | null | null | null | open | Django-nonrel: Syntax to Reset an App
===
To reset my app, I ran this:
./manage.py reset node
It is giving me this error output:
WARNING:root:The rdbms API is not available because the MySQLdb library could not be loaded.
Traceback (most recent call last):
File "./manage.py", line 11, in <module>
execute_manager(settings)
File "/home/a/mywebsites/django/seperolinux/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/home/a/mywebsites/django/seperolinux/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/a/mywebsites/django/seperolinux/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/a/mywebsites/django/seperolinux/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/home/a/mywebsites/django/seperolinux/django/core/management/base.py", line 286, in handle
app_output = self.handle_app(app, **options)
File "/home/a/mywebsites/django/seperolinux/django/core/management/commands/reset.py", line 35, in handle_app
sql_list = sql_reset(app, self.style, connection)
File "/home/a/mywebsites/django/seperolinux/django/core/management/sql.py", line 107, in sql_reset
return sql_delete(app, style, connection) + sql_all(app, style, connection)
File "/home/a/mywebsites/django/seperolinux/django/core/management/sql.py", line 66, in sql_delete
table_names = connection.introspection.get_table_list(cursor)
AttributeError: 'DatabaseIntrospection' object has no attribute 'get_table_list'
How do I reset a Model in Django-nonrel? | 0 |
11,373,312 | 07/07/2012 07:53:27 | 415,603 | 06/12/2010 18:27:25 | 666 | 29 | face.com api shutting down. Alternatives? | Sadly, the face.com API is being shut down by facebook.
Are there any decent alternatives out there?
I'm looking to check for a given image if there is a face in it + demographics content about it.
Help?
Thanks. | php | facebook | image | image-processing | image-recognition | null | open | face.com api shutting down. Alternatives?
===
Sadly, the face.com API is being shut down by facebook.
Are there any decent alternatives out there?
I'm looking to check for a given image if there is a face in it + demographics content about it.
Help?
Thanks. | 0 |
11,373,286 | 07/07/2012 07:50:14 | 1,318,844 | 04/07/2012 09:12:07 | 1 | 0 | Listview in Tablelayout in android | In my application i have 1 tablelayout,and 1 database.Now,i want to display that database content in a table layout.But it should look like a listview because i have to show the entries one below the other.Is it possible to have listview inside table layout,also give some idea how to set the database entries in the corresponding listview in table layout.
Here is my XML structure:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent" >
<TableLayout
android:id="@+id/tablelayout"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:paddingRight="2dip" >
<TableRow>
<TextView
android_layout_span="2"
android:layout_weight="1"
android:text="Income" />
</TableRow>
<TableRow>
<TextView
android:layout_weight="1"
android:text="Price:"/>
<TextView
android:layout_weight="1"
android:text="Price:" />
<ListView
android:id="@+id/listView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
</ListView>
</TableRow>
<TableRow>
<TextView
android:layout_weight="1"
android:text="Quantity:"/>
<TextView
android:id="@+id/et_url"
android:layout_weight="1"
android:text="Quantity:" />
</TableRow>
</TableLayout>
</ScrollView>
| android | tablelayout | null | null | null | null | open | Listview in Tablelayout in android
===
In my application i have 1 tablelayout,and 1 database.Now,i want to display that database content in a table layout.But it should look like a listview because i have to show the entries one below the other.Is it possible to have listview inside table layout,also give some idea how to set the database entries in the corresponding listview in table layout.
Here is my XML structure:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent" >
<TableLayout
android:id="@+id/tablelayout"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:paddingRight="2dip" >
<TableRow>
<TextView
android_layout_span="2"
android:layout_weight="1"
android:text="Income" />
</TableRow>
<TableRow>
<TextView
android:layout_weight="1"
android:text="Price:"/>
<TextView
android:layout_weight="1"
android:text="Price:" />
<ListView
android:id="@+id/listView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
</ListView>
</TableRow>
<TableRow>
<TextView
android:layout_weight="1"
android:text="Quantity:"/>
<TextView
android:id="@+id/et_url"
android:layout_weight="1"
android:text="Quantity:" />
</TableRow>
</TableLayout>
</ScrollView>
| 0 |
11,542,181 | 07/18/2012 13:09:29 | 1,534,743 | 07/18/2012 12:16:06 | 1 | 0 | AspectJ : Issue when combining multiple pointcuts in @Around advice | I'm a beginner in AspectJ so please guide me to resolve the issue happening as per the below approach.
@Aspect
public class TestAop {
@Pointcut("execution(public * com.packg.foo.ClassOne.*(..))")
public void fooPoint()
@Pointcut("execution(public * com.packg.cat.ClassTwo.*(..))")
public void catPoint()
@Pointcut("execution(public * com.packg.roo.ClassThree.*(..))")
public void rooPoint()
@Around("fooPoint() || catPoint() || rooPoint()")
public Object myAdvice(ProceedingJoinPoint joinPoint) {
//do something like joint proceed and all
}
When it is not working ?
If I combine all the three pointcuts with OR .
When it is working ?
If i keep only two pointcuts it is working.
Am I vioalating any rules of @around advice. Is it possible to have multiple execution/pointcuts?
Hoping for the answers...
| aop | aspectj | execution | pointcuts | null | null | open | AspectJ : Issue when combining multiple pointcuts in @Around advice
===
I'm a beginner in AspectJ so please guide me to resolve the issue happening as per the below approach.
@Aspect
public class TestAop {
@Pointcut("execution(public * com.packg.foo.ClassOne.*(..))")
public void fooPoint()
@Pointcut("execution(public * com.packg.cat.ClassTwo.*(..))")
public void catPoint()
@Pointcut("execution(public * com.packg.roo.ClassThree.*(..))")
public void rooPoint()
@Around("fooPoint() || catPoint() || rooPoint()")
public Object myAdvice(ProceedingJoinPoint joinPoint) {
//do something like joint proceed and all
}
When it is not working ?
If I combine all the three pointcuts with OR .
When it is working ?
If i keep only two pointcuts it is working.
Am I vioalating any rules of @around advice. Is it possible to have multiple execution/pointcuts?
Hoping for the answers...
| 0 |
11,542,186 | 07/18/2012 13:09:35 | 1,386,966 | 05/10/2012 11:40:47 | 14 | 0 | how does fscanf works with different variable types? | I was looking at the msdn explanation about fsacnf and tried changing the code.. it was a disaster and I don't understand how it works..
if for example I have a file x that has this information : "string" 7 3.13 'x'
when I write scanf("%s",&string_input) so the string is being saved and then it goes to the next in line ? -> to 7?
and I now I will write:
char test;
fscanf("%c" , &test) -- it will jump to the 'x' or take the 7 and turn it into it's ascii value?
here's the code I've tried, and the output :
#include <stdio.h>
FILE *stream;
int main( void )
{
long l;
float fp,fp1;
char s[81];
char c,t;
stream = fopen( "fscanf.out", "w+" );
if( stream == NULL )
printf( "The file fscanf.out was not opened\n" );
else
{
fprintf( stream, "%s %d %c%f%ld%f%c", "a-string",48,'y', 5.15,
65000, 3.14159, 'x' );
// Security caution!
// Beware loading data from a file without confirming its size,
// as it may lead to a buffer overrun situation.
/* Set pointer to beginning of file: */
fseek( stream, 0L, SEEK_SET );
/* Read data back from file: */
fscanf( stream, "%s", s );
fscanf( stream, "%c", &t );
fscanf( stream, "%c", &c );
fscanf( stream, "%f", &fp );
fscanf( stream, "%f", &fp1 );
fscanf( stream, "%ld", &l );
printf( "%s\n", s );
printf("%c\n" , t);
printf( "%ld\n", l );
printf( "%f\n", fp );
printf( "%c\n", c );
printf("f\n",fp1);
getchar();
fclose( stream );
}
}
this is the output :
a-string
-858553460
8.000000
4
f
can't understand why
thanks!! | c | file | variables | fscanf | null | null | open | how does fscanf works with different variable types?
===
I was looking at the msdn explanation about fsacnf and tried changing the code.. it was a disaster and I don't understand how it works..
if for example I have a file x that has this information : "string" 7 3.13 'x'
when I write scanf("%s",&string_input) so the string is being saved and then it goes to the next in line ? -> to 7?
and I now I will write:
char test;
fscanf("%c" , &test) -- it will jump to the 'x' or take the 7 and turn it into it's ascii value?
here's the code I've tried, and the output :
#include <stdio.h>
FILE *stream;
int main( void )
{
long l;
float fp,fp1;
char s[81];
char c,t;
stream = fopen( "fscanf.out", "w+" );
if( stream == NULL )
printf( "The file fscanf.out was not opened\n" );
else
{
fprintf( stream, "%s %d %c%f%ld%f%c", "a-string",48,'y', 5.15,
65000, 3.14159, 'x' );
// Security caution!
// Beware loading data from a file without confirming its size,
// as it may lead to a buffer overrun situation.
/* Set pointer to beginning of file: */
fseek( stream, 0L, SEEK_SET );
/* Read data back from file: */
fscanf( stream, "%s", s );
fscanf( stream, "%c", &t );
fscanf( stream, "%c", &c );
fscanf( stream, "%f", &fp );
fscanf( stream, "%f", &fp1 );
fscanf( stream, "%ld", &l );
printf( "%s\n", s );
printf("%c\n" , t);
printf( "%ld\n", l );
printf( "%f\n", fp );
printf( "%c\n", c );
printf("f\n",fp1);
getchar();
fclose( stream );
}
}
this is the output :
a-string
-858553460
8.000000
4
f
can't understand why
thanks!! | 0 |
11,542,188 | 07/18/2012 13:09:40 | 564,444 | 01/05/2011 19:09:16 | 427 | 16 | How to rename a wordpress blog? | I have a wordpress blog running under www.mydomain.com/blog1. I want to move this to www.mydomain.com/blog2. My blog1 links are indexed by google and I want to setup a 301 permanent redirect for them as-well. How can I do this? Thank you. | wordpress | null | null | null | null | null | open | How to rename a wordpress blog?
===
I have a wordpress blog running under www.mydomain.com/blog1. I want to move this to www.mydomain.com/blog2. My blog1 links are indexed by google and I want to setup a 301 permanent redirect for them as-well. How can I do this? Thank you. | 0 |
11,542,189 | 07/18/2012 13:09:51 | 685,016 | 03/31/2011 02:55:15 | 319 | 8 | Creating a Event in a dll and Handling the event in a Form | I have created a DLL using the following code. I have compiled this code as a DLL.
namespace DllEventTrigger
{
public class Trigger
{
public delegate void AlertEventHandler(Object sender, AlertEventArgs e);
public Trigger()
{
isRinging();
}
public void isRinging()
{
AlertEventArgs alertEventArgs = new AlertEventArgs();
alertEventArgs.uuiData = "Hello Damn World!!!";
CallAlert(new object(), alertEventArgs);
}
public event AlertEventHandler CallAlert;
}
public class AlertEventArgs : EventArgs
{
#region AlertEventArgs Properties
private string _uui = null;
#endregion
#region Get/Set Properties
public string uuiData
{
get { return _uui; }
set { _uui = value; }
}
#endregion
}
}
Now I'm trying to handle the event triggered by this dll in a forms application with this code.
namespace DLLTriggerReciever
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Trigger trigger = new Trigger();
trigger.isRinging();
trigger.CallAlert += new Trigger.AlertEventHandler(trigger_CallAlert);
}
void trigger_CallAlert(object sender, AlertEventArgs e)
{
label1.Text = e.uuiData;
}
}
}
My problem i'm not sure where i went wrong. Please suggest. | c# | .net | null | null | null | null | open | Creating a Event in a dll and Handling the event in a Form
===
I have created a DLL using the following code. I have compiled this code as a DLL.
namespace DllEventTrigger
{
public class Trigger
{
public delegate void AlertEventHandler(Object sender, AlertEventArgs e);
public Trigger()
{
isRinging();
}
public void isRinging()
{
AlertEventArgs alertEventArgs = new AlertEventArgs();
alertEventArgs.uuiData = "Hello Damn World!!!";
CallAlert(new object(), alertEventArgs);
}
public event AlertEventHandler CallAlert;
}
public class AlertEventArgs : EventArgs
{
#region AlertEventArgs Properties
private string _uui = null;
#endregion
#region Get/Set Properties
public string uuiData
{
get { return _uui; }
set { _uui = value; }
}
#endregion
}
}
Now I'm trying to handle the event triggered by this dll in a forms application with this code.
namespace DLLTriggerReciever
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Trigger trigger = new Trigger();
trigger.isRinging();
trigger.CallAlert += new Trigger.AlertEventHandler(trigger_CallAlert);
}
void trigger_CallAlert(object sender, AlertEventArgs e)
{
label1.Text = e.uuiData;
}
}
}
My problem i'm not sure where i went wrong. Please suggest. | 0 |
11,542,195 | 07/18/2012 13:10:21 | 1,475,167 | 06/22/2012 14:51:11 | 16 | 3 | how to call Soap Service from phone gap (iphone app development) | I am trying to call SOAP service using SOAP Client provided by http://www.guru4.net/articoli/javascript-soap-client/en/ but it is not working for me. please help me, how can I send and receive XML soap over phone gap platform. | iphone | soap | phonegap | null | null | null | open | how to call Soap Service from phone gap (iphone app development)
===
I am trying to call SOAP service using SOAP Client provided by http://www.guru4.net/articoli/javascript-soap-client/en/ but it is not working for me. please help me, how can I send and receive XML soap over phone gap platform. | 0 |
11,542,196 | 07/18/2012 13:10:23 | 1,001,495 | 10/18/2011 15:37:10 | 106 | 0 | Sql Server FOR XML - encoding result to prevent malformed xml | I have am using SQL SERVER 2008 R2. I have a stored proc that uses FOR XML to return results as XML. Here is what the stored proc looks like:
CREATE PROCEDURE [dbo].[myproc]
(
@ID int,
)
AS
SET NOCOUNT ON
BEGIN
SELECT
t1.FirstField
t2.AnotherField
t1.ThirdField
FROM table t1
INNER JOIN table2 t2 ON t1.ID = t2.ID
WHERE t1.id = @ID FOR XML RAW ('project'), ELEMENTS;
END
This works as expected and produces XML like this:
<project>
<FirstField>First field data</FirstField>
<AnotherField> Another field data</AnotherField>
<ThirdField>Third field data</ThirdField>
</project>
Which is what I want. However my concern is that when there are special chars in the XML such as < and > will that not screw things up and make the XML malformed? Is there a way I can get around this? I can do some checks in the code that calls this stored proc to see if it is valid XML but by the time that happens wouldn't it be too late? If anyone could make some suggestions as to how I should approach this I would appreciate it. Thanks much.
| sql | sql-server | sql-server-2008 | for-xml | null | null | open | Sql Server FOR XML - encoding result to prevent malformed xml
===
I have am using SQL SERVER 2008 R2. I have a stored proc that uses FOR XML to return results as XML. Here is what the stored proc looks like:
CREATE PROCEDURE [dbo].[myproc]
(
@ID int,
)
AS
SET NOCOUNT ON
BEGIN
SELECT
t1.FirstField
t2.AnotherField
t1.ThirdField
FROM table t1
INNER JOIN table2 t2 ON t1.ID = t2.ID
WHERE t1.id = @ID FOR XML RAW ('project'), ELEMENTS;
END
This works as expected and produces XML like this:
<project>
<FirstField>First field data</FirstField>
<AnotherField> Another field data</AnotherField>
<ThirdField>Third field data</ThirdField>
</project>
Which is what I want. However my concern is that when there are special chars in the XML such as < and > will that not screw things up and make the XML malformed? Is there a way I can get around this? I can do some checks in the code that calls this stored proc to see if it is valid XML but by the time that happens wouldn't it be too late? If anyone could make some suggestions as to how I should approach this I would appreciate it. Thanks much.
| 0 |
11,542,198 | 07/18/2012 13:10:27 | 1,049,765 | 11/16/2011 13:38:01 | 121 | 9 | Multiple MySQLi Prepared Statements and Vulnerability (Rate my code) | Super long question regarding MySQLi prepared statments in PHP. Here goes.
Is using MySQLi prepared statments completely invunerable to SQl injection? For example see my code below, am I correct in thinking I can use the $_POST variable straight from the user without any injection protection? For the purpose of this question please ignore validating data to make sure it is the correct format for my database (I always do that anyway), I'm more focussing on security here.
$mysqli=new mysqli($host, $user, $password, $database);
$stmt=$mysqli->stmt_init();
$stmt->prepare('INSERT INTO `tablename` (`column`) VALUES (?)');
$stmt->bind_param('s', $_POST['value']);
$stmt->execute();
$stmt->close();
$mysqli->close();
Also is my code correct? This only the second or third time I have written a prepared statement using the MySQLi class. Although it works, I was wondering if I am doing everything correctly? Could any part of that script be considered bad practice?
Lastly, how would I go about doing multiple prepared statements that use the same database connection? Do I just use the close() method on the $stmt and then initialize another $stmt class?
Thanks! | php | mysql | mysqli | null | null | null | open | Multiple MySQLi Prepared Statements and Vulnerability (Rate my code)
===
Super long question regarding MySQLi prepared statments in PHP. Here goes.
Is using MySQLi prepared statments completely invunerable to SQl injection? For example see my code below, am I correct in thinking I can use the $_POST variable straight from the user without any injection protection? For the purpose of this question please ignore validating data to make sure it is the correct format for my database (I always do that anyway), I'm more focussing on security here.
$mysqli=new mysqli($host, $user, $password, $database);
$stmt=$mysqli->stmt_init();
$stmt->prepare('INSERT INTO `tablename` (`column`) VALUES (?)');
$stmt->bind_param('s', $_POST['value']);
$stmt->execute();
$stmt->close();
$mysqli->close();
Also is my code correct? This only the second or third time I have written a prepared statement using the MySQLi class. Although it works, I was wondering if I am doing everything correctly? Could any part of that script be considered bad practice?
Lastly, how would I go about doing multiple prepared statements that use the same database connection? Do I just use the close() method on the $stmt and then initialize another $stmt class?
Thanks! | 0 |
11,542,199 | 07/18/2012 13:10:30 | 1,341,085 | 04/18/2012 10:36:44 | 13 | 0 | Trigger onchange html event on page load too | Ok I have a onchange event on a select field. It now works great. When the dropdown "networks" is changed it refreshes the second dropdown. I also want the ajax code at the top to trigger on page load as well as onchange so the second list gets populated. This is due to it being on an edit page. Here is the ajax call im using first
function get_cities(networks)
{
$.ajax({
type: "POST",
url: "select.php", /* The country id will be sent to this file */
beforeSend: function () {
$("#folder").html("<option>Loading ...</option>");
},
//data: "idnetworks="+networks,
data: "idnetworks="+networks +"&doc="+ <?php echo $row_rs_doc['parentid']; ? >,
success: function(msg){
$("#folder").html(msg);
}
});
}
now the two dropdown boxes
<label for="networks" ></label>
<select name="networks" id="networks" onload='get_cities($(this).val())'>
<?php
do {
?>
<option value="<?php echo $row_rs_net['idnetworks']?>"<?php if (!(strcmp($row_rs_net['idnetworks'], $row_rs_doc['network']))) {echo "selected=\"selected\"";} ?>><?php echo $row_rs_net['netname']?></option>
<?php
} while ($row_rs_net = mysql_fetch_assoc($rs_net));
$rows = mysql_num_rows($rs_net);
if($rows > 0) {
mysql_data_seek($rs_net, 0);
$row_rs_net = mysql_fetch_assoc($rs_net);
}
?>
</select>
<select name="folder" id="folder">
</select> | php | jquery | ajax | jquery-ajax | null | null | open | Trigger onchange html event on page load too
===
Ok I have a onchange event on a select field. It now works great. When the dropdown "networks" is changed it refreshes the second dropdown. I also want the ajax code at the top to trigger on page load as well as onchange so the second list gets populated. This is due to it being on an edit page. Here is the ajax call im using first
function get_cities(networks)
{
$.ajax({
type: "POST",
url: "select.php", /* The country id will be sent to this file */
beforeSend: function () {
$("#folder").html("<option>Loading ...</option>");
},
//data: "idnetworks="+networks,
data: "idnetworks="+networks +"&doc="+ <?php echo $row_rs_doc['parentid']; ? >,
success: function(msg){
$("#folder").html(msg);
}
});
}
now the two dropdown boxes
<label for="networks" ></label>
<select name="networks" id="networks" onload='get_cities($(this).val())'>
<?php
do {
?>
<option value="<?php echo $row_rs_net['idnetworks']?>"<?php if (!(strcmp($row_rs_net['idnetworks'], $row_rs_doc['network']))) {echo "selected=\"selected\"";} ?>><?php echo $row_rs_net['netname']?></option>
<?php
} while ($row_rs_net = mysql_fetch_assoc($rs_net));
$rows = mysql_num_rows($rs_net);
if($rows > 0) {
mysql_data_seek($rs_net, 0);
$row_rs_net = mysql_fetch_assoc($rs_net);
}
?>
</select>
<select name="folder" id="folder">
</select> | 0 |
11,650,861 | 07/25/2012 13:30:13 | 1,153,104 | 01/17/2012 03:27:46 | 3 | 0 | Junk values in char* varible | Code:
char* data = NULL;
data = new char[lengthOfParam]; //lengthOfParam = 3
//after allocation **data = ¥¥¥¥Ü\r**
memcpy(data,&buffer[offset],lengthOfParam); //**data = pki¥Ü\r**
Why i am getting that junk values??? How to avoid or remove those extra values bcs if i try to assign that value to any other array
ex:
obj[1] = data;
then the whole value with junk'll be assigned to that variable.
| c | symbian | null | null | null | null | open | Junk values in char* varible
===
Code:
char* data = NULL;
data = new char[lengthOfParam]; //lengthOfParam = 3
//after allocation **data = ¥¥¥¥Ü\r**
memcpy(data,&buffer[offset],lengthOfParam); //**data = pki¥Ü\r**
Why i am getting that junk values??? How to avoid or remove those extra values bcs if i try to assign that value to any other array
ex:
obj[1] = data;
then the whole value with junk'll be assigned to that variable.
| 0 |
11,650,867 | 07/25/2012 13:30:20 | 1,182,015 | 02/01/2012 06:07:07 | 1 | 0 | DLL with Python |
I am trying to call functions from a DLL
function oziRepositionWP(Number:integer;lat,lon:double):integer;stdcall;
I have written the code in python
no = c_int(1)
lat = c_double(34.00962)
lon = c_double(74.80067)
var =windll.OziAPI.oziRepositionWP(byref(no),byref(lat),byref(lon))
But i get the message
var =windll.OziAPI.oziRepositionWP(byref(no),byref(lat),byref(lon))
ValueError: Procedure probably called with not enough arguments (8 bytes missing)
where am i going wrong please help
| python | dll | null | null | null | null | open | DLL with Python
===
I am trying to call functions from a DLL
function oziRepositionWP(Number:integer;lat,lon:double):integer;stdcall;
I have written the code in python
no = c_int(1)
lat = c_double(34.00962)
lon = c_double(74.80067)
var =windll.OziAPI.oziRepositionWP(byref(no),byref(lat),byref(lon))
But i get the message
var =windll.OziAPI.oziRepositionWP(byref(no),byref(lat),byref(lon))
ValueError: Procedure probably called with not enough arguments (8 bytes missing)
where am i going wrong please help
| 0 |
11,650,824 | 07/25/2012 13:28:44 | 160,301 | 08/20/2009 19:27:38 | 225 | 8 | Django deserialize - I've specified a natural key manager but it wont' deserialize | First off, this is the page I used as a guide to put this together: https://docs.djangoproject.com/en/dev/topics/serialization/
Here is my model definition:
class LocationManager(models.Manager):
def get_by_natural_key(self, zip_code):
return self.get(zip_code=zip_code)
class Location(models.Model):
city = models.CharField('City', blank=True, null=True, max_length=50)
state = models.CharField('State', blank=True, null=True, max_length=2, choices=STATE_CHOICES)
zip_code = models.CharField('Zip Code', blank=False, null=False, max_length=9, unique=True)
date_added = models.DateField('Date Added')
objects = LocationManager()
def natural_key(self):
return self.zip_code
Here's a serialized item I'm trying to deserialize:
{
"pk": 10259,
"model": "some.model",
"fields": {
"content": "some content",
"created_on": "2012-07-24T16:10:44.570",
"location": "99801",
"title": "Some title"
}
}
The code I'm trying to deserialize the json with:
for news_obj in serializers.deserialize('json', news_json):
news_obj.save()
The error I get is:
IntegrityError: insert or update on table "news" violates foreign key constraint "news_location_id_fkey"
DETAIL: Key (location_id)=(99801) is not present in table "location".
So it seems it is trying to resolve the zip_code as the natural key rather than trying to check if the item exists in the database using the natural key I defined. What am I doing wrong? | django | serialization | null | null | null | null | open | Django deserialize - I've specified a natural key manager but it wont' deserialize
===
First off, this is the page I used as a guide to put this together: https://docs.djangoproject.com/en/dev/topics/serialization/
Here is my model definition:
class LocationManager(models.Manager):
def get_by_natural_key(self, zip_code):
return self.get(zip_code=zip_code)
class Location(models.Model):
city = models.CharField('City', blank=True, null=True, max_length=50)
state = models.CharField('State', blank=True, null=True, max_length=2, choices=STATE_CHOICES)
zip_code = models.CharField('Zip Code', blank=False, null=False, max_length=9, unique=True)
date_added = models.DateField('Date Added')
objects = LocationManager()
def natural_key(self):
return self.zip_code
Here's a serialized item I'm trying to deserialize:
{
"pk": 10259,
"model": "some.model",
"fields": {
"content": "some content",
"created_on": "2012-07-24T16:10:44.570",
"location": "99801",
"title": "Some title"
}
}
The code I'm trying to deserialize the json with:
for news_obj in serializers.deserialize('json', news_json):
news_obj.save()
The error I get is:
IntegrityError: insert or update on table "news" violates foreign key constraint "news_location_id_fkey"
DETAIL: Key (location_id)=(99801) is not present in table "location".
So it seems it is trying to resolve the zip_code as the natural key rather than trying to check if the item exists in the database using the natural key I defined. What am I doing wrong? | 0 |
11,650,868 | 07/25/2012 13:30:23 | 6,355 | 09/14/2008 18:12:35 | 883 | 27 | Is this way of function overloading for class hierarchies using templates safe? | Okay, this is a bit complicated so please bear with me. :)
We have this simple class hierarchy:
------------------------------------
class A {};
class DA : public A {};
class DDA : public DA {};
And we have the following functions operating on these classes:
---------------------------------------------------------------
void f(A x) {
std::cout << "f A" << std::endl;
}
void f(DA x) {
std::cout << "f DA" << std::endl;
}
void f(DDA x) {
std::cout << "f DDA" << std::endl;
}
Now we want to add another function that treats DA a little different.
(1) A first attempt could look like this:
-------------------------------------
void g(A t) {
std::cout << "generic treatment of A" << std::endl;
std::cout << "called from g: ";
f(t);
}
void g(DA t) {
std::cout << "special treatment of DA" << std::endl;
std::cout << "called from g: ";
f(t);
}
But calling this with an object of each of the classes clearly does not have the desired effect.
Call:
A a; DA b; DDA c;
g(a); g(b); g(c)
Result:
generic treatment of A
called from g: f A
special treatment of DA
called from g: f DA
special treatment of DA
called from g: f DA //PROBLEM: g forgot that this DA was actually a DDA
(2) So instead we might try to use templates:
-----------------------------------------
template<typename T>
void h(T t) {
std::cout << "generic treatment of A" << std::endl;
std::cout << "called from h: ";
f(t);
}
template<>
void h<>(DA t) {
std::cout << "special treatment of DA" << std::endl;
std::cout << "called from h: ";
f(t);
}
which results in:
generic treatment of A
called from h: f A
special treatment of DA
called from h: f DA
generic treatment of A //PROBLEM: template specialization is not used
called from h: f DDA
Well, how about we don't use template specialization but define a non-template function for the special case? ([Article][1] on the very confusing matter.) It turns out it behaves in exactly the same way because the non-template function which is according to the article a "first class citizen", seems to lose because a type conversion is necessary to use it. And if it would be used, well then we would just be back at the first solution (I assume) and it would forget the type of DDA.
(3) Now I came across this code at work which seems rather fancy to me:
-------------------------------------------------------------------
template<typename T>
void i(T t, void* magic) {
std::cout << "generic treatment of A" << std::endl;
std::cout << "called from i: ";
f(t);
}
template<typename T>
void i(T t, DA* magic) {
std::cout << "special treatment of DA" << std::endl;
std::cout << "called from i: ";
f(t);
}
But it seems to do exactly what I want:
generic treatment of A
called from i: f A
special treatment of DA
called from i: f DA
special treatment of DA
called from i: f DDA
Even though it needs to be called in a weird way:
i(a, &a); i(b, &b); i(c, &c);
Now I have several questions:
1. Why the hell does this work?
2. Do you think it is a good idea? Where are possible pitfalls?
3. Which other ways of doing this kind of specialization would you suggest?
4. (How do type conversions fit into the madness that is template partial ordering and such...)
I hope this was reasonably clear. :)
[1]: http://www.gotw.ca/publications/mill17.htm "[Sutter]" | c++ | class | templates | overloading | null | null | open | Is this way of function overloading for class hierarchies using templates safe?
===
Okay, this is a bit complicated so please bear with me. :)
We have this simple class hierarchy:
------------------------------------
class A {};
class DA : public A {};
class DDA : public DA {};
And we have the following functions operating on these classes:
---------------------------------------------------------------
void f(A x) {
std::cout << "f A" << std::endl;
}
void f(DA x) {
std::cout << "f DA" << std::endl;
}
void f(DDA x) {
std::cout << "f DDA" << std::endl;
}
Now we want to add another function that treats DA a little different.
(1) A first attempt could look like this:
-------------------------------------
void g(A t) {
std::cout << "generic treatment of A" << std::endl;
std::cout << "called from g: ";
f(t);
}
void g(DA t) {
std::cout << "special treatment of DA" << std::endl;
std::cout << "called from g: ";
f(t);
}
But calling this with an object of each of the classes clearly does not have the desired effect.
Call:
A a; DA b; DDA c;
g(a); g(b); g(c)
Result:
generic treatment of A
called from g: f A
special treatment of DA
called from g: f DA
special treatment of DA
called from g: f DA //PROBLEM: g forgot that this DA was actually a DDA
(2) So instead we might try to use templates:
-----------------------------------------
template<typename T>
void h(T t) {
std::cout << "generic treatment of A" << std::endl;
std::cout << "called from h: ";
f(t);
}
template<>
void h<>(DA t) {
std::cout << "special treatment of DA" << std::endl;
std::cout << "called from h: ";
f(t);
}
which results in:
generic treatment of A
called from h: f A
special treatment of DA
called from h: f DA
generic treatment of A //PROBLEM: template specialization is not used
called from h: f DDA
Well, how about we don't use template specialization but define a non-template function for the special case? ([Article][1] on the very confusing matter.) It turns out it behaves in exactly the same way because the non-template function which is according to the article a "first class citizen", seems to lose because a type conversion is necessary to use it. And if it would be used, well then we would just be back at the first solution (I assume) and it would forget the type of DDA.
(3) Now I came across this code at work which seems rather fancy to me:
-------------------------------------------------------------------
template<typename T>
void i(T t, void* magic) {
std::cout << "generic treatment of A" << std::endl;
std::cout << "called from i: ";
f(t);
}
template<typename T>
void i(T t, DA* magic) {
std::cout << "special treatment of DA" << std::endl;
std::cout << "called from i: ";
f(t);
}
But it seems to do exactly what I want:
generic treatment of A
called from i: f A
special treatment of DA
called from i: f DA
special treatment of DA
called from i: f DDA
Even though it needs to be called in a weird way:
i(a, &a); i(b, &b); i(c, &c);
Now I have several questions:
1. Why the hell does this work?
2. Do you think it is a good idea? Where are possible pitfalls?
3. Which other ways of doing this kind of specialization would you suggest?
4. (How do type conversions fit into the madness that is template partial ordering and such...)
I hope this was reasonably clear. :)
[1]: http://www.gotw.ca/publications/mill17.htm "[Sutter]" | 0 |
11,650,869 | 07/25/2012 13:30:24 | 1,272,852 | 03/15/2012 23:13:33 | 192 | 1 | appending contents to a div element on loading a page using jquery | I want to append the html contents receiver back from the sever (server 2) to the body of the current page (which I received from sever 1). This I want to achieve while loading the page (received from server 1).( Hence I am getting the original contents from two different servers.)
I tried using
function Faulttest() {var myarray=new Array();
var urlarray=new Array();
$(document).ready(function(){
$.get({
url:"http://csce.unl.edu:8080/Anomalies/index.jsp",
data: "html",
success: function(result) {
alert(result);
$('#body').append(result) // result will be the contents received from the server
},
dataType:"text/html"
});
});
// more contents
}
The HTML contents of the page are:
<body style="font-size:62.5%;" onload="Faulttest();" >
<div id="body" >
<h1>content top </h1>
//HTML CONTENTS GOES HERE
</div>
| jquery | html | ajax | get | load | null | open | appending contents to a div element on loading a page using jquery
===
I want to append the html contents receiver back from the sever (server 2) to the body of the current page (which I received from sever 1). This I want to achieve while loading the page (received from server 1).( Hence I am getting the original contents from two different servers.)
I tried using
function Faulttest() {var myarray=new Array();
var urlarray=new Array();
$(document).ready(function(){
$.get({
url:"http://csce.unl.edu:8080/Anomalies/index.jsp",
data: "html",
success: function(result) {
alert(result);
$('#body').append(result) // result will be the contents received from the server
},
dataType:"text/html"
});
});
// more contents
}
The HTML contents of the page are:
<body style="font-size:62.5%;" onload="Faulttest();" >
<div id="body" >
<h1>content top </h1>
//HTML CONTENTS GOES HERE
</div>
| 0 |
11,650,870 | 07/25/2012 13:30:30 | 753,632 | 05/14/2011 13:14:49 | 312 | 7 | HTTP: Most reliable way to determine if device accessing site is mobile | What is the most reliable way to determine whether the device accessing a site is a mobile device? There should also be a way to distinguish whether the device is a tablet or smartphone. A tablet can be 10 inches and therefore is capable of displaying a normal web page whereas a smartphone cannot and I want to deliver content specific to smartphones. I guess really what I should be checking is the screen resolution but I wasn't able to find a reliable way of doing that. The screen resolution should be in pixels and not pixels per inch. So 320x480 or 480x600 and 600x800 would be considered by my site to be mobile. But something with 1024x768 probably should be considered a desktop. | http | mobile | null | null | null | null | open | HTTP: Most reliable way to determine if device accessing site is mobile
===
What is the most reliable way to determine whether the device accessing a site is a mobile device? There should also be a way to distinguish whether the device is a tablet or smartphone. A tablet can be 10 inches and therefore is capable of displaying a normal web page whereas a smartphone cannot and I want to deliver content specific to smartphones. I guess really what I should be checking is the screen resolution but I wasn't able to find a reliable way of doing that. The screen resolution should be in pixels and not pixels per inch. So 320x480 or 480x600 and 600x800 would be considered by my site to be mobile. But something with 1024x768 probably should be considered a desktop. | 0 |
11,650,875 | 07/25/2012 13:30:42 | 469,350 | 10/07/2010 16:37:18 | 31 | 2 | After Code Signing for Gatekeeper: cannot longer access keychain items for my app | I want to code sign my Mac software to make it ready for Gatekeeper and OS X Lion.
So I changed to the build settings in Xcode and selected my Developer ID certificate. Building my project was successfully.
But if I run this new app I cannot longer access the keychain items of the app!
If I remove code signing everythings works ok.
Anybody knows a solution for that problem? | xcode | code-signing | osx-gatekeeper | null | null | null | open | After Code Signing for Gatekeeper: cannot longer access keychain items for my app
===
I want to code sign my Mac software to make it ready for Gatekeeper and OS X Lion.
So I changed to the build settings in Xcode and selected my Developer ID certificate. Building my project was successfully.
But if I run this new app I cannot longer access the keychain items of the app!
If I remove code signing everythings works ok.
Anybody knows a solution for that problem? | 0 |
11,650,876 | 07/25/2012 13:30:43 | 1,230,959 | 02/24/2012 14:19:28 | 191 | 8 | Django queries on querysets performance | I have a Model and I am doing a query :
my_objects = Model.objects.filter(user = request.user)
now over my_objects I am doing :
obj = my_objects.get(user = x )
I am trying to understand if my **.get** over my_objects will not generate another query to the database and will only work on the filter output ? or it will be generating another query.
| django | null | null | null | null | null | open | Django queries on querysets performance
===
I have a Model and I am doing a query :
my_objects = Model.objects.filter(user = request.user)
now over my_objects I am doing :
obj = my_objects.get(user = x )
I am trying to understand if my **.get** over my_objects will not generate another query to the database and will only work on the filter output ? or it will be generating another query.
| 0 |
11,650,883 | 07/25/2012 13:30:59 | 418,363 | 08/12/2010 11:57:52 | 121 | 4 | Cakephp redirects to /app/webroot when using www before domain name | When I enter my domain name with 'www' for example http://domain.nl everything works fine but when I use the same domain with 'www' before it, it redirects to /app/webroot witch gives errors. What can be the problem?
I use the default cakephp .htaccess files
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule> | .htaccess | cakephp | null | null | null | null | open | Cakephp redirects to /app/webroot when using www before domain name
===
When I enter my domain name with 'www' for example http://domain.nl everything works fine but when I use the same domain with 'www' before it, it redirects to /app/webroot witch gives errors. What can be the problem?
I use the default cakephp .htaccess files
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule> | 0 |
11,650,884 | 07/25/2012 13:31:01 | 1,023,651 | 11/01/2011 12:15:54 | 18 | 1 | insert same data into two field float | Please help, I have two columns, columns A and B (A and B of type float). so I want to make if I fill the value in column A and hit save, auto value I enter in column A will also appear in column B
I make like this
def _dept_count(self, cr, uid, ids,deposit,available,arg, context=None):
result = {}
for r in self.browse(cr, uid, ids, context=context):
available=0
if r.deposit:
available = deposit
result[r.id] = available
return result
_columns = {
'name': fields.many2one('res.partner','Partner'),
'date':fields.date('Date of Deposit'),
#'deposit': fields.function(_save_deposit, type='float',string='Deposit'),
'available': fields.float('Available'),
'note': fields.text('Description'),
}
but there is no response to anything. was not included in the database. please help
**P.S
his second was in the same database** | openerp | null | null | null | null | null | open | insert same data into two field float
===
Please help, I have two columns, columns A and B (A and B of type float). so I want to make if I fill the value in column A and hit save, auto value I enter in column A will also appear in column B
I make like this
def _dept_count(self, cr, uid, ids,deposit,available,arg, context=None):
result = {}
for r in self.browse(cr, uid, ids, context=context):
available=0
if r.deposit:
available = deposit
result[r.id] = available
return result
_columns = {
'name': fields.many2one('res.partner','Partner'),
'date':fields.date('Date of Deposit'),
#'deposit': fields.function(_save_deposit, type='float',string='Deposit'),
'available': fields.float('Available'),
'note': fields.text('Description'),
}
but there is no response to anything. was not included in the database. please help
**P.S
his second was in the same database** | 0 |
11,650,888 | 07/25/2012 13:31:13 | 1,264,351 | 03/12/2012 14:31:28 | 1 | 0 | jquery hide div if youtube embed src is empty | Hi all I want is that a (container) div gets hidden (.videocontainer) when the src="" and display when there is a link in the source. Hope someone can help out with this one
This is the code I'm working on that obviously isn't working:
<script type="text/javascript">
$(document).ready(function(){
if ($('iframe[src]').text() === "")
$(".videocontainer").hide(
});
</script>
</head>
<body>
<div class="videocontainer">
<div class="thevideo">
<iframe width="310" height="174" src="http://www.youtube.com/embed/860PGF9GXZY" frameborder="0" allowfullscreen></iframe>
</div>
</div>
</body>
</html>
| jquery | youtube | hide | null | null | null | open | jquery hide div if youtube embed src is empty
===
Hi all I want is that a (container) div gets hidden (.videocontainer) when the src="" and display when there is a link in the source. Hope someone can help out with this one
This is the code I'm working on that obviously isn't working:
<script type="text/javascript">
$(document).ready(function(){
if ($('iframe[src]').text() === "")
$(".videocontainer").hide(
});
</script>
</head>
<body>
<div class="videocontainer">
<div class="thevideo">
<iframe width="310" height="174" src="http://www.youtube.com/embed/860PGF9GXZY" frameborder="0" allowfullscreen></iframe>
</div>
</div>
</body>
</html>
| 0 |
11,499,975 | 07/16/2012 07:40:14 | 66,051 | 02/13/2009 12:54:57 | 1,117 | 59 | Designing a database for storing tables with arbitrary numbers of fileds | I need to build a leads aggregating system. In general what the system would do is storing the data a client sends from a landing page (name, phone, email etc).
The interesting part is that I don't know ahead what fields each landing page will contain. So, one landing page might need `name`, `phone` and `email`, while other landing page will gather `email` and `num_of_kids`. I will also need to save the caption for the field somehow - because I need to display `num_of_kids` as `Number of Children`. I was thinking of simply storing the whole thing in one field as a JSON object, but that felt cheap and wrong (and it would suck sorting and selecting it).
I'm open to suggestions and workaround ideas (the solution doesn't have to be strictly MySQL). | mysql | sql | null | null | null | null | open | Designing a database for storing tables with arbitrary numbers of fileds
===
I need to build a leads aggregating system. In general what the system would do is storing the data a client sends from a landing page (name, phone, email etc).
The interesting part is that I don't know ahead what fields each landing page will contain. So, one landing page might need `name`, `phone` and `email`, while other landing page will gather `email` and `num_of_kids`. I will also need to save the caption for the field somehow - because I need to display `num_of_kids` as `Number of Children`. I was thinking of simply storing the whole thing in one field as a JSON object, but that felt cheap and wrong (and it would suck sorting and selecting it).
I'm open to suggestions and workaround ideas (the solution doesn't have to be strictly MySQL). | 0 |
11,499,981 | 07/16/2012 07:40:27 | 1,202,326 | 02/10/2012 15:27:17 | 48 | 4 | How to turn off CSS validation warnings generated by Richfaces 4? | I've a custom ecss file in my RichFaces 4 application. This ecss file has some warnings but I'm O.K. with them and don't want to fix this warnings.
I include this ecss file in my pages using;
<h:outputStylesheet name="myTheme.ecss" library="css" />
Everything works well but richfaces generates some warnings in the server log about ecss file.
>WARNING: Problem parsing 'css/sws/workstationTheme.ecss' resource: Ignoring the whole rule.
>16-Jul-2012 10:26:59 org.richfaces.resource.CompiledCSSResource$ErrorHandlerImpl logException
>WARNING: Problem parsing 'css/myTheme.ecss' resource: Error in attribute >selector. >Invalid token "*". Was expecting one of: <S>, "=", "]", "~=", "|=".
Is there a way to turn off this warnings, they appear every time when I access a JSF page so my server log is pretty full with them.
<strong>Server</strong>: Tomcat 7<br>
<strong>JSF Ver.</strong> : javax.faces-2.1.8<br>
<strong>Rich Faces Ver</strong>: 4.2.2 | jsf-2.0 | richfaces | null | null | null | null | open | How to turn off CSS validation warnings generated by Richfaces 4?
===
I've a custom ecss file in my RichFaces 4 application. This ecss file has some warnings but I'm O.K. with them and don't want to fix this warnings.
I include this ecss file in my pages using;
<h:outputStylesheet name="myTheme.ecss" library="css" />
Everything works well but richfaces generates some warnings in the server log about ecss file.
>WARNING: Problem parsing 'css/sws/workstationTheme.ecss' resource: Ignoring the whole rule.
>16-Jul-2012 10:26:59 org.richfaces.resource.CompiledCSSResource$ErrorHandlerImpl logException
>WARNING: Problem parsing 'css/myTheme.ecss' resource: Error in attribute >selector. >Invalid token "*". Was expecting one of: <S>, "=", "]", "~=", "|=".
Is there a way to turn off this warnings, they appear every time when I access a JSF page so my server log is pretty full with them.
<strong>Server</strong>: Tomcat 7<br>
<strong>JSF Ver.</strong> : javax.faces-2.1.8<br>
<strong>Rich Faces Ver</strong>: 4.2.2 | 0 |
11,499,982 | 07/16/2012 07:40:30 | 1,263,342 | 03/12/2012 05:26:02 | 1 | 0 | The exception: SECURITY_ERR: DOM Exception 18 occurred when create the Web SQL Database | At the moment, I am developing an App for iOS (the version is iOS 5.1), in this App I used the JS to create Web SQL Database;
Here I describe the situation what I met:
First, I build the App and install it on my real device to do the test, everything works OK;
Then I change some code and update the version number of my App, rebuild and re-install it on my real device and run it again, this time an error alert, Error: SECURITY_ERR: DOM Exception 18. Because of this error, my App crashed;
But when I delete the App and re-install it again, the App can work well;
Please help me or instruct me how to resolve it!
Personally I prefer resolve this bug in JS Part;
Here is the code which I used to create the Web SQL Database:
try {
var dataBase = openDatabase("ipadlocalDb", "1.0", "local db", 5 * 1024 * 1024);
}
catch (e) {
alert(e);
}
Thank you in advance!!! | javascript | ios5 | null | null | null | null | open | The exception: SECURITY_ERR: DOM Exception 18 occurred when create the Web SQL Database
===
At the moment, I am developing an App for iOS (the version is iOS 5.1), in this App I used the JS to create Web SQL Database;
Here I describe the situation what I met:
First, I build the App and install it on my real device to do the test, everything works OK;
Then I change some code and update the version number of my App, rebuild and re-install it on my real device and run it again, this time an error alert, Error: SECURITY_ERR: DOM Exception 18. Because of this error, my App crashed;
But when I delete the App and re-install it again, the App can work well;
Please help me or instruct me how to resolve it!
Personally I prefer resolve this bug in JS Part;
Here is the code which I used to create the Web SQL Database:
try {
var dataBase = openDatabase("ipadlocalDb", "1.0", "local db", 5 * 1024 * 1024);
}
catch (e) {
alert(e);
}
Thank you in advance!!! | 0 |
11,499,984 | 07/16/2012 07:40:43 | 1,001,434 | 10/18/2011 15:08:29 | 1 | 0 | Create a Checkstyle Configuration from an Eclipse formatter file | At the moment our team is working with a custom eclipse Formatter configuration. Is there a way to import the generated xml file into Checkstyle to have both on the same ruleset? | eclipse | checkstyle | formatter | null | null | null | open | Create a Checkstyle Configuration from an Eclipse formatter file
===
At the moment our team is working with a custom eclipse Formatter configuration. Is there a way to import the generated xml file into Checkstyle to have both on the same ruleset? | 0 |
11,499,988 | 07/16/2012 07:41:07 | 1,270,935 | 03/15/2012 07:10:51 | 11 | 0 | validate entered data befor apply it to BindingSource underlying source | BindingSource BS = new BindingSource();
public Cource()
{
InitializeComponent();
}
private void Cource_Load(object sender, EventArgs e)
{
DataSet ds = new DataAccess.newCourcesDAC().GetAllTeachers();
BS.DataSource = ds;
BS.DataMember = "tblCourses";
dataGridView1.DataSource = BS;
txtCourseID.DataBindings.Add("Text", BS, "CourseID");
txtCourseName.DataBindings.Add("Text", BS, "CourseName");
txtPrequest.DataBindings.Add("Text", BS, "Prequest");
txtCourseContent.DataBindings.Add("Text", BS, "CourseContent");
}
private void btnAdd_Click(object sender, EventArgs e)
{
BS.AddNew();
}
I have a datasource with a datatable called "tblCourses" that have 4 columns.
I use a BindingSource to manage currency beetwen datagridView and 4 text box.
i use addNew metode of bindingSource to add new row to dataTable .
how can i validate entered data befor apply it to BindingSource underlying source?
| c# | null | null | null | null | null | open | validate entered data befor apply it to BindingSource underlying source
===
BindingSource BS = new BindingSource();
public Cource()
{
InitializeComponent();
}
private void Cource_Load(object sender, EventArgs e)
{
DataSet ds = new DataAccess.newCourcesDAC().GetAllTeachers();
BS.DataSource = ds;
BS.DataMember = "tblCourses";
dataGridView1.DataSource = BS;
txtCourseID.DataBindings.Add("Text", BS, "CourseID");
txtCourseName.DataBindings.Add("Text", BS, "CourseName");
txtPrequest.DataBindings.Add("Text", BS, "Prequest");
txtCourseContent.DataBindings.Add("Text", BS, "CourseContent");
}
private void btnAdd_Click(object sender, EventArgs e)
{
BS.AddNew();
}
I have a datasource with a datatable called "tblCourses" that have 4 columns.
I use a BindingSource to manage currency beetwen datagridView and 4 text box.
i use addNew metode of bindingSource to add new row to dataTable .
how can i validate entered data befor apply it to BindingSource underlying source?
| 0 |
11,499,759 | 07/16/2012 07:22:06 | 193,921 | 10/21/2009 16:05:30 | 441 | 5 | CakePHP 2: How to generate an sql insert script from an array | Can I generate an sql insert statement from an array returned by find methods?
Thanks. | mysql | cakephp-2.0 | dump | sql-insert | null | null | open | CakePHP 2: How to generate an sql insert script from an array
===
Can I generate an sql insert statement from an array returned by find methods?
Thanks. | 0 |
11,499,760 | 07/16/2012 07:22:11 | 297,042 | 03/19/2010 02:04:21 | 77 | 4 | bash - multiple operations without temp files (counting lines of code with custom exclusions) | I want to keep each operation on its own line with interspersed comments
is there anyway to do this without the kludgy temp files
#!/bin/sh
git diff --stat `git hash-object -t tree /dev/null` > tmp.txt
# not my code
grep -v "^ kazmath" tmp.txt > tmp2.txt
grep -v "\.obj " tmp2.txt > tmp.txt
grep -v "\.png " tmp.txt > tmp2.txt
grep -v "\.gbo " tmp2.txt > tmp.txt
# not my code
grep -v "obj2opengl\.pl " tmp.txt > tmp2.txt
grep -v "\.txt " tmp2.txt > tmp.txt
grep -v "\.md " tmp.txt > tmp2.txt
grep -v "\.blend " tmp2.txt > tmp.txt
# +'s at end of line
sed 's/+*$//' tmp.txt > tmp2.txt
# ditch last line
sed '$d' < tmp2.txt > tmp.txt
echo -n "lines of code "
cut -d '|' -f 2 tmp.txt | awk '{ sum+=$1} END {print sum}'
rm tmp.txt
rm tmp2.txt
| bash | count | null | null | null | null | open | bash - multiple operations without temp files (counting lines of code with custom exclusions)
===
I want to keep each operation on its own line with interspersed comments
is there anyway to do this without the kludgy temp files
#!/bin/sh
git diff --stat `git hash-object -t tree /dev/null` > tmp.txt
# not my code
grep -v "^ kazmath" tmp.txt > tmp2.txt
grep -v "\.obj " tmp2.txt > tmp.txt
grep -v "\.png " tmp.txt > tmp2.txt
grep -v "\.gbo " tmp2.txt > tmp.txt
# not my code
grep -v "obj2opengl\.pl " tmp.txt > tmp2.txt
grep -v "\.txt " tmp2.txt > tmp.txt
grep -v "\.md " tmp.txt > tmp2.txt
grep -v "\.blend " tmp2.txt > tmp.txt
# +'s at end of line
sed 's/+*$//' tmp.txt > tmp2.txt
# ditch last line
sed '$d' < tmp2.txt > tmp.txt
echo -n "lines of code "
cut -d '|' -f 2 tmp.txt | awk '{ sum+=$1} END {print sum}'
rm tmp.txt
rm tmp2.txt
| 0 |
11,499,993 | 07/16/2012 07:41:37 | 1,349,330 | 04/22/2012 09:18:26 | 1 | 0 | sharepoint online workflow activity crash | I have a workflow similar to the one from http://msdn.microsoft.com/en-us/magazine/hh288072.aspx.
Most of the time it works great. Sometimes however, it crashes and then says "An error has occurred in workflow CreateSiteFlow". The site then has been created successfully.
I found some references to the same problem, but all say to look at the log files. How does this work for SharePoint Online, or has someone guidelines for what could be wrong?
I found some references online about time-outs regarding to workflows. But I cannot find any specifics about this, and also I'm unable to see long time (including seconds, or even more precise) in the reports of the workflow..
Regards,
Matthijs ter Woord | sharepoint | activity | crash | workflow | online | null | open | sharepoint online workflow activity crash
===
I have a workflow similar to the one from http://msdn.microsoft.com/en-us/magazine/hh288072.aspx.
Most of the time it works great. Sometimes however, it crashes and then says "An error has occurred in workflow CreateSiteFlow". The site then has been created successfully.
I found some references to the same problem, but all say to look at the log files. How does this work for SharePoint Online, or has someone guidelines for what could be wrong?
I found some references online about time-outs regarding to workflows. But I cannot find any specifics about this, and also I'm unable to see long time (including seconds, or even more precise) in the reports of the workflow..
Regards,
Matthijs ter Woord | 0 |
11,472,313 | 07/13/2012 14:17:39 | 75,888 | 03/09/2009 23:08:49 | 1,138 | 42 | Django Manager - Override the default get_query_set to set a default "GROUP BY" | I am stuck with legacy db. I want to modify the default queryset in order to work proficiently with the db, to do this I need to use a `GROUP BY`. I know that I can do this which gets me the SQL I am after:
query = Variant.objects.all().query
query.group_by = ['name']
return QuerySet(query=query, model=Variant)
And this will result in the queryset that I am after. So I built a queryset Manager to help me out. The problem is that it's returning the right values but when I do a count on it it's wrong.
class VariantQuerySet(QuerySet):
def group_by_name(self):
self.query.group_by = ['name']
return self.filter()
class VariantManager(models.Manager):
def get_query_set(self):
return VariantQuerySet(self.model, using=self._db)
But then when I start playing with it..
>>> Variant.objects.filter(project__name__icontains="zam")
[<Variant: RevA>, <Variant: RevA>, <Variant: RevA>, <Variant: revB>, <Variant: RevC_Fiendish>, <Variant: RevA>, <Variant: RevA_tapeout>]
>>> Variant.objects.filter(project__name__icontains="zam").count()
7
>>> Variant.objects.filter(project__name__icontains="zam").group_by_name()
[<Variant: RevA>, <Variant: revB>, <Variant: RevC_Fiendish>, <Variant: RevA_tapeout>]
So far so good. 7 ungrouped items, 4 with grouping.
>>> Variant.objects.filter(project__name__icontains="zam").group_by_name().count()
7
So why is my count still stuck at 7 - it should be 4? I've I thought _result_cache was holding the value so I set that to None in the method but no luck. Any ideas why this is wrong?
| django | django-queryset | django-queries | django-query | null | null | open | Django Manager - Override the default get_query_set to set a default "GROUP BY"
===
I am stuck with legacy db. I want to modify the default queryset in order to work proficiently with the db, to do this I need to use a `GROUP BY`. I know that I can do this which gets me the SQL I am after:
query = Variant.objects.all().query
query.group_by = ['name']
return QuerySet(query=query, model=Variant)
And this will result in the queryset that I am after. So I built a queryset Manager to help me out. The problem is that it's returning the right values but when I do a count on it it's wrong.
class VariantQuerySet(QuerySet):
def group_by_name(self):
self.query.group_by = ['name']
return self.filter()
class VariantManager(models.Manager):
def get_query_set(self):
return VariantQuerySet(self.model, using=self._db)
But then when I start playing with it..
>>> Variant.objects.filter(project__name__icontains="zam")
[<Variant: RevA>, <Variant: RevA>, <Variant: RevA>, <Variant: revB>, <Variant: RevC_Fiendish>, <Variant: RevA>, <Variant: RevA_tapeout>]
>>> Variant.objects.filter(project__name__icontains="zam").count()
7
>>> Variant.objects.filter(project__name__icontains="zam").group_by_name()
[<Variant: RevA>, <Variant: revB>, <Variant: RevC_Fiendish>, <Variant: RevA_tapeout>]
So far so good. 7 ungrouped items, 4 with grouping.
>>> Variant.objects.filter(project__name__icontains="zam").group_by_name().count()
7
So why is my count still stuck at 7 - it should be 4? I've I thought _result_cache was holding the value so I set that to None in the method but no luck. Any ideas why this is wrong?
| 0 |
11,472,314 | 07/13/2012 14:17:39 | 790,701 | 06/09/2011 09:59:26 | 299 | 2 | Transparent logical filter on entities - App Engine | i'm not sure i can easily do this but i need to automatically add a filter on a field for every query related to my model. I've added a boolean property "active" to my model called Node.
For example
Node.query()
should return every node with the field Node.active set to True and ignore nodes with the active field set to false, without any other instructions.
Is it possible to override the function in any way or something similar? I'm not really good with neither python nor with app engine so i'm not sure i can actually do this.
| google-app-engine | null | null | null | null | null | open | Transparent logical filter on entities - App Engine
===
i'm not sure i can easily do this but i need to automatically add a filter on a field for every query related to my model. I've added a boolean property "active" to my model called Node.
For example
Node.query()
should return every node with the field Node.active set to True and ignore nodes with the active field set to false, without any other instructions.
Is it possible to override the function in any way or something similar? I'm not really good with neither python nor with app engine so i'm not sure i can actually do this.
| 0 |
11,472,319 | 07/13/2012 14:17:55 | 1,218,305 | 02/18/2012 16:35:07 | 42 | 1 | CSS opacity property value transitioning with javascript bug | I have a hidden div ("hidden" with both the visibility and the display property) that appears when a javascript function is triggered. Works fine but I want the appearing and disappearing to be smooth, using css transitions. This works fine for the disappearing part but not for the appearing one.
Here are the two appearing and disappearing functions:
function visiblize(obj1, obj2, opac1, opac2){
obj1.style.display='block';
obj1.style.visibility='visible';
obj1.style.opacity=opac1;
obj2.style.display='block';
obj2.style.visibility='visible';
obj2.style.opacity=opac2;
}
function invisiblize(obj1, obj2){
setTimeout(function(){obj1.style.display='none';
obj1.style.visibility='hidden';
}, 300);
obj1.style.opacity='0';
setTimeout(function(){obj2.style.display='none';
obj2.style.visibility='hidden';
}, 300);
obj2.style.opacity='0';
}
You can see the problem here, when clicking the "facebook", "twitter" or "google+" buttons:
http://libri1984.altervista.org/experiments/autore.php?nome=gino&cognome=luca | javascript | opacity | css-transitions | null | null | null | open | CSS opacity property value transitioning with javascript bug
===
I have a hidden div ("hidden" with both the visibility and the display property) that appears when a javascript function is triggered. Works fine but I want the appearing and disappearing to be smooth, using css transitions. This works fine for the disappearing part but not for the appearing one.
Here are the two appearing and disappearing functions:
function visiblize(obj1, obj2, opac1, opac2){
obj1.style.display='block';
obj1.style.visibility='visible';
obj1.style.opacity=opac1;
obj2.style.display='block';
obj2.style.visibility='visible';
obj2.style.opacity=opac2;
}
function invisiblize(obj1, obj2){
setTimeout(function(){obj1.style.display='none';
obj1.style.visibility='hidden';
}, 300);
obj1.style.opacity='0';
setTimeout(function(){obj2.style.display='none';
obj2.style.visibility='hidden';
}, 300);
obj2.style.opacity='0';
}
You can see the problem here, when clicking the "facebook", "twitter" or "google+" buttons:
http://libri1984.altervista.org/experiments/autore.php?nome=gino&cognome=luca | 0 |
11,472,304 | 07/13/2012 14:17:26 | 1,480,093 | 06/25/2012 13:18:42 | 15 | 0 | Keep a progress bar on top. Linux | Okay so I was just wondering if there is a way to have a progress bar on the top as the script is running to tell the user that x% of the process has been completed. Also is there a command that is built into the OS that would let me use a progress bar or would i have to design that as well in code? | linux | shell | unix | scripting | progress | null | open | Keep a progress bar on top. Linux
===
Okay so I was just wondering if there is a way to have a progress bar on the top as the script is running to tell the user that x% of the process has been completed. Also is there a command that is built into the OS that would let me use a progress bar or would i have to design that as well in code? | 0 |
11,472,333 | 07/13/2012 14:18:21 | 1,523,714 | 07/13/2012 13:43:54 | 1 | 0 | Python Dynamic Array allocation, Matlab style | I'm trying to move a few Matlab libraries that I've built to the python environment. So far, the biggest issue I faced is the dynamic allocation of arrays based on index specification. For example, using Matlab, typing the following:
x = [1 2];
x(5) = 3;
would result in:
x = [ 1 2 0 0 3]
In other words, I didn't know before hand the size of (x), nor its content. The array must be defined on the fly, based on the indices that I'm providing.
In python, trying the following:
from numpy import *
x = array([1,2])
x[4] = 3
Would result in the following error: IndexError: index out of bounds. On workaround is incrementing the array in a loop and then assigned the desired value as :
from numpy import *
x = array([1,2])
idx = 4
for i in range(size(x),idx+1):
x = append(x,0)
x[idx] = 3
print x
It works, but it's not very convenient and it might become very cumbersome for n-dimensional arrays. Anybody knows of a better approach. I though about subclassing ndarray to achieve my goal, but I'm not sure if it would work. Let me know if you have any suggestion.
Regards, | python | arrays | matlab | numpy | indexing | null | open | Python Dynamic Array allocation, Matlab style
===
I'm trying to move a few Matlab libraries that I've built to the python environment. So far, the biggest issue I faced is the dynamic allocation of arrays based on index specification. For example, using Matlab, typing the following:
x = [1 2];
x(5) = 3;
would result in:
x = [ 1 2 0 0 3]
In other words, I didn't know before hand the size of (x), nor its content. The array must be defined on the fly, based on the indices that I'm providing.
In python, trying the following:
from numpy import *
x = array([1,2])
x[4] = 3
Would result in the following error: IndexError: index out of bounds. On workaround is incrementing the array in a loop and then assigned the desired value as :
from numpy import *
x = array([1,2])
idx = 4
for i in range(size(x),idx+1):
x = append(x,0)
x[idx] = 3
print x
It works, but it's not very convenient and it might become very cumbersome for n-dimensional arrays. Anybody knows of a better approach. I though about subclassing ndarray to achieve my goal, but I'm not sure if it would work. Let me know if you have any suggestion.
Regards, | 0 |
11,472,334 | 07/13/2012 14:18:25 | 1,523,773 | 07/13/2012 14:05:28 | 1 | 0 | neural networks with large datasets (~2000) failed | Im trying to play abit with neurloab and test some situations. as example ill try to predict one letter on other letter - each letter is coded as o...1...0 array, so input has 26 0..1 values . and output variables ill generate on some simple input law . here is
import neurolab
...
def convert(v):
ret = np.zeros(mlen*len(chars))
for i in range(len(v)):
ret[chars.index(v[i])+i*len(chars)]=1
return ret
def gen_example():
return random.choice(chars)
def get_answer(a):
if a == 'a':
return 'a'
if a == 'b':
return 'a'
if a == 'c':
return random.choice(('a','b'))
return random.choice(chars)
inps=[]
iv =[]
tv=[]
for i in range(examples_num):
a = gen_example()
t = get_answer(a)
iv.append(convert(a))
tv.append(convert(t))
input = np.vstack(iv)
target = np.vstack(tv)
net = nl.net.newff(
np.array([[0,1],]*input.shape[1]),
[input.shape[1], target.shape[1]]
)
err = net.train(input, target, show=15,goal=0.01,epochs=epochs)
print net.sim([convert('a') , convert('b') , convert('c') , convert('d') ])
it works fine on some small datasets (200 ) and small dimensions but on large datasets 2000 neural network completly lost solutions - it was unexpectable
for example here is answer for datasetlen 200 and 10 chars
Epoch: 15; Error: 323.992687964;
Epoch: 30; Error: 169.898422744;
Epoch: 45; Error: 120.619292163;
Epoch: 60; Error: 106.286712965;
Epoch: 75; Error: 78.5218422963;
Epoch: 90; Error: 66.6415604051;
Epoch: 105; Error: 61.6016483777;
Epoch: 120; Error: 60.4755576521;
Epoch: 135; Error: 62.4428603766;
Epoch: 150; Error: 60.7550692954;
The maximum number of train epochs is reached
[[ 0.97293559 -0.00877903 0.01166136 0.01378009 0.03217591 0.00575149
0.04176477 0.00118451 -0.009721 0.0352841 ]
[ 0.98850972 -0.01769902 0.01351957 0.01343085 0.04014554 0.00546748
0.04610116 0.00821612 -0.01276102 0.01233721]
[ 0.41986823 0.52690818 0.01564266 0.01714206 0.05671181 0.0050912
0.05326165 0.00976181 -0.01158082 0.0136987 ]
[ 0.2003367 -0.0446579 0.22665431 0.15949141 0.14760051 0.0672652
0.12337698 0.01398636 -0.00772371 0.12108565]]
and here is answer for datasetlen 2000 and 10 chars
Epoch: 15; Error: 9183.38490998;
Epoch: 30; Error: 9605.99999987;
Epoch: 45; Error: 9606.0;
Epoch: 60; Error: 9606.0;
Epoch: 75; Error: 9606.0;
Epoch: 90; Error: 9606.0;
Epoch: 105; Error: 9606.0;
Epoch: 120; Error: 9606.0;
Epoch: 135; Error: 9606.0;
Epoch: 150; Error: 9606.0;
Epoch: 165; Error: 9606.0;
Epoch: 180; Error: 9606.0;
Epoch: 195; Error: 9606.0;
Epoch: 210; Error: 9606.0;
Epoch: 225; Error: 9606.0;
Epoch: 240; Error: 9606.0;
The maximum number of train epochs is reached
[[ 1. 1. 1. 1. -1. 1. 1. -1. 1. 1.]
[ 1. 1. 1. 1. -1. 1. 1. -1. 1. 1.]
[ 1. 1. 1. 1. -1. 1. 1. -1. 1. 1.]
[ 1. 1. 1. 1. -1. 1. 1. -1. 1. 1.]]
I think that is floatpoint problem may be somebody know solutions or suggestions ? | python | numpy | neural-network | neural-network-tuning | null | 07/14/2012 12:03:22 | too localized | neural networks with large datasets (~2000) failed
===
Im trying to play abit with neurloab and test some situations. as example ill try to predict one letter on other letter - each letter is coded as o...1...0 array, so input has 26 0..1 values . and output variables ill generate on some simple input law . here is
import neurolab
...
def convert(v):
ret = np.zeros(mlen*len(chars))
for i in range(len(v)):
ret[chars.index(v[i])+i*len(chars)]=1
return ret
def gen_example():
return random.choice(chars)
def get_answer(a):
if a == 'a':
return 'a'
if a == 'b':
return 'a'
if a == 'c':
return random.choice(('a','b'))
return random.choice(chars)
inps=[]
iv =[]
tv=[]
for i in range(examples_num):
a = gen_example()
t = get_answer(a)
iv.append(convert(a))
tv.append(convert(t))
input = np.vstack(iv)
target = np.vstack(tv)
net = nl.net.newff(
np.array([[0,1],]*input.shape[1]),
[input.shape[1], target.shape[1]]
)
err = net.train(input, target, show=15,goal=0.01,epochs=epochs)
print net.sim([convert('a') , convert('b') , convert('c') , convert('d') ])
it works fine on some small datasets (200 ) and small dimensions but on large datasets 2000 neural network completly lost solutions - it was unexpectable
for example here is answer for datasetlen 200 and 10 chars
Epoch: 15; Error: 323.992687964;
Epoch: 30; Error: 169.898422744;
Epoch: 45; Error: 120.619292163;
Epoch: 60; Error: 106.286712965;
Epoch: 75; Error: 78.5218422963;
Epoch: 90; Error: 66.6415604051;
Epoch: 105; Error: 61.6016483777;
Epoch: 120; Error: 60.4755576521;
Epoch: 135; Error: 62.4428603766;
Epoch: 150; Error: 60.7550692954;
The maximum number of train epochs is reached
[[ 0.97293559 -0.00877903 0.01166136 0.01378009 0.03217591 0.00575149
0.04176477 0.00118451 -0.009721 0.0352841 ]
[ 0.98850972 -0.01769902 0.01351957 0.01343085 0.04014554 0.00546748
0.04610116 0.00821612 -0.01276102 0.01233721]
[ 0.41986823 0.52690818 0.01564266 0.01714206 0.05671181 0.0050912
0.05326165 0.00976181 -0.01158082 0.0136987 ]
[ 0.2003367 -0.0446579 0.22665431 0.15949141 0.14760051 0.0672652
0.12337698 0.01398636 -0.00772371 0.12108565]]
and here is answer for datasetlen 2000 and 10 chars
Epoch: 15; Error: 9183.38490998;
Epoch: 30; Error: 9605.99999987;
Epoch: 45; Error: 9606.0;
Epoch: 60; Error: 9606.0;
Epoch: 75; Error: 9606.0;
Epoch: 90; Error: 9606.0;
Epoch: 105; Error: 9606.0;
Epoch: 120; Error: 9606.0;
Epoch: 135; Error: 9606.0;
Epoch: 150; Error: 9606.0;
Epoch: 165; Error: 9606.0;
Epoch: 180; Error: 9606.0;
Epoch: 195; Error: 9606.0;
Epoch: 210; Error: 9606.0;
Epoch: 225; Error: 9606.0;
Epoch: 240; Error: 9606.0;
The maximum number of train epochs is reached
[[ 1. 1. 1. 1. -1. 1. 1. -1. 1. 1.]
[ 1. 1. 1. 1. -1. 1. 1. -1. 1. 1.]
[ 1. 1. 1. 1. -1. 1. 1. -1. 1. 1.]
[ 1. 1. 1. 1. -1. 1. 1. -1. 1. 1.]]
I think that is floatpoint problem may be somebody know solutions or suggestions ? | 3 |
11,350,488 | 07/05/2012 18:38:37 | 1,504,774 | 07/05/2012 17:36:01 | 1 | 0 | Efficient way to calculate averages, standard deviations from a txt file | I am very new to Python.Here is a copy of what one of many txt files looks like.
Class 1:
Subject A:
posX posY posZ x(%) y(%)
0 2 0 81 72
0 2 180 63 38
-1 -2 0 79 84
-1 -2 180 85 95
. . . . .
Subject B:
posX posY posZ x(%) y(%)
0 2 0 71 73
-1 -2 0 69 88
. . . . .
Subject C:
posX posY posZ x(%) y(%)
0 2 0 86 71
-1 -2 0 81 55
. . . . .
Class 2:
Subject A:
posX posY posZ x(%) y(%)
0 2 0 81 72
-1 -2 0 79 84
. . . . .
- The number of classes, subjects, row entries all vary.
- Class1-Subject A always has posZ entries that have 0 alternating with 180
- Calculate average of x(%), y(%) by class and by subject
- Calculate standard deviation of x(%), y(%) by class and by subject
- * Also ignore posZ of 180 when calculating averages and std_deviations
I have developed an unwieldly solution in excel (using macro's and VBA) but I would rather go for a more optimal solution in python.
Specifically, I would like the output to look as follows
By Class By Subject
X Y X Y
Average Average
std_dev std_dev | numpy | python-2.7 | python | null | null | null | open | Efficient way to calculate averages, standard deviations from a txt file
===
I am very new to Python.Here is a copy of what one of many txt files looks like.
Class 1:
Subject A:
posX posY posZ x(%) y(%)
0 2 0 81 72
0 2 180 63 38
-1 -2 0 79 84
-1 -2 180 85 95
. . . . .
Subject B:
posX posY posZ x(%) y(%)
0 2 0 71 73
-1 -2 0 69 88
. . . . .
Subject C:
posX posY posZ x(%) y(%)
0 2 0 86 71
-1 -2 0 81 55
. . . . .
Class 2:
Subject A:
posX posY posZ x(%) y(%)
0 2 0 81 72
-1 -2 0 79 84
. . . . .
- The number of classes, subjects, row entries all vary.
- Class1-Subject A always has posZ entries that have 0 alternating with 180
- Calculate average of x(%), y(%) by class and by subject
- Calculate standard deviation of x(%), y(%) by class and by subject
- * Also ignore posZ of 180 when calculating averages and std_deviations
I have developed an unwieldly solution in excel (using macro's and VBA) but I would rather go for a more optimal solution in python.
Specifically, I would like the output to look as follows
By Class By Subject
X Y X Y
Average Average
std_dev std_dev | 0 |
11,350,471 | 07/05/2012 18:37:00 | 1,276,952 | 03/18/2012 13:47:45 | 91 | 0 | finding median of 5 elements | the following question was asked in a recent microsoft interview
Given an unsorted array of size 5.
How many minimum comparisons are needed to find the median? then he extended it for size n.
solution for 5 elements according to me is 6
`1) use 3 comparisons to arrange elements in array such that a[1]<a[2] , a[4]<a[5] and a[1]<a[4]
a) compare a[1] and a[2] and swap if necessary
b) compare a[4] and a[5] and swap if necessary
c) compare a[1] and a[4].if a[4] is smaller than a[1] , then swap a[1] wid a[4] and a[2] wid a[5]
2)if a[3]>a[2].if a[2]<a[4] median value = min(a[3],a[4]) else median value=min(a[2],a[5])
3)if a[3]<a[2].if a[3]>a[4] median value = min(a[3],a[5]) else median value=min(a[2],a[4]) `
**can this be extended to n elements. if not how can we find median in n elements in O(n) besides quickselect** | c++ | c | arrays | algorithm | median | null | open | finding median of 5 elements
===
the following question was asked in a recent microsoft interview
Given an unsorted array of size 5.
How many minimum comparisons are needed to find the median? then he extended it for size n.
solution for 5 elements according to me is 6
`1) use 3 comparisons to arrange elements in array such that a[1]<a[2] , a[4]<a[5] and a[1]<a[4]
a) compare a[1] and a[2] and swap if necessary
b) compare a[4] and a[5] and swap if necessary
c) compare a[1] and a[4].if a[4] is smaller than a[1] , then swap a[1] wid a[4] and a[2] wid a[5]
2)if a[3]>a[2].if a[2]<a[4] median value = min(a[3],a[4]) else median value=min(a[2],a[5])
3)if a[3]<a[2].if a[3]>a[4] median value = min(a[3],a[5]) else median value=min(a[2],a[4]) `
**can this be extended to n elements. if not how can we find median in n elements in O(n) besides quickselect** | 0 |
11,350,489 | 07/05/2012 18:38:42 | 659,463 | 03/14/2011 20:05:13 | 47 | 5 | How do you set a delegate for a protocol in a viewcontroller in another tab? | I would like some expert MVC design feedback please:
I have a UITabBarController with 2 tabs, each of the tabs leads to a Nav controller with a stack of VC.
The last view Controller on the 1st tab path will show an image. I would like that image to be stored in a table and viewed anytime the second tab is selected.
How do I send this image from the 1st tab-> NaVController->last VC (image VC) to 2nd tab -> NavController->table VC?
I have a couple of options:
1- Create a class method in the tableVC and have the imageVC call that class method and pass that image to be saved directly into user defaults. This seems to go against MVC
2- Create a protocol in imageVC with a method and delegate property and have the table VC adopt that method to save the image in an array. The problem here is that the only place to set the delegate is in ViewDidLoad:
[[[[self.tabBarController.viewControllers objectAtIndex:0] viewControllers] objectAtIndex:1] setDelegate:self];
The problem here is that if the user select the second tab from the start, the app will crash because obviously the viewControllers have not been loaded on the nav stack for the first tab. In the same token, if the user sees 1 image first and then selects the second tab, it will execute and set the delegate but without saving that first selected image.
There must be an easier way.....
Thanks in advance
KB
| ios | mvc | delegates | protocols | null | null | open | How do you set a delegate for a protocol in a viewcontroller in another tab?
===
I would like some expert MVC design feedback please:
I have a UITabBarController with 2 tabs, each of the tabs leads to a Nav controller with a stack of VC.
The last view Controller on the 1st tab path will show an image. I would like that image to be stored in a table and viewed anytime the second tab is selected.
How do I send this image from the 1st tab-> NaVController->last VC (image VC) to 2nd tab -> NavController->table VC?
I have a couple of options:
1- Create a class method in the tableVC and have the imageVC call that class method and pass that image to be saved directly into user defaults. This seems to go against MVC
2- Create a protocol in imageVC with a method and delegate property and have the table VC adopt that method to save the image in an array. The problem here is that the only place to set the delegate is in ViewDidLoad:
[[[[self.tabBarController.viewControllers objectAtIndex:0] viewControllers] objectAtIndex:1] setDelegate:self];
The problem here is that if the user select the second tab from the start, the app will crash because obviously the viewControllers have not been loaded on the nav stack for the first tab. In the same token, if the user sees 1 image first and then selects the second tab, it will execute and set the delegate but without saving that first selected image.
There must be an easier way.....
Thanks in advance
KB
| 0 |
11,350,498 | 07/05/2012 18:39:08 | 226,716 | 12/07/2009 22:14:17 | 42 | 5 | Django form.clean(), cleaned_data KeyError | In [Django 1.4 documentation][1], it says that `clean_<fieldname>` methods are run first, then form `clean` method is executed.
I have the following code sample. When `pmid` field is empty in the form, it should throw `ValidationError` exception, but it doesn't happen.
class MyForm(forms.Form):
pmid = forms.CharField()
.. other fields ..
def clean(self):
cd = super(MyForm, self).clean()
cd['pmid'] # returns KeyError and it's not in cd
return cd
I don't override any `clean_<field>` method.
[1]: https://docs.djangoproject.com/en/1.4/ref/forms/validation/ | django | forms | null | null | null | null | open | Django form.clean(), cleaned_data KeyError
===
In [Django 1.4 documentation][1], it says that `clean_<fieldname>` methods are run first, then form `clean` method is executed.
I have the following code sample. When `pmid` field is empty in the form, it should throw `ValidationError` exception, but it doesn't happen.
class MyForm(forms.Form):
pmid = forms.CharField()
.. other fields ..
def clean(self):
cd = super(MyForm, self).clean()
cd['pmid'] # returns KeyError and it's not in cd
return cd
I don't override any `clean_<field>` method.
[1]: https://docs.djangoproject.com/en/1.4/ref/forms/validation/ | 0 |
11,350,504 | 07/05/2012 18:39:35 | 1,252,698 | 03/06/2012 16:16:04 | 50 | 4 | Application slower on qt 4.8.0 than 4.7.4 | I have an application that I was developing with Qt 4.7.4 but I had the problem (the bug is reported) with the button's (too small) hit area. So I change for Qt 4.8.0. Now my problem with the button is resolved, but my application runs really slower that it ran with Qt 4.7.4. Is there anything I need to do? Kind of settings...
Thanks | qt | qt4.7 | qt4.8 | null | null | null | open | Application slower on qt 4.8.0 than 4.7.4
===
I have an application that I was developing with Qt 4.7.4 but I had the problem (the bug is reported) with the button's (too small) hit area. So I change for Qt 4.8.0. Now my problem with the button is resolved, but my application runs really slower that it ran with Qt 4.7.4. Is there anything I need to do? Kind of settings...
Thanks | 0 |
11,350,411 | 07/05/2012 18:32:29 | 756,586 | 05/17/2011 01:15:50 | 22 | 1 | HTML PHP Connecting | I'm here again. So here's the deal, I was thinking if it's possible if let's say I have a link when clicked will go to the said page but it will actually send a value to the target page. Let's say the value is pageno.
Could i do it like
<a href="displaypage.html?pageno=1">
would that kind of thing work? I mean I want the php which would be something like this
<?php $pageno=$_POST['pageno']; ?>
and then some other process stuff. Going back, I want the php file to get the pageno that was set in the link. Is that possible? If so please help. Thanks! | php | html | value | null | null | null | open | HTML PHP Connecting
===
I'm here again. So here's the deal, I was thinking if it's possible if let's say I have a link when clicked will go to the said page but it will actually send a value to the target page. Let's say the value is pageno.
Could i do it like
<a href="displaypage.html?pageno=1">
would that kind of thing work? I mean I want the php which would be something like this
<?php $pageno=$_POST['pageno']; ?>
and then some other process stuff. Going back, I want the php file to get the pageno that was set in the link. Is that possible? If so please help. Thanks! | 0 |
11,350,412 | 07/05/2012 18:32:29 | 755,939 | 05/16/2011 15:57:28 | 1 | 0 | OOP programming in python | I was reading Dietel's C++ programming book. In this book they mention how a programmer should release only the interface part of his code and not the implementation.
So carrying this over to python:
I have 2 files:
1) the implementation file = accountClass.py and
2) the interface file = useAccountClass.py
I have compiled the implementation file and have obtained the .pyc file. So when I provide my code to someone else, I would provide him with the .pyc file and the interface file, right?
Also, if I provide someone else with ONLY the .pyc file, can I expect him to write the interface on his own? I'm going to say no. But there's this one nagging doubt that I have:
The creators of numpy and scipy did not share the implementation with us end users. And I don't think they shared any interfaces either. But we can still search for the different classes and their methods inside both numpy and scipy. So, using this example of numpy and scipy, I guess what I'm trying to ask is:
Is it possible for someone else to create an interface to my code if I provide him/ her with only the compiled implementation file (in this case accountClass.pyc)? How will that person know what classes and methods I have defined in my implementation? I mean, will they use the
if __name__ = "__main__" : blah blah
or is there some other way?? | python | oop | null | null | null | null | open | OOP programming in python
===
I was reading Dietel's C++ programming book. In this book they mention how a programmer should release only the interface part of his code and not the implementation.
So carrying this over to python:
I have 2 files:
1) the implementation file = accountClass.py and
2) the interface file = useAccountClass.py
I have compiled the implementation file and have obtained the .pyc file. So when I provide my code to someone else, I would provide him with the .pyc file and the interface file, right?
Also, if I provide someone else with ONLY the .pyc file, can I expect him to write the interface on his own? I'm going to say no. But there's this one nagging doubt that I have:
The creators of numpy and scipy did not share the implementation with us end users. And I don't think they shared any interfaces either. But we can still search for the different classes and their methods inside both numpy and scipy. So, using this example of numpy and scipy, I guess what I'm trying to ask is:
Is it possible for someone else to create an interface to my code if I provide him/ her with only the compiled implementation file (in this case accountClass.pyc)? How will that person know what classes and methods I have defined in my implementation? I mean, will they use the
if __name__ = "__main__" : blah blah
or is there some other way?? | 0 |
11,350,509 | 07/05/2012 18:39:54 | 1,206,091 | 02/13/2012 05:19:36 | 9 | 0 | Using Python's basic I/O to manipulate or create Python Files? | Would the most efficient way-and I know it's not very efficient, but I honestly can't find any better way-to manipulate a Python (.py) file, to add/subtract/append code, be to use the basic file I/O module included in Python?
For an example:
obj = open('Codemanipulationtest.py', 'w+')
obj.write("print 'This shows you can do basic I/O?'")
obj.close()
Will manipulate a file I have, named "codemanipulationtest.py", and add to it a print statement. Is this something that can be worked upon or are there any easier or more safe/efficient methods for manipulating/creating new python code?
I've read over this: http://stackoverflow.com/questions/768634/python-parse-a-py-file-read-the-ast-modify-it-then-write-back-the-modified
And honestly it seems like the I/O method is easier. I am kind of newbish to Python so I may just be acting stupid.....thanks in advance for any responses. | python | io | code-generation | manipulation | null | null | open | Using Python's basic I/O to manipulate or create Python Files?
===
Would the most efficient way-and I know it's not very efficient, but I honestly can't find any better way-to manipulate a Python (.py) file, to add/subtract/append code, be to use the basic file I/O module included in Python?
For an example:
obj = open('Codemanipulationtest.py', 'w+')
obj.write("print 'This shows you can do basic I/O?'")
obj.close()
Will manipulate a file I have, named "codemanipulationtest.py", and add to it a print statement. Is this something that can be worked upon or are there any easier or more safe/efficient methods for manipulating/creating new python code?
I've read over this: http://stackoverflow.com/questions/768634/python-parse-a-py-file-read-the-ast-modify-it-then-write-back-the-modified
And honestly it seems like the I/O method is easier. I am kind of newbish to Python so I may just be acting stupid.....thanks in advance for any responses. | 0 |
11,350,513 | 07/05/2012 18:40:09 | 31,520 | 10/26/2008 00:12:27 | 5,284 | 155 | Storing and removing uploaded file properties | I am using CarrierWave to handle file uploads in a rails 3.2 app. Everything is working correctly with the basic file upload, storage, and removal.
I'm storing the file's SHA1 hash and length using `before_save` in my model so later downloads can be verified:
def calculate_file_attributes
self.length = attached_file.file.size
# SHA1 omitted
end
This part is working properly and I can see the length and hash fields update as new files are uploaded. The issue I'm having is that if a file is deleted, I want to `nil` out the length and hash. I haven't been able to figure out how to do this. I thought the following code in my uploader would work:
after :remove, :remove_file_attributes
def remove_file_attributes
model.length = nil
# SHA1 omitted
end
And although it is called, the changes aren't saved. I feel like I'm missing something obvious but I'm not sure what else to try. | ruby-on-rails | carrierwave | null | null | null | null | open | Storing and removing uploaded file properties
===
I am using CarrierWave to handle file uploads in a rails 3.2 app. Everything is working correctly with the basic file upload, storage, and removal.
I'm storing the file's SHA1 hash and length using `before_save` in my model so later downloads can be verified:
def calculate_file_attributes
self.length = attached_file.file.size
# SHA1 omitted
end
This part is working properly and I can see the length and hash fields update as new files are uploaded. The issue I'm having is that if a file is deleted, I want to `nil` out the length and hash. I haven't been able to figure out how to do this. I thought the following code in my uploader would work:
after :remove, :remove_file_attributes
def remove_file_attributes
model.length = nil
# SHA1 omitted
end
And although it is called, the changes aren't saved. I feel like I'm missing something obvious but I'm not sure what else to try. | 0 |
11,350,514 | 07/05/2012 18:40:09 | 62,671 | 02/04/2009 23:04:10 | 559 | 21 | WinForms ListBox Append Selection | I have a `ListBox` with `SelectionMode = MultiExtended`. I want the *default* behavior for the ListBox to be "append". In other words, the behavior you get when holding down the control key should be the default, passive functionality for the ListBox.
How would I do this? Do I need to subscribe to the "Mouse Down" and "Key Down" events manually? Is there a setting I'm missing?
Thanks. | c# | winforms | listbox | null | null | null | open | WinForms ListBox Append Selection
===
I have a `ListBox` with `SelectionMode = MultiExtended`. I want the *default* behavior for the ListBox to be "append". In other words, the behavior you get when holding down the control key should be the default, passive functionality for the ListBox.
How would I do this? Do I need to subscribe to the "Mouse Down" and "Key Down" events manually? Is there a setting I'm missing?
Thanks. | 0 |
11,410,803 | 07/10/2012 09:56:58 | 640,611 | 03/02/2011 05:36:57 | 15 | 1 | Hierarchical clustering with custom distance | I need to implement a hierarchical clustering algorithm based on a custom distance. The distance is computed by looking in a database for the value associated to the two ids of the objects that are being compared.
Is there an easy way to do this in Java? I took a look at Weka and their custom distance function but I cannot find a way to define instances so that when I am in the custom distance function I can get the IDs of the two original objects.
Any help would be greatly appreciated
Thanks a lot in advance
Rossella | java | cluster-analysis | weka | null | null | null | open | Hierarchical clustering with custom distance
===
I need to implement a hierarchical clustering algorithm based on a custom distance. The distance is computed by looking in a database for the value associated to the two ids of the objects that are being compared.
Is there an easy way to do this in Java? I took a look at Weka and their custom distance function but I cannot find a way to define instances so that when I am in the custom distance function I can get the IDs of the two original objects.
Any help would be greatly appreciated
Thanks a lot in advance
Rossella | 0 |
11,410,812 | 07/10/2012 09:57:25 | 1,026,102 | 11/02/2011 16:54:30 | 28 | 1 | QDatastream write data from unsigned char* buffer | How can I write data from unsigned char* buffer to QDatastream. Threre are methods writeBytes and writeRawData. But they accept const char*. Can I use unsigned char* for it? | qt | null | null | null | null | null | open | QDatastream write data from unsigned char* buffer
===
How can I write data from unsigned char* buffer to QDatastream. Threre are methods writeBytes and writeRawData. But they accept const char*. Can I use unsigned char* for it? | 0 |
11,410,815 | 07/10/2012 09:57:29 | 1,210,949 | 02/15/2012 09:47:41 | 8 | 1 | Keeping track of changes using rails - "changed?" | I am building a multi lingual website, using ruby on rails, where part of the content is supposed to be user generated and they are supposed to be able to create different versions of it for all languages. The language support is handled by i18.
Part of their content is created using Markdown through http://daringfireball.net/projects/markdown/basics .
In my database I save: object.content_markdown_en, object.content_html_en, object.content_markdown_sv, object.content_html_sv and so on for the different locales.
Now if a user changes the content, new html is supposed to be generated. But it seems unnecessary to regenerate the html for all locales if he only made changes in one of the languages.
I thought there might be some way to use something like
if object.content_markdown_[locale]_changed?
generate_new_html
end
that can be run in a loop for all possible locales. But I can't find any nice ways of doing this. | ruby-on-rails | internationalization | null | null | null | null | open | Keeping track of changes using rails - "changed?"
===
I am building a multi lingual website, using ruby on rails, where part of the content is supposed to be user generated and they are supposed to be able to create different versions of it for all languages. The language support is handled by i18.
Part of their content is created using Markdown through http://daringfireball.net/projects/markdown/basics .
In my database I save: object.content_markdown_en, object.content_html_en, object.content_markdown_sv, object.content_html_sv and so on for the different locales.
Now if a user changes the content, new html is supposed to be generated. But it seems unnecessary to regenerate the html for all locales if he only made changes in one of the languages.
I thought there might be some way to use something like
if object.content_markdown_[locale]_changed?
generate_new_html
end
that can be run in a loop for all possible locales. But I can't find any nice ways of doing this. | 0 |
11,410,827 | 07/10/2012 09:58:13 | 1,514,329 | 07/10/2012 09:26:57 | 1 | 0 | Why hoverInent is not working? | I'm trying to make a dropdown menu, but I have some problems with the hoverIntent instruction.
Javascript code:
$('li.dropdown').hoverIntent(
function() {
$(this).find('ul.submenu').slideDown();
},
function() {
$(this).find('ul.submenu').slideUp();
}
);
HTML code:
<div id="div_menu">
<ul class="menu">
<li class="leaf"><a href="#" style="color:#2154A3;">Inici</a></li>
<li class="dropdown">
<a href="#">Facultats</a>
<ul class="submenu">
<li style="margin:3px; border:none;"></li>
<li><a href="#">IQS</a></li>
<li><a href="#">UIC</a></li>
<li><a href="#">UPF</a></li>
<li><a href="#">ESCI</a></li>
</ul>
</li>
<li class="leaf"><a href="./instalaciones.html">Instal·lacions</a></li>
<li><a href="">Contacte</a></li>
</ul>
</div>
CSS code:
.leaf {
border-right: solid 1px #333;
}
.dropdown {
border-right: solid 1px #333;
}
With the hover function it works correctly, but if I put the mouse ove the "li" it makes the slideDown correctly, but if after that I move the mouse out and enter again and leave again it will stay sliding up and down. It look like if there were a stack adding every event it happend! | jquery | drop-down-menu | hover | hoverintent | null | null | open | Why hoverInent is not working?
===
I'm trying to make a dropdown menu, but I have some problems with the hoverIntent instruction.
Javascript code:
$('li.dropdown').hoverIntent(
function() {
$(this).find('ul.submenu').slideDown();
},
function() {
$(this).find('ul.submenu').slideUp();
}
);
HTML code:
<div id="div_menu">
<ul class="menu">
<li class="leaf"><a href="#" style="color:#2154A3;">Inici</a></li>
<li class="dropdown">
<a href="#">Facultats</a>
<ul class="submenu">
<li style="margin:3px; border:none;"></li>
<li><a href="#">IQS</a></li>
<li><a href="#">UIC</a></li>
<li><a href="#">UPF</a></li>
<li><a href="#">ESCI</a></li>
</ul>
</li>
<li class="leaf"><a href="./instalaciones.html">Instal·lacions</a></li>
<li><a href="">Contacte</a></li>
</ul>
</div>
CSS code:
.leaf {
border-right: solid 1px #333;
}
.dropdown {
border-right: solid 1px #333;
}
With the hover function it works correctly, but if I put the mouse ove the "li" it makes the slideDown correctly, but if after that I move the mouse out and enter again and leave again it will stay sliding up and down. It look like if there were a stack adding every event it happend! | 0 |
11,410,828 | 07/10/2012 09:58:16 | 927,026 | 09/03/2011 21:07:07 | 18 | 0 | reduce the size of the virtual keyboard in Android | Can I by any chance reduce the size of the virtual keyboard when it's in landscape mode? The landscape keyboard covers more than half of the screen where I can only read one line of the message. | android | android-keypad | null | null | null | null | open | reduce the size of the virtual keyboard in Android
===
Can I by any chance reduce the size of the virtual keyboard when it's in landscape mode? The landscape keyboard covers more than half of the screen where I can only read one line of the message. | 0 |
11,410,830 | 07/10/2012 09:58:20 | 1,285,315 | 03/22/2012 07:50:30 | 14 | 0 | Tomcat manager with virtual hosts | I have three web services running under three different domains in Tomcat. I have have four host entries in my server.xml:
1. localhost
2. Webservice1.com
3. Webservice2.com
4. Webservice3.com
Currently I can only access the Tomcat Web Application Manager on localhost. How can I get the web application manger to run on the other three hosts.
Tariq
| java | tomcat | hosts | null | null | null | open | Tomcat manager with virtual hosts
===
I have three web services running under three different domains in Tomcat. I have have four host entries in my server.xml:
1. localhost
2. Webservice1.com
3. Webservice2.com
4. Webservice3.com
Currently I can only access the Tomcat Web Application Manager on localhost. How can I get the web application manger to run on the other three hosts.
Tariq
| 0 |
11,410,831 | 07/10/2012 09:58:20 | 1,498,824 | 07/03/2012 12:48:38 | 8 | 0 | reverse an SPlist | I need to use extract the items from a list in reverse order (from last entry to the first, for now I manage to get all the items but form the first to the last. here is part of teh code I am using:
the List is on a different site collection.
using (SPSite oSite = new SPSite("urltolist"))
{
using (SPWeb oWeb = oSite.RootWeb)
{
SPList FItem = oWeb.Lists["List"];
foreach (SPListItem item in FItem.Items)
{
//Display entries
}
}
}
| c# | sharepoint | null | null | null | null | open | reverse an SPlist
===
I need to use extract the items from a list in reverse order (from last entry to the first, for now I manage to get all the items but form the first to the last. here is part of teh code I am using:
the List is on a different site collection.
using (SPSite oSite = new SPSite("urltolist"))
{
using (SPWeb oWeb = oSite.RootWeb)
{
SPList FItem = oWeb.Lists["List"];
foreach (SPListItem item in FItem.Items)
{
//Display entries
}
}
}
| 0 |
11,430,432 | 07/11/2012 10:15:27 | 1,070,213 | 11/28/2011 21:46:24 | 15 | 0 | NSMutableURLRequest with https gives an authenthication failure | The connection request method to url (https://broekzak.xxxx.xx/MobileService/Service.svc/login:), this is a https with a POST method.
If i change it on the server to GET and use the https I can authenticate
If I change it to POST and use the http link I can authenticate
POST and https does not work for some reason.. someone knows why?..
The code:
NSString *postData = @"{}";
NSData *requestData = [postData dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:allAppsURL] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:[NSString stringWithFormat:@"%d", [requestData length]] forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody: requestData];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[connectionDict setObject:connection forKey:@"all"];
THe auth method:
// If the application needs to authenthicate
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
if ([challenge previousFailureCount] == 0) {
NSLog(@"received authentication challenge");
KeychainItemWrapper *keychainItem = [[KeychainItemWrapper alloc] initWithIdentifier:@"TamTam" accessGroup:nil];
NSString *password = [keychainItem objectForKey:kSecValueData];
NSString *username = [keychainItem objectForKey:kSecAttrAccount];
username = [@"tamtam\\" stringByAppendingString:username];
NSURLCredential *newCredential = [[[NSURLCredential alloc] initWithUser:username password:password
persistence:NSURLCredentialPersistenceForSession] autorelease];
NSLog(@"credential created");
[[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge];
NSLog(@"responded to authentication challenge");
}
else {
// pull from server is always two connections, all and sub. To prevent multiple messages from pull do not check sub
if(!(connection == [connectionDict objectForKey:@"sub"])){
[[self delegate] serverConnection:NO process:@"login"];
}
NSLog(@"previous authentication failure");
}
} | ios | xcode | null | null | null | null | open | NSMutableURLRequest with https gives an authenthication failure
===
The connection request method to url (https://broekzak.xxxx.xx/MobileService/Service.svc/login:), this is a https with a POST method.
If i change it on the server to GET and use the https I can authenticate
If I change it to POST and use the http link I can authenticate
POST and https does not work for some reason.. someone knows why?..
The code:
NSString *postData = @"{}";
NSData *requestData = [postData dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:allAppsURL] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:[NSString stringWithFormat:@"%d", [requestData length]] forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody: requestData];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[connectionDict setObject:connection forKey:@"all"];
THe auth method:
// If the application needs to authenthicate
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
if ([challenge previousFailureCount] == 0) {
NSLog(@"received authentication challenge");
KeychainItemWrapper *keychainItem = [[KeychainItemWrapper alloc] initWithIdentifier:@"TamTam" accessGroup:nil];
NSString *password = [keychainItem objectForKey:kSecValueData];
NSString *username = [keychainItem objectForKey:kSecAttrAccount];
username = [@"tamtam\\" stringByAppendingString:username];
NSURLCredential *newCredential = [[[NSURLCredential alloc] initWithUser:username password:password
persistence:NSURLCredentialPersistenceForSession] autorelease];
NSLog(@"credential created");
[[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge];
NSLog(@"responded to authentication challenge");
}
else {
// pull from server is always two connections, all and sub. To prevent multiple messages from pull do not check sub
if(!(connection == [connectionDict objectForKey:@"sub"])){
[[self delegate] serverConnection:NO process:@"login"];
}
NSLog(@"previous authentication failure");
}
} | 0 |
11,430,436 | 07/11/2012 10:15:42 | 1,517,403 | 07/11/2012 10:08:01 | 1 | 0 | URL to open track in SoundCloud iOS app | I would like to open a SoundCloud track in the SoundCloud iOS app. I was under the impression that the correct url scheme to use is `soundcloud:track:[track_id]`.
This opens the SoundCloud app but doesn't select the correct track.
Can anyone shed some light on how to get this functioning correctly | ios | soundcloud | null | null | null | null | open | URL to open track in SoundCloud iOS app
===
I would like to open a SoundCloud track in the SoundCloud iOS app. I was under the impression that the correct url scheme to use is `soundcloud:track:[track_id]`.
This opens the SoundCloud app but doesn't select the correct track.
Can anyone shed some light on how to get this functioning correctly | 0 |
11,430,442 | 07/11/2012 10:15:49 | 1,517,391 | 07/11/2012 10:02:35 | 1 | 0 | When putting an int in a stringstream, it inserts weird characters | I'm trying to use stringstreams for getting ints into a string. I do it like this:
std::string const DilbertImage::startUrl = "http://tjanster.idg.se/dilbertimages/dil";
std::string const DilbertImage::endUrl = ".gif";
DilbertImage::DilbertImage(int d)
{
cal.setDate(d);
int year, month, date;
year = cal.getYear();
month = cal.getMonth();
date = cal.getNumDate();
std::stringstream ss;
ss << year << "/";
if(month < 10)
{
ss << 0;
}
ss << month << "/" << "Dilbert - " << cal.getNumDate() << ".gif";
filePath = ss.str();
ss.str("");
ss.clear();
ss << startUrl << date << endUrl;
url = ss.str();
std::cout << url << '\t' << filePath << std::endl;
}
I expect to get two nice strings that look like this:
url: http://tjanster.idg.se/dilbertimages/dil20060720.gif
filePath: /2006/07/Dilbert - 20060720.gif
But instead when I put the ints in the stringstream they somehow endup getting spaces (or some other blank character inserted in the middle of them) When I paste it from the console window the character shows as a *.
They end up looking like this:
url: http://tjanster.idg.se/dilbertimages/dil20*060*720.gif
filepath: /2*006/07/Dilbert - 20*060*720.gif
Why is this happening?
Here is the whole project: http://pastebin.com/20KF2dNL | c++ | stl | stringstream | null | null | null | open | When putting an int in a stringstream, it inserts weird characters
===
I'm trying to use stringstreams for getting ints into a string. I do it like this:
std::string const DilbertImage::startUrl = "http://tjanster.idg.se/dilbertimages/dil";
std::string const DilbertImage::endUrl = ".gif";
DilbertImage::DilbertImage(int d)
{
cal.setDate(d);
int year, month, date;
year = cal.getYear();
month = cal.getMonth();
date = cal.getNumDate();
std::stringstream ss;
ss << year << "/";
if(month < 10)
{
ss << 0;
}
ss << month << "/" << "Dilbert - " << cal.getNumDate() << ".gif";
filePath = ss.str();
ss.str("");
ss.clear();
ss << startUrl << date << endUrl;
url = ss.str();
std::cout << url << '\t' << filePath << std::endl;
}
I expect to get two nice strings that look like this:
url: http://tjanster.idg.se/dilbertimages/dil20060720.gif
filePath: /2006/07/Dilbert - 20060720.gif
But instead when I put the ints in the stringstream they somehow endup getting spaces (or some other blank character inserted in the middle of them) When I paste it from the console window the character shows as a *.
They end up looking like this:
url: http://tjanster.idg.se/dilbertimages/dil20*060*720.gif
filepath: /2*006/07/Dilbert - 20*060*720.gif
Why is this happening?
Here is the whole project: http://pastebin.com/20KF2dNL | 0 |
11,430,449 | 07/11/2012 10:16:02 | 34,537 | 11/05/2008 03:00:23 | 15,310 | 176 | C++ explicit char/short? | I'd like to pass a char to my function (fn). I DO NOT want ints and shorts to be typecast into it. So i figure i should have the value be implicitly cast into MyInt (which will only support char) then pass into fn. This should work bc IIRC only one typcast is allowed when passing onto function (so char->MyInt is ok while int->char->MyInt shouldn't).
However it appears both int and char work so i figure another layer of indirection (MyInt2) would fix it. Now they both can not be passed into fn... Is there a way where i can have chars passed in but not int?
#include <cstdio>
struct MyInt2{
int v;
MyInt2(char vv){v=vv;}
MyInt2(){}
};
struct MyInt{
MyInt2 v;
MyInt(MyInt2 vv){v=vv;}
};
void fn(MyInt a){
printf("%d", a.v);
}
int main() {
fn(1); //should cause error
fn((char)2); //should NOT cause error
}
| c++ | null | null | null | null | null | open | C++ explicit char/short?
===
I'd like to pass a char to my function (fn). I DO NOT want ints and shorts to be typecast into it. So i figure i should have the value be implicitly cast into MyInt (which will only support char) then pass into fn. This should work bc IIRC only one typcast is allowed when passing onto function (so char->MyInt is ok while int->char->MyInt shouldn't).
However it appears both int and char work so i figure another layer of indirection (MyInt2) would fix it. Now they both can not be passed into fn... Is there a way where i can have chars passed in but not int?
#include <cstdio>
struct MyInt2{
int v;
MyInt2(char vv){v=vv;}
MyInt2(){}
};
struct MyInt{
MyInt2 v;
MyInt(MyInt2 vv){v=vv;}
};
void fn(MyInt a){
printf("%d", a.v);
}
int main() {
fn(1); //should cause error
fn((char)2); //should NOT cause error
}
| 0 |
11,430,463 | 07/11/2012 10:16:49 | 185,041 | 10/06/2009 14:55:26 | 30 | 1 | subversion validation | We use subversion as a source control solution; however couple of my team mates aren't very faithful when it comes to provide a comment while checking in files.
I would like to put a couple of validation like...
A. A comment is mandatory with at least a specified number of characters.
B. Few words must be present in the checking in comment.
C. spaces in file names are rejected.
Is there a way to do so? I tried searching for a solution but it seems that isn't going that well... | svn | null | null | null | null | null | open | subversion validation
===
We use subversion as a source control solution; however couple of my team mates aren't very faithful when it comes to provide a comment while checking in files.
I would like to put a couple of validation like...
A. A comment is mandatory with at least a specified number of characters.
B. Few words must be present in the checking in comment.
C. spaces in file names are rejected.
Is there a way to do so? I tried searching for a solution but it seems that isn't going that well... | 0 |
11,571,824 | 07/20/2012 01:56:00 | 425,377 | 08/19/2010 14:44:27 | 58 | 0 | Excel 2010: Create multiple periodicity stock chart with one database | Currently is creating a stock chart with Excel 2010. However there is a lot of function about Excel 2010 that I dont know about and is not familiar with VBA.
Here is what I want to create. I would like to view my stock chart in multiple periodicity stock chart at one time. To do this I have to create database for each periodicity and automation for the indication need frequent formula update.
With one database, can someone show me how to create multiple periodicity stock chart? | charts | excel-2010 | stock | null | null | null | open | Excel 2010: Create multiple periodicity stock chart with one database
===
Currently is creating a stock chart with Excel 2010. However there is a lot of function about Excel 2010 that I dont know about and is not familiar with VBA.
Here is what I want to create. I would like to view my stock chart in multiple periodicity stock chart at one time. To do this I have to create database for each periodicity and automation for the indication need frequent formula update.
With one database, can someone show me how to create multiple periodicity stock chart? | 0 |
11,571,830 | 07/20/2012 01:57:44 | 1,516,379 | 07/11/2012 01:29:51 | 3 | 0 | WPF Prism - list view and data entry dialog | I have a listview which displays a list of Users (binds to UserListViewModel) - the user can add/edit/delete entries. What I would like to do is have the add button open a new window where the user can enter the new details and save. When the save is successful, I want the window to close and the listview to be refreshed to show the new addition.
What is the best approach for doing this using the MVVM pattern? I've read about using events, modal dialogs, etc, and the accepted answer to [this][1] question had a description of what i'm aiming for, but I can't seem to find an example of how this is implemented.
Can someone provide an example?
[1]: http://stackoverflow.com/a/5356620/1516379 "this" | wpf | mvvm | viewmodel | modal-dialog | null | null | open | WPF Prism - list view and data entry dialog
===
I have a listview which displays a list of Users (binds to UserListViewModel) - the user can add/edit/delete entries. What I would like to do is have the add button open a new window where the user can enter the new details and save. When the save is successful, I want the window to close and the listview to be refreshed to show the new addition.
What is the best approach for doing this using the MVVM pattern? I've read about using events, modal dialogs, etc, and the accepted answer to [this][1] question had a description of what i'm aiming for, but I can't seem to find an example of how this is implemented.
Can someone provide an example?
[1]: http://stackoverflow.com/a/5356620/1516379 "this" | 0 |
11,571,832 | 07/20/2012 01:57:54 | 1,493,339 | 06/30/2012 17:38:18 | 1 | 0 | Javascript: How to "GET" value from dynamic generate input | i use php to generate dynamic input, example generated code
**HTML**
<input type='text' name='name1' onBlur='getValue(1)'>
<input type='text' name='name2' onBlur='getValue(2)'>
<input type='text' name='name3' onBlur='getValue(3)'>
<input type='text' name='name4' onBlur='getValue(4)'>
<input type='text' name='name5' onBlur='getValue(5)'>
or more....
**Javascript**
function getValue(x){
var nam = document.myForm.name[x].value; <<< error?
if(nam>1000){
document.myForm.name[x].focus; <<< error?
alert ("input > 1000");
}
}
What the right way to code the javascript? which i pointed <<< error?
Thanks | javascript | null | null | null | null | null | open | Javascript: How to "GET" value from dynamic generate input
===
i use php to generate dynamic input, example generated code
**HTML**
<input type='text' name='name1' onBlur='getValue(1)'>
<input type='text' name='name2' onBlur='getValue(2)'>
<input type='text' name='name3' onBlur='getValue(3)'>
<input type='text' name='name4' onBlur='getValue(4)'>
<input type='text' name='name5' onBlur='getValue(5)'>
or more....
**Javascript**
function getValue(x){
var nam = document.myForm.name[x].value; <<< error?
if(nam>1000){
document.myForm.name[x].focus; <<< error?
alert ("input > 1000");
}
}
What the right way to code the javascript? which i pointed <<< error?
Thanks | 0 |
11,571,834 | 07/20/2012 01:58:02 | 822,229 | 06/30/2011 02:23:38 | 907 | 3 | How to remove duplicate users from a list but amalgamate their roles | Say I have a list of People who have a name and a list of roles:
Each item in the list is of type PersonDetails:
public class PersonDetails
{
public int Id { get; set; }
public string Name { get; set; }
public List<Role> Roles { get; set; }
}
public class Role
{
public string Name { get; set; }
}
So in my list of these items I might have the following:
1. Id 23 Eric whose roles contains a role with Role.Name = "Manager"
2. Id 23 Eric whose roles contains a role with Role.Name = "CEO"
3. Id 23 Eric whose roles contains a role with Role.Name = "CIO"
so that is how it is currently but because it is the same person I want my list to be:
1. Id 23 Eric whose roles contains "Manager", "CEO", "CIO"
Can anyone tell me how to change my list of items to be like this? | c# | linq | null | null | null | null | open | How to remove duplicate users from a list but amalgamate their roles
===
Say I have a list of People who have a name and a list of roles:
Each item in the list is of type PersonDetails:
public class PersonDetails
{
public int Id { get; set; }
public string Name { get; set; }
public List<Role> Roles { get; set; }
}
public class Role
{
public string Name { get; set; }
}
So in my list of these items I might have the following:
1. Id 23 Eric whose roles contains a role with Role.Name = "Manager"
2. Id 23 Eric whose roles contains a role with Role.Name = "CEO"
3. Id 23 Eric whose roles contains a role with Role.Name = "CIO"
so that is how it is currently but because it is the same person I want my list to be:
1. Id 23 Eric whose roles contains "Manager", "CEO", "CIO"
Can anyone tell me how to change my list of items to be like this? | 0 |
11,571,837 | 07/20/2012 01:58:28 | 583,916 | 01/21/2011 03:41:19 | 822 | 23 | SSH folder/file permissions | Is there away that I can run `chmod` to set the folders at 0755 and the files at 0644? or do I have to go through all folders etc | permissions | ssh | null | null | null | 07/20/2012 03:38:57 | off topic | SSH folder/file permissions
===
Is there away that I can run `chmod` to set the folders at 0755 and the files at 0644? or do I have to go through all folders etc | 2 |
11,571,840 | 07/20/2012 01:58:44 | 951,517 | 09/18/2011 18:14:57 | 261 | 31 | Zend_DB 'large select query' timeout without a reason | I have no idea why the following query would not work with Zend_Db:
SELECT `product`.*, MATCH (name) AGAINST ('>fruit* <(aalbes aardbei* abriko* ananas* appel* avocado* banaan bananen braam bramen bes* citroen* citrusvrucht* cranberr* dadel* drui* frambo* grapefruit* sinaasappel* kers* kiwi* limoen lime mandarijn* mango* meloen* nectarine* olij* passievrucht* peer peren perzik* pruim* sinaasappel* watermeloen*) ~>>>(pak chantilly spacelollies yoghurt frisdrank coebergh >fruitiez tea sultana drink melk* becel)*' IN BOOLEAN MODE) AS `score` FROM `product` WHERE (date_start <= '2012-07-20') AND (date_end >= '2012-07-20') AND (name NOT LIKE '%olvarit%') AND (name NOT LIKE '%soep%') AND (name NOT LIKE '%menu%') AND (name NOT LIKE '%maaltijd%') AND (MATCH (name) AGAINST ('>fruit* <(aalbes aardbei* abriko* ananas* appel* avocado* banaan bananen braam bramen bes* citroen* citrusvrucht* cranberr* dadel* drui* frambo* grapefruit* sinaasappel* kers* kiwi* limoen lime mandarijn* mango* meloen* nectarine* olij* passievrucht* peer peren perzik* pruim* sinaasappel* watermeloen*) ~>>>(pak chantilly spacelollies yoghurt frisdrank coebergh >fruitiez tea sultana drink melk* becel)*' IN BOOLEAN MODE))
Basically it can be generated, but if I try to fetch results the connection with the database goes in a timeout.
So here is the weird thing: It works in phpmyadmin just fine and pretty fast too. Also.. it works fine with the Zend_DB when it is a little smaller (i.e some less keywords). The thing is that I cannot find anywhere in Zend_DB documentation that queries should be limited in size or whatever. So anyone knows a solution?
With:
$mysqli = new mysqli('localhost', 'root', '', 'table');
$r = $mysqli->query($not_really_big_query_but_zend_db_thinks_it_is);
$p = array();
while ($row = $r->fetch_assoc()){
$p[] = $row;
}
Everything goes smooth as expected, no problems with how big my query is whatsoever. So what is Zend_db doing wrong. I don't really want to rewrite everything back.
Extra information: Xampp (with php 5.3) on a Windows PC. (gotta rhyme eh) | zend-db | zend-db-table | null | null | null | null | open | Zend_DB 'large select query' timeout without a reason
===
I have no idea why the following query would not work with Zend_Db:
SELECT `product`.*, MATCH (name) AGAINST ('>fruit* <(aalbes aardbei* abriko* ananas* appel* avocado* banaan bananen braam bramen bes* citroen* citrusvrucht* cranberr* dadel* drui* frambo* grapefruit* sinaasappel* kers* kiwi* limoen lime mandarijn* mango* meloen* nectarine* olij* passievrucht* peer peren perzik* pruim* sinaasappel* watermeloen*) ~>>>(pak chantilly spacelollies yoghurt frisdrank coebergh >fruitiez tea sultana drink melk* becel)*' IN BOOLEAN MODE) AS `score` FROM `product` WHERE (date_start <= '2012-07-20') AND (date_end >= '2012-07-20') AND (name NOT LIKE '%olvarit%') AND (name NOT LIKE '%soep%') AND (name NOT LIKE '%menu%') AND (name NOT LIKE '%maaltijd%') AND (MATCH (name) AGAINST ('>fruit* <(aalbes aardbei* abriko* ananas* appel* avocado* banaan bananen braam bramen bes* citroen* citrusvrucht* cranberr* dadel* drui* frambo* grapefruit* sinaasappel* kers* kiwi* limoen lime mandarijn* mango* meloen* nectarine* olij* passievrucht* peer peren perzik* pruim* sinaasappel* watermeloen*) ~>>>(pak chantilly spacelollies yoghurt frisdrank coebergh >fruitiez tea sultana drink melk* becel)*' IN BOOLEAN MODE))
Basically it can be generated, but if I try to fetch results the connection with the database goes in a timeout.
So here is the weird thing: It works in phpmyadmin just fine and pretty fast too. Also.. it works fine with the Zend_DB when it is a little smaller (i.e some less keywords). The thing is that I cannot find anywhere in Zend_DB documentation that queries should be limited in size or whatever. So anyone knows a solution?
With:
$mysqli = new mysqli('localhost', 'root', '', 'table');
$r = $mysqli->query($not_really_big_query_but_zend_db_thinks_it_is);
$p = array();
while ($row = $r->fetch_assoc()){
$p[] = $row;
}
Everything goes smooth as expected, no problems with how big my query is whatsoever. So what is Zend_db doing wrong. I don't really want to rewrite everything back.
Extra information: Xampp (with php 5.3) on a Windows PC. (gotta rhyme eh) | 0 |
11,571,842 | 07/20/2012 01:59:24 | 798,452 | 06/14/2011 20:25:46 | 655 | 36 | Upstart script with gunicorn not running | I'm trying to create an upstart script that will run gunicorn and it doesnt appear to be running. (Ubuntu 11.10 btw)
this is my test.sh script that starts gunicorn(it starts the server fine when I simply run it):
#!/bin/bash
set -e
LOGFILE=/www/mysite/mysite.log
LOGDIR=$(dirname $LOGFILE)
NUM_WORKERS=3
PORT=8000
BIND_IP=127.0.0.1:$PORT
SETTINGS_FILE=/www/mysite/settings_local.py
# user/group to run as
USER=myusername
test -d $LOGDIR || mkdir -p $LOGDIR
#sorry about the long line, it just adds all the above params
exec gunicorn_django --workers $NUM_WORKERS \--user=$USER --group=$GROUP --log-level=debug \--log-file=$LOGFILE 2>>$LOGFILE --bind $BIND_IP $SETTINGS_FILE
my runserver.conf file looks like this:
start on runlevel [2345]
stop on runlevel [06]
expect fork
respawn
respawn limit 10 5
exec /www/mysite/gunistart.sh
'sudo service runserver start' doesnt do anything (it starts the service but my script is never called)
'service runserver start' as nonroot gets me the error
> start: Rejected send message, 1 matched rules; type="method_call", sender=":1.3" (uid=1000 pid=1049 comm="start rtb ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")
any thoughts?
| ubuntu | gunicorn | upstart | null | null | null | open | Upstart script with gunicorn not running
===
I'm trying to create an upstart script that will run gunicorn and it doesnt appear to be running. (Ubuntu 11.10 btw)
this is my test.sh script that starts gunicorn(it starts the server fine when I simply run it):
#!/bin/bash
set -e
LOGFILE=/www/mysite/mysite.log
LOGDIR=$(dirname $LOGFILE)
NUM_WORKERS=3
PORT=8000
BIND_IP=127.0.0.1:$PORT
SETTINGS_FILE=/www/mysite/settings_local.py
# user/group to run as
USER=myusername
test -d $LOGDIR || mkdir -p $LOGDIR
#sorry about the long line, it just adds all the above params
exec gunicorn_django --workers $NUM_WORKERS \--user=$USER --group=$GROUP --log-level=debug \--log-file=$LOGFILE 2>>$LOGFILE --bind $BIND_IP $SETTINGS_FILE
my runserver.conf file looks like this:
start on runlevel [2345]
stop on runlevel [06]
expect fork
respawn
respawn limit 10 5
exec /www/mysite/gunistart.sh
'sudo service runserver start' doesnt do anything (it starts the service but my script is never called)
'service runserver start' as nonroot gets me the error
> start: Rejected send message, 1 matched rules; type="method_call", sender=":1.3" (uid=1000 pid=1049 comm="start rtb ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")
any thoughts?
| 0 |
11,594,459 | 07/21/2012 17:40:18 | 883,752 | 08/08/2011 09:32:21 | 40 | 0 | Jquery code only working into opera why? and how to fix? | i was coding around and with some help i could make this code to make a dropdown menu wich works as i want but only in Opera.. it refuses to work OK in all the other browsers.. I've been serching the problem but i'm not rally good at JavaScript. Actually i'm using the jquery cookie free script downloaded from internet wich helps me to save as cookies the visited pages, but the problem on ie an ffox is taht the browser don't even open down the tabs, when i do the mouseover only the font color canges but the background is stack on the original color.. Please can help me with that?
$("div.sdmenu p").mouseover(function(){
$(this).css({backgroundColor:"#861b1b"});
$(this).mouseout(function(){
$(this).css({backgroundColor:"#eee"});
});
});
$("div.sdmenu a.principal").mouseover(function(){
$(this).css({backgroundColor:"#861b1b"});
$(this).mouseout(function(){
$(this).css({backgroundColor:"#eee"});
});
});
$("div.sdmenu a.comp").mouseover(function(){
$(this).css({backgroundColor:"#861b1b"});
$(this).mouseout(function(){
$(this).css({backgroundColor:"#eee"});
});
});
$(document).ready(function(){
var cookie = $.cookie("actual");
if(cookie != null){
$("#"+cookie).show().$.cookie("actual" , null);
}
});
$("div.menu_body a").click(function(){
$.cookie("actual",$(this).parent().attr("id"));
});
$(".principal").click(function()
{
$(this).next("div.menu_body").slideToggle(300).siblings("div.menu_body").slideUp("slow");
$(this).siblings().css({backgroundColor:"#eee"}); $.cookie("actual", $(this).next("div.menu_body").attr('id'));
$(".title").css({backgroundColor:"#FFF"});
});
$(".supertext").click(function() {
var url = $(this).attr("href");
var index = url.indexOf('?');
var vars = url.substring(index + 1, url.length).split('&');
var params = {} ;
for(var i = 0; i < vars.length; i ++)
{
var param = vars[i].split('=');
params[param[0]] = param[1];
}
$.cookie("actual" , params.ref);
});
| javascript | jquery | cookies | null | null | null | open | Jquery code only working into opera why? and how to fix?
===
i was coding around and with some help i could make this code to make a dropdown menu wich works as i want but only in Opera.. it refuses to work OK in all the other browsers.. I've been serching the problem but i'm not rally good at JavaScript. Actually i'm using the jquery cookie free script downloaded from internet wich helps me to save as cookies the visited pages, but the problem on ie an ffox is taht the browser don't even open down the tabs, when i do the mouseover only the font color canges but the background is stack on the original color.. Please can help me with that?
$("div.sdmenu p").mouseover(function(){
$(this).css({backgroundColor:"#861b1b"});
$(this).mouseout(function(){
$(this).css({backgroundColor:"#eee"});
});
});
$("div.sdmenu a.principal").mouseover(function(){
$(this).css({backgroundColor:"#861b1b"});
$(this).mouseout(function(){
$(this).css({backgroundColor:"#eee"});
});
});
$("div.sdmenu a.comp").mouseover(function(){
$(this).css({backgroundColor:"#861b1b"});
$(this).mouseout(function(){
$(this).css({backgroundColor:"#eee"});
});
});
$(document).ready(function(){
var cookie = $.cookie("actual");
if(cookie != null){
$("#"+cookie).show().$.cookie("actual" , null);
}
});
$("div.menu_body a").click(function(){
$.cookie("actual",$(this).parent().attr("id"));
});
$(".principal").click(function()
{
$(this).next("div.menu_body").slideToggle(300).siblings("div.menu_body").slideUp("slow");
$(this).siblings().css({backgroundColor:"#eee"}); $.cookie("actual", $(this).next("div.menu_body").attr('id'));
$(".title").css({backgroundColor:"#FFF"});
});
$(".supertext").click(function() {
var url = $(this).attr("href");
var index = url.indexOf('?');
var vars = url.substring(index + 1, url.length).split('&');
var params = {} ;
for(var i = 0; i < vars.length; i ++)
{
var param = vars[i].split('=');
params[param[0]] = param[1];
}
$.cookie("actual" , params.ref);
});
| 0 |
11,594,462 | 07/21/2012 17:40:29 | 998,879 | 10/17/2011 09:26:46 | 91 | 1 | Querying a repeated property by count in NDB | Is there an efficient mechanism for querying by the number of items in a repeated property in NDB?
I'd like to do something like:
Class.query(class.repeated_property.count == 2)
but of course this doesn't work. | google-app-engine | app-engine-ndb | null | null | null | null | open | Querying a repeated property by count in NDB
===
Is there an efficient mechanism for querying by the number of items in a repeated property in NDB?
I'd like to do something like:
Class.query(class.repeated_property.count == 2)
but of course this doesn't work. | 0 |
11,594,465 | 07/21/2012 17:40:44 | 484,230 | 10/22/2010 13:02:24 | 815 | 29 | Why does std::runtime_error::what() return const char* instead of std::string const& | Why does `std::runtime_error::what()` return `const char*` instead of `std::string const&` ?
In many cases a direct return of a reference to the embedded string would be handy and it could avoid some overhead. So what is the rationale for not returning e.g. a const reference to the internal string in the first place and not offering an overloaded function ? I guess it goes along with a string ctor being able to throw an exception as well but I do not see the risk of returning a string reference. | c++ | string | exception | null | null | null | open | Why does std::runtime_error::what() return const char* instead of std::string const&
===
Why does `std::runtime_error::what()` return `const char*` instead of `std::string const&` ?
In many cases a direct return of a reference to the embedded string would be handy and it could avoid some overhead. So what is the rationale for not returning e.g. a const reference to the internal string in the first place and not offering an overloaded function ? I guess it goes along with a string ctor being able to throw an exception as well but I do not see the risk of returning a string reference. | 0 |
11,594,468 | 07/21/2012 17:40:58 | 670,017 | 03/21/2011 19:13:20 | 1,172 | 14 | ASP.NET "A generic error occurred in GDI+" only happens for PNG images on Vista machine | I've been searching for a resolution to this vexing problem and found quite a few answers, which unfortunately don't seem to work for me.
I have the following ASP.NET code that should output an image to the web browser as either JPEG or PNG:
public partial class MyImg : System.Web.UI.Page
{
private System.Drawing.Graphics gfx;
private Bitmap bmp;
protected void finalizeOutput(MyImageType imageType)
{
//Get image type
ImageFormat imgFmt;
string strContentType;
switch (imageType)
{
case MyImageType.SCGIT_GIF:
strContentType = "image/gif";
imgFmt = ImageFormat.Gif;
break;
case MyImageType.SCGIT_PNG:
strContentType = "image/png";
imgFmt = ImageFormat.Png;
break;
default:
strContentType = "image/jpeg";
imgFmt = ImageFormat.Jpeg;
break;
}
//Finalizing and Cleaning Up
Response.ContentType = strContentType;
bmp.Save(Response.OutputStream, imgFmt); //THROWS EXCEPTION for png type: "A generic error occurred in GDI+."
bmp.Dispose();
gfx.Dispose();
Response.End();
}
}
What happens is that the above method works flawlessly from my VS2010 development IIS installed on Windows 7, but when I try the exact same code on Vista, it throws the "A generic error occurred in GDI+" exception, but only for the image type PNG, it works OK for JPEG.
Any idea how to solve this? | c# | asp.net | gdi+ | null | null | null | open | ASP.NET "A generic error occurred in GDI+" only happens for PNG images on Vista machine
===
I've been searching for a resolution to this vexing problem and found quite a few answers, which unfortunately don't seem to work for me.
I have the following ASP.NET code that should output an image to the web browser as either JPEG or PNG:
public partial class MyImg : System.Web.UI.Page
{
private System.Drawing.Graphics gfx;
private Bitmap bmp;
protected void finalizeOutput(MyImageType imageType)
{
//Get image type
ImageFormat imgFmt;
string strContentType;
switch (imageType)
{
case MyImageType.SCGIT_GIF:
strContentType = "image/gif";
imgFmt = ImageFormat.Gif;
break;
case MyImageType.SCGIT_PNG:
strContentType = "image/png";
imgFmt = ImageFormat.Png;
break;
default:
strContentType = "image/jpeg";
imgFmt = ImageFormat.Jpeg;
break;
}
//Finalizing and Cleaning Up
Response.ContentType = strContentType;
bmp.Save(Response.OutputStream, imgFmt); //THROWS EXCEPTION for png type: "A generic error occurred in GDI+."
bmp.Dispose();
gfx.Dispose();
Response.End();
}
}
What happens is that the above method works flawlessly from my VS2010 development IIS installed on Windows 7, but when I try the exact same code on Vista, it throws the "A generic error occurred in GDI+" exception, but only for the image type PNG, it works OK for JPEG.
Any idea how to solve this? | 0 |
775,793 | 04/22/2009 05:18:50 | 48,810 | 12/24/2008 03:18:21 | 82 | 4 | WPF bind control size | I have a StackPanel with a list of custom user controlls that I would like to resize. I would like the user to be able to drag a slider and scale the control size up and down.
Is there a way to bind the control width to a slider value? Something similar to:
<MyControl Width="{Binding Path=SizeSlider.SelectedValue}"/>
Is this possible? Or should I just iterate through the controls and manually set the size whenever the slider value changes? | wpf | xaml | data-binding | .net | null | null | open | WPF bind control size
===
I have a StackPanel with a list of custom user controlls that I would like to resize. I would like the user to be able to drag a slider and scale the control size up and down.
Is there a way to bind the control width to a slider value? Something similar to:
<MyControl Width="{Binding Path=SizeSlider.SelectedValue}"/>
Is this possible? Or should I just iterate through the controls and manually set the size whenever the slider value changes? | 0 |
11,594,413 | 07/21/2012 17:35:29 | 940,936 | 09/12/2011 15:51:03 | 136 | 3 | Loading properties from JSON, getting "message sent to deallocated instance" | So I load my custom object from a web service and am trying to store the properties as NSStrings but keep running into this error:
-[CFString _cfTypeID]: message sent to deallocated instance 0x100d3d40
-[CFString retain]: message sent to deallocated instance 0x100d3d40
I enabled zombies, but that's not really showing me a solution.
My properties are defined as:
@property (strong, nonatomic) NSString *title;
@property (assign, nonatomic) NSString *ID;
@property (strong, nonatomic) NSString *redLabel;
@property (strong, nonatomic) NSString *greenLabel;
Then I create an instance of my object and call the webservice
QuickList *list = [[QuickList alloc] init];
[list loadLatestQuickList];
And finally, inside <code>loadLatestQuickList</code>...
NSURLRequest *request = // create a GET request...
[NSURLConnection sendAsynchronousRequest:request queue:notMainQueue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error){
NSError *parsingError;
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&parsingError];
if (!parsingError && [json isKindOfClass:[NSDictionary class]]) {
NSDictionary *dataDictionary = [json objectForKey:@"data"];
NSDictionary *quickListDictionary = [dataDictionary objectForKey:@"QuickList"];
NSString *ID = [quickListDictionary objectForKey:@"id"];
NSString *title = [quickListDictionary objectForKey:@"name"];
NSString *redLabel = [quickListDictionary objectForKey:@"red_label"];
NSString *greenLabel = [quickListDictionary objectForKey:@"green_label"];
self.ID = ID;
self.title = title;
self.redLabel = redLabel;
self.greenLabel = greenLabel;
// tell a channel that everything is loaded
}
else {
NSLog(@"%@",parsingError);
}
}];
Now whenever I try to access <code>list.ID</code> or some other property I get the "deallocated instance" error. Any thoughts as to why I'm getting this error? | objective-c | ios | automatic-ref-counting | null | null | null | open | Loading properties from JSON, getting "message sent to deallocated instance"
===
So I load my custom object from a web service and am trying to store the properties as NSStrings but keep running into this error:
-[CFString _cfTypeID]: message sent to deallocated instance 0x100d3d40
-[CFString retain]: message sent to deallocated instance 0x100d3d40
I enabled zombies, but that's not really showing me a solution.
My properties are defined as:
@property (strong, nonatomic) NSString *title;
@property (assign, nonatomic) NSString *ID;
@property (strong, nonatomic) NSString *redLabel;
@property (strong, nonatomic) NSString *greenLabel;
Then I create an instance of my object and call the webservice
QuickList *list = [[QuickList alloc] init];
[list loadLatestQuickList];
And finally, inside <code>loadLatestQuickList</code>...
NSURLRequest *request = // create a GET request...
[NSURLConnection sendAsynchronousRequest:request queue:notMainQueue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error){
NSError *parsingError;
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&parsingError];
if (!parsingError && [json isKindOfClass:[NSDictionary class]]) {
NSDictionary *dataDictionary = [json objectForKey:@"data"];
NSDictionary *quickListDictionary = [dataDictionary objectForKey:@"QuickList"];
NSString *ID = [quickListDictionary objectForKey:@"id"];
NSString *title = [quickListDictionary objectForKey:@"name"];
NSString *redLabel = [quickListDictionary objectForKey:@"red_label"];
NSString *greenLabel = [quickListDictionary objectForKey:@"green_label"];
self.ID = ID;
self.title = title;
self.redLabel = redLabel;
self.greenLabel = greenLabel;
// tell a channel that everything is loaded
}
else {
NSLog(@"%@",parsingError);
}
}];
Now whenever I try to access <code>list.ID</code> or some other property I get the "deallocated instance" error. Any thoughts as to why I'm getting this error? | 0 |
11,594,359 | 07/21/2012 17:29:46 | 1,070,609 | 11/29/2011 05:05:05 | 254 | 6 | Codeigniter URL rewrite --- Something strange | I just re-writed using htaccess ( with that I just removed the index.php part )
I just got a URL like this
http://localhost/mvc/movies/movie/3237-Movie-name-here
where
mvc - this root folder
movies - controller
movie - view
3237- Query string for getting from DB ( pk)
Movie-name - for SEO URL
with this I can get the movie details with pk 3237
Now I just need to rewrite this url to ( using htaccess )
http://localhost/mvc/movie/3237-Movie-name-here
Please help
Thanks | .htaccess | codeigniter | mod-rewrite | url-rewriting | null | null | open | Codeigniter URL rewrite --- Something strange
===
I just re-writed using htaccess ( with that I just removed the index.php part )
I just got a URL like this
http://localhost/mvc/movies/movie/3237-Movie-name-here
where
mvc - this root folder
movies - controller
movie - view
3237- Query string for getting from DB ( pk)
Movie-name - for SEO URL
with this I can get the movie details with pk 3237
Now I just need to rewrite this url to ( using htaccess )
http://localhost/mvc/movie/3237-Movie-name-here
Please help
Thanks | 0 |
11,373,314 | 07/07/2012 07:53:44 | 771,226 | 05/26/2011 11:40:27 | 167 | 4 | referencing the facebook sdk project in SSO application | ![Error while referencing the project][1]
Hi,
I am referring this tutorial to create facebook single sign on
[tutorial][1]https://developers.facebook.com/docs/mobile/android/build/
.I have setup the environment and when I have moved to step 4 of this tutorial i.e. referring the sdk project created in last step in my facebook app then I am getting this error attached screen shot.Please help me to add this referring to the facebook app.
Thanks,
Amandeep
[1]: http://i.stack.imgur.com/bedw3.jpg | java | android | facebook | eclipse | null | null | open | referencing the facebook sdk project in SSO application
===
![Error while referencing the project][1]
Hi,
I am referring this tutorial to create facebook single sign on
[tutorial][1]https://developers.facebook.com/docs/mobile/android/build/
.I have setup the environment and when I have moved to step 4 of this tutorial i.e. referring the sdk project created in last step in my facebook app then I am getting this error attached screen shot.Please help me to add this referring to the facebook app.
Thanks,
Amandeep
[1]: http://i.stack.imgur.com/bedw3.jpg | 0 |
11,373,315 | 07/07/2012 07:53:47 | 953,702 | 09/19/2011 23:41:14 | 90 | 3 | Mediaelement.js - Unexpected Behavior When Using <video> And Mp3 | I'm playing around with [mediaelement.js](http://www.mediaelementjs.com/) and it seems to be working well for videos, but I get some odd behavior when using `<video>` and mp3s.
<video controls poster="media/120701Video.jpg">
<source src="media/AreYouHurting-Death.mp3" type="audio/mpeg">
</video>
<script>
jQuery(document).ready(function($) {
$('video,audio').mediaelementplayer({
// if the <video width> is not specified, this is the default
defaultVideoWidth: 640,
// if the <video height> is not specified, this is the default
defaultVideoHeight: 360,
// if set, overrides <video width>
videoWidth: -1,
// if set, overrides <video height>
videoHeight: -1,
// width of audio player
audioWidth: 640,
// height of audio player
audioHeight: 30,
// initial volume when the player starts
startVolume: 0.8,
// useful for <audio> player loops
loop: false,
// enables Flash and Silverlight to resize to content size
enableAutosize: true,
// the order of controls you want on the control bar (and other plugins below)
features: ['playpause','progress','current','duration','tracks','volume','fullscreen'],
// Hide controls when playing and mouse is not over the video
alwaysShowControls: true,
// force iPad's native controls
iPadUseNativeControls: false,
// force iPhone's native controls
iPhoneUseNativeControls: false,
// force Android's native controls
AndroidUseNativeControls: false,
// forces the hour marker (##:00:00)
alwaysShowHours: false,
// show framecount in timecode (##:00:00:00)
showTimecodeFrameCount: false,
// used when showTimecodeFrameCount is set to true
framesPerSecond: 25,
// turns keyboard support on and off for this instance
enableKeyboard: true,
// when this player starts, it will pause other players
pauseOtherPlayers: true,
// array of keyboard commands
keyActions: []
});
});
</script>
If I use `<audio>`, everything is normal (except I don't have the ability to have a poster defined).
The odd behavior is as follows...
- Firefox / Opera won't play the file (the the whole file downloads by how the progress bar looks but the counter never leaves 00:00)
- Chrome shrinks it down to `<audio>` size
The logical choice would be to use `<audio>`, but I want the posters (for instance, so show cover art while an album is playing). | html5-video | mediaelement.js | null | null | null | null | open | Mediaelement.js - Unexpected Behavior When Using <video> And Mp3
===
I'm playing around with [mediaelement.js](http://www.mediaelementjs.com/) and it seems to be working well for videos, but I get some odd behavior when using `<video>` and mp3s.
<video controls poster="media/120701Video.jpg">
<source src="media/AreYouHurting-Death.mp3" type="audio/mpeg">
</video>
<script>
jQuery(document).ready(function($) {
$('video,audio').mediaelementplayer({
// if the <video width> is not specified, this is the default
defaultVideoWidth: 640,
// if the <video height> is not specified, this is the default
defaultVideoHeight: 360,
// if set, overrides <video width>
videoWidth: -1,
// if set, overrides <video height>
videoHeight: -1,
// width of audio player
audioWidth: 640,
// height of audio player
audioHeight: 30,
// initial volume when the player starts
startVolume: 0.8,
// useful for <audio> player loops
loop: false,
// enables Flash and Silverlight to resize to content size
enableAutosize: true,
// the order of controls you want on the control bar (and other plugins below)
features: ['playpause','progress','current','duration','tracks','volume','fullscreen'],
// Hide controls when playing and mouse is not over the video
alwaysShowControls: true,
// force iPad's native controls
iPadUseNativeControls: false,
// force iPhone's native controls
iPhoneUseNativeControls: false,
// force Android's native controls
AndroidUseNativeControls: false,
// forces the hour marker (##:00:00)
alwaysShowHours: false,
// show framecount in timecode (##:00:00:00)
showTimecodeFrameCount: false,
// used when showTimecodeFrameCount is set to true
framesPerSecond: 25,
// turns keyboard support on and off for this instance
enableKeyboard: true,
// when this player starts, it will pause other players
pauseOtherPlayers: true,
// array of keyboard commands
keyActions: []
});
});
</script>
If I use `<audio>`, everything is normal (except I don't have the ability to have a poster defined).
The odd behavior is as follows...
- Firefox / Opera won't play the file (the the whole file downloads by how the progress bar looks but the counter never leaves 00:00)
- Chrome shrinks it down to `<audio>` size
The logical choice would be to use `<audio>`, but I want the posters (for instance, so show cover art while an album is playing). | 0 |
11,373,317 | 07/07/2012 07:53:55 | 1,503,607 | 07/05/2012 09:57:00 | 3 | 0 | Can't Understand Controllers of MVC in Zend Framework | I'm a novice to php5 and Zend Framework and I'm using Zend Studio. I have gone through many documentations but I still can't understand the concept behind the controllers in Zend.
To explain in short, I'm trying to develop a small web application for accounts handling. I have not made any changes to the default index.php file. here it is:
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
||define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv ('APPLICATION_ENV'): 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/* function _initView()
{
$view = new Zend_View();
$view->addScriptPath(APPLICATION_PATH . '/views/scripts/');
} */
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();
here is my IndexController.php
<?php
class IndexController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
}
}
I haven't done any changes there also, as I can't understand the concept.
my index.phtml :
<html>
<style>
</style>
<body>
<img alt="" src="http://localhost/Accounts/application/views/scripts/images/logo.png">
<div id="text" >
<h1>Welcome</h1><br><hr>
<h4>Please Log In To View The Main Page</h4></div><br><br><br>
<form action="main/main" method="post"><center><table>
<tr>
<td>User Name :</td> <td><input type="text" name="uname"/></td>
</tr>
<tr>
<td>Passowrd :</td> <td><input type="password" name="pwd"/></td>
</tr>
<tr>
<td><center><input type="submit" value="Log In"/></center></td> <td><center><input type="reset" value="Cancel"/></center></td>
</tr>
</table></center></form>
</body>
</html>
**please note that I have specified
<form action="main/main">
to go to the next page , which is "main.phtml".
But this doesn't work.
here is my MainController.php:
<?php
require_once ('library/Zend/Controller/Action.php');
class MainController extends Zend_Controller_Action {
public function init()
{
/* Initialize action controller here */
}
public function indexAction(){
}
public function mainAction()
{
include 'views/scripts/main/main.phtml';
}
}
in the above controller, if I specify,
include 'views/scripts/main/main.phtml';
or not, it works the same.
On the browser, nothing is displayed when I tried to login.
As I have not specified any criteria to the log in, I think this should display the main.phtml.
here it is:
<html xmlns="http://www.w3.org/1999/xhtml" lang = "en">
<style>
</style>
<head>
<meta name="keywords" content="" /></meta>
<meta name="description" content="" /></meta>
<link rel="shortcut icon" href="http://localhost/Accounts/application/views/scripts/images/favicon.ico" >
<title>Accounts Handling</title>
</head>
<body>
<div id="header"></div>
<div id="main">
<div id="menu">
<?php include ('C:\wamp\www\Accounts\application\views\scripts\header\header.php');?>
</div>
<div id="content">
<center><img src="http://localhost/Accounts/application/views/scripts/images/accounts.jpg" alt="image" height=600px width=550px/></center>
</div>
<div>
<?php include ('C:\wamp\www\Accounts\application\views\scripts\footer\footer.php');?>
</div>
</div>
</body>
</html>
What's wrong in my code? Why doesn't this work?
what I need to understand how these controllers work. How do they link the views?
I know the post is quite lengthy, but I'm really in need of finding a solution.. please help me with this...
Thanks in advance
Charu | zend-framework | php5 | zend-studio | null | null | null | open | Can't Understand Controllers of MVC in Zend Framework
===
I'm a novice to php5 and Zend Framework and I'm using Zend Studio. I have gone through many documentations but I still can't understand the concept behind the controllers in Zend.
To explain in short, I'm trying to develop a small web application for accounts handling. I have not made any changes to the default index.php file. here it is:
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
||define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv ('APPLICATION_ENV'): 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/* function _initView()
{
$view = new Zend_View();
$view->addScriptPath(APPLICATION_PATH . '/views/scripts/');
} */
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();
here is my IndexController.php
<?php
class IndexController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
}
}
I haven't done any changes there also, as I can't understand the concept.
my index.phtml :
<html>
<style>
</style>
<body>
<img alt="" src="http://localhost/Accounts/application/views/scripts/images/logo.png">
<div id="text" >
<h1>Welcome</h1><br><hr>
<h4>Please Log In To View The Main Page</h4></div><br><br><br>
<form action="main/main" method="post"><center><table>
<tr>
<td>User Name :</td> <td><input type="text" name="uname"/></td>
</tr>
<tr>
<td>Passowrd :</td> <td><input type="password" name="pwd"/></td>
</tr>
<tr>
<td><center><input type="submit" value="Log In"/></center></td> <td><center><input type="reset" value="Cancel"/></center></td>
</tr>
</table></center></form>
</body>
</html>
**please note that I have specified
<form action="main/main">
to go to the next page , which is "main.phtml".
But this doesn't work.
here is my MainController.php:
<?php
require_once ('library/Zend/Controller/Action.php');
class MainController extends Zend_Controller_Action {
public function init()
{
/* Initialize action controller here */
}
public function indexAction(){
}
public function mainAction()
{
include 'views/scripts/main/main.phtml';
}
}
in the above controller, if I specify,
include 'views/scripts/main/main.phtml';
or not, it works the same.
On the browser, nothing is displayed when I tried to login.
As I have not specified any criteria to the log in, I think this should display the main.phtml.
here it is:
<html xmlns="http://www.w3.org/1999/xhtml" lang = "en">
<style>
</style>
<head>
<meta name="keywords" content="" /></meta>
<meta name="description" content="" /></meta>
<link rel="shortcut icon" href="http://localhost/Accounts/application/views/scripts/images/favicon.ico" >
<title>Accounts Handling</title>
</head>
<body>
<div id="header"></div>
<div id="main">
<div id="menu">
<?php include ('C:\wamp\www\Accounts\application\views\scripts\header\header.php');?>
</div>
<div id="content">
<center><img src="http://localhost/Accounts/application/views/scripts/images/accounts.jpg" alt="image" height=600px width=550px/></center>
</div>
<div>
<?php include ('C:\wamp\www\Accounts\application\views\scripts\footer\footer.php');?>
</div>
</div>
</body>
</html>
What's wrong in my code? Why doesn't this work?
what I need to understand how these controllers work. How do they link the views?
I know the post is quite lengthy, but I'm really in need of finding a solution.. please help me with this...
Thanks in advance
Charu | 0 |
11,373,318 | 07/07/2012 07:53:56 | 1,451,479 | 06/12/2012 14:27:20 | 17 | 0 | PHP, ArrayObject, getIterator(); | I am trying to understand what **getIterator()** is,I will explain:
As i know getIterator is a Method we call to include an external Iterator,
The problem is getIterator include **it's own methods** the closes think looks the same is Iterator interface but it can't be an interface it can be class but i am trying to search it inside the SPL.php source code and didn't find any, I mabye making this more complicated then it's really is, I will be happy if some one can help me understand where it is at the SPL.php source code and what is it(class,etc), Thank you all and have a nice day. | php | spl | arrayobject | null | null | null | open | PHP, ArrayObject, getIterator();
===
I am trying to understand what **getIterator()** is,I will explain:
As i know getIterator is a Method we call to include an external Iterator,
The problem is getIterator include **it's own methods** the closes think looks the same is Iterator interface but it can't be an interface it can be class but i am trying to search it inside the SPL.php source code and didn't find any, I mabye making this more complicated then it's really is, I will be happy if some one can help me understand where it is at the SPL.php source code and what is it(class,etc), Thank you all and have a nice day. | 0 |
11,373,323 | 07/07/2012 07:54:54 | 1,425,745 | 05/30/2012 10:04:03 | 8 | 0 | how to create java class on json data? | {
"data": [
{
"name": "acac",
"id": "00000"
},
{
"name": "adcd",
"id": "1111111"
}
],
"paging": {
"next": "https://graph.facebook.com/00000000/friends?...."
}
}
I am trying to get facebook friends list in my android app.I am getting friends list as json data.now my question is how to create java class from json data.I already created two classes for "data" and "paging".I am stucked in how to use both of this class while parsing.
Thanks in advance | android | facebook | json | null | null | null | open | how to create java class on json data?
===
{
"data": [
{
"name": "acac",
"id": "00000"
},
{
"name": "adcd",
"id": "1111111"
}
],
"paging": {
"next": "https://graph.facebook.com/00000000/friends?...."
}
}
I am trying to get facebook friends list in my android app.I am getting friends list as json data.now my question is how to create java class from json data.I already created two classes for "data" and "paging".I am stucked in how to use both of this class while parsing.
Thanks in advance | 0 |
11,373,324 | 07/07/2012 07:54:57 | 1,508,410 | 07/07/2012 07:38:31 | 1 | 0 | How to select a node that has not attributes but has a specific value in XML | I have stored a specific number in a variable ($ResId) from one part of an XML file, and I have the following in a different section.
<CalculatedWho>
<ResourceId>85</ResourceId>
<ResourceId>49</ResourceId>
<ResourceId>43</ResourceId>
<ResourceId>41</ResourceId>
</CalculatedWho>
If any of these match the number stored in the variable, I would then perform a particular task. I've tried the following and several other things, but have yet to get it right.
<xsl:for-each select="//StrategyPool/Strategy">
<xsl:if test="//StrategyPool/Strategy/CalculatedWho/ResourceId[text()=$ResId]" >
<xsl:value-of select="StrategyName"/>
</xsl:if>
</xsl:for-each>
| xml | null | null | null | null | null | open | How to select a node that has not attributes but has a specific value in XML
===
I have stored a specific number in a variable ($ResId) from one part of an XML file, and I have the following in a different section.
<CalculatedWho>
<ResourceId>85</ResourceId>
<ResourceId>49</ResourceId>
<ResourceId>43</ResourceId>
<ResourceId>41</ResourceId>
</CalculatedWho>
If any of these match the number stored in the variable, I would then perform a particular task. I've tried the following and several other things, but have yet to get it right.
<xsl:for-each select="//StrategyPool/Strategy">
<xsl:if test="//StrategyPool/Strategy/CalculatedWho/ResourceId[text()=$ResId]" >
<xsl:value-of select="StrategyName"/>
</xsl:if>
</xsl:for-each>
| 0 |
11,373,331 | 07/07/2012 07:55:32 | 682,901 | 03/29/2011 21:33:56 | 112 | 5 | Overlapping hover decoration | Given the following images, I'm really not sure how best to approach this issue.
![enter image description here][1]
![enter image description here][2]
![enter image description here][3]
![enter image description here][4]
I mean I could make a sprite image and position each link/icon absolute so that when the hover state occurs they don't push each other. However the problem is the clickable area will grow with the hover state thereby overlapping the other buttons and making them hard to click.
Any suggestions/ideas would be greatly appreciated.
Cheers!
[1]: http://i.stack.imgur.com/NF26L.png
[2]: http://i.stack.imgur.com/AzNlg.png
[3]: http://i.stack.imgur.com/BcrLd.png
[4]: http://i.stack.imgur.com/VVGgV.png | javascript | jquery | html | css | html5 | null | open | Overlapping hover decoration
===
Given the following images, I'm really not sure how best to approach this issue.
![enter image description here][1]
![enter image description here][2]
![enter image description here][3]
![enter image description here][4]
I mean I could make a sprite image and position each link/icon absolute so that when the hover state occurs they don't push each other. However the problem is the clickable area will grow with the hover state thereby overlapping the other buttons and making them hard to click.
Any suggestions/ideas would be greatly appreciated.
Cheers!
[1]: http://i.stack.imgur.com/NF26L.png
[2]: http://i.stack.imgur.com/AzNlg.png
[3]: http://i.stack.imgur.com/BcrLd.png
[4]: http://i.stack.imgur.com/VVGgV.png | 0 |
11,373,332 | 07/07/2012 07:55:34 | 471,397 | 10/10/2010 07:28:51 | 1,727 | 123 | last update in mongoengine | Is there any way to find last update Document in Collection? in other way sort collection by update
somethings like this
people = Person.objects.order_by_update()
or i must add update time for each doc?
I use `mongodb`, `mongoengine`, `flask`
| mongodb | mongoengine | null | null | null | null | open | last update in mongoengine
===
Is there any way to find last update Document in Collection? in other way sort collection by update
somethings like this
people = Person.objects.order_by_update()
or i must add update time for each doc?
I use `mongodb`, `mongoengine`, `flask`
| 0 |
11,373,334 | 07/07/2012 07:56:00 | 1,269,086 | 03/14/2012 13:18:58 | 1,583 | 117 | Android Light Sensor Returns null | i am develop project with light sensor but,my problem is light sensor return always null and i am testing device is **samsung galaxy y** . my doubt is light sensor my code is wrong or my galaxy y not contains light sensor?
i have tried below code:
package com.example.lightsensor;
import android.app.Activity;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
public class LightSensorActivity extends Activity {
ProgressBar lightMeter;
TextView textMax, textReading;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.light_sensor_layout);
lightMeter = (ProgressBar)findViewById(R.id.lightmeter);
textMax = (TextView)findViewById(R.id.max);
textReading = (TextView)findViewById(R.id.reading);
SensorManager sensorManager
= (SensorManager)getSystemService(Context.SENSOR_SERVICE);
Sensor lightSensor
= sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
if (lightSensor == null){
Toast.makeText(LightSensorActivity.this,
"No Light Sensor! quit-",
Toast.LENGTH_LONG).show();
}else{
float max = lightSensor.getMaximumRange();
lightMeter.setMax((int)max);
textMax.setText("Max Reading: " + String.valueOf(max));
sensorManager.registerListener(lightSensorEventListener,
lightSensor,
SensorManager.SENSOR_DELAY_NORMAL);
}
}
SensorEventListener lightSensorEventListener
= new SensorEventListener(){
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// TODO Auto-generated method stub
}
@Override
public void onSensorChanged(SensorEvent event) {
// TODO Auto-generated method stub
if(event.sensor.getType()==Sensor.TYPE_LIGHT){
float currentReading = event.values[0];
lightMeter.setProgress((int)currentReading);
textReading.setText("Current Reading: " + String.valueOf(currentReading));
}
}
};
}
can any one help me what's wrong code or device not contain light sensor?
Thanks in Advance!
| android | null | null | null | null | null | open | Android Light Sensor Returns null
===
i am develop project with light sensor but,my problem is light sensor return always null and i am testing device is **samsung galaxy y** . my doubt is light sensor my code is wrong or my galaxy y not contains light sensor?
i have tried below code:
package com.example.lightsensor;
import android.app.Activity;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
public class LightSensorActivity extends Activity {
ProgressBar lightMeter;
TextView textMax, textReading;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.light_sensor_layout);
lightMeter = (ProgressBar)findViewById(R.id.lightmeter);
textMax = (TextView)findViewById(R.id.max);
textReading = (TextView)findViewById(R.id.reading);
SensorManager sensorManager
= (SensorManager)getSystemService(Context.SENSOR_SERVICE);
Sensor lightSensor
= sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
if (lightSensor == null){
Toast.makeText(LightSensorActivity.this,
"No Light Sensor! quit-",
Toast.LENGTH_LONG).show();
}else{
float max = lightSensor.getMaximumRange();
lightMeter.setMax((int)max);
textMax.setText("Max Reading: " + String.valueOf(max));
sensorManager.registerListener(lightSensorEventListener,
lightSensor,
SensorManager.SENSOR_DELAY_NORMAL);
}
}
SensorEventListener lightSensorEventListener
= new SensorEventListener(){
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// TODO Auto-generated method stub
}
@Override
public void onSensorChanged(SensorEvent event) {
// TODO Auto-generated method stub
if(event.sensor.getType()==Sensor.TYPE_LIGHT){
float currentReading = event.values[0];
lightMeter.setProgress((int)currentReading);
textReading.setText("Current Reading: " + String.valueOf(currentReading));
}
}
};
}
can any one help me what's wrong code or device not contain light sensor?
Thanks in Advance!
| 0 |
11,373,340 | 07/07/2012 07:57:01 | 639,406 | 03/01/2011 13:28:10 | 1,173 | 110 | Fix div position and load mouse over content over another div using z-index | My data is correctly alerting the data on `mouseover` over the div, however i m still struggling with my CSS weakness. I need to display the data over the `rightsideblock` div using `z-index` property on mouseover instead of alerting. I created a class `mydatatoshow` to hold the data with rhe display set to none but i am not able to configure it correctly. Help me with this as i googled a lot. Kindly suggest some links that may be helpful for developers for fixing css issues.
My CSS --
<style type="text/css">
.container{width:999px;}
.leftsideblock{float:left; border:1px solid green;width:674px;}
.rightsideblock{border:5px solid blue;}
</style>
My Body Content --
<body>
<div class="container">
<div class="leftsideblock">
<div class="mydivdata">
<table width="650" border="0">
<tbody>
<tr>
<td width="90" valign="top" rowspan="2" class="myimageclass"> </td>
<td width="193" valign="top">Monday 07 July 2012</td>
<td width="424">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</td>
</tr>
</tbody>
</table>
</div>
<div class="mydivdata">
<table width="650" border="0">
<tbody>
<tr>
<td width="90" valign="top" rowspan="2" class="myimageclass"> </td>
<td width="193" valign="top">Friday 06 July 2012 8:00AM</td>
<td width="424">
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="mydatatoshow" style="display:none;">
</div>
<div class="rightsideblock">
<p>
This is right sidebar data.This is right sidebar data.This is right sidebar data.This is right sidebar data.This is right sidebar data.This is right sidebar data.This is right sidebar data.This is right sidebar data.This is right sidebar data.This is right sidebar data.This is right sidebar data.This is right sidebar data.This is right sidebar data.
</p>
</div>
</div>
</body>
My JS--
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.mydivdata').mouseover(function(){
var mydata = $(this).text();
alert(mydata);
});
});
</script>
| javascript | jquery | css | z-index | mouseover | null | open | Fix div position and load mouse over content over another div using z-index
===
My data is correctly alerting the data on `mouseover` over the div, however i m still struggling with my CSS weakness. I need to display the data over the `rightsideblock` div using `z-index` property on mouseover instead of alerting. I created a class `mydatatoshow` to hold the data with rhe display set to none but i am not able to configure it correctly. Help me with this as i googled a lot. Kindly suggest some links that may be helpful for developers for fixing css issues.
My CSS --
<style type="text/css">
.container{width:999px;}
.leftsideblock{float:left; border:1px solid green;width:674px;}
.rightsideblock{border:5px solid blue;}
</style>
My Body Content --
<body>
<div class="container">
<div class="leftsideblock">
<div class="mydivdata">
<table width="650" border="0">
<tbody>
<tr>
<td width="90" valign="top" rowspan="2" class="myimageclass"> </td>
<td width="193" valign="top">Monday 07 July 2012</td>
<td width="424">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</td>
</tr>
</tbody>
</table>
</div>
<div class="mydivdata">
<table width="650" border="0">
<tbody>
<tr>
<td width="90" valign="top" rowspan="2" class="myimageclass"> </td>
<td width="193" valign="top">Friday 06 July 2012 8:00AM</td>
<td width="424">
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="mydatatoshow" style="display:none;">
</div>
<div class="rightsideblock">
<p>
This is right sidebar data.This is right sidebar data.This is right sidebar data.This is right sidebar data.This is right sidebar data.This is right sidebar data.This is right sidebar data.This is right sidebar data.This is right sidebar data.This is right sidebar data.This is right sidebar data.This is right sidebar data.This is right sidebar data.
</p>
</div>
</div>
</body>
My JS--
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.mydivdata').mouseover(function(){
var mydata = $(this).text();
alert(mydata);
});
});
</script>
| 0 |
11,542,207 | 07/18/2012 13:10:59 | 1,344,395 | 04/19/2012 15:16:03 | 11 | 0 | render function doesn't exist in play framework 2.0.2? | I downloaded and installed play framework 2.0.2 and then created a project. I eclipsified the project and opened it in eclipse.
I have a class called Application which extends Controller class. In most examples around the web, I see controllers like the following.
public class Application extends Controller {
public static void index() {
render(arg0,arg1,...);
}
public static void tasks() {
render(arg0,arg1,...);
}
public static void newTask() {
render(arg0,arg1,...);
}
public static void deleteTask(Long id) {
render(arg0,arg1,...);
}
}
However in my default application, I can only do the following. I don't know how to do the previous one.
public class Application extends Controller {
public static Result index() {
return ok("Hello World!");
}
public static Result tasks() {
return ok(indexabc.render("hello world"));
}
public static Result newTask() {
return TODO;
}
public static Result deleteTask(Long id) {
return TODO;
}
}
In my code when I try to replace "Result" return type with "void", there is no problem. However, when I want to call "render()" method with some parameters, that method doesn't exist. I can't find a way for how to call render function. Waiting for your answers. Thanks. | controller | playframework | render | null | null | null | open | render function doesn't exist in play framework 2.0.2?
===
I downloaded and installed play framework 2.0.2 and then created a project. I eclipsified the project and opened it in eclipse.
I have a class called Application which extends Controller class. In most examples around the web, I see controllers like the following.
public class Application extends Controller {
public static void index() {
render(arg0,arg1,...);
}
public static void tasks() {
render(arg0,arg1,...);
}
public static void newTask() {
render(arg0,arg1,...);
}
public static void deleteTask(Long id) {
render(arg0,arg1,...);
}
}
However in my default application, I can only do the following. I don't know how to do the previous one.
public class Application extends Controller {
public static Result index() {
return ok("Hello World!");
}
public static Result tasks() {
return ok(indexabc.render("hello world"));
}
public static Result newTask() {
return TODO;
}
public static Result deleteTask(Long id) {
return TODO;
}
}
In my code when I try to replace "Result" return type with "void", there is no problem. However, when I want to call "render()" method with some parameters, that method doesn't exist. I can't find a way for how to call render function. Waiting for your answers. Thanks. | 0 |
11,542,190 | 07/18/2012 13:09:53 | 578,871 | 01/17/2011 17:44:32 | 83 | 7 | Editing a just inserted record | I am making a crud application ui in javascript and i was wondering how this can be done.Basically,i want to be able to edit a record that i have just inserted.For instance in grids such as jqgrid and extjs,this is possible and i am having a hard time figuring out how that is accomplished.In plain php and html,i would have an hidden input that holds some hidden value like
<input name="id" type="hidden" id="id" value="<? echo $rows['id']; ?>">
I have this fiddle that i am using to investigate what normally happens http://jsfiddle.net/thiswolf/EgHP7/ | php | javascript | null | null | null | null | open | Editing a just inserted record
===
I am making a crud application ui in javascript and i was wondering how this can be done.Basically,i want to be able to edit a record that i have just inserted.For instance in grids such as jqgrid and extjs,this is possible and i am having a hard time figuring out how that is accomplished.In plain php and html,i would have an hidden input that holds some hidden value like
<input name="id" type="hidden" id="id" value="<? echo $rows['id']; ?>">
I have this fiddle that i am using to investigate what normally happens http://jsfiddle.net/thiswolf/EgHP7/ | 0 |
11,541,737 | 07/18/2012 12:46:33 | 1,380,428 | 05/07/2012 18:23:26 | 133 | 16 | Silverlight AutoCompleteBox duplicates items | I have AutoCompleteBox in Silverlight. When you are typing first time it displays everything ok. But if you change search text it will now show both results. For example, if you type "A" it will show results which starts <b>only with "A"</b> but when you delete the text and type type "B" instead it will show results which starts with <b>"A" or "B"</b>. Then if you type in "A" again it will continue to duplicate values. It took about two hours but I can't find out solution. How can I fix that?
Any help is appreciated. | c# | silverlight | autocompletebox | null | null | null | open | Silverlight AutoCompleteBox duplicates items
===
I have AutoCompleteBox in Silverlight. When you are typing first time it displays everything ok. But if you change search text it will now show both results. For example, if you type "A" it will show results which starts <b>only with "A"</b> but when you delete the text and type type "B" instead it will show results which starts with <b>"A" or "B"</b>. Then if you type in "A" again it will continue to duplicate values. It took about two hours but I can't find out solution. How can I fix that?
Any help is appreciated. | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.