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,410,686
07/10/2012 09:49:54
173,234
09/14/2009 16:07:37
2,194
131
Warning: preg_match(): Unknown modifier ' ' in
I don't understand what is wrong, how can I have this error for this simple regex. I can type whatever I want, it will always give me the same error. And in the message itself it doesn't show which modifier causes the problem, the modifier is just empty. public function getRows($content) { $regex = '/[a-z]+/'; preg_match($content, $regex, $rows); print_r($rows); exit; return $return; }
php
preg-match
null
null
null
null
open
Warning: preg_match(): Unknown modifier ' ' in === I don't understand what is wrong, how can I have this error for this simple regex. I can type whatever I want, it will always give me the same error. And in the message itself it doesn't show which modifier causes the problem, the modifier is just empty. public function getRows($content) { $regex = '/[a-z]+/'; preg_match($content, $regex, $rows); print_r($rows); exit; return $return; }
0
11,410,687
07/10/2012 09:49:54
822,992
06/30/2011 12:02:00
1
0
Slow File Writing on linux embedded system
I have multiple writes on a same database file. We insert and update many entries in the DB file. I have seen that insert and update in the file takes some (X) milliseconds to complete the task. Once in a while after 1500 inserts/updates time taken to insert and update is 20X. Again it starts inserting/updating normally. Can I know whats the reason for this. My page size is 512 Bytes. I use paged writing into the DB file.
linux
file
embedded
system
writing
null
open
Slow File Writing on linux embedded system === I have multiple writes on a same database file. We insert and update many entries in the DB file. I have seen that insert and update in the file takes some (X) milliseconds to complete the task. Once in a while after 1500 inserts/updates time taken to insert and update is 20X. Again it starts inserting/updating normally. Can I know whats the reason for this. My page size is 512 Bytes. I use paged writing into the DB file.
0
11,410,688
07/10/2012 09:49:59
1,189,879
02/04/2012 21:04:35
31
0
Adding a a new view to a view controller - iOS
I'm working on an application, where when I press the menu button, the IBAction creates a overlay with ( add a subview ). This subview must hold buttons which must be accessible. I initially made a mistake by adding the extra buttons to the previous view. Thus when I pressed the menu button the new overlay popped out with the extra buttons not being accessible. Is there any suggestions? Im a newbie to iOS programming. Thank you
ios
xcode
subview
null
null
null
open
Adding a a new view to a view controller - iOS === I'm working on an application, where when I press the menu button, the IBAction creates a overlay with ( add a subview ). This subview must hold buttons which must be accessible. I initially made a mistake by adding the extra buttons to the previous view. Thus when I pressed the menu button the new overlay popped out with the extra buttons not being accessible. Is there any suggestions? Im a newbie to iOS programming. Thank you
0
11,410,693
07/10/2012 09:50:15
1,131,777
01/05/2012 09:42:16
3
0
NSInvocationOperation with bad access crash
I got a big problem with NSInvocationOperation. When I run on my iPod 4, firmware 5.0.1, it's OK. But on my iPhone 4, iOS 4.1, it crashed. This is my code: CustomAnnotation *annotation = [[[ModelManager defaultModelManager] getAnnotationDictionaryInMemory] objectForKey:joltId]; if (annotation == nil) annotation = [[[ModelManager defaultModelManager] getAnnotationDictionaryInMemory] annotationWithInstagramId:eID]; if (annotation == nil) continue; //THIS ONE CRASH ON IPHONE 4 OS 4.1 NSDictionary *param = [[NSDictionary alloc] initWithObjectsAndKeys: @"aKey", @"aValue", nil]; NSInvocationOperation *op = [[NSInvocationOperation alloc] initWithTarget:annotation selector:@selector(updateAnnotation:) object:param]; [_queue addOperation:op]; [op autorelease]; I don't know where it wrong? Please help me. Thanks all !!!
nsinvocationoperation
null
null
null
null
null
open
NSInvocationOperation with bad access crash === I got a big problem with NSInvocationOperation. When I run on my iPod 4, firmware 5.0.1, it's OK. But on my iPhone 4, iOS 4.1, it crashed. This is my code: CustomAnnotation *annotation = [[[ModelManager defaultModelManager] getAnnotationDictionaryInMemory] objectForKey:joltId]; if (annotation == nil) annotation = [[[ModelManager defaultModelManager] getAnnotationDictionaryInMemory] annotationWithInstagramId:eID]; if (annotation == nil) continue; //THIS ONE CRASH ON IPHONE 4 OS 4.1 NSDictionary *param = [[NSDictionary alloc] initWithObjectsAndKeys: @"aKey", @"aValue", nil]; NSInvocationOperation *op = [[NSInvocationOperation alloc] initWithTarget:annotation selector:@selector(updateAnnotation:) object:param]; [_queue addOperation:op]; [op autorelease]; I don't know where it wrong? Please help me. Thanks all !!!
0
11,410,700
07/10/2012 09:50:37
542,994
08/09/2010 11:41:11
203
9
How to bring drop shadow effect for a div on mouseover using jQuery / Javascript
I have many divs in an html page. I need to give these divs a drop shadow effect on mouseover using jQuery/Javascript. I can get it work if the drop shadow is to be applied initially but I am not able to get it work at the run time. The divs which needs to have shadow applied has a common class. In the fiddle it is test. I have created a fiddle http://jsfiddle.net/bobbyfrancisjoseph/ZEuVE/2/ It should work on IE8 and above and so I guess CSS3 can be used.
javascript
jquery
mouseevent
null
null
null
open
How to bring drop shadow effect for a div on mouseover using jQuery / Javascript === I have many divs in an html page. I need to give these divs a drop shadow effect on mouseover using jQuery/Javascript. I can get it work if the drop shadow is to be applied initially but I am not able to get it work at the run time. The divs which needs to have shadow applied has a common class. In the fiddle it is test. I have created a fiddle http://jsfiddle.net/bobbyfrancisjoseph/ZEuVE/2/ It should work on IE8 and above and so I guess CSS3 can be used.
0
11,410,495
07/10/2012 09:37:34
1,017,310
10/27/2011 20:42:48
22
1
"extending" enum
I have multiple enum's that all have the same constructor and attributes, like this: enum Enum1 { A(1,2), B(3,4); public int a, b; private Enum1(int a, int b) { this.a = a; this.b = b; } } enum Enum2 { C(6,7), D(8,9); public int a, b; private Enum1(int a, int b) { this.a = a; this.b = b; } } and so on... Unfortunately Enum1 and Enum2 already extend Enum, so it isn't possible to write a superclass they could extend. Is there another way to archive this?
java
enums
null
null
null
null
open
"extending" enum === I have multiple enum's that all have the same constructor and attributes, like this: enum Enum1 { A(1,2), B(3,4); public int a, b; private Enum1(int a, int b) { this.a = a; this.b = b; } } enum Enum2 { C(6,7), D(8,9); public int a, b; private Enum1(int a, int b) { this.a = a; this.b = b; } } and so on... Unfortunately Enum1 and Enum2 already extend Enum, so it isn't possible to write a superclass they could extend. Is there another way to archive this?
0
11,410,496
07/10/2012 09:37:34
1,368,272
05/01/2012 17:44:19
8
0
Restoring redmine issues by email and svn
We lost server with redmine. Now we have old database dump and email notifications by redmine and svn history with descriptions (descriptions contains num of issue and some comment). Does anybody know any way to restore some of lost information?
backup
redmine
null
null
null
null
open
Restoring redmine issues by email and svn === We lost server with redmine. Now we have old database dump and email notifications by redmine and svn history with descriptions (descriptions contains num of issue and some comment). Does anybody know any way to restore some of lost information?
0
11,410,497
07/10/2012 09:37:35
1,276,473
03/18/2012 03:14:08
292
0
Does the flag register need to be saved when an interrupt occurs, or a process scheduling happens?
I know all the general registers are pushed on the stack when the an interrupts happen, but I can't see any code that flag register are save. The assembly instruction like setl which depends on the flag register, is easy to make a wrong result when restoring from an interrupt, if the flag register is corrupted.
linux
assembly
linux-kernel
x86
null
null
open
Does the flag register need to be saved when an interrupt occurs, or a process scheduling happens? === I know all the general registers are pushed on the stack when the an interrupts happen, but I can't see any code that flag register are save. The assembly instruction like setl which depends on the flag register, is easy to make a wrong result when restoring from an interrupt, if the flag register is corrupted.
0
11,410,706
07/10/2012 09:51:08
1,503,607
07/05/2012 09:57:00
19
0
Can't display a Zend Form in my .phtml file
I'm working on a small php application using Zend Framework. I created a form using `Zend_Form` but when I try to display it in the browser, it's not working properly. Here is my Form class: <?php class IndexForm extends Zend_Form { public function init(){ $this->setAction('main/main'); $this->setMethod('post'); $username = $this->addElement('text','uname',array('filters'=>array('StringTrim','StringToLower'), 'validators'=>array('Alpha', array('StringLength',false,array(3,20)), ), 'required'=>true, 'label'=>'User Name:')); $password = $this->addElement('password','pwd',array('filters'=>array('StringTrim'), 'validtors'=>array('Alnum', array('StringLength',false,array(6,20)),), 'required'=>true, 'label'=>'Password:' )); $login = $this->addElement('submit', 'login', array( 'required' => false, 'ignore' => true, 'label' => 'Login', )); } } ?> Here is my IndexController.php <?php class IndexController extends Zend_Controller_Action { public function init() { /* * Initialize action controller here */ } public function indexAction() { include APPLICATION_PATH.'/models/Forms/IndexForm.php'; $form = new IndexForm(); $this->view->form = $form; } } Here is my `index.phtml`, where I need to display the form. <html> <style> </style> <body><br> <img alt="" src="http://localhost/Accounts/application/views/scripts/images/logo.png" width=200px height=80px><!-- see whether you can get the host name dynamically --> <div id="text" > <h1>Welcome</h1><br><hr> <h4>Please Log in To View The Main Page</h4></div> <?=$this->form?> <!--here I want to display the form--> <div><?php include APPLICATION_PATH.'/views/scripts/layouts/footer.php';?> </div> </body> </html> The output I get instead of the form is `form?>`. Why is this? what's wrong in my codes? Please help me. Thanks in advance Charu
php
zend-framework
zend-form
null
null
null
open
Can't display a Zend Form in my .phtml file === I'm working on a small php application using Zend Framework. I created a form using `Zend_Form` but when I try to display it in the browser, it's not working properly. Here is my Form class: <?php class IndexForm extends Zend_Form { public function init(){ $this->setAction('main/main'); $this->setMethod('post'); $username = $this->addElement('text','uname',array('filters'=>array('StringTrim','StringToLower'), 'validators'=>array('Alpha', array('StringLength',false,array(3,20)), ), 'required'=>true, 'label'=>'User Name:')); $password = $this->addElement('password','pwd',array('filters'=>array('StringTrim'), 'validtors'=>array('Alnum', array('StringLength',false,array(6,20)),), 'required'=>true, 'label'=>'Password:' )); $login = $this->addElement('submit', 'login', array( 'required' => false, 'ignore' => true, 'label' => 'Login', )); } } ?> Here is my IndexController.php <?php class IndexController extends Zend_Controller_Action { public function init() { /* * Initialize action controller here */ } public function indexAction() { include APPLICATION_PATH.'/models/Forms/IndexForm.php'; $form = new IndexForm(); $this->view->form = $form; } } Here is my `index.phtml`, where I need to display the form. <html> <style> </style> <body><br> <img alt="" src="http://localhost/Accounts/application/views/scripts/images/logo.png" width=200px height=80px><!-- see whether you can get the host name dynamically --> <div id="text" > <h1>Welcome</h1><br><hr> <h4>Please Log in To View The Main Page</h4></div> <?=$this->form?> <!--here I want to display the form--> <div><?php include APPLICATION_PATH.'/views/scripts/layouts/footer.php';?> </div> </body> </html> The output I get instead of the form is `form?>`. Why is this? what's wrong in my codes? Please help me. Thanks in advance Charu
0
11,410,707
07/10/2012 09:51:18
1,215,889
02/17/2012 09:48:21
1
0
altering gcc to recognize new escape sequence
I have started to work on code optimisation in gcc. Just to start off I wanted to add a few escape sequence like \c and make it behave the way i want.I am working on gcc 4.6.2. For that I have to know where is source code should I modifyto file where escape sequences are defined.
c
gcc
null
null
null
07/11/2012 10:44:08
not a real question
altering gcc to recognize new escape sequence === I have started to work on code optimisation in gcc. Just to start off I wanted to add a few escape sequence like \c and make it behave the way i want.I am working on gcc 4.6.2. For that I have to know where is source code should I modifyto file where escape sequences are defined.
1
11,734,377
07/31/2012 06:31:06
216,190
11/21/2009 19:13:45
672
6
Forking a process
I have a process that goes to the database and gets data. The complexities and my questions are as follow: Some data comes from one data source and the rest come from the other data source. I was wondering once i start a process, i can create the object where in i will dump all the data and then fork ( as in C language). an send each process to different data source. Question 1 : If i do something like fork, it updates both the dumping of data simultaneously right? i.e. if parent process is getting data from source A and dumping in Object O, and chil process is getting from B and dumping in Object O only, the O gets populated simultaneously right? It will not create two objects one with data from A and other with data from B. Also, the efficiency of this process lies in the multiprocessor systems only? Question 2: Is there anything like this in Java? Thanks.
java
c
fork
null
null
null
open
Forking a process === I have a process that goes to the database and gets data. The complexities and my questions are as follow: Some data comes from one data source and the rest come from the other data source. I was wondering once i start a process, i can create the object where in i will dump all the data and then fork ( as in C language). an send each process to different data source. Question 1 : If i do something like fork, it updates both the dumping of data simultaneously right? i.e. if parent process is getting data from source A and dumping in Object O, and chil process is getting from B and dumping in Object O only, the O gets populated simultaneously right? It will not create two objects one with data from A and other with data from B. Also, the efficiency of this process lies in the multiprocessor systems only? Question 2: Is there anything like this in Java? Thanks.
0
11,734,465
07/31/2012 06:39:05
1,389,664
05/11/2012 14:20:37
1
0
Display hindi characters in blackberry os 5.0 application
We are developing an app in which we have to develope the whole app in hindi i.e labelfield containg hindi characters. Kindly help if any one knows how we can do it.
blackberry
null
null
null
null
null
open
Display hindi characters in blackberry os 5.0 application === We are developing an app in which we have to develope the whole app in hindi i.e labelfield containg hindi characters. Kindly help if any one knows how we can do it.
0
11,734,467
07/31/2012 06:39:14
214,260
11/19/2009 02:35:50
346
10
Is there any way to do a launchpad ppa for a ant project?
I have a normal netbeans project and used jdeb to create a deb package. I was hoping to upload that to launchpad ppa i created, but realized that launchpad requires to build the packages itself, probably to have both the sources and the signature so as to have a bit more security and deterrence towards malicious code. Ok, fine jdeb is out. But how can i build my project from their sandbox considering it's a normal netbeans ant project, not a buildtools project? Also considering that i depend on some (but not all but that is already solved in my ant file) binary jars libraries? Is it impossible without compiling all libraries used that are not in the repositories?
java
ubuntu
ant
launchpad
null
null
open
Is there any way to do a launchpad ppa for a ant project? === I have a normal netbeans project and used jdeb to create a deb package. I was hoping to upload that to launchpad ppa i created, but realized that launchpad requires to build the packages itself, probably to have both the sources and the signature so as to have a bit more security and deterrence towards malicious code. Ok, fine jdeb is out. But how can i build my project from their sandbox considering it's a normal netbeans ant project, not a buildtools project? Also considering that i depend on some (but not all but that is already solved in my ant file) binary jars libraries? Is it impossible without compiling all libraries used that are not in the repositories?
0
11,734,470
07/31/2012 06:39:19
165,674
08/30/2009 18:29:18
2,485
142
How does one use Resources.getFraction()?
How do I store a fractional value like `3.1416` in resources? What to write in the XML and how to retrieve it in Java code? The documentation for [`getFraction()`][1] states: > `public float getFraction (int id, int base, int pbase)` > > Retrieve a fractional unit for a particular resource ID. > > **Parameters** > `base` The base value of this fraction. In other words, a standard > fraction is multiplied by this value. > `pbase` The parent base value of > this fraction. In other words, a parent fraction (nn%p) is multiplied > by this value. > > **Returns** > Attribute fractional value multiplied by the > appropriate base value [This answer][2] shows a simple example of percentages without going into the details of what the arguments mean. [1]: http://developer.android.com/reference/android/content/res/Resources.html#getFraction%28int,%20int,%20int%29 [2]: http://stackoverflow.com/a/6021880/165674
android
android-resources
null
null
null
null
open
How does one use Resources.getFraction()? === How do I store a fractional value like `3.1416` in resources? What to write in the XML and how to retrieve it in Java code? The documentation for [`getFraction()`][1] states: > `public float getFraction (int id, int base, int pbase)` > > Retrieve a fractional unit for a particular resource ID. > > **Parameters** > `base` The base value of this fraction. In other words, a standard > fraction is multiplied by this value. > `pbase` The parent base value of > this fraction. In other words, a parent fraction (nn%p) is multiplied > by this value. > > **Returns** > Attribute fractional value multiplied by the > appropriate base value [This answer][2] shows a simple example of percentages without going into the details of what the arguments mean. [1]: http://developer.android.com/reference/android/content/res/Resources.html#getFraction%28int,%20int,%20int%29 [2]: http://stackoverflow.com/a/6021880/165674
0
11,734,471
07/31/2012 06:39:20
1,563,147
07/30/2012 14:01:23
1
0
using javascript function to initialize php variable
hi i want to initialize php variable in javascript function and than call the php function with php initialized variable. Please help me for solving this problem... <?php function printDiv($abc) { echo '<div align="center" width="100%"> ' . $abc . ' </div>'; } ?> <script type="text/javascript"> function callPhpFunction(jsabc) { <?php $abc ?> = jsabc; document.write("<?php printDiv($abc) ?>"); } </script>
php
javascript
null
null
null
07/31/2012 11:08:46
too localized
using javascript function to initialize php variable === hi i want to initialize php variable in javascript function and than call the php function with php initialized variable. Please help me for solving this problem... <?php function printDiv($abc) { echo '<div align="center" width="100%"> ' . $abc . ' </div>'; } ?> <script type="text/javascript"> function callPhpFunction(jsabc) { <?php $abc ?> = jsabc; document.write("<?php printDiv($abc) ?>"); } </script>
3
11,734,473
07/31/2012 06:39:25
1,542,433
07/21/2012 09:03:59
6
0
Upload multiple images to server with progress bar in a table
I want to upload multiple images to server.and want to show the progress as well for that i need to show all images with progress bar in table. please suggest me what is the best way and if any sample code available will help much
iphone
ios
ipad
image-uploading
null
null
open
Upload multiple images to server with progress bar in a table === I want to upload multiple images to server.and want to show the progress as well for that i need to show all images with progress bar in table. please suggest me what is the best way and if any sample code available will help much
0
11,734,481
07/31/2012 06:40:07
257,688
01/24/2010 05:21:30
15
2
Like facebook fanpage page with koala
I'm using Koala to post a status message to the users facebook page. How do I get the user to like the product's fanpage in the process? def post_to_facebook_feed(message) facebook_client = Koala::Facebook::API.new(token) facebook_client.put_connections('me', 'feed', message: message) end Maybe something like? def post_to_facebook_feed(message) facebook_client = Koala::Facebook::API.new(token) facebook_client.put_connections('me', 'feed', message: message) #mock up code facebook_client.put_like('me', 'fanpage', fan_page: "facebook.com/{fan_page_name}") end
ruby-on-rails
ruby
facebook-opengraph
koala
null
null
open
Like facebook fanpage page with koala === I'm using Koala to post a status message to the users facebook page. How do I get the user to like the product's fanpage in the process? def post_to_facebook_feed(message) facebook_client = Koala::Facebook::API.new(token) facebook_client.put_connections('me', 'feed', message: message) end Maybe something like? def post_to_facebook_feed(message) facebook_client = Koala::Facebook::API.new(token) facebook_client.put_connections('me', 'feed', message: message) #mock up code facebook_client.put_like('me', 'fanpage', fan_page: "facebook.com/{fan_page_name}") end
0
11,734,483
07/31/2012 06:40:30
837,719
07/10/2011 15:13:10
7
0
Android scroll bug > only visible on touch
I'm creating a web app with PhoneGap 1.9 and on android I'm running into a problem, currently running on Android 3.2. I have a simple ul list with li elements, for some reason the content doesn't get visible instantly when scrolling, but you have to touch the screen to get the contest visible. I attached two images, that should be more explanatory. To note, I load additional content when reaching the bottom of the scroll. scrolling down with one move; > image: http://puu.sh/Ng05.jpg touching the bottom of the screen - the content only now appears; > image: http://puu.sh/Ng0F.jpg Other than that, sometimes the scroll also gets quite buggy, e.g. it jumps up/down when touching the content. Thanks!
android
web-applications
phonegap
cordova
null
null
open
Android scroll bug > only visible on touch === I'm creating a web app with PhoneGap 1.9 and on android I'm running into a problem, currently running on Android 3.2. I have a simple ul list with li elements, for some reason the content doesn't get visible instantly when scrolling, but you have to touch the screen to get the contest visible. I attached two images, that should be more explanatory. To note, I load additional content when reaching the bottom of the scroll. scrolling down with one move; > image: http://puu.sh/Ng05.jpg touching the bottom of the screen - the content only now appears; > image: http://puu.sh/Ng0F.jpg Other than that, sometimes the scroll also gets quite buggy, e.g. it jumps up/down when touching the content. Thanks!
0
11,734,484
07/31/2012 06:40:30
1,564,875
07/31/2012 06:30:19
1
0
Could you show how we can open a specific tab in the accordion from another page?
I have been following tutorials from "learnnerd", a Youtube contributer. Url: http://www.youtube.com/watch?v=WjHt_v6nK_E&list=UU08OUGXLKqlnADsUDqA8evg&index=2&feature=plcp I have made my website using the codes he provided. Here's my website: http://www.alliedantennas.com.au (check services) I would like to link a tab on my home page to open a specific accordion in my services pages. I've researched but still know little. I don't know much about Javascript. Thank you.
accordion
null
null
null
null
null
open
Could you show how we can open a specific tab in the accordion from another page? === I have been following tutorials from "learnnerd", a Youtube contributer. Url: http://www.youtube.com/watch?v=WjHt_v6nK_E&list=UU08OUGXLKqlnADsUDqA8evg&index=2&feature=plcp I have made my website using the codes he provided. Here's my website: http://www.alliedantennas.com.au (check services) I would like to link a tab on my home page to open a specific accordion in my services pages. I've researched but still know little. I don't know much about Javascript. Thank you.
0
11,724,098
07/30/2012 15:00:56
1,257,074
03/08/2012 13:10:36
16
2
MySQL query IN GROUP_CONCAT not working
Having problems with a MySQL query. Only returning the results for the first item in the resulting GROUP_CONCAT array. i.e resulting array is [1,3,4], the quesitionnaires for only user id 1 is returned. $query_search = "SELECT questionnaires_index.id, questionnaires_index.ea_num, questionnaires_index.address, questionnaires_index.status, questionnaires_index.json_stored, users.username FROM questionnaires_index INNER JOIN users ON users.id = questionnaires_index.interviewer_id WHERE questionnaires_index.interviewer_id IN (SELECT GROUP_CONCAT(id) FROM users WHERE supervisor = (SELECT id FROM users WHERE username = '".$username."'))"; Am I using GROUP_CONCAT incorrectly? Is there a better way of doing this?
mysql
select
inner-join
group-concat
null
null
open
MySQL query IN GROUP_CONCAT not working === Having problems with a MySQL query. Only returning the results for the first item in the resulting GROUP_CONCAT array. i.e resulting array is [1,3,4], the quesitionnaires for only user id 1 is returned. $query_search = "SELECT questionnaires_index.id, questionnaires_index.ea_num, questionnaires_index.address, questionnaires_index.status, questionnaires_index.json_stored, users.username FROM questionnaires_index INNER JOIN users ON users.id = questionnaires_index.interviewer_id WHERE questionnaires_index.interviewer_id IN (SELECT GROUP_CONCAT(id) FROM users WHERE supervisor = (SELECT id FROM users WHERE username = '".$username."'))"; Am I using GROUP_CONCAT incorrectly? Is there a better way of doing this?
0
11,499,923
07/16/2012 07:35:34
1,518,070
07/11/2012 14:22:46
29
0
JQuery - Duplicating drag and drop object
When I drag my proposed item the clone helper is dragged and the original object is left in its place, but cannot be dragged again after. I need to be able to drag the same object twice.How can I do this? $('.drop').droppable({ drop: function(event, ui) { if (ui.draggable[10, 10].id) { $(this).append($(ui.helper).clone().draggable()); } } });
jquery
null
null
null
null
null
open
JQuery - Duplicating drag and drop object === When I drag my proposed item the clone helper is dragged and the original object is left in its place, but cannot be dragged again after. I need to be able to drag the same object twice.How can I do this? $('.drop').droppable({ drop: function(event, ui) { if (ui.draggable[10, 10].id) { $(this).append($(ui.helper).clone().draggable()); } } });
0
11,499,904
07/16/2012 07:33:19
629,875
02/23/2011 09:20:18
46
6
nfs encoding issue
I have a Celerra NS-20 that export a filesystem with cifs and nfs. The files are written by windows machines. When I mount the cifs in linux all filename special characters are ok, but when mount the nfs (same filesystem) the filenames special character are broken. Are there a way to mount the filesystem changing the encoding ?
encoding
nfs
cifs
null
null
null
open
nfs encoding issue === I have a Celerra NS-20 that export a filesystem with cifs and nfs. The files are written by windows machines. When I mount the cifs in linux all filename special characters are ok, but when mount the nfs (same filesystem) the filenames special character are broken. Are there a way to mount the filesystem changing the encoding ?
0
11,499,932
07/16/2012 07:36:13
417,145
08/11/2010 11:10:49
59
0
WPF popup window
I would like to let the usr choose their options after a button being clicked. For example, there are two buttons, "Restart Now" and "Restart Later". It is better to have a popup window, and should be presented modally. MessageBox is NOT the solution, as it does not allow user to change the title of buttons. Can anyone gives out a solution, i am pretty new to .Net Thank you!
c#
wpf
null
null
null
null
open
WPF popup window === I would like to let the usr choose their options after a button being clicked. For example, there are two buttons, "Restart Now" and "Restart Later". It is better to have a popup window, and should be presented modally. MessageBox is NOT the solution, as it does not allow user to change the title of buttons. Can anyone gives out a solution, i am pretty new to .Net Thank you!
0
11,499,933
07/16/2012 07:36:14
1,526,609
07/15/2012 07:42:44
1
0
UTF8 Unicode problems
I need a simple PHP&MySQL source that works fine on UTF8 Unicode system. Please give me the simplest source that works at 100% on UTF8 Unicode. I wait for you help. Thank you.
php
mysql
unicode
utf-8
source
07/16/2012 08:07:49
not a real question
UTF8 Unicode problems === I need a simple PHP&MySQL source that works fine on UTF8 Unicode system. Please give me the simplest source that works at 100% on UTF8 Unicode. I wait for you help. Thank you.
1
11,499,935
07/16/2012 07:36:19
1,222,771
02/21/2012 07:08:08
17
0
How can we set time or delay of 5 seconds in dropdown sub menu?
How can we set time or delay of 5 seconds in dropdown. Requirement are like this: When someone hover over main menu then its shows that submenu for 5 sec only when your mouse is away from main menu or sub menu. For now i have increased the height of ul upto height of banner images so that it will not be hide untill you move your mouse out of that banner area. Below is the site link: http://transitions.advisorproducts.com/home and this is one reference site link : http://focusyou.com/home (my requirement are like this, but i don't want to copy this code, i want to implement in my own code) Below is the js: $(function() { $("ul.dropdown li").hover(function() { $(this).addClass("hover"); $('ul:first',this).css('visibility', 'visible'); }, function() { $(this).removeClass("hover"); $('ul:first',this).css('visibility', 'hidden'); }); $("ul.dropdown li ul li:has(ul)").find("a:first").append(" &raquo; "); }); Thanks in advance :)
javascript
jquery
null
null
null
null
open
How can we set time or delay of 5 seconds in dropdown sub menu? === How can we set time or delay of 5 seconds in dropdown. Requirement are like this: When someone hover over main menu then its shows that submenu for 5 sec only when your mouse is away from main menu or sub menu. For now i have increased the height of ul upto height of banner images so that it will not be hide untill you move your mouse out of that banner area. Below is the site link: http://transitions.advisorproducts.com/home and this is one reference site link : http://focusyou.com/home (my requirement are like this, but i don't want to copy this code, i want to implement in my own code) Below is the js: $(function() { $("ul.dropdown li").hover(function() { $(this).addClass("hover"); $('ul:first',this).css('visibility', 'visible'); }, function() { $(this).removeClass("hover"); $('ul:first',this).css('visibility', 'hidden'); }); $("ul.dropdown li ul li:has(ul)").find("a:first").append(" &raquo; "); }); Thanks in advance :)
0
11,499,912
07/16/2012 07:34:19
1,510,985
07/09/2012 04:19:12
11
2
An error occurred while installing Adobe AIR
- I'm trying many time to install Adobe AIR. Normal : Error said... > **An error occurred while installing Adobe AIR. Installation may not be allowed by your administrator. Please contact your administrator.** Then, I run as Administrator, but I get same error message... - I download installer again, but there is same error message... - I install with same installer in another laptop, but I get same error message... I'm on Win XP SP3 professional edition.(another laptop : XP SP3 home edition) Download AIR [Link][1] This is log... There is no command line?? > [2012-07-16:14:23:25] Runtime Installer begin with version 3.3.0.3670 on Windows XP x86 <br/>[2012-07-16:14:23:25] **Commandline is:** <br/>[2012-07-16:14:23:25] No installed runtime detected <br/>[2012-07-16:14:23:28] Starting runtime install. Installing runtime version 3.3.0.3670 <br/>[2012-07-16:14:23:28] Installing msi at c:\docume~1\admini~1\locals~1\temp\air1fb.tmp\setup.msi with guid {65CB4C08-C47B-4A7E-A6A4-50C06ADA5FC6} <br/>[2012-07-16:14:23:28] Error occurred during msi install operation; beginning rollback: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="1601" errorID=0] <br/>[2012-07-16:14:23:28] Rolling back install of c:\docume~1\admini~1\locals~1\temp\air1fb.tmp\setup.msi <br/>[2012-07-16:14:23:28] Rollback complete <br/>[2012-07-16:14:23:28] Exiting due to error: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="1601" errorID=0] <br/>[2012-07-16:14:23:30] Runtime Installer end with exit code 7 This is relate [link][2] ,but there is no point too. Have you got any other suggestion? Thank... [1]: http://get.adobe.com/air/otherversions/ [2]: http://stackoverflow.com/questions/11416258/error-installing-air-app
flash
flex
air
adobe
salesforce
null
open
An error occurred while installing Adobe AIR === - I'm trying many time to install Adobe AIR. Normal : Error said... > **An error occurred while installing Adobe AIR. Installation may not be allowed by your administrator. Please contact your administrator.** Then, I run as Administrator, but I get same error message... - I download installer again, but there is same error message... - I install with same installer in another laptop, but I get same error message... I'm on Win XP SP3 professional edition.(another laptop : XP SP3 home edition) Download AIR [Link][1] This is log... There is no command line?? > [2012-07-16:14:23:25] Runtime Installer begin with version 3.3.0.3670 on Windows XP x86 <br/>[2012-07-16:14:23:25] **Commandline is:** <br/>[2012-07-16:14:23:25] No installed runtime detected <br/>[2012-07-16:14:23:28] Starting runtime install. Installing runtime version 3.3.0.3670 <br/>[2012-07-16:14:23:28] Installing msi at c:\docume~1\admini~1\locals~1\temp\air1fb.tmp\setup.msi with guid {65CB4C08-C47B-4A7E-A6A4-50C06ADA5FC6} <br/>[2012-07-16:14:23:28] Error occurred during msi install operation; beginning rollback: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="1601" errorID=0] <br/>[2012-07-16:14:23:28] Rolling back install of c:\docume~1\admini~1\locals~1\temp\air1fb.tmp\setup.msi <br/>[2012-07-16:14:23:28] Rollback complete <br/>[2012-07-16:14:23:28] Exiting due to error: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="1601" errorID=0] <br/>[2012-07-16:14:23:30] Runtime Installer end with exit code 7 This is relate [link][2] ,but there is no point too. Have you got any other suggestion? Thank... [1]: http://get.adobe.com/air/otherversions/ [2]: http://stackoverflow.com/questions/11416258/error-installing-air-app
0
11,499,938
07/16/2012 07:36:39
1,514,105
07/10/2012 08:05:59
12
1
android app cannot resolve host
Hi I'm developing an app in Android which connects with a wcf service and returns me the results.The wcf is written with soap and I'm using KSOAP2 for connecting.At first I was connecting to a certain url and everything was working nicely.Then i had to change url and i get an unknown exception unable to resolve host:No address associated with name.I've done my research and the solution to all the other similar problems was adding in the Android Manifest internet connection.But i've done that already.Any suggestions? an other detail is that using the first url ,in which my app was working fine, is a normal url the second is in a local server ,by the way though my pc is connected properly in this server.(properly meaning that when i use the url with my browser has no problem connecting with it )
java
android
null
null
null
null
open
android app cannot resolve host === Hi I'm developing an app in Android which connects with a wcf service and returns me the results.The wcf is written with soap and I'm using KSOAP2 for connecting.At first I was connecting to a certain url and everything was working nicely.Then i had to change url and i get an unknown exception unable to resolve host:No address associated with name.I've done my research and the solution to all the other similar problems was adding in the Android Manifest internet connection.But i've done that already.Any suggestions? an other detail is that using the first url ,in which my app was working fine, is a normal url the second is in a local server ,by the way though my pc is connected properly in this server.(properly meaning that when i use the url with my browser has no problem connecting with it )
0
11,499,942
07/16/2012 07:37:00
1,525,494
07/14/2012 11:28:07
3
0
Android-Code to Implement PDF Viewer
Here i need to use Pdf-Viewer in my app.i took many API as a reference but still stucking up in viewing Pdf files from SDCARD. here my code `**First.java** public class First extends ListActivity { String[] pdflist; File[] imagelist; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.main); File images = Environment.getExternalStorageDirectory(); imagelist = images.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return ((name.endsWith(".pdf"))); } }); pdflist = new String[imagelist.length]; for (int i = 0; i < imagelist.length; i++) { pdflist[i] = imagelist[i].getName(); } this.setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, pdflist)); } protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); String path = imagelist[(int) id].getAbsolutePath(); openPdfIntent(path); } private void openPdfIntent(String path) { try { final Intent intent = new Intent(First.this, Second.class); intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, path); startActivity(intent); } catch (Exception e) { e.printStackTrace(); } }} **Second.java** public class Second extends PdfViewerActivity { @Override public int getPreviousPageImageResource() { // TODO Auto-generated method stub return R.drawable.left_arrow; } @Override public int getNextPageImageResource() { // TODO Auto-generated method stub return R.drawable.right_arrow; } @Override public int getZoomInImageResource() { // TODO Auto-generated method stub return R.drawable.zoom_in; } @Override public int getZoomOutImageResource() { // TODO Auto-generated method stub return R.drawable.zoom_out; } @Override public int getPdfPasswordLayoutResource() { // TODO Auto-generated method stub return R.layout.pdf_file_password; } @Override public int getPdfPageNumberResource() { // TODO Auto-generated method stub return R.layout.dialog_pagenumber; } @Override public int getPdfPasswordEditField() { // TODO Auto-generated method stub return R.id.etPassword; } @Override public int getPdfPasswordOkButton() { // TODO Auto-generated method stub return R.id.btOK; } @Override public int getPdfPasswordExitButton() { // TODO Auto-generated method stub return R.id.btExit; } @Override public int getPdfPageNumberEditField() { // TODO Auto-generated method stub return R.id.pagenum_edit; }} And i used [Android-Pdf-Reader-Library][1] project.in my emulator Dialogue as"Loading pdf file" is appearing after clicking on Pdf files. Help me.. [1]: https://github.com/jblough/Android-Pdf-Viewer-Library
android
pdf
null
null
null
null
open
Android-Code to Implement PDF Viewer === Here i need to use Pdf-Viewer in my app.i took many API as a reference but still stucking up in viewing Pdf files from SDCARD. here my code `**First.java** public class First extends ListActivity { String[] pdflist; File[] imagelist; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.main); File images = Environment.getExternalStorageDirectory(); imagelist = images.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return ((name.endsWith(".pdf"))); } }); pdflist = new String[imagelist.length]; for (int i = 0; i < imagelist.length; i++) { pdflist[i] = imagelist[i].getName(); } this.setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, pdflist)); } protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); String path = imagelist[(int) id].getAbsolutePath(); openPdfIntent(path); } private void openPdfIntent(String path) { try { final Intent intent = new Intent(First.this, Second.class); intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, path); startActivity(intent); } catch (Exception e) { e.printStackTrace(); } }} **Second.java** public class Second extends PdfViewerActivity { @Override public int getPreviousPageImageResource() { // TODO Auto-generated method stub return R.drawable.left_arrow; } @Override public int getNextPageImageResource() { // TODO Auto-generated method stub return R.drawable.right_arrow; } @Override public int getZoomInImageResource() { // TODO Auto-generated method stub return R.drawable.zoom_in; } @Override public int getZoomOutImageResource() { // TODO Auto-generated method stub return R.drawable.zoom_out; } @Override public int getPdfPasswordLayoutResource() { // TODO Auto-generated method stub return R.layout.pdf_file_password; } @Override public int getPdfPageNumberResource() { // TODO Auto-generated method stub return R.layout.dialog_pagenumber; } @Override public int getPdfPasswordEditField() { // TODO Auto-generated method stub return R.id.etPassword; } @Override public int getPdfPasswordOkButton() { // TODO Auto-generated method stub return R.id.btOK; } @Override public int getPdfPasswordExitButton() { // TODO Auto-generated method stub return R.id.btExit; } @Override public int getPdfPageNumberEditField() { // TODO Auto-generated method stub return R.id.pagenum_edit; }} And i used [Android-Pdf-Reader-Library][1] project.in my emulator Dialogue as"Loading pdf file" is appearing after clicking on Pdf files. Help me.. [1]: https://github.com/jblough/Android-Pdf-Viewer-Library
0
11,499,943
07/16/2012 07:37:13
1,528,161
07/16/2012 07:24:55
1
0
I am a beginner in Fone Monkey. I performed the following steps and run the simple Hello World program. But failed to.
I am a beginner in Fone Monkey. I performed the following steps and run the simple Hello World program. But failed to. Should I proceed with any more steps. 1. Installed the AspectJ Development Tools plugin for eclipse. 2. Right-clicked on the Android project in eclipse and Converted to AspectJ Project. 3. Copied the fonemonkey folder into the root of the eclipse project and opened the folder. 4. Right-click on the fonemonkey/aspects folder and select Build Path > Use as Source Folder. 5. Open the fonemonkey/libs directory. Select fonemonkey.jar and servlet-api.jar, right click and select Build Path > Add to Build Path. 6. Open your project's Android manifest file and add the following permissions if you app is not already using them: android.permission.GET_TASKS android.permission.INTERNET 7. Clean-build.
android
null
null
null
null
null
open
I am a beginner in Fone Monkey. I performed the following steps and run the simple Hello World program. But failed to. === I am a beginner in Fone Monkey. I performed the following steps and run the simple Hello World program. But failed to. Should I proceed with any more steps. 1. Installed the AspectJ Development Tools plugin for eclipse. 2. Right-clicked on the Android project in eclipse and Converted to AspectJ Project. 3. Copied the fonemonkey folder into the root of the eclipse project and opened the folder. 4. Right-click on the fonemonkey/aspects folder and select Build Path > Use as Source Folder. 5. Open the fonemonkey/libs directory. Select fonemonkey.jar and servlet-api.jar, right click and select Build Path > Add to Build Path. 6. Open your project's Android manifest file and add the following permissions if you app is not already using them: android.permission.GET_TASKS android.permission.INTERNET 7. Clean-build.
0
11,499,944
07/16/2012 07:37:22
1,484,779
06/27/2012 06:58:25
46
3
Can't find hidden file in sdcard
I am downloading a file to the sd memory card of the client, I use the dot (".") in front of the name of the file to hide it, the problem is that when searching for it then to open it, not found. Any way to find it? Edit: I'm looking for it as well: File file = new File("/sdcard/SEAS Campus/" , "." + StudiesVO.bookID+".pdf"); if(file.exists()){} Also without a point, but no results Thanks!
android
hidden-files
null
null
null
null
open
Can't find hidden file in sdcard === I am downloading a file to the sd memory card of the client, I use the dot (".") in front of the name of the file to hide it, the problem is that when searching for it then to open it, not found. Any way to find it? Edit: I'm looking for it as well: File file = new File("/sdcard/SEAS Campus/" , "." + StudiesVO.bookID+".pdf"); if(file.exists()){} Also without a point, but no results Thanks!
0
11,628,242
07/24/2012 09:47:32
818,557
06/28/2011 05:29:41
1,316
100
Calling javascript file residing in a different folder
Am new to javascript. Am trying to call an external javascript file from jsp. I have no problem in doing the above but when I tried to place this **javascript in a different folder and then call**, am not able to do it. Code which calls js from jsp <input type="submit" name="submit" value="Submit" onclick="validate(this.form)"></input> Added these lines in the *head* part of the jsp <script src="scripts/validate.js"> </script>
javascript
null
null
null
null
null
open
Calling javascript file residing in a different folder === Am new to javascript. Am trying to call an external javascript file from jsp. I have no problem in doing the above but when I tried to place this **javascript in a different folder and then call**, am not able to do it. Code which calls js from jsp <input type="submit" name="submit" value="Submit" onclick="validate(this.form)"></input> Added these lines in the *head* part of the jsp <script src="scripts/validate.js"> </script>
0
11,628,245
07/24/2012 09:47:37
582,836
01/20/2011 11:02:56
487
35
Sorting DateTime Column In JQuery Datatables and ASP.NET MVC
I am using the JQuery Datatables plugin in an ASP.NET MVC project to display some tabular data, which is in turn taken from a database using Entity Framework. I have configured the Datatable to use ajax search and sort routines, and I am using an extension method to allow me to specify the name of a column to be sorted as a string. This works perfectly for most fields, but I get an error when trying to sort a field that contains a DateTime object. View JQuery Code: $('#Orders').dataTable({ "bServerSide": true, "sAjaxSource": "/Suppliers/GetOrders/@Model.ID", "aaSorting": [[1, 'desc']], "bProcessing": true, bAutoWidth: false, "sPaginationType": "full_numbers", "aoColumns": [ { "bVisible": false }, { "sName": "OrderNumber", "bSearchable": false, "bSortable": true, "fnRender": function (oObj) { return '<a href=\"/Orders/View/' + oObj.aData[0] + '\">' + oObj.aData[1] + '</a>'; } }, { "sName": "Supplier", "bSortable": true }, { "sName": "Client" }, { "sName": "OrderPlaced" }, { "sName": "OrderReceived"}, { "sName": "OrderedBy" }, { "sName": "Actions", "fnRender": function (oObj) { return '<a href=\"/Orders/View/' + oObj.aData[0] + '\">view</a>'; } } ] }); Controller code: var data = DataContext.Jobs.Select(job => new { job.ClientID, job.UniverseID, job.ID, job.JobID, job.Title, OfficeName = job.Office.Name, JobStatus = job.JobStatus.Status, job.Progress }).Where(x => x.ClientID == id && x.UniverseID == Universe.ID); data = data.OrderByField(columnNames[Convert.ToInt32(Request["iSortCol_0"])], Request["sSortDir_0"]); And my ExtensionMethod is as follows, based on some code I found online. I'm not entirely sure I understand what this code is doing, which doesnt help me find my problem! public static IQueryable<T> OrderByField<T>(this IQueryable<T> q, string SortField, string SortDirection) { var param = Expression.Parameter(typeof(T), "p"); var prop = Expression.Property(param, SortField); var exp = Expression.Lambda(prop, param); string method = ""; if (SortDirection == "asc") method = "OrderBy"; else method = "OrderByDescending"; Type[] types = new Type[] { q.ElementType, exp.Body.Type }; var mce = Expression.Call(typeof(Queryable), method, types, q.Expression, exp); return q.Provider.CreateQuery<T>(mce); } Finally, the error I get when trying to sort a column containing a date: Instance property 'OrderPlaced' is not defined for type '<>f__AnonymousType6`9[System.Nullable`1[System.Int32],System.Int32,System.Int32,System.String,System.String,System.String,System.Nullable`1[System.DateTime],System.Nullable`1 this occurs in the extension method, on line `var prop = Expression.Property(param, SortField);`
asp.net-mvc-3
entity-framework
jquery-ui
extension-methods
datatables
null
open
Sorting DateTime Column In JQuery Datatables and ASP.NET MVC === I am using the JQuery Datatables plugin in an ASP.NET MVC project to display some tabular data, which is in turn taken from a database using Entity Framework. I have configured the Datatable to use ajax search and sort routines, and I am using an extension method to allow me to specify the name of a column to be sorted as a string. This works perfectly for most fields, but I get an error when trying to sort a field that contains a DateTime object. View JQuery Code: $('#Orders').dataTable({ "bServerSide": true, "sAjaxSource": "/Suppliers/GetOrders/@Model.ID", "aaSorting": [[1, 'desc']], "bProcessing": true, bAutoWidth: false, "sPaginationType": "full_numbers", "aoColumns": [ { "bVisible": false }, { "sName": "OrderNumber", "bSearchable": false, "bSortable": true, "fnRender": function (oObj) { return '<a href=\"/Orders/View/' + oObj.aData[0] + '\">' + oObj.aData[1] + '</a>'; } }, { "sName": "Supplier", "bSortable": true }, { "sName": "Client" }, { "sName": "OrderPlaced" }, { "sName": "OrderReceived"}, { "sName": "OrderedBy" }, { "sName": "Actions", "fnRender": function (oObj) { return '<a href=\"/Orders/View/' + oObj.aData[0] + '\">view</a>'; } } ] }); Controller code: var data = DataContext.Jobs.Select(job => new { job.ClientID, job.UniverseID, job.ID, job.JobID, job.Title, OfficeName = job.Office.Name, JobStatus = job.JobStatus.Status, job.Progress }).Where(x => x.ClientID == id && x.UniverseID == Universe.ID); data = data.OrderByField(columnNames[Convert.ToInt32(Request["iSortCol_0"])], Request["sSortDir_0"]); And my ExtensionMethod is as follows, based on some code I found online. I'm not entirely sure I understand what this code is doing, which doesnt help me find my problem! public static IQueryable<T> OrderByField<T>(this IQueryable<T> q, string SortField, string SortDirection) { var param = Expression.Parameter(typeof(T), "p"); var prop = Expression.Property(param, SortField); var exp = Expression.Lambda(prop, param); string method = ""; if (SortDirection == "asc") method = "OrderBy"; else method = "OrderByDescending"; Type[] types = new Type[] { q.ElementType, exp.Body.Type }; var mce = Expression.Call(typeof(Queryable), method, types, q.Expression, exp); return q.Provider.CreateQuery<T>(mce); } Finally, the error I get when trying to sort a column containing a date: Instance property 'OrderPlaced' is not defined for type '<>f__AnonymousType6`9[System.Nullable`1[System.Int32],System.Int32,System.Int32,System.String,System.String,System.String,System.Nullable`1[System.DateTime],System.Nullable`1 this occurs in the extension method, on line `var prop = Expression.Property(param, SortField);`
0
11,628,254
07/24/2012 09:48:08
1,459,031
06/15/2012 14:57:57
232
1
streamreader exception URI formats are not supported
I am using `azure blob storage`. I stored an txt file in the storage, and now i am trying to read it through : StreamReader reader = new StreamReader(Blob.Uri.AbsoluteUri); Blob containes the reference of the blob where txt file is stored. But here i am getting the exception `(URI formats are not supported.)`. I think the `streamreader` does'nt support the URI formate. Can anybody please give me a better work arround for this ? ( i know one that we can use `DowmloadToFile` method of `CloudBlob` to download the file and then create an address by using Server.MapPath and put that address instead of URI. But if there is any other better solution for this then please let me know )
c#
azure
windows-azure-storage
null
null
null
open
streamreader exception URI formats are not supported === I am using `azure blob storage`. I stored an txt file in the storage, and now i am trying to read it through : StreamReader reader = new StreamReader(Blob.Uri.AbsoluteUri); Blob containes the reference of the blob where txt file is stored. But here i am getting the exception `(URI formats are not supported.)`. I think the `streamreader` does'nt support the URI formate. Can anybody please give me a better work arround for this ? ( i know one that we can use `DowmloadToFile` method of `CloudBlob` to download the file and then create an address by using Server.MapPath and put that address instead of URI. But if there is any other better solution for this then please let me know )
0
11,628,256
07/24/2012 09:48:12
929,227
09/05/2011 16:30:16
61
10
PBKDF2 with SHA256 on android
I want to generate a derived hash of a password using PBKDF2 with SHA256. with this `SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1")` this work but it use SHA1. With `SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256")` (or `SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256","SC")` when with spongycastle) i have an error.
android
encryption
sha256
pbkdf2
null
null
open
PBKDF2 with SHA256 on android === I want to generate a derived hash of a password using PBKDF2 with SHA256. with this `SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1")` this work but it use SHA1. With `SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256")` (or `SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256","SC")` when with spongycastle) i have an error.
0
11,626,493
07/24/2012 07:55:30
1,341,373
04/18/2012 12:52:07
154
13
how to create new plugin for jqplot -option?
I've added just a few lines to the jqplot.pointlabels.js file so I get an extra option in the jqplot pointlabels option. How do I make a new plugin for that? Of course I like to keep those changes if I need to update. I'm not sure how to do this. I'm trying to make a timeline / Gantt like graph. Each item or line piece is a series with just two points. So instead of having pointlabels at each end, I calculate the center and place just one label. So in jqplot.pointlabels.js, line 322 would be: if (p.centerLabel) { var ell = xax.u2p(pd[i][0]) + ((xax.u2p(pd[1][0]) - xax.u2p(pd[0][0])) / 2) +p.xOffset(elem, location); } else { var ell = xax.u2p(pd[i][0]) + p.xOffset(elem, location); } and in the options of jqplot I would write something like: pointLabels:{ show:true, location:'s', fontSize: '1em', centerLabel: true, // extra option, see code labelsFromSeries: true, formatter: $.jqplot.DefaultTickFormatter, } I could copy all the code to a new plugin called jqplot.singleSeriesLabels.js but how do I get jqplot to use that plugin for the 'pointLabels'?
jqplot
labels
series
gantt
null
null
open
how to create new plugin for jqplot -option? === I've added just a few lines to the jqplot.pointlabels.js file so I get an extra option in the jqplot pointlabels option. How do I make a new plugin for that? Of course I like to keep those changes if I need to update. I'm not sure how to do this. I'm trying to make a timeline / Gantt like graph. Each item or line piece is a series with just two points. So instead of having pointlabels at each end, I calculate the center and place just one label. So in jqplot.pointlabels.js, line 322 would be: if (p.centerLabel) { var ell = xax.u2p(pd[i][0]) + ((xax.u2p(pd[1][0]) - xax.u2p(pd[0][0])) / 2) +p.xOffset(elem, location); } else { var ell = xax.u2p(pd[i][0]) + p.xOffset(elem, location); } and in the options of jqplot I would write something like: pointLabels:{ show:true, location:'s', fontSize: '1em', centerLabel: true, // extra option, see code labelsFromSeries: true, formatter: $.jqplot.DefaultTickFormatter, } I could copy all the code to a new plugin called jqplot.singleSeriesLabels.js but how do I get jqplot to use that plugin for the 'pointLabels'?
0
11,628,262
07/24/2012 09:48:31
974,680
10/01/2011 17:06:06
43
0
Send mail from PHP with minimum 3rd party services?
Dont ignore if this sounds like a duplicate. I went through similar questions here but couldnt resolve my doubts. Im developing a site in my localhost. Its coded in PHP. I need to send mail to my site's customers from my PHP script. I know we can use gmail smtp server for this. But due to the limit on the mail/day set by google, i prefer not to use them. But my doubts are: 1. Can i do it without gmail's smtp server or anyone else's smtp server? 2. What all components would i need to send mails from my localhost as well as from my online webserver? 3. Does all the webservers come pre-configured to enable us to send mail from site? 4. What is sendMail, phpMailer, pearMail etc.? I've been advised to use them. But what are they? Thanks a lot!
php
smtp
sendmail
null
null
null
open
Send mail from PHP with minimum 3rd party services? === Dont ignore if this sounds like a duplicate. I went through similar questions here but couldnt resolve my doubts. Im developing a site in my localhost. Its coded in PHP. I need to send mail to my site's customers from my PHP script. I know we can use gmail smtp server for this. But due to the limit on the mail/day set by google, i prefer not to use them. But my doubts are: 1. Can i do it without gmail's smtp server or anyone else's smtp server? 2. What all components would i need to send mails from my localhost as well as from my online webserver? 3. Does all the webservers come pre-configured to enable us to send mail from site? 4. What is sendMail, phpMailer, pearMail etc.? I've been advised to use them. But what are they? Thanks a lot!
0
11,628,264
07/24/2012 09:48:37
1,547,882
07/24/2012 07:27:26
6
0
how to disable delay signed in c#.net web projects
I am getting these error as Build (web): Could not load file or assembly 'PetShop.DBUtility, Version=4.0.0.0, Culture=neutral, PublicKeyToken=a7987b61c51ca872' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045) So i figure it out that i need to disable the delay signal of that dll which i am using in my project i am using vsexpress10 c# edition for development Waiting for your solution
c#
.net
null
null
null
null
open
how to disable delay signed in c#.net web projects === I am getting these error as Build (web): Could not load file or assembly 'PetShop.DBUtility, Version=4.0.0.0, Culture=neutral, PublicKeyToken=a7987b61c51ca872' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045) So i figure it out that i need to disable the delay signal of that dll which i am using in my project i am using vsexpress10 c# edition for development Waiting for your solution
0
11,628,265
07/24/2012 09:48:39
1,128,694
01/03/2012 20:58:56
67
0
PHP - Adding text values of multiple text box values to a variable
I want to add the following information to a variable, (The txt-via-hn textboxes are house numbers, the txt-via are address details) $vias = $_POST['txt-via-hn2'].' '.$_POST['txt-via2'] .$_POST['txt-via-hn3'].' '.$_POST['txt-via3'] .$_POST['txt-via-hn4'].' '.$_POST['txt-via4'] .$_POST['txt-via-hn5'].' '.$_POST['txt-via5'] .$_POST['txt-via-hn6'].' '.$_POST['txt-via6'] .$_POST['txt-via-hn7'].' '.$_POST['txt-via7'] .$_POST['txt-via-hn8'].' '.$_POST['txt-via8'] .$_POST['txt-via-hn9'].' '.$_POST['txt-via9'] .$_POST['txt-via-hn10'].' '.$_POST['txt-via10']; I'm fairly new to PHP so I'm not too sure how to go about doing this but basically the format that I need this to be in is as follows: $vias = <vias> <vh1>$_POST['txt-via-hn2']</vh1><vi1>$_POST['txt-via2']</vi1> <vh2>$_POST['txt-via-hn3']</vh2><vi2>$_POST['txt-via3']</vi2> <vh3>$_POST['txt-via-hn4']</vh3><vi3>$_POST['txt-via4']</vi3> <vh4>$_POST['txt-via-hn5']</vh4><vi4>$_POST['txt-via5']</vi4> <vh5>$_POST['txt-via-hn6']</vh5><vi5>$_POST['txt-via6']</vi5> <vh6>$_POST['txt-via-hn7']</vh6><vi6>$_POST['txt-via7']</vi6> <vh7>$_POST['txt-via-hn8']</vh7><vi7>$_POST['txt-via8']</vi7> <vh8>$_POST['txt-via-hn9']</vh8><vi8>$_POST['txt-via9']</vi8> <vh9>$_POST['txt-via-hn10']</vh9><vi9>$_POST['txt-via10']</vi9> </vias> Also, if for example `$_POST['txt-via-hn10']` & `$_POST['txt-via10']` are empty, would it be possible that `<vh9> and </vh9>` are not included in the variable? Any help on this would be much appreciated! :)
php
null
null
null
null
null
open
PHP - Adding text values of multiple text box values to a variable === I want to add the following information to a variable, (The txt-via-hn textboxes are house numbers, the txt-via are address details) $vias = $_POST['txt-via-hn2'].' '.$_POST['txt-via2'] .$_POST['txt-via-hn3'].' '.$_POST['txt-via3'] .$_POST['txt-via-hn4'].' '.$_POST['txt-via4'] .$_POST['txt-via-hn5'].' '.$_POST['txt-via5'] .$_POST['txt-via-hn6'].' '.$_POST['txt-via6'] .$_POST['txt-via-hn7'].' '.$_POST['txt-via7'] .$_POST['txt-via-hn8'].' '.$_POST['txt-via8'] .$_POST['txt-via-hn9'].' '.$_POST['txt-via9'] .$_POST['txt-via-hn10'].' '.$_POST['txt-via10']; I'm fairly new to PHP so I'm not too sure how to go about doing this but basically the format that I need this to be in is as follows: $vias = <vias> <vh1>$_POST['txt-via-hn2']</vh1><vi1>$_POST['txt-via2']</vi1> <vh2>$_POST['txt-via-hn3']</vh2><vi2>$_POST['txt-via3']</vi2> <vh3>$_POST['txt-via-hn4']</vh3><vi3>$_POST['txt-via4']</vi3> <vh4>$_POST['txt-via-hn5']</vh4><vi4>$_POST['txt-via5']</vi4> <vh5>$_POST['txt-via-hn6']</vh5><vi5>$_POST['txt-via6']</vi5> <vh6>$_POST['txt-via-hn7']</vh6><vi6>$_POST['txt-via7']</vi6> <vh7>$_POST['txt-via-hn8']</vh7><vi7>$_POST['txt-via8']</vi7> <vh8>$_POST['txt-via-hn9']</vh8><vi8>$_POST['txt-via9']</vi8> <vh9>$_POST['txt-via-hn10']</vh9><vi9>$_POST['txt-via10']</vi9> </vias> Also, if for example `$_POST['txt-via-hn10']` & `$_POST['txt-via10']` are empty, would it be possible that `<vh9> and </vh9>` are not included in the variable? Any help on this would be much appreciated! :)
0
11,628,267
07/24/2012 09:48:43
1,092,355
12/11/2011 15:24:13
11
0
Packaging Images with SQL Server Script
i have a sql server db which needs to be deployed with an asp.net application. In a particular master table data is populated via a batch when installing the app. There are some images which must be saved in the db during installation. How do I package these images and how do I supply the path to these images ?
sql-server
null
null
null
null
null
open
Packaging Images with SQL Server Script === i have a sql server db which needs to be deployed with an asp.net application. In a particular master table data is populated via a batch when installing the app. There are some images which must be saved in the db during installation. How do I package these images and how do I supply the path to these images ?
0
11,542,093
07/18/2012 13:04:55
238,284
12/24/2009 15:57:58
101
6
Create a desktop application in Java, Which should not run in anyother machine than which I prefer
I am trying to create a desktop application in Java, 1. It should not run in another machine than which I prefer. 2. It should not run after a particular expiry data. Is there any good idea to do so. Please help me. Thanks in advance. ---------- **According to my knowledge(very less) I have some suggestion:** **For Point1:** By Hard-coding my application's startUp to check for the ProcessorId(because it is unique one) If it is a valid one it should execute else show a "Expired" alert. But for doing this i should give a separate jar setUp to each user which i dont mind. **For Point2:** Should maintain a encrypted file which will store the current date. During each startup of the application. I will update the date field in the file if the current date is greater than the one in the file. If not i will display a "Expired" alert. This may look funny but this is what I can think.
java
encryption
jar
privacy
piracy-prevention
null
open
Create a desktop application in Java, Which should not run in anyother machine than which I prefer === I am trying to create a desktop application in Java, 1. It should not run in another machine than which I prefer. 2. It should not run after a particular expiry data. Is there any good idea to do so. Please help me. Thanks in advance. ---------- **According to my knowledge(very less) I have some suggestion:** **For Point1:** By Hard-coding my application's startUp to check for the ProcessorId(because it is unique one) If it is a valid one it should execute else show a "Expired" alert. But for doing this i should give a separate jar setUp to each user which i dont mind. **For Point2:** Should maintain a encrypted file which will store the current date. During each startup of the application. I will update the date field in the file if the current date is greater than the one in the file. If not i will display a "Expired" alert. This may look funny but this is what I can think.
0
11,542,097
07/18/2012 13:05:05
1,476,365
06/23/2012 04:49:16
11
1
extracting a dictionary key and assigning it to a variable in python
The file names.dat looks exactly like this: Fry, Philip J.;999 111-1111;999 222-2222 Rodriguez, Bender B.;999 333-3333;999 444-4444 Farnsworth, Professor;999 555-5555;999 666-6666 Leela, Turanga;999 777-7777;999 888-8888 Wong, Amy;999 999-9999;999 101-1010 And the below code gives the printed results down at the bottom. What I want to do is make a menu driven program that will allow the user to choose by number which record they want to modify. In pseudo code it would look something like this: * the first block of code with the numbered phone listing goes here * Enter by number the record you want to modify * User enters 3 * For Rodriguez, Bender B enter a c to modify the cell phone or enter an h to modify the home phone * User enters h * Type in the 10 digit phone number with no spaces * User enters 7771234567 * Record gets changed * Enter p to view the modified phone book (which would show all the records but with a different phone for Bender * Would you like to make another modification? y for yes, n for no My problem is that I can't find a way to bind the primary key to the entered user number. Being that python dictionaries have no order I'm finding this hard to do. Can someone please help? I only need that, the rest I can do myself. pBook = {} fp = open('names.dat') # populate pBook while 1: line = fp.readline() if not line: break x = line[:-1] data = x.split(';') pBook[data[0]] = {'home': data[1], 'cell': data[2]} fp.close() # optional if you want to see the dictionary structure # print pBook i = 1 print '\nPhone listings:\n' for record in pBook: key = str(i) i += 1 print key + ')', record + ':', 'Home', pBook[record]['home'] + ',', 'Cell', pBook[record]['cell'] print '' >Phone listings: 1) Farnsworth, Professor: Home 999 555-5555, Cell 999 666-6666 2) Fry, Philip J.: Home 999 111-1111, Cell 999 222-2222 3) Rodriguez, Bender B.: Home 999 333-3333, Cell 999 444-4444 4) Wong, Amy: Home 999 999-9999, Cell 999 101-1010 5) Leela, Turanga: Home 999 777-7777, Cell 999 888-8888 Results of printing pBook after it has been populated, formatted for this post so it's easier understand its structure. The primary key is the person's name, the values is another dictionary where 'cell' and 'home' are keys and the phone numbers are the respective values. { 'Farnsworth, Professor': {'cell': '999 666-6666', 'home': '999 555-5555'}, 'Fry, Philip J.': {'cell ': '999 222-2222', 'home': '999 111-1111'}, 'Rodriguez, Bender B.': {'cell': '999 444-4444', 'home': '999 333-3333'}, 'Wong, Amy' : {'cell': '999 101-1010', 'home': '999 999-9999'}, 'Leela, Turanga': {'cell': '999 888-8888', 'home': '999 777-7777'} }
python
variables
dictionary
key
primary-key
null
open
extracting a dictionary key and assigning it to a variable in python === The file names.dat looks exactly like this: Fry, Philip J.;999 111-1111;999 222-2222 Rodriguez, Bender B.;999 333-3333;999 444-4444 Farnsworth, Professor;999 555-5555;999 666-6666 Leela, Turanga;999 777-7777;999 888-8888 Wong, Amy;999 999-9999;999 101-1010 And the below code gives the printed results down at the bottom. What I want to do is make a menu driven program that will allow the user to choose by number which record they want to modify. In pseudo code it would look something like this: * the first block of code with the numbered phone listing goes here * Enter by number the record you want to modify * User enters 3 * For Rodriguez, Bender B enter a c to modify the cell phone or enter an h to modify the home phone * User enters h * Type in the 10 digit phone number with no spaces * User enters 7771234567 * Record gets changed * Enter p to view the modified phone book (which would show all the records but with a different phone for Bender * Would you like to make another modification? y for yes, n for no My problem is that I can't find a way to bind the primary key to the entered user number. Being that python dictionaries have no order I'm finding this hard to do. Can someone please help? I only need that, the rest I can do myself. pBook = {} fp = open('names.dat') # populate pBook while 1: line = fp.readline() if not line: break x = line[:-1] data = x.split(';') pBook[data[0]] = {'home': data[1], 'cell': data[2]} fp.close() # optional if you want to see the dictionary structure # print pBook i = 1 print '\nPhone listings:\n' for record in pBook: key = str(i) i += 1 print key + ')', record + ':', 'Home', pBook[record]['home'] + ',', 'Cell', pBook[record]['cell'] print '' >Phone listings: 1) Farnsworth, Professor: Home 999 555-5555, Cell 999 666-6666 2) Fry, Philip J.: Home 999 111-1111, Cell 999 222-2222 3) Rodriguez, Bender B.: Home 999 333-3333, Cell 999 444-4444 4) Wong, Amy: Home 999 999-9999, Cell 999 101-1010 5) Leela, Turanga: Home 999 777-7777, Cell 999 888-8888 Results of printing pBook after it has been populated, formatted for this post so it's easier understand its structure. The primary key is the person's name, the values is another dictionary where 'cell' and 'home' are keys and the phone numbers are the respective values. { 'Farnsworth, Professor': {'cell': '999 666-6666', 'home': '999 555-5555'}, 'Fry, Philip J.': {'cell ': '999 222-2222', 'home': '999 111-1111'}, 'Rodriguez, Bender B.': {'cell': '999 444-4444', 'home': '999 333-3333'}, 'Wong, Amy' : {'cell': '999 101-1010', 'home': '999 999-9999'}, 'Leela, Turanga': {'cell': '999 888-8888', 'home': '999 777-7777'} }
0
11,542,098
07/18/2012 13:05:12
1,499,785
07/03/2012 19:27:24
8
0
Javascript form serialization for JSON
I am trying to serialize a form into a JSON object in such a way that i can send the data via AJAX. I'm using the function below: $.fn.serializeObject = function() { var arrayData, objectData; arrayData = this.serializeArray(); objectData = {}; $.each(arrayData, function() { var value; if (this.value != null && this.value != '') { value = this.value; } else { value = null; } if (objectData[this.name] != null) { if (!objectData[this.name].push) { objectData[this.name] = [ objectData[this.name] ]; } objectData[this.name].push(value); } else { objectData[this.name] = value; } }); return objectData; }; The problem is that my serialization does not take into account cyclic data structures. For example i have in my form <form:input path="discipline.cnfpDisciplineCode" class="required" /> and this gets serialized as { ... discipline.cnfpDisciplineCode : someValue ... } Is there an elegant solution to serialize the form to make it look like { ... discipline : { cnfpDisciplineCode : someValue } ... } Or do i have to implement the whole parsing algorithm myself? Thank you.
javascript
ajax
json
serialization
null
null
open
Javascript form serialization for JSON === I am trying to serialize a form into a JSON object in such a way that i can send the data via AJAX. I'm using the function below: $.fn.serializeObject = function() { var arrayData, objectData; arrayData = this.serializeArray(); objectData = {}; $.each(arrayData, function() { var value; if (this.value != null && this.value != '') { value = this.value; } else { value = null; } if (objectData[this.name] != null) { if (!objectData[this.name].push) { objectData[this.name] = [ objectData[this.name] ]; } objectData[this.name].push(value); } else { objectData[this.name] = value; } }); return objectData; }; The problem is that my serialization does not take into account cyclic data structures. For example i have in my form <form:input path="discipline.cnfpDisciplineCode" class="required" /> and this gets serialized as { ... discipline.cnfpDisciplineCode : someValue ... } Is there an elegant solution to serialize the form to make it look like { ... discipline : { cnfpDisciplineCode : someValue } ... } Or do i have to implement the whole parsing algorithm myself? Thank you.
0
11,542,046
07/18/2012 13:02:48
1,040,718
11/10/2011 22:42:51
605
29
retrieving the cell / column value with JQuery / JavaScript
I have this following Table, which utilizes Google Visualization API: <html> <head> <script type='text/javascript' src='https://www.google.com/jsapi'></script> <script type='text/javascript'> google.load('visualization', '1', {packages:['table']}); google.setOnLoadCallback(drawTable); function drawTable() { var data = new google.visualization.DataTable(); data.addColumn('string', 'Name'); data.addColumn('number', 'Salary'); data.addColumn('boolean', 'Full Time Employee'); data.addRows([ ['Mike', {v: 10000, f: '$10,000'}, true], ['Jim', {v:8000, f: '$8,000'}, false], ['Alice', {v: 12500, f: '$12,500'}, true], ['Bob', {v: 7000, f: '$7,000'}, true] ]); var table = new google.visualization.Table(document.getElementById('table_div')); table.draw(data, {showRowNumber: true}); } </script> </head> <body> <div id='table_div'></div> </body> </html> What would I like to know is how to, when I click in a cell: 1. Return the Column Index in which that cell is located ? 2. Return the name of the column's header ? 3. How to return that specifically cell's value ? If I figure out how to do at least one of those, then my problem will be solved. It has dodged me a lot. Thanks
javascript
jquery
html
null
null
null
open
retrieving the cell / column value with JQuery / JavaScript === I have this following Table, which utilizes Google Visualization API: <html> <head> <script type='text/javascript' src='https://www.google.com/jsapi'></script> <script type='text/javascript'> google.load('visualization', '1', {packages:['table']}); google.setOnLoadCallback(drawTable); function drawTable() { var data = new google.visualization.DataTable(); data.addColumn('string', 'Name'); data.addColumn('number', 'Salary'); data.addColumn('boolean', 'Full Time Employee'); data.addRows([ ['Mike', {v: 10000, f: '$10,000'}, true], ['Jim', {v:8000, f: '$8,000'}, false], ['Alice', {v: 12500, f: '$12,500'}, true], ['Bob', {v: 7000, f: '$7,000'}, true] ]); var table = new google.visualization.Table(document.getElementById('table_div')); table.draw(data, {showRowNumber: true}); } </script> </head> <body> <div id='table_div'></div> </body> </html> What would I like to know is how to, when I click in a cell: 1. Return the Column Index in which that cell is located ? 2. Return the name of the column's header ? 3. How to return that specifically cell's value ? If I figure out how to do at least one of those, then my problem will be solved. It has dodged me a lot. Thanks
0
11,542,110
07/18/2012 13:05:48
378,065
06/28/2010 13:36:25
760
49
How do I safely change the value of the primary key field in a Django model?
I have a Django model with a custom specified primary key: class ModelA(models.Model): my_primary_key = models.CharField(primary_key=True, ...) ... I also have other models which have ForeignKey references to this model: class ModelB(models.Model): ref_to_A = models.ForeignKey('ModelA', ...) ... class ModelC(models.Model): ref_to_A = models.ForeignKey('ModelA', ...) ... ... I have some instances of ModelA, and need to change the value for my_primary_key for these instances. What is the best way to go about doing this?
database
django
django-models
django-orm
null
null
open
How do I safely change the value of the primary key field in a Django model? === I have a Django model with a custom specified primary key: class ModelA(models.Model): my_primary_key = models.CharField(primary_key=True, ...) ... I also have other models which have ForeignKey references to this model: class ModelB(models.Model): ref_to_A = models.ForeignKey('ModelA', ...) ... class ModelC(models.Model): ref_to_A = models.ForeignKey('ModelA', ...) ... ... I have some instances of ModelA, and need to change the value for my_primary_key for these instances. What is the best way to go about doing this?
0
11,542,116
07/18/2012 13:06:07
542,664
12/14/2010 22:55:51
579
22
Ignoring strange Parsing errors with Xerces
I am trying to parse the following url as a DOM Document in Java: http://www.op.org/en/rss-category-home/8. However, when I do this, I get the following error: 13:51:38,470 ERROR ~ Error processing site Site 1 org.xml.sax.SAXParseException: The entity "acirc" was referenced, but not declared. at org.apache.xerces.parsers.DOMParser.parse(Unknown Source) at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source) at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:124) at logic.server.RssReader.readRss(RssReader.java:44) at logic.server.GatherData.doJobWithResult(GatherData.java:49) at logic.server.GatherData.doJobWithResult(GatherData.java:1) I read somewhere that the Xerces parser in the current JRE is has a bug related to this, so downloaded Xerces2 2.11.0, but still have the same problem. How can I get around this problem. I have no control over the RSS feed itself, but need to parse the XML to process the articles. My code is: DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = dbf.newDocumentBuilder(); Document dom = builder.parse(rssUrl.openStream()); NodeList nodes = dom.getElementsByTagName("item"); etc. etc. Any help to get around this problem is really appreciated!
java
xml
xml-parsing
xerces
null
null
open
Ignoring strange Parsing errors with Xerces === I am trying to parse the following url as a DOM Document in Java: http://www.op.org/en/rss-category-home/8. However, when I do this, I get the following error: 13:51:38,470 ERROR ~ Error processing site Site 1 org.xml.sax.SAXParseException: The entity "acirc" was referenced, but not declared. at org.apache.xerces.parsers.DOMParser.parse(Unknown Source) at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source) at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:124) at logic.server.RssReader.readRss(RssReader.java:44) at logic.server.GatherData.doJobWithResult(GatherData.java:49) at logic.server.GatherData.doJobWithResult(GatherData.java:1) I read somewhere that the Xerces parser in the current JRE is has a bug related to this, so downloaded Xerces2 2.11.0, but still have the same problem. How can I get around this problem. I have no control over the RSS feed itself, but need to parse the XML to process the articles. My code is: DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = dbf.newDocumentBuilder(); Document dom = builder.parse(rssUrl.openStream()); NodeList nodes = dom.getElementsByTagName("item"); etc. etc. Any help to get around this problem is really appreciated!
0
11,350,311
07/05/2012 18:26:10
898,763
08/17/2011 13:49:53
1,351
69
Junit 4 - running all the tests in a test class
I have been setting up some contract JUnit 4 tests (following advice in answer to this [question][1]) - e.g. if I have an interface (I've included generics in the example, since I'm using them in my project): public interface MyInterface<T> { public T myMethod(); } I create an abstract contract test - e.g.: public abstract class AbstractMyInterfaceTest<T> { private final MyInterface<T> _impl; // plus, store stuff to test against; public AbstractMyInterfaceTest(MyInterface<T> impl, ... stuff to test against){ _impl = impl; // stuff to test against... } @Test public void testMyMethod(){ // test some stuff... } } ...and extend this abstract test class for each implementation (which I am running with `@RunWith(Parameterized.class)`). I'm also passing some variables to test the implementation of the interface against into the abstract test class. However, in actuality, some interfaces return objects that are implementations of other interfaces, and I would like to be able to test this implementation using the abstract contract class for that interface (...and against the relevant variables). At the moment, I'm adding the following to the abstract test classes: // N.b. not setting @Test - so doesn't run all tests twice... public void runTests(){ testMyMethod(); // etc. } However, is there was a better way of doing this, perhaps making use of features in JUnit 4? I've seen stuff about the `@RunWith(Suite.class)` annotation, but that seems to be about running multiple test classes from a single test class, and doesn't allow you to pass variables into the different test classes that are being run. There may be a way to use this `Suite` to solve my problem, but I'm not sure what it is... [1]: http://stackoverflow.com/questions/11157042/java-contract-tests
java
unit-testing
interface
junit4
null
null
open
Junit 4 - running all the tests in a test class === I have been setting up some contract JUnit 4 tests (following advice in answer to this [question][1]) - e.g. if I have an interface (I've included generics in the example, since I'm using them in my project): public interface MyInterface<T> { public T myMethod(); } I create an abstract contract test - e.g.: public abstract class AbstractMyInterfaceTest<T> { private final MyInterface<T> _impl; // plus, store stuff to test against; public AbstractMyInterfaceTest(MyInterface<T> impl, ... stuff to test against){ _impl = impl; // stuff to test against... } @Test public void testMyMethod(){ // test some stuff... } } ...and extend this abstract test class for each implementation (which I am running with `@RunWith(Parameterized.class)`). I'm also passing some variables to test the implementation of the interface against into the abstract test class. However, in actuality, some interfaces return objects that are implementations of other interfaces, and I would like to be able to test this implementation using the abstract contract class for that interface (...and against the relevant variables). At the moment, I'm adding the following to the abstract test classes: // N.b. not setting @Test - so doesn't run all tests twice... public void runTests(){ testMyMethod(); // etc. } However, is there was a better way of doing this, perhaps making use of features in JUnit 4? I've seen stuff about the `@RunWith(Suite.class)` annotation, but that seems to be about running multiple test classes from a single test class, and doesn't allow you to pass variables into the different test classes that are being run. There may be a way to use this `Suite` to solve my problem, but I'm not sure what it is... [1]: http://stackoverflow.com/questions/11157042/java-contract-tests
0
11,350,324
07/05/2012 18:26:48
179,531
09/26/2009 17:36:26
143
5
index action getting executed after every action call (MVC2)
In my controller, i don't have a requirement for index action since i got my action names from marketing. When i execute a given action, as soon as its html gets rendered, the index action gets called automatically (found out as elmah started sending page not found errors). Right now, i have put an index action in the controller and it is returning null to tackle this issue. I didn't wanted to redirect to "welcome" action which is default. On Tuesday evening, i didn't had this problem. Between then and now nothing changed and my QA, production (2 servers) and local development all are doing this. I have double checked the code and i am not calling from anywhere the index action. In this controller i have 12 actions and all have the same issue. Global.asa public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional, Area = "" }, // Parameter defaults new string[] { "Site.Controllers" } ); } protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); //RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes); } My main landing page is: http://www.domina.come/ReportingCenter/AnnualReport/Welcome I have the following in the area registration. I have changed "index" to "Welcome" and now this is getting called instead of index after every other action call. namespace Site.Areas.ReportingCenter { public class ReportingCenterAreaRegistration : AreaRegistration { public override string AreaName { get { return "ReportingCenter"; } } public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( "ReportingCenter_default", "ReportingCenter/{controller}/{action}/{id}", new { action = "Index", id = UrlParameter.Optional } ); } } } Thanks for looking!
asp.net-mvc-2
null
null
null
null
null
open
index action getting executed after every action call (MVC2) === In my controller, i don't have a requirement for index action since i got my action names from marketing. When i execute a given action, as soon as its html gets rendered, the index action gets called automatically (found out as elmah started sending page not found errors). Right now, i have put an index action in the controller and it is returning null to tackle this issue. I didn't wanted to redirect to "welcome" action which is default. On Tuesday evening, i didn't had this problem. Between then and now nothing changed and my QA, production (2 servers) and local development all are doing this. I have double checked the code and i am not calling from anywhere the index action. In this controller i have 12 actions and all have the same issue. Global.asa public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional, Area = "" }, // Parameter defaults new string[] { "Site.Controllers" } ); } protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); //RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes); } My main landing page is: http://www.domina.come/ReportingCenter/AnnualReport/Welcome I have the following in the area registration. I have changed "index" to "Welcome" and now this is getting called instead of index after every other action call. namespace Site.Areas.ReportingCenter { public class ReportingCenterAreaRegistration : AreaRegistration { public override string AreaName { get { return "ReportingCenter"; } } public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( "ReportingCenter_default", "ReportingCenter/{controller}/{action}/{id}", new { action = "Index", id = UrlParameter.Optional } ); } } } Thanks for looking!
0
11,350,325
07/05/2012 18:26:48
1,500,039
07/03/2012 21:37:11
1
0
Class Libraries, MVC, and Data Annotation
I'm new to MVC and am unsure about proper design. I have class objects which I use in a variety of applications. I have taken the approach to write a custom view model class so that I can have access to properties in all of these objects and have strong typing. Without re-typing all my class code in the view model is there any way to have the properties in these objects validated using data annotation? Please let me know if my approach and design is all wrong. [Required] public User user = new User("username"); //User has lots properites and methods, could i validate inside my class code? //What I'd like to avoid is putting the following stuff in my custom view model class, //since I already have a class library with this stuff: public class User { [Required] [StringLength(160)] public string prop1 { get; set; } [Required] [StringLength(160)] public string prop2 { get; set; } [Required] [StringLength(160)] public string prop3 { get; set; } public User(string token) { SetUser(token); } public void SetUser(string token) { this.prop1 = "this"; this.prop2 = "this2"; this.prop3 = "this3"; }
asp.net
mvc
design
null
null
null
open
Class Libraries, MVC, and Data Annotation === I'm new to MVC and am unsure about proper design. I have class objects which I use in a variety of applications. I have taken the approach to write a custom view model class so that I can have access to properties in all of these objects and have strong typing. Without re-typing all my class code in the view model is there any way to have the properties in these objects validated using data annotation? Please let me know if my approach and design is all wrong. [Required] public User user = new User("username"); //User has lots properites and methods, could i validate inside my class code? //What I'd like to avoid is putting the following stuff in my custom view model class, //since I already have a class library with this stuff: public class User { [Required] [StringLength(160)] public string prop1 { get; set; } [Required] [StringLength(160)] public string prop2 { get; set; } [Required] [StringLength(160)] public string prop3 { get; set; } public User(string token) { SetUser(token); } public void SetUser(string token) { this.prop1 = "this"; this.prop2 = "this2"; this.prop3 = "this3"; }
0
11,350,331
07/05/2012 18:27:28
1,504,859
07/05/2012 18:19:57
1
0
How to query second 10 records order by date in varchar format in DB2
assuming below table; column name | type id | int date | varchar when use ROWNUMBER() OVER( ORDER BY TYPE_DATE ) as ROWID, TO_DATE( date, 'mm\dd\yyyy' ) as TYPE_DATE, * FROM TABLE. I always get below error: SQL0104N an expected token "*" was found following .... <select_sublist> here are three questions: 1. why '*' can not be used here 2. why new column can not be used in OVER() 3. how to get second 10 records order by a formatted column
db2
null
null
null
null
null
open
How to query second 10 records order by date in varchar format in DB2 === assuming below table; column name | type id | int date | varchar when use ROWNUMBER() OVER( ORDER BY TYPE_DATE ) as ROWID, TO_DATE( date, 'mm\dd\yyyy' ) as TYPE_DATE, * FROM TABLE. I always get below error: SQL0104N an expected token "*" was found following .... <select_sublist> here are three questions: 1. why '*' can not be used here 2. why new column can not be used in OVER() 3. how to get second 10 records order by a formatted column
0
11,350,333
07/05/2012 18:27:29
1,504,849
07/05/2012 18:14:11
1
0
go:video tag with token links
I am trying to use the OG tags for my site and share videos. this works fine but then after a period of time the video link i share expires. the link is from cloudfront and is being set for a limited about of time 15 min. I have tried extending the time limit on the video to 36 hours after reading about Facebook scraping the page for new metadata every 24 hours but it doesn't get the new link. i also tried to force it https://developers.facebook.com/tools/debug/ with no luck. Does Facebook not update the video tag when it scrapes? Or am i missing some param? <meta property="og:type" content="movie" /> <meta property="og:url" content="<?php echo $url; ?>" /> <meta property="og:video:height" content="<?php echo $version['height']?>" /> <meta property="og:video:width" content="<?php echo $version['width']?>" /> <meta property="og:video:type" content="application/x-shockwave-flash" /> <meta property="og:title" content="<?php echo $pageMetaData['title']?>" /> <meta property="og:description" content="<?php echo $pageMetaData['description']?>" /> <meta property="og:image" content="<?php echo $this->Image->resize('/img/videos/'.$video['Video']['image1'], $width=200, $height=200, $aspect = true, $htmlAttributes = array(),$fulltag = false, $cut = false, $return = false);?>" /> <meta property="og:video" content="<?php echo urlencode($link)?>&autostart=true" />
video
opengraph
token
amazon-cloudfront
null
null
open
go:video tag with token links === I am trying to use the OG tags for my site and share videos. this works fine but then after a period of time the video link i share expires. the link is from cloudfront and is being set for a limited about of time 15 min. I have tried extending the time limit on the video to 36 hours after reading about Facebook scraping the page for new metadata every 24 hours but it doesn't get the new link. i also tried to force it https://developers.facebook.com/tools/debug/ with no luck. Does Facebook not update the video tag when it scrapes? Or am i missing some param? <meta property="og:type" content="movie" /> <meta property="og:url" content="<?php echo $url; ?>" /> <meta property="og:video:height" content="<?php echo $version['height']?>" /> <meta property="og:video:width" content="<?php echo $version['width']?>" /> <meta property="og:video:type" content="application/x-shockwave-flash" /> <meta property="og:title" content="<?php echo $pageMetaData['title']?>" /> <meta property="og:description" content="<?php echo $pageMetaData['description']?>" /> <meta property="og:image" content="<?php echo $this->Image->resize('/img/videos/'.$video['Video']['image1'], $width=200, $height=200, $aspect = true, $htmlAttributes = array(),$fulltag = false, $cut = false, $return = false);?>" /> <meta property="og:video" content="<?php echo urlencode($link)?>&autostart=true" />
0
11,350,334
07/05/2012 18:27:30
842,697
07/13/2011 12:50:04
73
3
How to import an Android Projects with git into workspace using egit?
In my projects I use some Android Libraries that are hosted on github, for example, [facebook android sdk][1]. Until now I downloaded the .zip with the library and added it to my workspace. This made keeping up to date libraries were a tedious job. I want to use the option "Import > Git" in eclipse to import the Android Projects. And later use "Team > Pull" to obtain the latest versions of these projects. Is that possible? How? My two principal problems are: - The android project there is not in the root of the repository, and - there is not .project file. [1]: https://github.com/facebook/facebook-android-sdk
android
eclipse
git
egit
null
null
open
How to import an Android Projects with git into workspace using egit? === In my projects I use some Android Libraries that are hosted on github, for example, [facebook android sdk][1]. Until now I downloaded the .zip with the library and added it to my workspace. This made keeping up to date libraries were a tedious job. I want to use the option "Import > Git" in eclipse to import the Android Projects. And later use "Team > Pull" to obtain the latest versions of these projects. Is that possible? How? My two principal problems are: - The android project there is not in the root of the repository, and - there is not .project file. [1]: https://github.com/facebook/facebook-android-sdk
0
11,472,184
07/13/2012 14:11:18
1,475,765
06/22/2012 19:29:31
64
2
Java class will not compile
I am getting a couple errors I cannot seem to fix... This is example code, so I'm confused what's going on. The error's are commented to the side of the lines where they show up. import java.io.DataInputStream; import java.io.DataOutputStream; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; public class Connect { URL url; URLConnection urlConnection; DataOutputStream outStream; DataInputStream inStream; // Build request body String body = "fname=" + URLEncoder.encode("Atli", "UTF-8"); //Syntax error on token ";", { expected after this token // Create connection url = new URL("http://192.168.1.68/test/POST/post.php"); urlConnection = url.openConnection(); ((HttpURLConnection)urlConnection).setRequestMethod("POST"); urlConnection.setDoInput(true); urlConnection.setDoOutput(true); urlConnection.setUseCaches(false); urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); urlConnection.setRequestProperty("Content-Length", ""+ body.length()); // Create I/O streams outStream = new DataOutputStream(urlConnection.getOutputStream()); inStream = new DataInputStream(urlConnection.getInputStream()); // Send request outStream.writeBytes(body); outStream.flush(); outStream.close(); // Get Response // - For debugging purposes only! String buffer; while((buffer = inStream.readLine()) != null) { System.out.println(buffer); } // Close I/O streams inStream.close(); outStream.close(); }//Syntax error, insert "}" to complete ClassBody Anybody see something obvious that I don't? On a side note, if the php echoes back html code, upon running this class, is java capable of understanding the html code?
java
httpconnection
null
null
null
null
open
Java class will not compile === I am getting a couple errors I cannot seem to fix... This is example code, so I'm confused what's going on. The error's are commented to the side of the lines where they show up. import java.io.DataInputStream; import java.io.DataOutputStream; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; public class Connect { URL url; URLConnection urlConnection; DataOutputStream outStream; DataInputStream inStream; // Build request body String body = "fname=" + URLEncoder.encode("Atli", "UTF-8"); //Syntax error on token ";", { expected after this token // Create connection url = new URL("http://192.168.1.68/test/POST/post.php"); urlConnection = url.openConnection(); ((HttpURLConnection)urlConnection).setRequestMethod("POST"); urlConnection.setDoInput(true); urlConnection.setDoOutput(true); urlConnection.setUseCaches(false); urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); urlConnection.setRequestProperty("Content-Length", ""+ body.length()); // Create I/O streams outStream = new DataOutputStream(urlConnection.getOutputStream()); inStream = new DataInputStream(urlConnection.getInputStream()); // Send request outStream.writeBytes(body); outStream.flush(); outStream.close(); // Get Response // - For debugging purposes only! String buffer; while((buffer = inStream.readLine()) != null) { System.out.println(buffer); } // Close I/O streams inStream.close(); outStream.close(); }//Syntax error, insert "}" to complete ClassBody Anybody see something obvious that I don't? On a side note, if the php echoes back html code, upon running this class, is java capable of understanding the html code?
0
11,472,187
07/13/2012 14:11:41
884,209
08/08/2011 13:59:11
94
1
jquery set css for multiple elements syntax
I'm developing an Jquery plugin and have to set many css values inside of script to make it flexible. It looks something like this: ...var loadingBarInsideFWidth = loadingBarWidth - 4; var loadingBarInsideWidth; $(holder).find('.round').css({ 'width':setRoundWidth, 'height':setRoundWidth }); $(holder).find('.pointer').css({ 'width':setPointerWidth, 'height':setPointerWidth, 'left':rotCenter, 'top':rotCenter*2 });... and so on for about 70 rows of code. Just wanted to ask if it's ok so, or is there a better way? thx
jquery
css
syntax
null
null
null
open
jquery set css for multiple elements syntax === I'm developing an Jquery plugin and have to set many css values inside of script to make it flexible. It looks something like this: ...var loadingBarInsideFWidth = loadingBarWidth - 4; var loadingBarInsideWidth; $(holder).find('.round').css({ 'width':setRoundWidth, 'height':setRoundWidth }); $(holder).find('.pointer').css({ 'width':setPointerWidth, 'height':setPointerWidth, 'left':rotCenter, 'top':rotCenter*2 });... and so on for about 70 rows of code. Just wanted to ask if it's ok so, or is there a better way? thx
0
11,472,188
07/13/2012 14:11:42
357,455
06/03/2010 12:27:18
76
4
MVC 3 WebGrid with a dynamic source
I have a dynamic list of data with a dynamic number of columns being created by a PIVOT function. Everything more or less works, but I wanted to apply some custom formatting to some of the columns. I figured out how to get a list of the columns by just taking the first row and casting it like so: var columns = Model.Comparisons.Select(x => x).FirstOrDefault() as IDictionary<string, object>; Next I decided to create my List<WebGridColumn> by looping over the "columns", which works as long as I reference the dynamic fields in the "format:" clause by their dynamic field name directly for example: foreach (var c in columns) { switch (c.Key) { case "Cost": cols.Add(grid.Column( columnName: c.Key, header: c.Key, format: (item) => Convert.ToDecimal(item.Cost).ToString("C"))); break; default: cols.Add(grid.Column(columnName: c.Key, header: c.Key, format: item => item[c.Key])); break; } } The "default" does not dynamically get the value of each record. I believe it has to do with the "item[c.Key]" vs item.Cost. The problem is I don't want to have to write different case for each field, primarily because I don't know them ahead of time as the data can change. There are about 6 fields that will always be present. I do know however the datatype, which is why I wanted to put a custom format on them.
mvc
webgrid
expandoobject
null
null
null
open
MVC 3 WebGrid with a dynamic source === I have a dynamic list of data with a dynamic number of columns being created by a PIVOT function. Everything more or less works, but I wanted to apply some custom formatting to some of the columns. I figured out how to get a list of the columns by just taking the first row and casting it like so: var columns = Model.Comparisons.Select(x => x).FirstOrDefault() as IDictionary<string, object>; Next I decided to create my List<WebGridColumn> by looping over the "columns", which works as long as I reference the dynamic fields in the "format:" clause by their dynamic field name directly for example: foreach (var c in columns) { switch (c.Key) { case "Cost": cols.Add(grid.Column( columnName: c.Key, header: c.Key, format: (item) => Convert.ToDecimal(item.Cost).ToString("C"))); break; default: cols.Add(grid.Column(columnName: c.Key, header: c.Key, format: item => item[c.Key])); break; } } The "default" does not dynamically get the value of each record. I believe it has to do with the "item[c.Key]" vs item.Cost. The problem is I don't want to have to write different case for each field, primarily because I don't know them ahead of time as the data can change. There are about 6 fields that will always be present. I do know however the datatype, which is why I wanted to put a custom format on them.
0
11,472,166
07/13/2012 14:10:01
492,624
10/31/2010 07:47:36
6,845
305
Choosing an ORM for Android project (min. API level 7)
I currently have an application, where it's primary performance issue is using file-based database consisted of JSON responses. I'd like to rewrite my application to use SQLite database feature. Since I'm lazy, I'd like to use some kind of ORM. So far I have found only two big ORM libraries: - [ORMLite][1] - [GreenDAO ORM][2] - [DB4O][3] My primary goal is to **raise performance on working with data as much as possible** But I've found two possible issues with those libraries. - ORMLite uses **annotations**, which is big **performance issue in pre-honeycomb** due to [this bug][4] - GreenDAO is using some kind of code generator, and that would slow me down on development as I would have to write generator, and then use generated code. And I don't very like this idea. - DB4O is JPA, which I've always considered as slow and heavy on memory usage, therefore unsuitable for low-end devices (remember the Android API v7) So my questions are: 1. **Should I use ORM/JPA layer in Android application?** 2. **If so, what library would you recommend me to use?** (and please add some arguments too) [1]: http://ormlite.com/sqlite_java_android_orm.shtml [2]: http://greendao-orm.com/ [3]: http://java.dzone.com/articles/using-db4o-android-application [4]: https://code.google.com/p/android/issues/detail?id=7811
java
android
database
sqlite
orm
null
open
Choosing an ORM for Android project (min. API level 7) === I currently have an application, where it's primary performance issue is using file-based database consisted of JSON responses. I'd like to rewrite my application to use SQLite database feature. Since I'm lazy, I'd like to use some kind of ORM. So far I have found only two big ORM libraries: - [ORMLite][1] - [GreenDAO ORM][2] - [DB4O][3] My primary goal is to **raise performance on working with data as much as possible** But I've found two possible issues with those libraries. - ORMLite uses **annotations**, which is big **performance issue in pre-honeycomb** due to [this bug][4] - GreenDAO is using some kind of code generator, and that would slow me down on development as I would have to write generator, and then use generated code. And I don't very like this idea. - DB4O is JPA, which I've always considered as slow and heavy on memory usage, therefore unsuitable for low-end devices (remember the Android API v7) So my questions are: 1. **Should I use ORM/JPA layer in Android application?** 2. **If so, what library would you recommend me to use?** (and please add some arguments too) [1]: http://ormlite.com/sqlite_java_android_orm.shtml [2]: http://greendao-orm.com/ [3]: http://java.dzone.com/articles/using-db4o-android-application [4]: https://code.google.com/p/android/issues/detail?id=7811
0
11,472,194
07/13/2012 14:11:54
1,005,978
10/20/2011 19:56:28
11
0
How do I make a UIImagePickerController camera not take up the whole screen?
I have a tab bar controller. I want to have a camera always open on one of the tabs, but underneath the camera, you can still see the rest of the tabs. How do I make it so that the camera doesn't take up the whole screen, but is just above the tab bar? (By the way, to be specific, I'm not actually using a UIIMagePickerController, but the ZBarReader) Thank you
iphone
objective-c
sdk
uiimagepickercontroller
zbar-sdk
null
open
How do I make a UIImagePickerController camera not take up the whole screen? === I have a tab bar controller. I want to have a camera always open on one of the tabs, but underneath the camera, you can still see the rest of the tabs. How do I make it so that the camera doesn't take up the whole screen, but is just above the tab bar? (By the way, to be specific, I'm not actually using a UIIMagePickerController, but the ZBarReader) Thank you
0
11,472,198
07/13/2012 14:11:56
456,135
09/23/2010 12:12:58
1,659
115
struts2 jquery plugin wraps html to returned id
I am using struts2-jquery plugin in my project. I am trying to submit a form using `<sj:submit>` tag like this: <sj:submit id="caseSubmit" targets="result" formIds="mainForm" onCompleteTopics="caseSubmitted" button="true"/> The struts.xml mapping for this action is as follows: <action name="submitAddCase" class="com.xxx.action.AddCaseAction"> <result type="json"> <param name="root">caseId</param> </result> </action> The onComPleteTopics code $.subscribe('caseSubmitted', function(event,data) { var indexPre = event.originalEvent.request.responseText.indexOf("<pre>")+5; var indexPreEnd = event.originalEvent.request.responseText.indexOf("</pre>"); var id = event.originalEvent.request.responseText.substring(indexPre,indexPreEnd); $("#case_id").val(id); }); What I want is to use the `caseId` returned to load some other stuff on the same page. But, `event.originalEvent.request.responseText` returns `caseId` wrapped in pre tag like this <pre>154000</pre> This is how it is returned in firefox. In chrome it is returned in another form. How can I get th caseId's original value without wrapped html. Right now I am using javascript's substring method to get the value it is not working in chrome because of a different returned format
jquery
jquery-ui
jquery-ajax
jquery-plugins
struts2
null
open
struts2 jquery plugin wraps html to returned id === I am using struts2-jquery plugin in my project. I am trying to submit a form using `<sj:submit>` tag like this: <sj:submit id="caseSubmit" targets="result" formIds="mainForm" onCompleteTopics="caseSubmitted" button="true"/> The struts.xml mapping for this action is as follows: <action name="submitAddCase" class="com.xxx.action.AddCaseAction"> <result type="json"> <param name="root">caseId</param> </result> </action> The onComPleteTopics code $.subscribe('caseSubmitted', function(event,data) { var indexPre = event.originalEvent.request.responseText.indexOf("<pre>")+5; var indexPreEnd = event.originalEvent.request.responseText.indexOf("</pre>"); var id = event.originalEvent.request.responseText.substring(indexPre,indexPreEnd); $("#case_id").val(id); }); What I want is to use the `caseId` returned to load some other stuff on the same page. But, `event.originalEvent.request.responseText` returns `caseId` wrapped in pre tag like this <pre>154000</pre> This is how it is returned in firefox. In chrome it is returned in another form. How can I get th caseId's original value without wrapped html. Right now I am using javascript's substring method to get the value it is not working in chrome because of a different returned format
0
11,472,200
07/13/2012 14:12:11
1,517,578
07/11/2012 11:12:53
1
0
Recurring payments for SaaS sites
I have a development taking place that I would ultimately like to deliver as an SaaS website. I currently have no experience in this sort of platform and I am looking for guidance on a few things, namely: 1. What providers should I be looking at? 2. Should I utilize an API or hand-ball the customer to the service provider? 3. Monthly subscriptions.. 4. ..honestly, where do I begin? I know that PayPal provide all sorts of payment options and I have experience using the IPN for one-off payments, but I'm wondering if there's a better alternative. ..is it too much to hope for a provider that handles basically everything and only notifies me when someone doesn't pay/get's declined in the same way the PayPal IPN notifies of payments? Any help is appreciated.
saas
recurring-billing
null
null
null
null
open
Recurring payments for SaaS sites === I have a development taking place that I would ultimately like to deliver as an SaaS website. I currently have no experience in this sort of platform and I am looking for guidance on a few things, namely: 1. What providers should I be looking at? 2. Should I utilize an API or hand-ball the customer to the service provider? 3. Monthly subscriptions.. 4. ..honestly, where do I begin? I know that PayPal provide all sorts of payment options and I have experience using the IPN for one-off payments, but I'm wondering if there's a better alternative. ..is it too much to hope for a provider that handles basically everything and only notifies me when someone doesn't pay/get's declined in the same way the PayPal IPN notifies of payments? Any help is appreciated.
0
11,472,201
07/13/2012 14:12:13
844,063
07/14/2011 07:44:51
56
0
EF and data change tracking
I'm a bit new to EF and would like to ask a few questions to understand the framework better specially data change tracking. Here's my scenario: 1. Create a DBContext and get an entity with specified criteria 2. Detach the entity and pass the entity to the calling module 3. When the entity is modfied create a new DBContext and save it With this scenario i'm not sure how to this. Does the state tracking of EF works in this scenario or should i manually track this myself?
entity-framework-4
data
tracking
null
null
null
open
EF and data change tracking === I'm a bit new to EF and would like to ask a few questions to understand the framework better specially data change tracking. Here's my scenario: 1. Create a DBContext and get an entity with specified criteria 2. Detach the entity and pass the entity to the calling module 3. When the entity is modfied create a new DBContext and save it With this scenario i'm not sure how to this. Does the state tracking of EF works in this scenario or should i manually track this myself?
0
11,472,204
07/13/2012 14:12:17
355,375
06/01/2010 12:05:18
1,098
79
Show Loading Dialog When Making A HTTP Request in Android
In an effort to learn Android I am writing a small app. The first thing I am trying to do is login via a remote API. I would like to show a "loading" dialog when the call is being made (in case he user in using mobile internet). Researching this has shown two possible methods. One is to use a **ProgressDialog** and a private class that extends **Thread**, the other is using a private class that extends **AsyncTask**. Which is best/more appropriate for this task? I have tried using the ProgressDialog version but am struggling. I have put the function making the http request in the extended Thread run() method, but am unsure on how to pass the response data (JSON) back into my activity. Any and all help gratefully received.
android
null
null
null
null
null
open
Show Loading Dialog When Making A HTTP Request in Android === In an effort to learn Android I am writing a small app. The first thing I am trying to do is login via a remote API. I would like to show a "loading" dialog when the call is being made (in case he user in using mobile internet). Researching this has shown two possible methods. One is to use a **ProgressDialog** and a private class that extends **Thread**, the other is using a private class that extends **AsyncTask**. Which is best/more appropriate for this task? I have tried using the ProgressDialog version but am struggling. I have put the function making the http request in the extended Thread run() method, but am unsure on how to pass the response data (JSON) back into my activity. Any and all help gratefully received.
0
11,472,205
07/13/2012 14:12:23
969,613
09/28/2011 17:22:04
972
18
What is the WPF equivalent of Windows Forms' `StartPosition` property?
On Windows Forms, you have the `StartPosition` property which allows you to specify the position on the screen your form will be placed when it launches. Does WPF have an equivalent and if so what is it? Thanks
wpf
null
null
null
null
null
open
What is the WPF equivalent of Windows Forms' `StartPosition` property? === On Windows Forms, you have the `StartPosition` property which allows you to specify the position on the screen your form will be placed when it launches. Does WPF have an equivalent and if so what is it? Thanks
0
11,650,677
07/25/2012 13:20:35
741,850
05/06/2011 13:29:01
172
16
MVC 4 simple reroute, how?
I am trying to do something seemingly simple in MVC 4: I get a request on a route that looks like this >data/* whatever * I would then like to reroute this to the following: >Content/data/* whatever * I guess this should be done with the `routes.MapRoute` in `RouteConfig.cs`, however I cant figure out how.
routing
asp.net-mvc-4
null
null
null
null
open
MVC 4 simple reroute, how? === I am trying to do something seemingly simple in MVC 4: I get a request on a route that looks like this >data/* whatever * I would then like to reroute this to the following: >Content/data/* whatever * I guess this should be done with the `routes.MapRoute` in `RouteConfig.cs`, however I cant figure out how.
0
11,650,679
07/25/2012 13:20:42
1,524,894
07/14/2012 00:54:31
1
0
Pygame - Space Invaders aliens, hit detection, and bounding area?
http://pastebin.com/FvQTpeqh is the code I have so far, but I want to change it so if the player attempts to move outside the area of the screen, the spaceship will stay stuck on one side or the other also I would like to be able to make 5 rows of aliens with 11 aliens in each row, but I'm not quite sure how to do this and I would like to be able to append them to a list lastly, I'm wondering how I can detect whether a player or alien has been hit by a bullet you may have to supply your own images, the sprites for aliens and players are 50x50
python
pygame
null
null
null
07/26/2012 09:44:22
too localized
Pygame - Space Invaders aliens, hit detection, and bounding area? === http://pastebin.com/FvQTpeqh is the code I have so far, but I want to change it so if the player attempts to move outside the area of the screen, the spaceship will stay stuck on one side or the other also I would like to be able to make 5 rows of aliens with 11 aliens in each row, but I'm not quite sure how to do this and I would like to be able to append them to a list lastly, I'm wondering how I can detect whether a player or alien has been hit by a bullet you may have to supply your own images, the sprites for aliens and players are 50x50
3
11,650,802
07/25/2012 13:27:30
411,846
08/05/2010 10:34:04
364
24
How to gracefully stop a server process which is listening on a pipe on Windows
I have a named pipe server similar to the MSDN sample at http://msdn.microsoft.com/en-us/library/windows/desktop/aa365588(v=vs.85).aspx and would like to allow clients to send an "exit" message which causes the server to gracefully stop. So in the "InstanceThread()", if a special message is received, I would like to make the server stop. I tried to stop the call to ConnectNamedPipe() in the main thread from the separate thread for "InstanceThread()" by closing the pipe handle, but this does not work. I already tried various things, among others closing the overall pipe, exiting directly from the InstanceThread, ... but none of them causes the call to ConnectNamedPipe() to stop. I played with SetNamedPipeHandleState(), but it complicates the implementation hugely, also using overlapped I/O seems overkill for this simple requirement. So is there an easier way to get ConnectNamedPipe() to return when the server process should be stopped and not wait endlessly for client connections?
windows
visual-c++
named-pipes
null
null
null
open
How to gracefully stop a server process which is listening on a pipe on Windows === I have a named pipe server similar to the MSDN sample at http://msdn.microsoft.com/en-us/library/windows/desktop/aa365588(v=vs.85).aspx and would like to allow clients to send an "exit" message which causes the server to gracefully stop. So in the "InstanceThread()", if a special message is received, I would like to make the server stop. I tried to stop the call to ConnectNamedPipe() in the main thread from the separate thread for "InstanceThread()" by closing the pipe handle, but this does not work. I already tried various things, among others closing the overall pipe, exiting directly from the InstanceThread, ... but none of them causes the call to ConnectNamedPipe() to stop. I played with SetNamedPipeHandleState(), but it complicates the implementation hugely, also using overlapped I/O seems overkill for this simple requirement. So is there an easier way to get ConnectNamedPipe() to return when the server process should be stopped and not wait endlessly for client connections?
0
11,650,810
07/25/2012 13:27:55
1,526,612
07/15/2012 07:45:48
13
0
Selenuim on IE9 and jQuery addClass and removeClass
Hi – apologies for a bot of a generic question... We are automating our UI testing by using Selenium Web Driver (v2.24.1), and it works like a dream with the exception on IE9. We are doing part of client side functionality by hiding/showing UI controls via addClass and removeClass jQuery methods. addClass and removeClass jquery methods append (or remove) classes from DOM. This way, we can do Selenium DOM iteration looking for those changes in order to trigger actions... Our problem is that those DOM changes are not reflected in IE9 – e.g. functionally everything is working correctly on IE, but the “dom is static”, thus Selenium cannot reckognize some panel is shown or hidden... So, the question: 1) Is there a way to reflect the addClass and removeClass in IE9 in a dynamic manner? 2) Should we possibly monitor/capture changes in a different way? (Possibly assigning some kind of event listeners on the components that are causing us problem?) Hope this question is not too vague – this is not an issue with one particular component, but I think it is more down to the way we are trying to use Selenium in a generic way across multiple products...
javascript
jquery
selenium
internet-explorer-9
removeclass
null
open
Selenuim on IE9 and jQuery addClass and removeClass === Hi – apologies for a bot of a generic question... We are automating our UI testing by using Selenium Web Driver (v2.24.1), and it works like a dream with the exception on IE9. We are doing part of client side functionality by hiding/showing UI controls via addClass and removeClass jQuery methods. addClass and removeClass jquery methods append (or remove) classes from DOM. This way, we can do Selenium DOM iteration looking for those changes in order to trigger actions... Our problem is that those DOM changes are not reflected in IE9 – e.g. functionally everything is working correctly on IE, but the “dom is static”, thus Selenium cannot reckognize some panel is shown or hidden... So, the question: 1) Is there a way to reflect the addClass and removeClass in IE9 in a dynamic manner? 2) Should we possibly monitor/capture changes in a different way? (Possibly assigning some kind of event listeners on the components that are causing us problem?) Hope this question is not too vague – this is not an issue with one particular component, but I think it is more down to the way we are trying to use Selenium in a generic way across multiple products...
0
11,650,812
07/25/2012 13:28:00
1,551,722
07/25/2012 13:10:17
1
0
Get exception from threads in java
I have a question with my code. I have two threads running from the main method & I want to catch the exception that can occur in any of the two threads in the main method. Future<Object> incoming=Executors.newSingleThreadExecutor().submit(new Task1(param1)); Future<Object> outgoing=Executors.newSingleThreadExecutor().submit(new Task2(param2)); Problem is that if i use Future Object & call get() method for the exception, it will block my code & i would not know if say thread 2 has finished/throws exception before thread 1. How can i handle this elegantly instead of this? while(!(incoming.isDone() || outgoing.isDone())){}
java
multithreading
exception
future
null
null
open
Get exception from threads in java === I have a question with my code. I have two threads running from the main method & I want to catch the exception that can occur in any of the two threads in the main method. Future<Object> incoming=Executors.newSingleThreadExecutor().submit(new Task1(param1)); Future<Object> outgoing=Executors.newSingleThreadExecutor().submit(new Task2(param2)); Problem is that if i use Future Object & call get() method for the exception, it will block my code & i would not know if say thread 2 has finished/throws exception before thread 1. How can i handle this elegantly instead of this? while(!(incoming.isDone() || outgoing.isDone())){}
0
11,443,330
07/12/2012 00:03:30
1,519,330
07/11/2012 23:50:24
1
0
ERROR: Wrong number of arguments to #<procedure
When I run the following piece of code, I encountered an error: **ERROR: Wrong number of arguments to #<procedure lattice->cartesian (x)>** ;;;; function definition (define (eps-func p) (let* ((p (lattice->cartesian)) (x (vector3-x p)) (y (vector3-y p)) (z (vector3-z p))) (if (> sin(* 2 pi x y z) 0) (make dielectric (epsilon 12)) (make dielectric (epsilon 1))))) ;;;; function call (set! default-material (make material-function (material-func eps-func))) I cannot figure out where it is wrong. The above code is only part of a control file. Some background information is as following: (lattice->cartesian x) where x is a vector3 vector3 is a datatype defined somewhere 3-vector functions (vector3 x y z) Create a new 3-vector with the given components. (vector3-x v) (vector3-y v) (vector3-z v) Return the corresponding component of the vector v. material-func [function] A function of one argument, the position vector3
scheme
null
null
null
null
null
open
ERROR: Wrong number of arguments to #<procedure === When I run the following piece of code, I encountered an error: **ERROR: Wrong number of arguments to #<procedure lattice->cartesian (x)>** ;;;; function definition (define (eps-func p) (let* ((p (lattice->cartesian)) (x (vector3-x p)) (y (vector3-y p)) (z (vector3-z p))) (if (> sin(* 2 pi x y z) 0) (make dielectric (epsilon 12)) (make dielectric (epsilon 1))))) ;;;; function call (set! default-material (make material-function (material-func eps-func))) I cannot figure out where it is wrong. The above code is only part of a control file. Some background information is as following: (lattice->cartesian x) where x is a vector3 vector3 is a datatype defined somewhere 3-vector functions (vector3 x y z) Create a new 3-vector with the given components. (vector3-x v) (vector3-y v) (vector3-z v) Return the corresponding component of the vector v. material-func [function] A function of one argument, the position vector3
0
11,443,332
07/12/2012 00:04:09
185,840
10/07/2009 18:22:05
2,634
111
scala Either & Neither handling
Not sure what to call this, Option would fit just as well as Either, I need to handle a 3rd case regardless. Scalaz likely already provides something like this, but am curious to know how, without a separate library, one can concisely handle the following simple case: I need to check if user session exists, both actual user and admin logged-in-as-user scenarios, the latter taking precedence over the former; if neither conditions exists, show login screen. The actual user session check looks like: request.session.get(Security.username) map { id=> f(Success(id.toInt, request)) } getOrElse( onFail(request) ) // onFail = show login and I need to add in the admin impersonating user case: request.session.get(Security.impersonate) map { id=> f(Success(id.toInt, request)) } getOrElse( onFail(request) ) I could getOrElse it all together but would prefer to clean things up a bit, the operation is the same regardless of user or admin-as-user cases.
scala
handling
either
null
null
null
open
scala Either & Neither handling === Not sure what to call this, Option would fit just as well as Either, I need to handle a 3rd case regardless. Scalaz likely already provides something like this, but am curious to know how, without a separate library, one can concisely handle the following simple case: I need to check if user session exists, both actual user and admin logged-in-as-user scenarios, the latter taking precedence over the former; if neither conditions exists, show login screen. The actual user session check looks like: request.session.get(Security.username) map { id=> f(Success(id.toInt, request)) } getOrElse( onFail(request) ) // onFail = show login and I need to add in the admin impersonating user case: request.session.get(Security.impersonate) map { id=> f(Success(id.toInt, request)) } getOrElse( onFail(request) ) I could getOrElse it all together but would prefer to clean things up a bit, the operation is the same regardless of user or admin-as-user cases.
0
11,443,335
07/12/2012 00:04:41
1,241,357
02/29/2012 22:15:44
48
0
Trouble understanding instance variable
Here is the definition: In object-oriented programming with classes, an instance variable is a variable defined in a class (i.e. a member variable) // I get this part , for which each object of the class has a separate copy. // This part I don't get. How can an object have a seperate copy? a seperate copy of what? Sorry for asking basic questions, I'm still a noob. Thank you
c++
null
null
null
null
null
open
Trouble understanding instance variable === Here is the definition: In object-oriented programming with classes, an instance variable is a variable defined in a class (i.e. a member variable) // I get this part , for which each object of the class has a separate copy. // This part I don't get. How can an object have a seperate copy? a seperate copy of what? Sorry for asking basic questions, I'm still a noob. Thank you
0
11,443,336
07/12/2012 00:04:44
1,196,150
02/08/2012 02:20:44
488
0
Rails: Recursion in has_many/self reference association to find all children
I have two models like this: class Manager < ActiveRecord::Base has_many :clients has_many :managers, :class_name => "Manager" belongs_to :boss, :class_name => "Manager" end class Client < ActiveRecord::Base belongs_to :manager end I am trying to find all the clients for a specific Manager. So, let's say I have this hierarchy: Manager1 has Manager2 and Manager3 Manager2 has Manager4 Manager5 has Manager6 and Manager7 Manager4 has two clients: Client1 and Client2 Manager 6 has one client: Client3 Manager 7 has no clients. So, given Manager 1 (top boss) I would like to get: Client1, Client2 and Client3 ids. I have tried doing a recursion method in Manager model like this: def accessible_clients clients = [] unless self.managers.nil? self.managers.each do |child_manager| clients << child_manager.accessible_clients end else unless self.clients.nil? self.clients.each do |client_manager| return client_manager.id end end end end But I believe I am wrong and it might be an easier/correct way of doing this.
ruby-on-rails-3
recursion
associations
self-reference
null
null
open
Rails: Recursion in has_many/self reference association to find all children === I have two models like this: class Manager < ActiveRecord::Base has_many :clients has_many :managers, :class_name => "Manager" belongs_to :boss, :class_name => "Manager" end class Client < ActiveRecord::Base belongs_to :manager end I am trying to find all the clients for a specific Manager. So, let's say I have this hierarchy: Manager1 has Manager2 and Manager3 Manager2 has Manager4 Manager5 has Manager6 and Manager7 Manager4 has two clients: Client1 and Client2 Manager 6 has one client: Client3 Manager 7 has no clients. So, given Manager 1 (top boss) I would like to get: Client1, Client2 and Client3 ids. I have tried doing a recursion method in Manager model like this: def accessible_clients clients = [] unless self.managers.nil? self.managers.each do |child_manager| clients << child_manager.accessible_clients end else unless self.clients.nil? self.clients.each do |client_manager| return client_manager.id end end end end But I believe I am wrong and it might be an easier/correct way of doing this.
0
11,443,337
07/12/2012 00:04:51
360,921
06/08/2010 00:26:51
164
8
Why is my for-in loop is looping double the size of my array?
I am using a for-in loop to iterate over an array of two elements, but it is like its looping twice. I have an example here: http://jsbin.com/etoyac/8/
javascript
dom
loops
for-in-loop
null
null
open
Why is my for-in loop is looping double the size of my array? === I am using a for-in loop to iterate over an array of two elements, but it is like its looping twice. I have an example here: http://jsbin.com/etoyac/8/
0
11,443,338
07/12/2012 00:05:15
494,094
11/01/2010 21:31:25
129
2
Advice on learning software development and design patterns
I've been programming for a while and I know basics of Java, C, and C++. I know a bit of Object Oriented Programming. At the moment, I'm trying to improve my knowledge (and I need to use C# for a programming project). But I feel really lost and frustrated in this path. I want to learn more than just the basics of a language. I want to learn Design Patterns and developing and planning a software project but I don't know how to proceed. I tried reading books on Design Patterns but they feel so abstract when I don't have a specific project to do. I'm really confused on this, how did you learn Object Oriented Design and Design Patterns? I feel that if I just read a book, I won't learn much. I feel that Head First Design Patterns book tries to make it too simplistic. And the Gang of Four book feels too theoretical (and it says you need to learn Object Oriented Design first). I like books/resources that are more direct-to-the-point and have some exercises. What would your suggestion be in this situation?
design-patterns
software-design
null
null
null
null
open
Advice on learning software development and design patterns === I've been programming for a while and I know basics of Java, C, and C++. I know a bit of Object Oriented Programming. At the moment, I'm trying to improve my knowledge (and I need to use C# for a programming project). But I feel really lost and frustrated in this path. I want to learn more than just the basics of a language. I want to learn Design Patterns and developing and planning a software project but I don't know how to proceed. I tried reading books on Design Patterns but they feel so abstract when I don't have a specific project to do. I'm really confused on this, how did you learn Object Oriented Design and Design Patterns? I feel that if I just read a book, I won't learn much. I feel that Head First Design Patterns book tries to make it too simplistic. And the Gang of Four book feels too theoretical (and it says you need to learn Object Oriented Design first). I like books/resources that are more direct-to-the-point and have some exercises. What would your suggestion be in this situation?
0
11,443,339
07/12/2012 00:05:18
686,280
03/31/2011 17:59:32
16
0
Rails, SRP, and Unit Tests
**Preamble** Hey, this is my first time attempting to build an app with SRP in mind and really trying to use tests to drive the code for the site, rather than starting with my data architecture (AR) and then building the app to fit. But... I'm running into problems... I've subscribed to and watched a lot of Destroy All Software screencasts and in theory I like what he preaches but I'm having trouble making it work in practice. **Problem at hand** So I know the main feature of my app will be to search profiles based on location. So I write a simple cucumber feature for that (purposely leaving off routes/controllers/etc for the time being to simplify the task at hand). search.feature: Feature: Search for profiles Scenario: By zipcode When I search for 90210 Then I will see profiles near 90210 search_steps.rb: When /^I search for 90210$/ do @profiles = ProfileSearch.new.near_location(90210).all end Then /^I will see profiles near 90210$/ do pending # express the regexp above with the code you wish you had end No problems... now on to specs. profile_search_spec.rb: require_relative '../../app/services/profile_search' describe ProfileSearch do it "finds nearby profiles" it "does not find far away profiles" end profile_search.rb: class ProfileSearch end So I've used a ProfileSearch class for a few reasons. 1. It seems like the right thing to do to move as much business logic as possible outside of AR (SRP). 2. POROs make for faster tests (no loading rails) 3. I plan to use ElasticSearch or Solr in the near future and would like for the interface to remain the same. Now, I'm not really sure what to do next. ProfileSearch obviously depends on the Profile model, and I'm quite certain that this will be AR. So the question is do I start spec'ing out and building Profile and just start loading rails in my tests. This seems like the easiest option but something about it seems wrong. I feel like I would be desiging and building behaviour that my app hasn't specifically called for yet. I would have to think about fields and relations and storage, etc. All of which my app currently shouldn't care about. Or should I use stubs/mocks for all calls to Profile in my ProfileSearch spec and make sure the correct methods are being called. This also seems wrong because I'm not really testing the behaviour then, and the test would have to be rewritten when switching to Solr/Elastic even though the same behaviour would be expected. Or maybe I should actually create a working Profile model that doesn't use AR for the time being but responds correctly to all the right methods as Uncle Bob demonstrated when building his wiki thing. This seems like it might be the best approach theoretically but knowing I will be using AR in the future it also seems quite redundant. Or... f*ck it and throw everything in the AR model :\ There are so many patterns, principles, and best practices floating around in my head I don't know wtf to do. What would you do?
ruby-on-rails
unit-testing
solid-principles
srp
null
null
open
Rails, SRP, and Unit Tests === **Preamble** Hey, this is my first time attempting to build an app with SRP in mind and really trying to use tests to drive the code for the site, rather than starting with my data architecture (AR) and then building the app to fit. But... I'm running into problems... I've subscribed to and watched a lot of Destroy All Software screencasts and in theory I like what he preaches but I'm having trouble making it work in practice. **Problem at hand** So I know the main feature of my app will be to search profiles based on location. So I write a simple cucumber feature for that (purposely leaving off routes/controllers/etc for the time being to simplify the task at hand). search.feature: Feature: Search for profiles Scenario: By zipcode When I search for 90210 Then I will see profiles near 90210 search_steps.rb: When /^I search for 90210$/ do @profiles = ProfileSearch.new.near_location(90210).all end Then /^I will see profiles near 90210$/ do pending # express the regexp above with the code you wish you had end No problems... now on to specs. profile_search_spec.rb: require_relative '../../app/services/profile_search' describe ProfileSearch do it "finds nearby profiles" it "does not find far away profiles" end profile_search.rb: class ProfileSearch end So I've used a ProfileSearch class for a few reasons. 1. It seems like the right thing to do to move as much business logic as possible outside of AR (SRP). 2. POROs make for faster tests (no loading rails) 3. I plan to use ElasticSearch or Solr in the near future and would like for the interface to remain the same. Now, I'm not really sure what to do next. ProfileSearch obviously depends on the Profile model, and I'm quite certain that this will be AR. So the question is do I start spec'ing out and building Profile and just start loading rails in my tests. This seems like the easiest option but something about it seems wrong. I feel like I would be desiging and building behaviour that my app hasn't specifically called for yet. I would have to think about fields and relations and storage, etc. All of which my app currently shouldn't care about. Or should I use stubs/mocks for all calls to Profile in my ProfileSearch spec and make sure the correct methods are being called. This also seems wrong because I'm not really testing the behaviour then, and the test would have to be rewritten when switching to Solr/Elastic even though the same behaviour would be expected. Or maybe I should actually create a working Profile model that doesn't use AR for the time being but responds correctly to all the right methods as Uncle Bob demonstrated when building his wiki thing. This seems like it might be the best approach theoretically but knowing I will be using AR in the future it also seems quite redundant. Or... f*ck it and throw everything in the AR model :\ There are so many patterns, principles, and best practices floating around in my head I don't know wtf to do. What would you do?
0
11,443,344
07/12/2012 00:06:16
1,212,830
02/16/2012 02:00:51
11
1
Api call to upload file for article or page
i'm new here, and trying to understand from the docs how to upload images for articles/blog posts through the api. I can see the "Asset" resource is it the one i have to deal with? how is the file structure of the store bucket? Image uploaded to the blog can be accessed through URI like this http://cdn.shopify.com/s/files/xxxxxxxxxxxx/files/wwb_drapers_large.jpg Image uploaded as a theme asset can be accessed through URI like this http://cdn.shopify.com/s/files/xxxxxxxxxxxx/assets/logo.png
api
shopify
null
null
null
null
open
Api call to upload file for article or page === i'm new here, and trying to understand from the docs how to upload images for articles/blog posts through the api. I can see the "Asset" resource is it the one i have to deal with? how is the file structure of the store bucket? Image uploaded to the blog can be accessed through URI like this http://cdn.shopify.com/s/files/xxxxxxxxxxxx/files/wwb_drapers_large.jpg Image uploaded as a theme asset can be accessed through URI like this http://cdn.shopify.com/s/files/xxxxxxxxxxxx/assets/logo.png
0
11,443,350
07/12/2012 00:06:54
379,420
09/03/2009 22:33:32
319
14
Ruby on Rails Inline around_save Callback Yields a LocalJumpError
In Rails 3.0.5 & Ruby 1.9.3, is it possible to define the body of an `around_save` callback inline with the `around_save` declaration? That is, I've noticed that this case works properly: around_save :around_save_body def around_save_body puts 'before save' yield puts 'after save' end [114] pry(main)> a = Activity.find(57) => #<Activity id: 57, ... > [115] pry(main)> a.save before save after save => true Whereas if I put the body inline, I get a LocalJumpError: around_save do |activity| puts 'before save' yield puts 'after save' end [117] pry(main)> a = Activity.find(57) => #<Activity id: 57, ... > [118] pry(main)> a.save before save LocalJumpError: no block given (yield) from /home/maksim/hkn/website/app/models/activity.rb:47:in `block in <class:Activity>' I tried changing `yield` to `yield activity` in the second example, but I got the same result. Is it possible to have my `around_save` body be inline with the `around_save` declaration?
ruby-on-rails
ruby
callback
ruby-1.9
null
null
open
Ruby on Rails Inline around_save Callback Yields a LocalJumpError === In Rails 3.0.5 & Ruby 1.9.3, is it possible to define the body of an `around_save` callback inline with the `around_save` declaration? That is, I've noticed that this case works properly: around_save :around_save_body def around_save_body puts 'before save' yield puts 'after save' end [114] pry(main)> a = Activity.find(57) => #<Activity id: 57, ... > [115] pry(main)> a.save before save after save => true Whereas if I put the body inline, I get a LocalJumpError: around_save do |activity| puts 'before save' yield puts 'after save' end [117] pry(main)> a = Activity.find(57) => #<Activity id: 57, ... > [118] pry(main)> a.save before save LocalJumpError: no block given (yield) from /home/maksim/hkn/website/app/models/activity.rb:47:in `block in <class:Activity>' I tried changing `yield` to `yield activity` in the second example, but I got the same result. Is it possible to have my `around_save` body be inline with the `around_save` declaration?
0
11,443,351
07/12/2012 00:07:04
486,927
10/25/2010 21:03:16
56
1
Method to take account for device orientation for OS snapshot
This is regarding the OS taking a snapshot of the app when applicationDidEnterBackground returns. Here is a link to a [reference][1]. [1]: http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html <br><br> When the OS takes a snapshot, it doesn't account for device orientation when the user starts the app again. For example, if I am on an iPad and presses the home button; the OS takes the snapshot. And if the device orientation is rotated, the launch image is wrong. If I do not have a choice to display an overlay (which is of course orientation-independent), how can I overcome this? Note: I need to do this mainly of the sensitive data being displayed during launch. Thank you.
objective-c
ipad
null
null
null
null
open
Method to take account for device orientation for OS snapshot === This is regarding the OS taking a snapshot of the app when applicationDidEnterBackground returns. Here is a link to a [reference][1]. [1]: http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html <br><br> When the OS takes a snapshot, it doesn't account for device orientation when the user starts the app again. For example, if I am on an iPad and presses the home button; the OS takes the snapshot. And if the device orientation is rotated, the launch image is wrong. If I do not have a choice to display an overlay (which is of course orientation-independent), how can I overcome this? Note: I need to do this mainly of the sensitive data being displayed during launch. Thank you.
0
11,443,353
07/12/2012 00:07:14
749,090
05/11/2011 16:23:03
43
0
jQuery ajaxSend prevention for a specific ajax request
All my website is almost depending on ajax, there's a little problem i cant solve, one of the ajax request takes way longer than expected till it loads which causes the ajaxSend text or image to be ran until this request is complete<br><br> i tried to use display:none; and hide(); for the loading div in this ajax but it realizes there is a loading request when some other ajax request is sent<br><br> how to completely prevent it from popping up in a specific ajax request ( $.get(); )?
jquery
ajax
loading
selector
null
null
open
jQuery ajaxSend prevention for a specific ajax request === All my website is almost depending on ajax, there's a little problem i cant solve, one of the ajax request takes way longer than expected till it loads which causes the ajaxSend text or image to be ran until this request is complete<br><br> i tried to use display:none; and hide(); for the loading div in this ajax but it realizes there is a loading request when some other ajax request is sent<br><br> how to completely prevent it from popping up in a specific ajax request ( $.get(); )?
0
11,567,834
07/19/2012 19:21:06
893,620
08/14/2011 04:57:38
51
0
jQuery AJAX $.each with Instagram JSON
I'm trying to print information using jQuery and AJAX to print from an Instagram API call... Here's what I have so far... $.ajax({ type: 'GET', url: 'ajaxloadlikes.php', data: { user: user, max_id: maxid }, dataType: 'json', cache: false, success: function(data) { $.each(data.data[i], function(i, img) { $('ul#photos').append('<li><div class="image"><a href="/media.php?user=' + img.user. + '&id=' + img.id + '"><img src="' + img.url + '" alt="" /></a><a href="/media.php?user=' + img.user + '&id=' + img.id + '"><img class="hoverimage" src="/zoom.png" alt="" /></a></div></li>​'); }); $('#more').data('maxid', img.next_id); } }); my ajaxloadlikes.php file prints out: {"next_id":"*next-id*","images":[{"id":"*image id*","url":"*image low_resolution link*","user":"*user*"},{"id":"*image id*","url":"*image low_resolution link*","user":"*user*"}, etc... for the life of me, I can't figure out why this won't work... I use a similar file for other ajax calls, but this one won't work!
javascript
jquery
ajax
instagram
null
null
open
jQuery AJAX $.each with Instagram JSON === I'm trying to print information using jQuery and AJAX to print from an Instagram API call... Here's what I have so far... $.ajax({ type: 'GET', url: 'ajaxloadlikes.php', data: { user: user, max_id: maxid }, dataType: 'json', cache: false, success: function(data) { $.each(data.data[i], function(i, img) { $('ul#photos').append('<li><div class="image"><a href="/media.php?user=' + img.user. + '&id=' + img.id + '"><img src="' + img.url + '" alt="" /></a><a href="/media.php?user=' + img.user + '&id=' + img.id + '"><img class="hoverimage" src="/zoom.png" alt="" /></a></div></li>​'); }); $('#more').data('maxid', img.next_id); } }); my ajaxloadlikes.php file prints out: {"next_id":"*next-id*","images":[{"id":"*image id*","url":"*image low_resolution link*","user":"*user*"},{"id":"*image id*","url":"*image low_resolution link*","user":"*user*"}, etc... for the life of me, I can't figure out why this won't work... I use a similar file for other ajax calls, but this one won't work!
0
11,567,837
07/19/2012 19:21:15
654,434
03/10/2011 22:56:04
1,208
124
How do I get HTML5 Video to scrub in chrome when delivered via a service?
So due to content being on a different drive than my server application's virtual directory, I've had to implement a file getting service. I am able to the get the file size. Then I want to set the content headers so that the browser knows the total size and thus knows how to proportion the seek bar. Here I set the total size header: string bytes = Convert.ToString( fInfo.Length ); Response.AddHeader("Content-Length", bytes ); Response.AddHeader("Content-Range", "bytes 0-" + bytes + "/" + bytes); Resulting in: Content-Length: 1389363 Content-Type: video/ogg Content-Range: bytes 0-1389363/1389364 I downloaded the resulting file and confirmed that the bytes match. Works fine in Firefox, all wacky in chrome. **In chrome it plays to the end, but does not move the seek bar and then shows negative infinity in the current time when it reaches the end. ALSO I cannot scrub the video at all, presumably because it has an invalid duration.** playing the same file directly in chrome works properly, so maybe it's some content header that chrome wants that firefox don't give a s#%t about? Any ideas? Wrong length unit? built-in server side g-zip encoding interfering? I'm using standard video object: <video class="videoplayer" controls="" autoplay="autoplay" tabindex="0"> <source type="video/ogg" src="http://vb_html.dev/GetFile.aspx?filename=c:/_assets/4c2c09c2-f2ff-e011-a992-009056af18ff/softsignage/softsignage-00000000600.ogv"></source> Your browser does not support the video tag. </video> For more reference this is how I'm passing the file data: FileStream mystream = new FileStream(anyFilePath, FileMode.Open, FileAccess.Read); byte[] buffer = new byte[4096]; using (BinaryReader reader = new BinaryReader(mystream)) { while (true) { int bytesRead = mystream.Read(buffer, 0, buffer.Length); if (bytesRead == 0) break; Response.OutputStream.Write(buffer, 0, bytesRead); } }
c#
google-chrome
html5-video
seek
null
null
open
How do I get HTML5 Video to scrub in chrome when delivered via a service? === So due to content being on a different drive than my server application's virtual directory, I've had to implement a file getting service. I am able to the get the file size. Then I want to set the content headers so that the browser knows the total size and thus knows how to proportion the seek bar. Here I set the total size header: string bytes = Convert.ToString( fInfo.Length ); Response.AddHeader("Content-Length", bytes ); Response.AddHeader("Content-Range", "bytes 0-" + bytes + "/" + bytes); Resulting in: Content-Length: 1389363 Content-Type: video/ogg Content-Range: bytes 0-1389363/1389364 I downloaded the resulting file and confirmed that the bytes match. Works fine in Firefox, all wacky in chrome. **In chrome it plays to the end, but does not move the seek bar and then shows negative infinity in the current time when it reaches the end. ALSO I cannot scrub the video at all, presumably because it has an invalid duration.** playing the same file directly in chrome works properly, so maybe it's some content header that chrome wants that firefox don't give a s#%t about? Any ideas? Wrong length unit? built-in server side g-zip encoding interfering? I'm using standard video object: <video class="videoplayer" controls="" autoplay="autoplay" tabindex="0"> <source type="video/ogg" src="http://vb_html.dev/GetFile.aspx?filename=c:/_assets/4c2c09c2-f2ff-e011-a992-009056af18ff/softsignage/softsignage-00000000600.ogv"></source> Your browser does not support the video tag. </video> For more reference this is how I'm passing the file data: FileStream mystream = new FileStream(anyFilePath, FileMode.Open, FileAccess.Read); byte[] buffer = new byte[4096]; using (BinaryReader reader = new BinaryReader(mystream)) { while (true) { int bytesRead = mystream.Read(buffer, 0, buffer.Length); if (bytesRead == 0) break; Response.OutputStream.Write(buffer, 0, bytesRead); } }
0
11,567,842
07/19/2012 19:21:35
768,459
05/24/2011 20:12:23
70
6
IIS 7 Subdomains not responding
I have an IIS 7 server running with subdomains. I am finding that a few subdomains are not sending any kind of response. Where would I start to figure this out?
iis7
httpresponse
subdomains
null
null
null
open
IIS 7 Subdomains not responding === I have an IIS 7 server running with subdomains. I am finding that a few subdomains are not sending any kind of response. Where would I start to figure this out?
0
11,567,844
07/19/2012 19:21:39
1,475,788
06/22/2012 19:37:17
24
0
SQL Many to many select distinct
I need some help with the following query. So far what I have is below. What I am trying to do is get uniqure ServiceEntryPart records when parts are same and multiple service entry records when parts are unique. The following query works fine with the search filters, its just I need to get unique records when multiple parts are not present. Thanks SELECT * FROM ServiceEntryPart INNER JOIN Part on ServiceEntryPart.PartID = Part.ID WHERE (ServiceDateTime between @StartDate and @EndDate) AND ((@ActivePart = 0 AND Part.Active is not null) or (@ActivePart = 1 and Part.Active = 0)) AND (ServiceEntryPart.ServiceTypeIDs = ISNULL(@ServiceTypes,ServiceEntryPart.ServiceTypeIDs)) AND ( @ServiceTypes is null or charindex(','+cast(ServiceEntryPart.ServiceTypeIDs as varchar(255))+',', ','+@ServiceTypes+',') > 0) Sample Filter @ServiceTypes = (2,3) OR @ServiceTypes = '' @ActivePart = 1 or @ActivePart = 0 DBO.ServiceEntryPart ID SERVICEENTRYID PartID ServiceTypeIDs 1063 1 266 1 1064 1 267 1 1065 1 268 1,2 706 96 324 7 707 96 327 7 682 244 397 NULL 683 264 382 NULL DBO.Part ID DESCRIPTION PARENTID ACTIVE 13 Barcode Reader 2 1 14 Dispersion Motor 2 1 15 Robot 2 1 16 RFID Reader 2 1 20 Gantry 3 0 23 Sample Wash Cup 3 1 24 R1Wash Cup 3 1
sql
sql-server
null
null
null
07/20/2012 06:46:49
not a real question
SQL Many to many select distinct === I need some help with the following query. So far what I have is below. What I am trying to do is get uniqure ServiceEntryPart records when parts are same and multiple service entry records when parts are unique. The following query works fine with the search filters, its just I need to get unique records when multiple parts are not present. Thanks SELECT * FROM ServiceEntryPart INNER JOIN Part on ServiceEntryPart.PartID = Part.ID WHERE (ServiceDateTime between @StartDate and @EndDate) AND ((@ActivePart = 0 AND Part.Active is not null) or (@ActivePart = 1 and Part.Active = 0)) AND (ServiceEntryPart.ServiceTypeIDs = ISNULL(@ServiceTypes,ServiceEntryPart.ServiceTypeIDs)) AND ( @ServiceTypes is null or charindex(','+cast(ServiceEntryPart.ServiceTypeIDs as varchar(255))+',', ','+@ServiceTypes+',') > 0) Sample Filter @ServiceTypes = (2,3) OR @ServiceTypes = '' @ActivePart = 1 or @ActivePart = 0 DBO.ServiceEntryPart ID SERVICEENTRYID PartID ServiceTypeIDs 1063 1 266 1 1064 1 267 1 1065 1 268 1,2 706 96 324 7 707 96 327 7 682 244 397 NULL 683 264 382 NULL DBO.Part ID DESCRIPTION PARENTID ACTIVE 13 Barcode Reader 2 1 14 Dispersion Motor 2 1 15 Robot 2 1 16 RFID Reader 2 1 20 Gantry 3 0 23 Sample Wash Cup 3 1 24 R1Wash Cup 3 1
1
11,567,847
07/19/2012 19:21:43
1,188,600
02/03/2012 22:57:16
64
1
Making an app that prints
Before I ask my question I want to clarify that I dont expect you gusy to fully write out the answer for me, just give me a link on where I can learn how to do this or something like that. How can you program an app to print something out that you have made within the app. Basically what I plan on doing is make an app that will make a QR Code for some information that will be writen out on the app, then I want to hit a button and print the QR Code to the printer that is set up. How would I go about doing this? Thanks
android
printing
qr-code
tablet
null
07/19/2012 20:12:45
not a real question
Making an app that prints === Before I ask my question I want to clarify that I dont expect you gusy to fully write out the answer for me, just give me a link on where I can learn how to do this or something like that. How can you program an app to print something out that you have made within the app. Basically what I plan on doing is make an app that will make a QR Code for some information that will be writen out on the app, then I want to hit a button and print the QR Code to the printer that is set up. How would I go about doing this? Thanks
1
11,567,848
07/19/2012 19:21:46
1,538,895
07/19/2012 19:15:36
1
0
Displaying random canvas using c# for wp7 app
I'm creating a quiz game for Windows 7. Each question opens up in a new canvas. How can I randomize the canvas view so that each time a player plays the game he gets random questions?
windows-phone-7
random
null
null
null
null
open
Displaying random canvas using c# for wp7 app === I'm creating a quiz game for Windows 7. Each question opens up in a new canvas. How can I randomize the canvas view so that each time a player plays the game he gets random questions?
0
11,567,856
07/19/2012 19:22:27
1,460,917
06/16/2012 17:12:53
44
0
creating a li menu to function as a form list
wanted a clean looking select list that isnt to heavy manage to get part of the way but struggling with collecting the data and send it to form. the most practical way is maybe collecting the span value and entering as into a hidden input field? not sure running out of ideas to make it function. tried doing it with a radio button worked but could get it to hide and be selected correctly... http://jsfiddle.net/D6CE4/1 css: /* Select list boxes sexy */ .desc { color:#6b6b6b;} .desc a {color:#0092dd;} .dropdown dd, .dropdown dt, .dropdown ul { margin:0px; padding:0px; } .dropdown dd { position:relative; } .dropdown a, .dropdown a:visited {font-family:Arial, Helvetica, sans-serif; font-size: 13px; color:#666; text-decoration:none; outline:none; border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px;} .dropdown a:hover { color:#fff;} .dropdown dt a:hover { text-align:left; color:#666; border: 1px solid #00C1F2;} .dropdown dt a {background:#fff url(/images/arrow.png) no-repeat scroll right center; display:block; padding-right: 17px; padding-left:3px; border:1px solid #00C1F2; width:120px;} .dropdown dt a span {cursor:pointer; display:block; padding:2px;} .dropdown dd ul { background:#fff none repeat scroll 0 0; border:1px solid #00C1F2; color:#000; display:none; left:0px; padding:0px 0px; position:absolute; top:0px; width:140px; list-style:none; border-radius: 3px; -moz-border-radius: 3px;-webkit-border-radius: 3px;} .dropdown span.value { display:none;} .dropdown dd ul li a { padding:3px; display:block;} .dropdown dd ul li a:hover { background-color:#00C1F2;} html: <form accept-charset='utf-8' method='get' action='dac' onsubmit="return check_domain_input()" class='normal-input-width'> <input type='hidden' name='no-upsell' value='1'/> <p><input style="width:118px" type='text' name='domain'/> . <dl id="sample" class="dropdown"> <dt><a href="#"><span>Please select </span></a></dt> <dd> <ul> <li><a href="#"><span class="value" ></span> <label for="thing">co.uk</label><!-- <input type="radio" name="tld" id="thing" value="co.uk" >--></div></a></li> <li><a href="#"><span class="value" ></span><label for="thing">com</label> <input style="display:none" type="radio" name="tld" id="thing" value="com" ></div></a></li> </ul> </dd> </dl><span id="result"></span> <input type='submit' value='Search'/></p> </form> js $(document).ready(function() { $(".dropdown dt a").click(function() { $(".dropdown dd ul").toggle(); }); $(".dropdown dd ul li a").click(function() { var text = $(this).html(); $(".dropdown dt a span").html(text); $(".dropdown dd ul").hide(); $("#result").html("Selected value is: " + getSelectedValue("sample")); }); function getSelectedValue(id) { return $("#" + id).find("dt a span.value").html(); } $(document).bind('click', function(e) { var $clicked = $(e.target); if (! $clicked.parents().hasClass("dropdown")) $(".dropdown dd ul").hide(); }); });
jquery
css
css3
null
null
null
open
creating a li menu to function as a form list === wanted a clean looking select list that isnt to heavy manage to get part of the way but struggling with collecting the data and send it to form. the most practical way is maybe collecting the span value and entering as into a hidden input field? not sure running out of ideas to make it function. tried doing it with a radio button worked but could get it to hide and be selected correctly... http://jsfiddle.net/D6CE4/1 css: /* Select list boxes sexy */ .desc { color:#6b6b6b;} .desc a {color:#0092dd;} .dropdown dd, .dropdown dt, .dropdown ul { margin:0px; padding:0px; } .dropdown dd { position:relative; } .dropdown a, .dropdown a:visited {font-family:Arial, Helvetica, sans-serif; font-size: 13px; color:#666; text-decoration:none; outline:none; border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px;} .dropdown a:hover { color:#fff;} .dropdown dt a:hover { text-align:left; color:#666; border: 1px solid #00C1F2;} .dropdown dt a {background:#fff url(/images/arrow.png) no-repeat scroll right center; display:block; padding-right: 17px; padding-left:3px; border:1px solid #00C1F2; width:120px;} .dropdown dt a span {cursor:pointer; display:block; padding:2px;} .dropdown dd ul { background:#fff none repeat scroll 0 0; border:1px solid #00C1F2; color:#000; display:none; left:0px; padding:0px 0px; position:absolute; top:0px; width:140px; list-style:none; border-radius: 3px; -moz-border-radius: 3px;-webkit-border-radius: 3px;} .dropdown span.value { display:none;} .dropdown dd ul li a { padding:3px; display:block;} .dropdown dd ul li a:hover { background-color:#00C1F2;} html: <form accept-charset='utf-8' method='get' action='dac' onsubmit="return check_domain_input()" class='normal-input-width'> <input type='hidden' name='no-upsell' value='1'/> <p><input style="width:118px" type='text' name='domain'/> . <dl id="sample" class="dropdown"> <dt><a href="#"><span>Please select </span></a></dt> <dd> <ul> <li><a href="#"><span class="value" ></span> <label for="thing">co.uk</label><!-- <input type="radio" name="tld" id="thing" value="co.uk" >--></div></a></li> <li><a href="#"><span class="value" ></span><label for="thing">com</label> <input style="display:none" type="radio" name="tld" id="thing" value="com" ></div></a></li> </ul> </dd> </dl><span id="result"></span> <input type='submit' value='Search'/></p> </form> js $(document).ready(function() { $(".dropdown dt a").click(function() { $(".dropdown dd ul").toggle(); }); $(".dropdown dd ul li a").click(function() { var text = $(this).html(); $(".dropdown dt a span").html(text); $(".dropdown dd ul").hide(); $("#result").html("Selected value is: " + getSelectedValue("sample")); }); function getSelectedValue(id) { return $("#" + id).find("dt a span.value").html(); } $(document).bind('click', function(e) { var $clicked = $(e.target); if (! $clicked.parents().hasClass("dropdown")) $(".dropdown dd ul").hide(); }); });
0
11,410,696
07/10/2012 09:50:25
1,511,590
07/09/2012 09:35:08
1
0
How to compile multiple C-programs into one executable file using makefile???
please write down a makefile for compiling multiple C programs into one executable file.
makefile
gnu-make
null
null
null
07/10/2012 10:44:16
not constructive
How to compile multiple C-programs into one executable file using makefile??? === please write down a makefile for compiling multiple C programs into one executable file.
4
11,410,708
07/10/2012 09:51:18
18,771
09/19/2008 11:44:16
96,733
2,678
"Auth fail" in jsch-0.1.42 with Java 1.4.2
I have this simple Java program that uses [Jsch][1] to connect to an SFTP server. The connection fails with an "Auth fail" exception on Java 1.4.2, but it connects flawlessly on Java 1.7. try { JSch jsch = new JSch(); jsch.setKnownHosts(KNOWN_HOSTS_PATH); jsch.addIdentity(PRIVATE_KEY_PATH, PASSPHRASE); Session session =jsch.getSession(USERNAME, HOSTNAME, 22); session.connect(2500); Channel channel = session.openChannel("shell"); channel.setInputStream(System.in); channel.setOutputStream(System.out); channel.connect(); } catch (Exception e) { e.printStackTrace(System.err); } The key I'm using is an `ssh-rsa 4096` bit key. The `.pub` key file exists in the same directory as the private key. When connecting a logger, I see the following messages before the exception (which occurs on `channel.connect();`): <pre> INFO: Connecting to &lt;redacted&gt; port 22 INFO: Connection established INFO: Remote version string: SSH-2.0-OpenSSH_5.1p1 Debian-5 INFO: Local version string: SSH-2.0-JSCH-0.1.42 INFO: CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256 INFO: arcfour is not available. INFO: arcfour128 is not available. INFO: arcfour256 is not available. INFO: SSH_MSG_KEXINIT sent INFO: SSH_MSG_KEXINIT received INFO: kex: server->client aes128-ctr hmac-md5 none INFO: kex: client->server aes128-ctr hmac-md5 none INFO: SSH_MSG_KEXDH_INIT sent INFO: expecting SSH_MSG_KEXDH_REPLY INFO: ssh_rsa_verify: signature true INFO: Host '&lt;redacted&gt;' is known and mathces the RSA host key INFO: SSH_MSG_NEWKEYS sent INFO: SSH_MSG_NEWKEYS received INFO: SSH_MSG_SERVICE_REQUEST sent INFO: SSH_MSG_SERVICE_ACCEPT received INFO: Authentications that can continue: publickey,keyboard-interactive,password INFO: Next authentication method: publickey INFO: Authentications that can continue: password INFO: Next authentication method: password INFO: Disconnecting from &lt;redacted&gt; port 22 com.jcraft.jsch.JSchException: Auth fail at com.jcraft.jsch.Session.connect(Session.java:452) at TestJsch.main(TestJsch.java:19) </pre> When I run the same program with Java 1.7, it says <pre> INFO: Connecting to &lt;redacted&gt; port 22 INFO: Connection established INFO: Remote version string: SSH-2.0-OpenSSH_5.1p1 Debian-5 INFO: Local version string: SSH-2.0-JSCH-0.1.42 INFO: CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256 INFO: SSH_MSG_KEXINIT sent INFO: SSH_MSG_KEXINIT received INFO: kex: server->client aes128-ctr hmac-md5 none INFO: kex: client->server aes128-ctr hmac-md5 none INFO: SSH_MSG_KEXDH_INIT sent INFO: expecting SSH_MSG_KEXDH_REPLY INFO: ssh_rsa_verify: signature true INFO: Host '&lt;redacted&gt;' is known and mathces the RSA host key INFO: SSH_MSG_NEWKEYS sent INFO: SSH_MSG_NEWKEYS received INFO: SSH_MSG_SERVICE_REQUEST sent INFO: SSH_MSG_SERVICE_ACCEPT receivedINFO: Authentications that can continue: publickey,keyboard-interactive,password INFO: Next authentication method: publickey INFO: Authentication succeeded (publickey). Linux &lt;redacted&gt; 2.6.26-2-amd64 #1 SMP Mon Jun 13 16:29:33 UTC 2011 x86_64 &lt;server welcome message follows&gt; </pre> I have installed the Java Cryptography Extensions (JCE) for the 1.4 VM. What could be the source of that problem? [1]: http://www.jcraft.com/jsch/
java
jsch
null
null
null
null
open
"Auth fail" in jsch-0.1.42 with Java 1.4.2 === I have this simple Java program that uses [Jsch][1] to connect to an SFTP server. The connection fails with an "Auth fail" exception on Java 1.4.2, but it connects flawlessly on Java 1.7. try { JSch jsch = new JSch(); jsch.setKnownHosts(KNOWN_HOSTS_PATH); jsch.addIdentity(PRIVATE_KEY_PATH, PASSPHRASE); Session session =jsch.getSession(USERNAME, HOSTNAME, 22); session.connect(2500); Channel channel = session.openChannel("shell"); channel.setInputStream(System.in); channel.setOutputStream(System.out); channel.connect(); } catch (Exception e) { e.printStackTrace(System.err); } The key I'm using is an `ssh-rsa 4096` bit key. The `.pub` key file exists in the same directory as the private key. When connecting a logger, I see the following messages before the exception (which occurs on `channel.connect();`): <pre> INFO: Connecting to &lt;redacted&gt; port 22 INFO: Connection established INFO: Remote version string: SSH-2.0-OpenSSH_5.1p1 Debian-5 INFO: Local version string: SSH-2.0-JSCH-0.1.42 INFO: CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256 INFO: arcfour is not available. INFO: arcfour128 is not available. INFO: arcfour256 is not available. INFO: SSH_MSG_KEXINIT sent INFO: SSH_MSG_KEXINIT received INFO: kex: server->client aes128-ctr hmac-md5 none INFO: kex: client->server aes128-ctr hmac-md5 none INFO: SSH_MSG_KEXDH_INIT sent INFO: expecting SSH_MSG_KEXDH_REPLY INFO: ssh_rsa_verify: signature true INFO: Host '&lt;redacted&gt;' is known and mathces the RSA host key INFO: SSH_MSG_NEWKEYS sent INFO: SSH_MSG_NEWKEYS received INFO: SSH_MSG_SERVICE_REQUEST sent INFO: SSH_MSG_SERVICE_ACCEPT received INFO: Authentications that can continue: publickey,keyboard-interactive,password INFO: Next authentication method: publickey INFO: Authentications that can continue: password INFO: Next authentication method: password INFO: Disconnecting from &lt;redacted&gt; port 22 com.jcraft.jsch.JSchException: Auth fail at com.jcraft.jsch.Session.connect(Session.java:452) at TestJsch.main(TestJsch.java:19) </pre> When I run the same program with Java 1.7, it says <pre> INFO: Connecting to &lt;redacted&gt; port 22 INFO: Connection established INFO: Remote version string: SSH-2.0-OpenSSH_5.1p1 Debian-5 INFO: Local version string: SSH-2.0-JSCH-0.1.42 INFO: CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256 INFO: SSH_MSG_KEXINIT sent INFO: SSH_MSG_KEXINIT received INFO: kex: server->client aes128-ctr hmac-md5 none INFO: kex: client->server aes128-ctr hmac-md5 none INFO: SSH_MSG_KEXDH_INIT sent INFO: expecting SSH_MSG_KEXDH_REPLY INFO: ssh_rsa_verify: signature true INFO: Host '&lt;redacted&gt;' is known and mathces the RSA host key INFO: SSH_MSG_NEWKEYS sent INFO: SSH_MSG_NEWKEYS received INFO: SSH_MSG_SERVICE_REQUEST sent INFO: SSH_MSG_SERVICE_ACCEPT receivedINFO: Authentications that can continue: publickey,keyboard-interactive,password INFO: Next authentication method: publickey INFO: Authentication succeeded (publickey). Linux &lt;redacted&gt; 2.6.26-2-amd64 #1 SMP Mon Jun 13 16:29:33 UTC 2011 x86_64 &lt;server welcome message follows&gt; </pre> I have installed the Java Cryptography Extensions (JCE) for the 1.4 VM. What could be the source of that problem? [1]: http://www.jcraft.com/jsch/
0
11,410,711
07/10/2012 09:51:26
1,129,347
01/04/2012 06:45:16
3
0
Updated servlet class not being referred in tomcat ubuntu
I am beginner to servlets. I am trying to create and run servlets using tomcat in ubuntu. I am facing a problem. I am able to call the servlet from the html file by adding an entries into web.xml. But when I change the java program a little and recompile and invoke the new servlet class, the html still seems to call the old one. Any help is appreciated. Thanks.
servlets
ubuntu
tomcat6
null
null
null
open
Updated servlet class not being referred in tomcat ubuntu === I am beginner to servlets. I am trying to create and run servlets using tomcat in ubuntu. I am facing a problem. I am able to call the servlet from the html file by adding an entries into web.xml. But when I change the java program a little and recompile and invoke the new servlet class, the html still seems to call the old one. Any help is appreciated. Thanks.
0
11,410,716
07/10/2012 09:51:39
1,254,352
03/07/2012 10:02:16
8
0
C# - change "where" restriction through inheritance
let's say I have an generic data access layer, that is supposed to support different implementations. To realize this I have an base interface `IPeristenceService` that defines all methods to access data inside the persistence tier. The interface could look something like this: public interface IPersistence { TData GetData<TData, TKey>(TKey Key); } So the persistence service cannot create instances of objects that are only defined by their interfaces, so it is a good decision to restrict the implementation of the `GetData`-method: public interface IPersistence { TData GetData<TData, TKey>(TKey Key) where TData : class, new(); } This is pretty straightforward, because developers who are implementing this interface will not be able to compile their code when they try to return an interface pointer. The data inside the persistence layer needs to be represented by implemented objects, not by interfaces! Now assume we are creating an persistence service, that persists data inside an relational database, represented by entities. All entities are inheriting from one base interface: `IEntity`. Passing non-entity objects must fail, because the persistence service can only persist entities. So we need to validate if the passed object instance inherits from `IEntity`. Using the where-notation this would be possible during compile-time, but simply implementing an interface like this: public class DbPersistence : IPersistence { public TData IPersistence.GetData<TData, TKey>(TKey Key) where TData : IEntity, class, new(); { // fancy data access code } } does not work, does it?! Is there any way to realize what I am trying to do? Thank you in advance :-)
c#
oop
inheritance
null
null
null
open
C# - change "where" restriction through inheritance === let's say I have an generic data access layer, that is supposed to support different implementations. To realize this I have an base interface `IPeristenceService` that defines all methods to access data inside the persistence tier. The interface could look something like this: public interface IPersistence { TData GetData<TData, TKey>(TKey Key); } So the persistence service cannot create instances of objects that are only defined by their interfaces, so it is a good decision to restrict the implementation of the `GetData`-method: public interface IPersistence { TData GetData<TData, TKey>(TKey Key) where TData : class, new(); } This is pretty straightforward, because developers who are implementing this interface will not be able to compile their code when they try to return an interface pointer. The data inside the persistence layer needs to be represented by implemented objects, not by interfaces! Now assume we are creating an persistence service, that persists data inside an relational database, represented by entities. All entities are inheriting from one base interface: `IEntity`. Passing non-entity objects must fail, because the persistence service can only persist entities. So we need to validate if the passed object instance inherits from `IEntity`. Using the where-notation this would be possible during compile-time, but simply implementing an interface like this: public class DbPersistence : IPersistence { public TData IPersistence.GetData<TData, TKey>(TKey Key) where TData : IEntity, class, new(); { // fancy data access code } } does not work, does it?! Is there any way to realize what I am trying to do? Thank you in advance :-)
0
11,410,718
07/10/2012 09:51:43
1,400,538
05/17/2012 08:57:23
32
0
Permission issue while starting a service from android
I have written a service as part of an application. I try to call this service from a second application using the following code: Intent intent = new Intent () ; intent.setClassName("com.test" ,"com.test.DownloadService") ; // Create a new Messenger for the communication back Messenger messenger = new Messenger(handler); intent.putExtra("MESSENGER", messenger); intent.setData(Uri.parse("http://www.vogella.com/index.html")); intent.putExtra("urlpath", "http://www.vogella.com/index.html"); this.startService(intent); It gives the following exception 07-10 09:27:28.819: ERROR/AndroidRuntime(4226): FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{com.inject/com.inject.MyActivity}: java.lang.SecurityException: Not allowed to start service Intent { dat=http://www.vogella.com/index.html cmp=com.test/.DownloadService (has extras) } without permission not exported from uid 10109 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1971) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1996) at android.app.ActivityThread.access$700(ActivityThread.java:126) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1156) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4458) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.SecurityException: Not allowed to start service Intent { dat=http://www.vogella.com/index.html cmp=com.test/.DownloadService (has extras) } without permission not exported from uid 10109 at android.app.ContextImpl.startService(ContextImpl.java:1122) at android.content.ContextWrapper.startService(ContextWrapper.java:359) at com.inject.MyActivity.onCreate(MyActivity.java:28) at android.app.Activity.performCreate(Activity.java:4465) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1935) ... 11 more Why this permission issue occurs? The following code works perfect when I call the service from the same app: Intent intent = new Intent(this, DownloadService.class); // Create a new Messenger for the communication back Messenger messenger = new Messenger(handler); intent.putExtra("MESSENGER", messenger); intent.setData(Uri.parse("http://www.vogella.com/index.html")); intent.putExtra("urlpath", "http://www.vogella.com/index.html"); startService(intent); Can someone please let me know why I get this permission issue when I call the service from a different application, though I have given all the required permissions in App2's manifest.
android
android-intent
android-service
android-permissions
null
null
open
Permission issue while starting a service from android === I have written a service as part of an application. I try to call this service from a second application using the following code: Intent intent = new Intent () ; intent.setClassName("com.test" ,"com.test.DownloadService") ; // Create a new Messenger for the communication back Messenger messenger = new Messenger(handler); intent.putExtra("MESSENGER", messenger); intent.setData(Uri.parse("http://www.vogella.com/index.html")); intent.putExtra("urlpath", "http://www.vogella.com/index.html"); this.startService(intent); It gives the following exception 07-10 09:27:28.819: ERROR/AndroidRuntime(4226): FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{com.inject/com.inject.MyActivity}: java.lang.SecurityException: Not allowed to start service Intent { dat=http://www.vogella.com/index.html cmp=com.test/.DownloadService (has extras) } without permission not exported from uid 10109 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1971) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1996) at android.app.ActivityThread.access$700(ActivityThread.java:126) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1156) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4458) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.SecurityException: Not allowed to start service Intent { dat=http://www.vogella.com/index.html cmp=com.test/.DownloadService (has extras) } without permission not exported from uid 10109 at android.app.ContextImpl.startService(ContextImpl.java:1122) at android.content.ContextWrapper.startService(ContextWrapper.java:359) at com.inject.MyActivity.onCreate(MyActivity.java:28) at android.app.Activity.performCreate(Activity.java:4465) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1935) ... 11 more Why this permission issue occurs? The following code works perfect when I call the service from the same app: Intent intent = new Intent(this, DownloadService.class); // Create a new Messenger for the communication back Messenger messenger = new Messenger(handler); intent.putExtra("MESSENGER", messenger); intent.setData(Uri.parse("http://www.vogella.com/index.html")); intent.putExtra("urlpath", "http://www.vogella.com/index.html"); startService(intent); Can someone please let me know why I get this permission issue when I call the service from a different application, though I have given all the required permissions in App2's manifest.
0
11,410,719
07/10/2012 09:52:04
1,426,344
05/30/2012 14:58:16
15
0
GET the CURRENT LOCATION lattitude and longitude
i have some code that i want to use to get the longitude and latitude... here's the code package ncsu.course.android.broadcastchatui1; import java.util.ArrayList; import java.util.Locale; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import java.io.IOException; import java.util.List; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.location.Address; import android.location.Geocoder; import ncsu.course.android.broadcastchatui1.R; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech.Engine; import android.speech.tts.TextToSpeech.OnInitListener; import android.speech.RecognizerIntent; import android.util.Log; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.inputmethod.EditorInfo; import android.widget.ArrayAdapter; import android.widget.ImageButton; import android.widget.EditText; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; /** * This is the main Activity that displays GUI. */ public class BroadcastChat extends Activity { // Debugging double LATITUDE = 37.42233; double LONGITUDE = -122.083; private static final long MINIMUM_DISTANCE_CHANGE_FOR_UPDATES = 1; // in Meters private static final long MINIMUM_TIME_BETWEEN_UPDATES = 1000; // in Milliseconds protected LocationManager locationManager; private static final String TAG = "BcastChatUI"; private static final boolean D = true; private Context _context; private TextToSpeech tts = null; private static int REQ_CODE = 1; private boolean ttsIsInit = false; private boolean awalan = false; private String pesan = "haha"; private String tanya; private String siapa = "saya"; private int SPEECH_REQUEST_CODE = 1234; // Layout Views private ListView mConversationView; private EditText mOutEditText; private ImageButton mSendButton; // Name of the connected device private ArrayAdapter<String> mConversationArrayAdapter; private StringBuffer mOutStringBuffer; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); _context = this.getApplicationContext(); if(D) Log.e(TAG, "+++ ON CREATE +++"); /* Use the LocationManager class to obtain GPS locations */ locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, MINIMUM_TIME_BETWEEN_UPDATES, MINIMUM_DISTANCE_CHANGE_FOR_UPDATES, new MyLocationListener() ); // Set up the window layout setContentView(R.layout.main); } private class MyLocationListener implements LocationListener { public void onLocationChanged(Location location) { String message = String.format( "New Location \n Longitude: %1$s \n Latitude: %2$s", location.getLongitude(), location.getLatitude() ); Toast.makeText(BroadcastChat.this, message, Toast.LENGTH_LONG).show(); } public void onStatusChanged(String s, int i, Bundle b) { Toast.makeText(BroadcastChat.this, "Provider status changed", Toast.LENGTH_LONG).show(); } public void onProviderDisabled(String s) { Toast.makeText(BroadcastChat.this, "Provider disabled by the user. GPS turned off", Toast.LENGTH_LONG).show(); } public void onProviderEnabled(String s) { Toast.makeText(BroadcastChat.this, "Provider enabled by the user. GPS turned on", Toast.LENGTH_LONG).show(); } } private void cektempat(){ Geocoder geocoder = new Geocoder(this, Locale.ENGLISH); try { Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); List<Address> addresses = geocoder.getFromLocation(LATITUDE, LONGITUDE, 1); if(addresses != null) { Address returnedAddress = addresses.get(0); StringBuilder strReturnedAddress = new StringBuilder("Anda ada di "); for(int i=0; i<returnedAddress.getMaxAddressLineIndex(); i++) { strReturnedAddress.append(returnedAddress.getAddressLine(i)).append("\n"); } pesan = strReturnedAddress.toString(); String message = pesan; sendMessage(message); startTextToSpeech2(); } else{ pesan = "Maaf saya tidak tahu anda dimana"; String message = pesan; sendMessage(message); startTextToSpeech2(); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); pesan = "IO EXCEPCTION ERROR"; String message = pesan; sendMessage(message); startTextToSpeech2(); } } public void onStart() { super.onStart(); if(D) Log.e(TAG, "++ ON START ++"); awalan = false; setupChat(); startTextToSpeech(); String message = "Selamat datang di kiosban"; sendMessage(message); } private void startTextToSpeech() { Intent intent = new Intent(Engine.ACTION_CHECK_TTS_DATA); startActivityForResult(intent, REQ_CODE); } private void startTextToSpeech2() { Intent intent = new Intent(Engine.ACTION_CHECK_TTS_DATA); startActivityForResult(intent, REQ_CODE); } private void sendRecognizeIntent() { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Apa yang bisa kami bantu?"); intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 100); startActivityForResult(intent, SPEECH_REQUEST_CODE); } protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQ_CODE) { if (resultCode == Engine.CHECK_VOICE_DATA_PASS) { tts = new TextToSpeech(this, new OnInitListener() { public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { ttsIsInit = true; if (tts.isLanguageAvailable(Locale.ENGLISH) >= 0) tts.setLanguage(Locale.ENGLISH); tts.setPitch(0.8f); tts.setSpeechRate(1.0f); if (awalan == false){ awalan = true; awalspeak(); } if (awalan == true){ speak(); } } } }); } /**if no voice data is currently available, * start a new activity using the ACTION_INSTALL_TTS_DATA action * from the TTS Engine class to initiate its installation */ else { Intent installVoice = new Intent(Engine.ACTION_INSTALL_TTS_DATA); startActivity(installVoice); } } if (requestCode == SPEECH_REQUEST_CODE) { if (resultCode == RESULT_OK) { ArrayList<String> matches = data .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); if (matches.size() == 0) { tts.speak("Heard nothing", TextToSpeech.QUEUE_FLUSH, null); } tanya = matches.get(0); String pertanyaan = tanya; sendTanya(pertanyaan); } } else { Log.d(TAG, "result NOT ok"); } super.onActivityResult(requestCode, resultCode, data); } private void speak() { if (tts != null && ttsIsInit) { String text = pesan; tts.speak(text, TextToSpeech.QUEUE_ADD, null); } } private void jawab() { ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>(); postParameters.add(new BasicNameValuePair("tanya", tanya)); /* String valid = "1";*/ String response = null; try { response = CustomHttpClient.executeHttpPost("http://kiosban.com/android/jamesband.php", postParameters); String res = response.toString(); res = res.trim(); res = res.replaceAll("\\s+"," "); pesan = res; String message = pesan; if(res.equals("lokasi")){ cektempat(); }else{ sendMessage(message); startTextToSpeech2(); } } catch (Exception e) {} } private void awalspeak() { if (tts != null && ttsIsInit) { String text = "selamat datang di kiosban"; tts.speak(text, TextToSpeech.QUEUE_ADD, null); } } public synchronized void onResume() { super.onResume(); if(D) Log.e(TAG, "+ ON RESUME +"); } private void setupChat() { Log.d(TAG, "setupChat()"); // Initialize the array adapter for the conversation thread mConversationArrayAdapter = new ArrayAdapter<String>(this, R.layout.message); mConversationView = (ListView) findViewById(R.id.in); mConversationView.setAdapter(mConversationArrayAdapter); // Initialize the compose field with a listener for the return key mOutEditText = (EditText) findViewById(R.id.edit_text_out); mOutEditText.setOnEditorActionListener(mWriteListener); mOutEditText.setVisibility(View.GONE); // Initialize the send button with a listener that for click events mSendButton = (ImageButton) findViewById(R.id.button_send); mSendButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { if(D) Log.e(TAG, "[sendButton clicked]"); // Send a message using content of the edit text widget sendRecognizeIntent(); } }); // Initialize the buffer for outgoing messages mOutStringBuffer = new StringBuffer(""); } public synchronized void onPause() { super.onPause(); if(D) Log.e(TAG, "- ON PAUSE -"); } public void onStop() { super.onStop(); if(D) Log.e(TAG, "-- ON STOP --"); } public void onDestroy() { super.onDestroy(); if(D) Log.e(TAG, "--- ON DESTROY ---"); } private void sendMessage(String message) { // Check that there's actually something to send if (message.length() > 0 ) { // We will send a message via wifi // Reset out string buffer to zero and clear the edit text field mOutStringBuffer.setLength(0); mOutEditText.setText(mOutStringBuffer); }else{ Toast.makeText(this, "Please type a message", Toast.LENGTH_SHORT).show(); return; } // Add message to UI mConversationArrayAdapter.add("James Band: " + message); } private void sendTanya(String pertanyaan) { // Check that there's actually something to send if (pertanyaan.length() > 0 ) { // We will send a message via wifi // Reset out string buffer to zero and clear the edit text field mOutStringBuffer.setLength(0); mOutEditText.setText(mOutStringBuffer); }else{ Toast.makeText(this, "Please type a message", Toast.LENGTH_SHORT).show(); return; } mConversationArrayAdapter.add("Me: " + pertanyaan); jawab(); } // The action listener for the EditText widget, to listen for the return key private TextView.OnEditorActionListener mWriteListener = new TextView.OnEditorActionListener() { public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { // If the action is a key-up event on the return key, send the message if (actionId == EditorInfo.IME_NULL // return key && event.getAction() == KeyEvent.ACTION_UP) // the key has been released { String pertanyaan = view.getText().toString(); sendTanya(pertanyaan); } if(D) Log.i(TAG, "END onEditorAction"); return true; } }; } Its work when i using that code, it give the street name, the script give me the street name from LATITUDE value and LONGITUDE value that i insert it manually, but if i change the code below List<Address> addresses = geocoder.getFromLocation(LATITUDE, LONGITUDE, 1); on cektempat(); part to List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); i get my code doesnt work, i was set the permission to but the code still didnt work.. anybody can help me? thanks before
android
latitude
longitude
null
null
null
open
GET the CURRENT LOCATION lattitude and longitude === i have some code that i want to use to get the longitude and latitude... here's the code package ncsu.course.android.broadcastchatui1; import java.util.ArrayList; import java.util.Locale; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import java.io.IOException; import java.util.List; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.location.Address; import android.location.Geocoder; import ncsu.course.android.broadcastchatui1.R; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech.Engine; import android.speech.tts.TextToSpeech.OnInitListener; import android.speech.RecognizerIntent; import android.util.Log; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.inputmethod.EditorInfo; import android.widget.ArrayAdapter; import android.widget.ImageButton; import android.widget.EditText; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; /** * This is the main Activity that displays GUI. */ public class BroadcastChat extends Activity { // Debugging double LATITUDE = 37.42233; double LONGITUDE = -122.083; private static final long MINIMUM_DISTANCE_CHANGE_FOR_UPDATES = 1; // in Meters private static final long MINIMUM_TIME_BETWEEN_UPDATES = 1000; // in Milliseconds protected LocationManager locationManager; private static final String TAG = "BcastChatUI"; private static final boolean D = true; private Context _context; private TextToSpeech tts = null; private static int REQ_CODE = 1; private boolean ttsIsInit = false; private boolean awalan = false; private String pesan = "haha"; private String tanya; private String siapa = "saya"; private int SPEECH_REQUEST_CODE = 1234; // Layout Views private ListView mConversationView; private EditText mOutEditText; private ImageButton mSendButton; // Name of the connected device private ArrayAdapter<String> mConversationArrayAdapter; private StringBuffer mOutStringBuffer; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); _context = this.getApplicationContext(); if(D) Log.e(TAG, "+++ ON CREATE +++"); /* Use the LocationManager class to obtain GPS locations */ locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, MINIMUM_TIME_BETWEEN_UPDATES, MINIMUM_DISTANCE_CHANGE_FOR_UPDATES, new MyLocationListener() ); // Set up the window layout setContentView(R.layout.main); } private class MyLocationListener implements LocationListener { public void onLocationChanged(Location location) { String message = String.format( "New Location \n Longitude: %1$s \n Latitude: %2$s", location.getLongitude(), location.getLatitude() ); Toast.makeText(BroadcastChat.this, message, Toast.LENGTH_LONG).show(); } public void onStatusChanged(String s, int i, Bundle b) { Toast.makeText(BroadcastChat.this, "Provider status changed", Toast.LENGTH_LONG).show(); } public void onProviderDisabled(String s) { Toast.makeText(BroadcastChat.this, "Provider disabled by the user. GPS turned off", Toast.LENGTH_LONG).show(); } public void onProviderEnabled(String s) { Toast.makeText(BroadcastChat.this, "Provider enabled by the user. GPS turned on", Toast.LENGTH_LONG).show(); } } private void cektempat(){ Geocoder geocoder = new Geocoder(this, Locale.ENGLISH); try { Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); List<Address> addresses = geocoder.getFromLocation(LATITUDE, LONGITUDE, 1); if(addresses != null) { Address returnedAddress = addresses.get(0); StringBuilder strReturnedAddress = new StringBuilder("Anda ada di "); for(int i=0; i<returnedAddress.getMaxAddressLineIndex(); i++) { strReturnedAddress.append(returnedAddress.getAddressLine(i)).append("\n"); } pesan = strReturnedAddress.toString(); String message = pesan; sendMessage(message); startTextToSpeech2(); } else{ pesan = "Maaf saya tidak tahu anda dimana"; String message = pesan; sendMessage(message); startTextToSpeech2(); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); pesan = "IO EXCEPCTION ERROR"; String message = pesan; sendMessage(message); startTextToSpeech2(); } } public void onStart() { super.onStart(); if(D) Log.e(TAG, "++ ON START ++"); awalan = false; setupChat(); startTextToSpeech(); String message = "Selamat datang di kiosban"; sendMessage(message); } private void startTextToSpeech() { Intent intent = new Intent(Engine.ACTION_CHECK_TTS_DATA); startActivityForResult(intent, REQ_CODE); } private void startTextToSpeech2() { Intent intent = new Intent(Engine.ACTION_CHECK_TTS_DATA); startActivityForResult(intent, REQ_CODE); } private void sendRecognizeIntent() { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Apa yang bisa kami bantu?"); intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 100); startActivityForResult(intent, SPEECH_REQUEST_CODE); } protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQ_CODE) { if (resultCode == Engine.CHECK_VOICE_DATA_PASS) { tts = new TextToSpeech(this, new OnInitListener() { public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { ttsIsInit = true; if (tts.isLanguageAvailable(Locale.ENGLISH) >= 0) tts.setLanguage(Locale.ENGLISH); tts.setPitch(0.8f); tts.setSpeechRate(1.0f); if (awalan == false){ awalan = true; awalspeak(); } if (awalan == true){ speak(); } } } }); } /**if no voice data is currently available, * start a new activity using the ACTION_INSTALL_TTS_DATA action * from the TTS Engine class to initiate its installation */ else { Intent installVoice = new Intent(Engine.ACTION_INSTALL_TTS_DATA); startActivity(installVoice); } } if (requestCode == SPEECH_REQUEST_CODE) { if (resultCode == RESULT_OK) { ArrayList<String> matches = data .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); if (matches.size() == 0) { tts.speak("Heard nothing", TextToSpeech.QUEUE_FLUSH, null); } tanya = matches.get(0); String pertanyaan = tanya; sendTanya(pertanyaan); } } else { Log.d(TAG, "result NOT ok"); } super.onActivityResult(requestCode, resultCode, data); } private void speak() { if (tts != null && ttsIsInit) { String text = pesan; tts.speak(text, TextToSpeech.QUEUE_ADD, null); } } private void jawab() { ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>(); postParameters.add(new BasicNameValuePair("tanya", tanya)); /* String valid = "1";*/ String response = null; try { response = CustomHttpClient.executeHttpPost("http://kiosban.com/android/jamesband.php", postParameters); String res = response.toString(); res = res.trim(); res = res.replaceAll("\\s+"," "); pesan = res; String message = pesan; if(res.equals("lokasi")){ cektempat(); }else{ sendMessage(message); startTextToSpeech2(); } } catch (Exception e) {} } private void awalspeak() { if (tts != null && ttsIsInit) { String text = "selamat datang di kiosban"; tts.speak(text, TextToSpeech.QUEUE_ADD, null); } } public synchronized void onResume() { super.onResume(); if(D) Log.e(TAG, "+ ON RESUME +"); } private void setupChat() { Log.d(TAG, "setupChat()"); // Initialize the array adapter for the conversation thread mConversationArrayAdapter = new ArrayAdapter<String>(this, R.layout.message); mConversationView = (ListView) findViewById(R.id.in); mConversationView.setAdapter(mConversationArrayAdapter); // Initialize the compose field with a listener for the return key mOutEditText = (EditText) findViewById(R.id.edit_text_out); mOutEditText.setOnEditorActionListener(mWriteListener); mOutEditText.setVisibility(View.GONE); // Initialize the send button with a listener that for click events mSendButton = (ImageButton) findViewById(R.id.button_send); mSendButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { if(D) Log.e(TAG, "[sendButton clicked]"); // Send a message using content of the edit text widget sendRecognizeIntent(); } }); // Initialize the buffer for outgoing messages mOutStringBuffer = new StringBuffer(""); } public synchronized void onPause() { super.onPause(); if(D) Log.e(TAG, "- ON PAUSE -"); } public void onStop() { super.onStop(); if(D) Log.e(TAG, "-- ON STOP --"); } public void onDestroy() { super.onDestroy(); if(D) Log.e(TAG, "--- ON DESTROY ---"); } private void sendMessage(String message) { // Check that there's actually something to send if (message.length() > 0 ) { // We will send a message via wifi // Reset out string buffer to zero and clear the edit text field mOutStringBuffer.setLength(0); mOutEditText.setText(mOutStringBuffer); }else{ Toast.makeText(this, "Please type a message", Toast.LENGTH_SHORT).show(); return; } // Add message to UI mConversationArrayAdapter.add("James Band: " + message); } private void sendTanya(String pertanyaan) { // Check that there's actually something to send if (pertanyaan.length() > 0 ) { // We will send a message via wifi // Reset out string buffer to zero and clear the edit text field mOutStringBuffer.setLength(0); mOutEditText.setText(mOutStringBuffer); }else{ Toast.makeText(this, "Please type a message", Toast.LENGTH_SHORT).show(); return; } mConversationArrayAdapter.add("Me: " + pertanyaan); jawab(); } // The action listener for the EditText widget, to listen for the return key private TextView.OnEditorActionListener mWriteListener = new TextView.OnEditorActionListener() { public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { // If the action is a key-up event on the return key, send the message if (actionId == EditorInfo.IME_NULL // return key && event.getAction() == KeyEvent.ACTION_UP) // the key has been released { String pertanyaan = view.getText().toString(); sendTanya(pertanyaan); } if(D) Log.i(TAG, "END onEditorAction"); return true; } }; } Its work when i using that code, it give the street name, the script give me the street name from LATITUDE value and LONGITUDE value that i insert it manually, but if i change the code below List<Address> addresses = geocoder.getFromLocation(LATITUDE, LONGITUDE, 1); on cektempat(); part to List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); i get my code doesnt work, i was set the permission to but the code still didnt work.. anybody can help me? thanks before
0
5,797,797
04/26/2011 23:49:41
394,963
07/18/2010 03:39:56
16
1
attach() inside function
I'd like to give a params argument to a function and then attach it so that I can use a instead of params$a everytime I refer to the list element a. run.simulation<-function(model,params){ attach(params) # # Use elements of params as parameters in a simulation detach(params) } Is there a problem with this? If I have defined a global variable named c and have also defined an element named c of the list "params" , whose value would be used after the attach command?
r
attach
scoping
null
null
null
open
attach() inside function === I'd like to give a params argument to a function and then attach it so that I can use a instead of params$a everytime I refer to the list element a. run.simulation<-function(model,params){ attach(params) # # Use elements of params as parameters in a simulation detach(params) } Is there a problem with this? If I have defined a global variable named c and have also defined an element named c of the list "params" , whose value would be used after the attach command?
0
5,797,798
04/26/2011 23:49:48
654,478
03/10/2011 23:37:36
60
6
sample Bash script or commadn to retrive number files in directory
I have problem with number of files in directory I use $(ls /test -l | grep '^-' | wc -l) but this way retrive just number of files in the same path but dont retrive number of files in subdirectors if I have /test/1 /test/1/2 /test/1/3 /test/1/4/1 /test/1/4/2 /test/1/5 my question how to retrive number of files in /test thanks for advice
linux
shell
null
null
null
null
open
sample Bash script or commadn to retrive number files in directory === I have problem with number of files in directory I use $(ls /test -l | grep '^-' | wc -l) but this way retrive just number of files in the same path but dont retrive number of files in subdirectors if I have /test/1 /test/1/2 /test/1/3 /test/1/4/1 /test/1/4/2 /test/1/5 my question how to retrive number of files in /test thanks for advice
0
11,410,722
07/10/2012 09:52:23
1,432,033
06/02/2012 06:01:52
752
80
Altering User Definde Table Types in SQL
How can I alter a User Definde Table Types in SQL server ?
sql
user-defined-types
null
null
null
null
open
Altering User Definde Table Types in SQL === How can I alter a User Definde Table Types in SQL server ?
0
11,410,728
07/10/2012 09:52:42
1,227,714
02/23/2012 07:19:53
45
0
Custom Functions in Thread
I have a simple Question: I have a Thread named rlMF. I created it this way: public Thread rlMF = new Thread(new Runnable() { public void run() { reloadMissingFiles(); stopTh(); } public void stopTh() { activityStopped = true; } }); Now i want to call the stopTh Function from outer Thread. Why can't i simply call rlMF.stopTh(); and what can i do else? Example: protected void onPause() { Log.d("Info", "destroying..."); activityStopped = true; rlMF.stopTh(); super.onPause(); } Is not working...
java
android
null
null
null
null
open
Custom Functions in Thread === I have a simple Question: I have a Thread named rlMF. I created it this way: public Thread rlMF = new Thread(new Runnable() { public void run() { reloadMissingFiles(); stopTh(); } public void stopTh() { activityStopped = true; } }); Now i want to call the stopTh Function from outer Thread. Why can't i simply call rlMF.stopTh(); and what can i do else? Example: protected void onPause() { Log.d("Info", "destroying..."); activityStopped = true; rlMF.stopTh(); super.onPause(); } Is not working...
0
11,349,819
07/05/2012 17:54:01
278,859
02/22/2010 17:00:18
363
16
JSONObjectWithData returns null if degree symbol is in json object
JSONObjectWithData is returning null without an error if the json string contains a degree sign ° (U+00B0). The json string displays fine if I serve it to my desktop browser. My code (a category) with a few NSLogs to see what is happening looks like this... +(NSDictionary*)dictionaryWithContentsOfJSONURLString:(NSString *)urlAddress{ __autoreleasing NSError* error = nil; NSData* data = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlAddress] options:NSDataReadingUncached error:&error]; if (error != nil) { NSLog(@"%@",[error localizedDescription]); } else { NSLog(@"No Error: %@", data); //looks good here. console displays the raw data } id result = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error]; if (error != nil) { NSLog(@"%@",[error localizedDescription]); return nil; } else { NSLog(@"No Error: %@", [result objectForKey:@"exams"]); //console displays the value ("No Error: value for key...") unless a degree symbol is present in which case it displays No Error: (null) } return result; } So I am not getting any errors but the JSONOBjectWithData returns null if the received json string contains a degree symbol. I used NSString with contents of URL to see how xCode is seeing the string and instead of a degree symbol I am getting wht I thiink is an elipsis ∞ symbol. When viewed in a browser the same string is a degree symbol. Is this a bug? I must be missing something. Thanks, John
iphone
xcode
json
nsjsonserialization
null
null
open
JSONObjectWithData returns null if degree symbol is in json object === JSONObjectWithData is returning null without an error if the json string contains a degree sign ° (U+00B0). The json string displays fine if I serve it to my desktop browser. My code (a category) with a few NSLogs to see what is happening looks like this... +(NSDictionary*)dictionaryWithContentsOfJSONURLString:(NSString *)urlAddress{ __autoreleasing NSError* error = nil; NSData* data = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlAddress] options:NSDataReadingUncached error:&error]; if (error != nil) { NSLog(@"%@",[error localizedDescription]); } else { NSLog(@"No Error: %@", data); //looks good here. console displays the raw data } id result = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error]; if (error != nil) { NSLog(@"%@",[error localizedDescription]); return nil; } else { NSLog(@"No Error: %@", [result objectForKey:@"exams"]); //console displays the value ("No Error: value for key...") unless a degree symbol is present in which case it displays No Error: (null) } return result; } So I am not getting any errors but the JSONOBjectWithData returns null if the received json string contains a degree symbol. I used NSString with contents of URL to see how xCode is seeing the string and instead of a degree symbol I am getting wht I thiink is an elipsis ∞ symbol. When viewed in a browser the same string is a degree symbol. Is this a bug? I must be missing something. Thanks, John
0
11,350,340
07/05/2012 18:27:47
1,496,235
07/02/2012 13:56:42
5
0
How would I assign a control an order number?
I'm in a predicament. I have created a method which draws all the controls to the panel, but its draws them based on the order which I have listed them, which means PictureBox1 will always be *behind* all the other pictureboxes. Example: e.Graphics.DrawImage(PictureBox1.BackgroundImage, new Rectangle(PictureBox1.Location, PictureBox1.Size)); e.Graphics.DrawImage(PictureBox2.BackgroundImage, new Rectangle(PictureBox2.Location, PictureBox2.Size)); it draws PictureBox1 **first**, then PictureBox2 **second**., then PictureBox3 **third** etc.. Now when I push a button when focus is on picturebox2 I would like the DrawImage order to be changed so that PictureBox2 is drawn last. I'm sure one of you has a great solution to this, I would like to listen to any suggestions you may have.
c#
null
null
null
null
null
open
How would I assign a control an order number? === I'm in a predicament. I have created a method which draws all the controls to the panel, but its draws them based on the order which I have listed them, which means PictureBox1 will always be *behind* all the other pictureboxes. Example: e.Graphics.DrawImage(PictureBox1.BackgroundImage, new Rectangle(PictureBox1.Location, PictureBox1.Size)); e.Graphics.DrawImage(PictureBox2.BackgroundImage, new Rectangle(PictureBox2.Location, PictureBox2.Size)); it draws PictureBox1 **first**, then PictureBox2 **second**., then PictureBox3 **third** etc.. Now when I push a button when focus is on picturebox2 I would like the DrawImage order to be changed so that PictureBox2 is drawn last. I'm sure one of you has a great solution to this, I would like to listen to any suggestions you may have.
0
11,350,341
07/05/2012 18:27:49
1,269,363
03/14/2012 15:12:48
1
0
How can i interleave elements of 2 lists in scala
i'm trying to combine 2 lists in such a way that it inserts elements from list #2 after every n-th element in list #1. So having val a = List(1,2,3,4,5,6,7) val b = List(101,102,103) val n = 3 i want the resulting list to look like this : List(1,2,3,101,4,5,6,102,7) I have this working using a left fold on the list a, but I'm wondering how the same logic could be accomplished using Scalaz? thanks for any suggestions, Marcin
scala
scalaz
null
null
null
null
open
How can i interleave elements of 2 lists in scala === i'm trying to combine 2 lists in such a way that it inserts elements from list #2 after every n-th element in list #1. So having val a = List(1,2,3,4,5,6,7) val b = List(101,102,103) val n = 3 i want the resulting list to look like this : List(1,2,3,101,4,5,6,102,7) I have this working using a left fold on the list a, but I'm wondering how the same logic could be accomplished using Scalaz? thanks for any suggestions, Marcin
0
11,350,342
07/05/2012 18:27:49
937,682
09/09/2011 22:59:16
42
1
Way to iterate two items at a time in a list?
I am wondering if there is a better way to iterate two items at a time in a list. I work with Maya a lot, and one of its commands (listConnections) returns a list of alternating values. The list will look like [connectionDestination, connectionSource, connectionDestination, connectionSource]. To do anything with this list, I would ideally like to do something similar to: for destination, source in cmds.listConnections(): print source, destination You could, of course just iterate every other item in the list using [::2] and enumerate and source would be the index+1, but then you have to add in extra checks for odd numbered lists and stuff. The closest thing I have come up with so far is: from itertools import izip connections = cmds.listConnections() for destination, source in izip(connections[::2], connections[1::2]): print source, destination This isn't super important, as I already have ways of doing what I want. This just seems like one of those things that there should be a better way of doing it.
python
maya
null
null
null
null
open
Way to iterate two items at a time in a list? === I am wondering if there is a better way to iterate two items at a time in a list. I work with Maya a lot, and one of its commands (listConnections) returns a list of alternating values. The list will look like [connectionDestination, connectionSource, connectionDestination, connectionSource]. To do anything with this list, I would ideally like to do something similar to: for destination, source in cmds.listConnections(): print source, destination You could, of course just iterate every other item in the list using [::2] and enumerate and source would be the index+1, but then you have to add in extra checks for odd numbered lists and stuff. The closest thing I have come up with so far is: from itertools import izip connections = cmds.listConnections() for destination, source in izip(connections[::2], connections[1::2]): print source, destination This isn't super important, as I already have ways of doing what I want. This just seems like one of those things that there should be a better way of doing it.
0
11,350,345
07/05/2012 18:28:00
1,175,599
01/28/2012 19:16:33
2,896
228
How to insert TD in datatables
Have spent the morning on the examples page, and can't seem to spot why this isn't working. The intent is to populate the table with ajax(currently a sample txt file), and add a column to each row to allow editing and deletion. Have tried all sorts of variations of the below code (which has evolved to ugly), but can see why it won't work. No errors of any kind (in firebug or anywhere else) it just doesn't do add the columns as the code "is supposed" to do. jQuery(document).ready(function($) { $(function() { tableActions(); function initTable () { var myTable = $('#example').dataTable( { "iDisplayLength": 10, "bJQueryUI": true, "sPaginationType": "full_numbers", "bProcessing": true, "bStateSave": false, "sAjaxSource": 'datatables_example_arrays.txt', "aLengthMenu": [[10, 15, 25, -1], [10, 15, 25, "All"]], "bRetrieve": true } ); return myTable; } function tableActions () { var oTable = initTable(); /* Insert an 'edit' column with image to the table */ var nCloneTh = document.createElement( 'th' ); var nCloneTd = document.createElement( 'td' ); nCloneTd.innerHTML = '<img src="title_edit.png">'; nCloneTd.className = "center"; $('#example thead tr').each( function () { oTable.insertBefore( nCloneTh, this.childNodes[0] ); } ); $('#example tbody tr').each( function () { oTable.insertBefore( nCloneTd.cloneNode( true ), this.childNodes[0] ); } ); } }); });
jquery
datatables
null
null
null
null
open
How to insert TD in datatables === Have spent the morning on the examples page, and can't seem to spot why this isn't working. The intent is to populate the table with ajax(currently a sample txt file), and add a column to each row to allow editing and deletion. Have tried all sorts of variations of the below code (which has evolved to ugly), but can see why it won't work. No errors of any kind (in firebug or anywhere else) it just doesn't do add the columns as the code "is supposed" to do. jQuery(document).ready(function($) { $(function() { tableActions(); function initTable () { var myTable = $('#example').dataTable( { "iDisplayLength": 10, "bJQueryUI": true, "sPaginationType": "full_numbers", "bProcessing": true, "bStateSave": false, "sAjaxSource": 'datatables_example_arrays.txt', "aLengthMenu": [[10, 15, 25, -1], [10, 15, 25, "All"]], "bRetrieve": true } ); return myTable; } function tableActions () { var oTable = initTable(); /* Insert an 'edit' column with image to the table */ var nCloneTh = document.createElement( 'th' ); var nCloneTd = document.createElement( 'td' ); nCloneTd.innerHTML = '<img src="title_edit.png">'; nCloneTd.className = "center"; $('#example thead tr').each( function () { oTable.insertBefore( nCloneTh, this.childNodes[0] ); } ); $('#example tbody tr').each( function () { oTable.insertBefore( nCloneTd.cloneNode( true ), this.childNodes[0] ); } ); } }); });
0
11,350,346
07/05/2012 18:28:06
1,502,258
07/04/2012 18:20:38
1
0
jQuery live preview / selector not working
Ok. jQuery is not my strong suit. I am showing a live address as the person types it in, in another DIV. There has to be : 1) A better way to iterate through the fields without all the vars? 2) My select onchange is not working / showing the value? Any ideas / help is greatly appreciated. jQuery(function($) { var billfirstname = $('#billing_first_name'), preview_first_name = $('#billing_first_name_mirror'); var billlastname = $('#billing_last_name'), preview_last_name = $('#billing_last_name_mirror'); var billadd1 = $('#billing_address_1'), preview_bill1 = $('#billing_address_1_mirror'); var billadd2 = $('#billing_address_2'), preview_bill2 = $('#billing_address_2_mirror'); var billcity = $('#billing_city'), preview_bcity = $('#billing_address_city_mirror'); var billstate = $('#billing_state option:selected'), preview_bstate = $('#billing_address_state_mirror'); billfirstname.bind('keyup blur change click', function(e) { preview_first_name.text(billfirstname.val()); }); billlastname.bind('keyup blur change click', function(e) { preview_last_name.text(billlastname.val()); }); billadd1.bind('keyup blur change click', function(e) { preview_bill1.text(billadd1.val()); }); billadd2.bind('keyup blur change click', function(e) { preview_bill2.text(billadd2.val()); }); billcity.bind('keyup blur change click', function(e) { preview_bcity.text(billcity.val()); }); billstate.bind('change',function(e) { preview_bstate.text(billstate.val()); }); });
jquery
jquery-selectors
null
null
null
null
open
jQuery live preview / selector not working === Ok. jQuery is not my strong suit. I am showing a live address as the person types it in, in another DIV. There has to be : 1) A better way to iterate through the fields without all the vars? 2) My select onchange is not working / showing the value? Any ideas / help is greatly appreciated. jQuery(function($) { var billfirstname = $('#billing_first_name'), preview_first_name = $('#billing_first_name_mirror'); var billlastname = $('#billing_last_name'), preview_last_name = $('#billing_last_name_mirror'); var billadd1 = $('#billing_address_1'), preview_bill1 = $('#billing_address_1_mirror'); var billadd2 = $('#billing_address_2'), preview_bill2 = $('#billing_address_2_mirror'); var billcity = $('#billing_city'), preview_bcity = $('#billing_address_city_mirror'); var billstate = $('#billing_state option:selected'), preview_bstate = $('#billing_address_state_mirror'); billfirstname.bind('keyup blur change click', function(e) { preview_first_name.text(billfirstname.val()); }); billlastname.bind('keyup blur change click', function(e) { preview_last_name.text(billlastname.val()); }); billadd1.bind('keyup blur change click', function(e) { preview_bill1.text(billadd1.val()); }); billadd2.bind('keyup blur change click', function(e) { preview_bill2.text(billadd2.val()); }); billcity.bind('keyup blur change click', function(e) { preview_bcity.text(billcity.val()); }); billstate.bind('change',function(e) { preview_bstate.text(billstate.val()); }); });
0