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,713,339
07/29/2012 22:00:45
1,561,583
07/29/2012 21:49:07
1
0
.NET Claim in three namespaces
Now this is odd. After completing some research on claims based solutions in .NET, found that different authors refer to different classes in .NET namespace when actually speaking on the same matter. Claim class (not to mention other Identity, Principal, Manager, Helper classes around) is defined in 3 different namespaces. It is clear that WIF is separate add-on for .NET 3.5 and 4.0 and that it is rewritten and made part of core in 4.5. However it could really help to have clear directions on what class to use for new projects (so that port to 4.5 after could be easier). Does anybody else have more info on the subject? 1st link: <http://msdn.microsoft.com/en-us/library/ms572956(v=vs.110)> (System.IdentityModel.Claims namespace) 2nd: <http://msdn.microsoft.com/en-us/library/microsoft.identitymodel.claims.claim.aspx> (Microsoft.IdentityModel.Claims) 3rd: (System.Security.Claims.Claim)
.net
wif
claims-based-identity
null
null
null
open
.NET Claim in three namespaces === Now this is odd. After completing some research on claims based solutions in .NET, found that different authors refer to different classes in .NET namespace when actually speaking on the same matter. Claim class (not to mention other Identity, Principal, Manager, Helper classes around) is defined in 3 different namespaces. It is clear that WIF is separate add-on for .NET 3.5 and 4.0 and that it is rewritten and made part of core in 4.5. However it could really help to have clear directions on what class to use for new projects (so that port to 4.5 after could be easier). Does anybody else have more info on the subject? 1st link: <http://msdn.microsoft.com/en-us/library/ms572956(v=vs.110)> (System.IdentityModel.Claims namespace) 2nd: <http://msdn.microsoft.com/en-us/library/microsoft.identitymodel.claims.claim.aspx> (Microsoft.IdentityModel.Claims) 3rd: (System.Security.Claims.Claim)
0
11,226,366
06/27/2012 12:36:18
1,104,823
12/18/2011 19:15:58
312
3
C, C++ and Matlab for embedded systems
I am working on an embedded system and need to do some semi-complex matrix mathematical calculations. What is the best solution for performance, using C++ and a matrix library, using C and interfacing with matlab, or something else. Could someone also provide some details about how the code will be on the system? Thanks
c++
c
matlab
embedded
system
06/27/2012 14:26:42
not a real question
C, C++ and Matlab for embedded systems === I am working on an embedded system and need to do some semi-complex matrix mathematical calculations. What is the best solution for performance, using C++ and a matrix library, using C and interfacing with matlab, or something else. Could someone also provide some details about how the code will be on the system? Thanks
1
11,226,371
06/27/2012 12:36:29
1,114,409
12/24/2011 08:45:23
43
0
php error handling using session and redirecting
I have a php file which checks for login and password from users database, it works fine. But I am unable to validate the exact error to display if the user does not exist or password incorrect to the user and go back to previous page after error, help me how to display these errors. <?php // access.php include_once 'common.php'; include_once 'db.php'; session_start(); $uid = isset($_POST['uid']) ? $_POST['uid'] : $_SESSION['uid']; $pwd = isset($_POST['pwd']) ? $_POST['pwd'] : $_SESSION['pwd']; if(!isset($uid)) { ?> <!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Login</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <head> <style type="text/css"> <!-- .style1 { font-size: 16px; font-family: Verdana, Arial, Helvetica, sans-serif; } .style3 { font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; } --> </style> </head> <body> <h1 class="style1"> <br><br> Login Required </h1> <span class="style3"><br> You <strong>must login to access this area </strong>of the site. <br> <br> If you are not a registered user, please contact your Admin to sign up for instant access!</span> <p><form method="post" action="<?=$_SERVER['PHP_SELF']?>"> <span class="style3">User ID:&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="uid" size="12" /> <br> <br /> Password:</span> <input type="password" name="pwd" SIZE="12" /> <br> <br /> <input type="submit" value="Login" /> </form></p> </body> </html> <?php exit; } $_SESSION['uid'] = $uid; $_SESSION['pwd'] = $pwd; dbConnect("svga"); $sql = "SELECT * FROM user WHERE userid = '$uid' AND password = '$pwd'"; $result = mysql_query($sql); if (!$result) { error('A database error occurred while checking your '. 'login details.\\nIf this error persists, please '. 'contact [email protected].'); } if (mysql_num_rows($result) == 0) { unset($_SESSION['uid']); unset($_SESSION['pwd']); ?> <!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> Access Denied </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- .style1 { font-size: 16px; font-family: Verdana, Arial, Helvetica, sans-serif; } .style3 { font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; } --> </style> </head> <body> <br/> <br/> <h1 class="style1"> Access Denied </h1> <p class="style3">Your user ID or password is incorrect, or you are not a registered user on this site. To try logging in again, click <a href="<?=$_SERVER['PHP_SELF']?>">here</a>. To access, please contact our Admin !</a>.</p> </body> </html> <?php exit; } $username = mysql_result($result,0,'fullname'); $_SESSION['user'] = mysql_result($result,0,'userid'); ?>
php
mysql
redirect
login
null
null
open
php error handling using session and redirecting === I have a php file which checks for login and password from users database, it works fine. But I am unable to validate the exact error to display if the user does not exist or password incorrect to the user and go back to previous page after error, help me how to display these errors. <?php // access.php include_once 'common.php'; include_once 'db.php'; session_start(); $uid = isset($_POST['uid']) ? $_POST['uid'] : $_SESSION['uid']; $pwd = isset($_POST['pwd']) ? $_POST['pwd'] : $_SESSION['pwd']; if(!isset($uid)) { ?> <!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Login</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <head> <style type="text/css"> <!-- .style1 { font-size: 16px; font-family: Verdana, Arial, Helvetica, sans-serif; } .style3 { font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; } --> </style> </head> <body> <h1 class="style1"> <br><br> Login Required </h1> <span class="style3"><br> You <strong>must login to access this area </strong>of the site. <br> <br> If you are not a registered user, please contact your Admin to sign up for instant access!</span> <p><form method="post" action="<?=$_SERVER['PHP_SELF']?>"> <span class="style3">User ID:&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="uid" size="12" /> <br> <br /> Password:</span> <input type="password" name="pwd" SIZE="12" /> <br> <br /> <input type="submit" value="Login" /> </form></p> </body> </html> <?php exit; } $_SESSION['uid'] = $uid; $_SESSION['pwd'] = $pwd; dbConnect("svga"); $sql = "SELECT * FROM user WHERE userid = '$uid' AND password = '$pwd'"; $result = mysql_query($sql); if (!$result) { error('A database error occurred while checking your '. 'login details.\\nIf this error persists, please '. 'contact [email protected].'); } if (mysql_num_rows($result) == 0) { unset($_SESSION['uid']); unset($_SESSION['pwd']); ?> <!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> Access Denied </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- .style1 { font-size: 16px; font-family: Verdana, Arial, Helvetica, sans-serif; } .style3 { font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; } --> </style> </head> <body> <br/> <br/> <h1 class="style1"> Access Denied </h1> <p class="style3">Your user ID or password is incorrect, or you are not a registered user on this site. To try logging in again, click <a href="<?=$_SERVER['PHP_SELF']?>">here</a>. To access, please contact our Admin !</a>.</p> </body> </html> <?php exit; } $username = mysql_result($result,0,'fullname'); $_SESSION['user'] = mysql_result($result,0,'userid'); ?>
0
11,226,372
06/27/2012 12:36:37
1,127,443
01/03/2012 08:30:44
79
9
Logical difference in 2 xmls
I have 2 xmls, one ~5000 odd line & other ~26000lines. How can I find detailed differences between the two (like missing elements/attributes; changes; new elements/attributes; etc) so that i can get a logical overview of everything AND WITHOUT DOING IT MANUALLY. I tried StylusStudio, but it failed to give a desirable result. Anyone?
xml
difference
null
null
null
null
open
Logical difference in 2 xmls === I have 2 xmls, one ~5000 odd line & other ~26000lines. How can I find detailed differences between the two (like missing elements/attributes; changes; new elements/attributes; etc) so that i can get a logical overview of everything AND WITHOUT DOING IT MANUALLY. I tried StylusStudio, but it failed to give a desirable result. Anyone?
0
11,226,379
06/27/2012 12:36:52
1,185,296
02/02/2012 13:53:08
1
0
Php rewriting the query using .htcaccess
i want php to php redirection. http://www.website.com/abc.php/p=1 to http://www.website.com/the_value_of_1.php provided both the pages are existing! Please help ASAP!
php
php5
null
null
null
06/27/2012 12:44:33
not a real question
Php rewriting the query using .htcaccess === i want php to php redirection. http://www.website.com/abc.php/p=1 to http://www.website.com/the_value_of_1.php provided both the pages are existing! Please help ASAP!
1
11,226,383
06/27/2012 12:36:58
60,711
01/30/2009 17:07:35
32,087
921
equivalent of @inlineCallbacks in Tornado?
I have lot of code in my Tornado app which looks like this: @tornado.web.asynchronous def get(self): ... some_async_call(..., callback=self._step1) def _step1(self, response): ... some_async_call(..., callback=self._step2) def _step2(self, response): ... some_async_call(..., callback=self._finish_request) def _finish_request(self, response): ... self.write(something) self.finish() Obviously inline callbacks would simplify that code a lot, it would look something like: @inlineCallbacks @tornado.web.asynchronous def get(self): ... yield some_async_call(...) ... yield some_async_call(...) ... yield some_async_call(...) ... self.write(something) self.finish() Is there a way of having inline callbacks or otherwise simplifying the code in Tornado?
python
callback
twisted
tornado
null
null
open
equivalent of @inlineCallbacks in Tornado? === I have lot of code in my Tornado app which looks like this: @tornado.web.asynchronous def get(self): ... some_async_call(..., callback=self._step1) def _step1(self, response): ... some_async_call(..., callback=self._step2) def _step2(self, response): ... some_async_call(..., callback=self._finish_request) def _finish_request(self, response): ... self.write(something) self.finish() Obviously inline callbacks would simplify that code a lot, it would look something like: @inlineCallbacks @tornado.web.asynchronous def get(self): ... yield some_async_call(...) ... yield some_async_call(...) ... yield some_async_call(...) ... self.write(something) self.finish() Is there a way of having inline callbacks or otherwise simplifying the code in Tornado?
0
11,226,386
06/27/2012 12:37:00
1,371,886
05/03/2012 08:00:47
21
0
Sending 100's of page request at the same time
I want to test the performance of my website. I have hosted it on godaddy and I want to see how it performance when 100s of users are trying to access it. Is their a way to do the above? Is their a script that can be developed to send multiple page request? Thanks
performance
request
page
multiple
null
null
open
Sending 100's of page request at the same time === I want to test the performance of my website. I have hosted it on godaddy and I want to see how it performance when 100s of users are trying to access it. Is their a way to do the above? Is their a script that can be developed to send multiple page request? Thanks
0
11,226,388
06/27/2012 12:37:02
953,078
09/19/2011 16:18:10
11
1
Alternating reads and writes to an SQLite database from within a single process
I'm using an SQLite database as a substitute for a very large in-memory data structure, so I have a simple single-threaded process repeatedly reading from and writing to the database through a single database connection. (I'm using the SQLite C API directly from within a C++ application.) If I perform a write operation, can I later read that data back in without first performing a COMMIT operation? That is, would it work to execute "BEGIN TRANSACTION" when I open the file, do all of my data processing (interleaving reads and writes), then execute "COMMIT" just before closing the file? I was hoping that OS-level file buffers would allow for this sort of behaviour (e.g., see ["Are Unix reads and writes to a single file atomically serialized?"][1]), or perhaps some sort of internal SQLite buffering would come into play, but couldn't find this addressed specifically anywhere. [1]: http://stackoverflow.com/questions/5200923/are-unix-reads-and-writes-to-a-single-file-atomically-serialized [2]: http://www.sqlite.org/sharedcache.html
c++
c
sqlite
null
null
null
open
Alternating reads and writes to an SQLite database from within a single process === I'm using an SQLite database as a substitute for a very large in-memory data structure, so I have a simple single-threaded process repeatedly reading from and writing to the database through a single database connection. (I'm using the SQLite C API directly from within a C++ application.) If I perform a write operation, can I later read that data back in without first performing a COMMIT operation? That is, would it work to execute "BEGIN TRANSACTION" when I open the file, do all of my data processing (interleaving reads and writes), then execute "COMMIT" just before closing the file? I was hoping that OS-level file buffers would allow for this sort of behaviour (e.g., see ["Are Unix reads and writes to a single file atomically serialized?"][1]), or perhaps some sort of internal SQLite buffering would come into play, but couldn't find this addressed specifically anywhere. [1]: http://stackoverflow.com/questions/5200923/are-unix-reads-and-writes-to-a-single-file-atomically-serialized [2]: http://www.sqlite.org/sharedcache.html
0
11,226,389
06/27/2012 12:37:02
1,485,387
06/27/2012 10:55:40
1
0
Function with weak atributte can not be overwritten
I would like to overwrite function (interupt handlers) with the weak attribute, but linker does not link my definition. Codes are shorted for better reading. vectors.c void NMI_Handler (void) __attribute__((weak)); void HardFault_Handler (void) __attribute__((weak)); __attribute__ ((section(".vectors"), used)) void (* const gVectors[])(void) = { NMI_Handler, HardFault_Handler }; void NMI_Handler (void) { while(1); } void HardFault_Handler (void) { while(1); } I redefine default definition in the file cpuexcept.cpp extern "C" __attribute__((naked)) void NMI_Handler() { EXCEPT_ENTRY(CPUExcept); } extern "C" __attribute__((naked)) void HardFault_Handler() { EXCEPT_ENTRY(CPUExcept); } If I compile and dump it, output (library lib.a) is: cpuexcept.oo: file format elf32-littlearm rw-rw-rw- 0/0 4728 Jun 26 16:20 2012 cpuexcept.oo architecture: arm, flags 0x00000011: HAS_RELOC, HAS_SYMS start address 0x00000000 private flags = 5000000: [Version5 EABI] Sections: Idx Name Size VMA LMA File off Algn Flags 0 .text 0000051c 00000000 00000000 00000034 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE 1 .data 00000000 00000000 00000000 00000550 2**0 CONTENTS, ALLOC, LOAD, DATA 2 .bss 00000000 00000000 00000000 00000550 2**0 ALLOC 3 .rodata 000001dc 00000000 00000000 00000550 2**2 CONTENTS, ALLOC, LOAD, READONLY, DATA 4 .comment 00000012 00000000 00000000 0000072c 2**0 CONTENTS, READONLY 5 .ARM.attributes 00000031 00000000 00000000 0000073e 2**0 CONTENTS, READONLY SYMBOL TABLE: 00000000 l df *ABS* 00000000 cpuexcept.cpp 00000000 l d .text 00000000 .text 00000000 l d .data 00000000 .data 00000000 l d .bss 00000000 .bss 000004e0 g F .text 0000000a NMI_Handler 000004ec g F .text 0000000a HardFault_Handler 000004e0 <NMI_Handler>: 4e0: e92d 0ff0 stmdb sp!, {r4, r5, r6, r7, r8, r9, sl, fp} 4e4: 4668 mov r0, sp 4e6: f7ff fffe bl c0 <CPUExcept> 4e6: R_ARM_THM_CALL CPUExcept 4ea: bf00 nop 000004ec <HardFault_Handler>: 4ec: e92d 0ff0 stmdb sp!, {r4, r5, r6, r7, r8, r9, sl, fp} 4f0: 4668 mov r0, sp 4f2: f7ff fffe bl c0 <CPUExcept> 4f2: R_ARM_THM_CALL CPUExcept 4f6: bf00 nop vectors.o: file format elf32-littlearm rw-rw-rw- 0/0 4464 Jun 27 13:52 2012 vectors.o architecture: arm, flags 0x00000011: HAS_RELOC, HAS_SYMS start address 0x00000000 private flags = 5000000: [Version5 EABI] Sections: Idx Name Size VMA LMA File off Algn Flags 0 .text 00000114 00000000 00000000 00000034 2**2 CONTENTS, ALLOC, LOAD, READONLY, CODE 1 .data 00000000 00000000 00000000 00000148 2**0 CONTENTS, ALLOC, LOAD, DATA 2 .bss 00000000 00000000 00000000 00000148 2**0 ALLOC 3 .vectors 00000130 00000000 00000000 00000148 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA 4 .comment 00000012 00000000 00000000 00000278 2**0 CONTENTS, READONLY 5 .ARM.attributes 00000031 00000000 00000000 0000028a 2**0 CONTENTS, READONLY SYMBOL TABLE: 00000000 l df *ABS* 00000000 vectors.c 00000000 l d .text 00000000 .text 00000000 l d .data 00000000 .data 00000000 l d .bss 00000000 .bss 00000000 l d .vectors 00000000 .vectors 00000000 l d .comment 00000000 .comment 00000000 l d .ARM.attributes 00000000 .ARM.attributes 00000000 w F .text 00000002 NMI_Handler 00000004 w F .text 00000002 HardFault_Handler 00000000 <NMI_Handler>: 0: e7fe b.n 0 <NMI_Handler> 2: bf00 nop 00000004 <HardFault_Handler>: 4: e7fe b.n 4 <HardFault_Handler> 6: bf00 nop Default function with the weak attribute is linked in to target application. My definition is linked correct, if I define function f() in cpuexcept.cpp and I use it in main function or if my definiton of handler is in other .c module. I use arm-none-eabi-gcc 4.6.2 (YAGARTO) compiler in cygwin.
c++
c
gcc
arm
weak-linking
null
open
Function with weak atributte can not be overwritten === I would like to overwrite function (interupt handlers) with the weak attribute, but linker does not link my definition. Codes are shorted for better reading. vectors.c void NMI_Handler (void) __attribute__((weak)); void HardFault_Handler (void) __attribute__((weak)); __attribute__ ((section(".vectors"), used)) void (* const gVectors[])(void) = { NMI_Handler, HardFault_Handler }; void NMI_Handler (void) { while(1); } void HardFault_Handler (void) { while(1); } I redefine default definition in the file cpuexcept.cpp extern "C" __attribute__((naked)) void NMI_Handler() { EXCEPT_ENTRY(CPUExcept); } extern "C" __attribute__((naked)) void HardFault_Handler() { EXCEPT_ENTRY(CPUExcept); } If I compile and dump it, output (library lib.a) is: cpuexcept.oo: file format elf32-littlearm rw-rw-rw- 0/0 4728 Jun 26 16:20 2012 cpuexcept.oo architecture: arm, flags 0x00000011: HAS_RELOC, HAS_SYMS start address 0x00000000 private flags = 5000000: [Version5 EABI] Sections: Idx Name Size VMA LMA File off Algn Flags 0 .text 0000051c 00000000 00000000 00000034 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE 1 .data 00000000 00000000 00000000 00000550 2**0 CONTENTS, ALLOC, LOAD, DATA 2 .bss 00000000 00000000 00000000 00000550 2**0 ALLOC 3 .rodata 000001dc 00000000 00000000 00000550 2**2 CONTENTS, ALLOC, LOAD, READONLY, DATA 4 .comment 00000012 00000000 00000000 0000072c 2**0 CONTENTS, READONLY 5 .ARM.attributes 00000031 00000000 00000000 0000073e 2**0 CONTENTS, READONLY SYMBOL TABLE: 00000000 l df *ABS* 00000000 cpuexcept.cpp 00000000 l d .text 00000000 .text 00000000 l d .data 00000000 .data 00000000 l d .bss 00000000 .bss 000004e0 g F .text 0000000a NMI_Handler 000004ec g F .text 0000000a HardFault_Handler 000004e0 <NMI_Handler>: 4e0: e92d 0ff0 stmdb sp!, {r4, r5, r6, r7, r8, r9, sl, fp} 4e4: 4668 mov r0, sp 4e6: f7ff fffe bl c0 <CPUExcept> 4e6: R_ARM_THM_CALL CPUExcept 4ea: bf00 nop 000004ec <HardFault_Handler>: 4ec: e92d 0ff0 stmdb sp!, {r4, r5, r6, r7, r8, r9, sl, fp} 4f0: 4668 mov r0, sp 4f2: f7ff fffe bl c0 <CPUExcept> 4f2: R_ARM_THM_CALL CPUExcept 4f6: bf00 nop vectors.o: file format elf32-littlearm rw-rw-rw- 0/0 4464 Jun 27 13:52 2012 vectors.o architecture: arm, flags 0x00000011: HAS_RELOC, HAS_SYMS start address 0x00000000 private flags = 5000000: [Version5 EABI] Sections: Idx Name Size VMA LMA File off Algn Flags 0 .text 00000114 00000000 00000000 00000034 2**2 CONTENTS, ALLOC, LOAD, READONLY, CODE 1 .data 00000000 00000000 00000000 00000148 2**0 CONTENTS, ALLOC, LOAD, DATA 2 .bss 00000000 00000000 00000000 00000148 2**0 ALLOC 3 .vectors 00000130 00000000 00000000 00000148 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA 4 .comment 00000012 00000000 00000000 00000278 2**0 CONTENTS, READONLY 5 .ARM.attributes 00000031 00000000 00000000 0000028a 2**0 CONTENTS, READONLY SYMBOL TABLE: 00000000 l df *ABS* 00000000 vectors.c 00000000 l d .text 00000000 .text 00000000 l d .data 00000000 .data 00000000 l d .bss 00000000 .bss 00000000 l d .vectors 00000000 .vectors 00000000 l d .comment 00000000 .comment 00000000 l d .ARM.attributes 00000000 .ARM.attributes 00000000 w F .text 00000002 NMI_Handler 00000004 w F .text 00000002 HardFault_Handler 00000000 <NMI_Handler>: 0: e7fe b.n 0 <NMI_Handler> 2: bf00 nop 00000004 <HardFault_Handler>: 4: e7fe b.n 4 <HardFault_Handler> 6: bf00 nop Default function with the weak attribute is linked in to target application. My definition is linked correct, if I define function f() in cpuexcept.cpp and I use it in main function or if my definiton of handler is in other .c module. I use arm-none-eabi-gcc 4.6.2 (YAGARTO) compiler in cygwin.
0
11,215,280
06/26/2012 20:16:07
280,354
02/24/2010 13:25:59
624
17
Inserting text with new lines into a textarea
I am trying to insert data from a database into a textarea. I can't figure out how to make new lines though. I am using jquery's val() function to set the textarea content. I put \n but it just shows up in the textarea instead of making a newline. I have also tried \r\n with the same result.
jquery
html
null
null
null
null
open
Inserting text with new lines into a textarea === I am trying to insert data from a database into a textarea. I can't figure out how to make new lines though. I am using jquery's val() function to set the textarea content. I put \n but it just shows up in the textarea instead of making a newline. I have also tried \r\n with the same result.
0
11,215,283
06/26/2012 20:16:21
1,483,862
06/26/2012 20:10:31
1
0
Alias 403 Forbidden with Apache
I'm trying to create a folder named week7 and an html page named hello.html in that folder I created a folder named week7 out of the Document Root. I chose this location for it: /usr/local/www/week7 while my document root is: /usr/local/www/apache22/data in httpd.conf and under <ifModule Alias_module> tag, I wrote: Alias /week7 /usr/local/www/week7 <Directory /usr/local/www/week7> Require all granted </Directory> After rebooting the server, I got the following message: Forbidden 403 message. I tried changing permissions for the hello.html file, the week7 folder and even the www folder and nothing changed. Any ideas?
apache
alias
directive
mod-alias
null
null
open
Alias 403 Forbidden with Apache === I'm trying to create a folder named week7 and an html page named hello.html in that folder I created a folder named week7 out of the Document Root. I chose this location for it: /usr/local/www/week7 while my document root is: /usr/local/www/apache22/data in httpd.conf and under <ifModule Alias_module> tag, I wrote: Alias /week7 /usr/local/www/week7 <Directory /usr/local/www/week7> Require all granted </Directory> After rebooting the server, I got the following message: Forbidden 403 message. I tried changing permissions for the hello.html file, the week7 folder and even the www folder and nothing changed. Any ideas?
0
11,567,528
07/19/2012 18:59:31
1,387,518
05/10/2012 15:22:25
1
1
Ordering a table by time and based on the first appearance of an ID
I'm looking to order a log table so that it is grouped by id based on the first appearance of the id. In my example below, I have a table 'test' and I want to group the table by id so that all the ids are together, i.e. list all '623' entries then all '444' entries. I want the '623' entries to come first because the first '623' record came before the first '444' entries. Input: ╔══════════╦═════╗ ║ time ║ id ║ ╠══════════╬═════╣ ║ 01:45:10 ║ 623 ║ ║ 02:45:20 ║ 444 ║ ║ 03:45:30 ║ 444 ║ ║ 04:45:40 ║ 623 ║ ║ 05:45:50 ║ 623 ║ ║ 06:45:00 ║ 444 ║ ╚══════════╩═════╝ Output: +----------+-----+ | time | id | +----------+-----+ | 01:45:10 | 623 | | 04:45:40 | 623 | | 05:45:50 | 623 | | 02:45:20 | 444 | | 03:45:30 | 444 | | 06:45:00 | 444 | +----------+-----+ The closest I've come is this: select time, id from test group by id, time +----------+-----+ | time | id | +----------+-----+ | 02:45:20 | 444 | | 03:45:30 | 444 | | 06:45:00 | 444 | | 01:45:10 | 623 | | 04:45:40 | 623 | | 05:45:50 | 623 | +----------+-----+ But this isn't exactly it because it's ordering by the id. I'm not sure what the proper syntax is to have all the '623' entries get listed first because the first '623' record came before the first '444' entry. Thanks in advance for any help.
mysql
group-by
order-by
null
null
null
open
Ordering a table by time and based on the first appearance of an ID === I'm looking to order a log table so that it is grouped by id based on the first appearance of the id. In my example below, I have a table 'test' and I want to group the table by id so that all the ids are together, i.e. list all '623' entries then all '444' entries. I want the '623' entries to come first because the first '623' record came before the first '444' entries. Input: ╔══════════╦═════╗ ║ time ║ id ║ ╠══════════╬═════╣ ║ 01:45:10 ║ 623 ║ ║ 02:45:20 ║ 444 ║ ║ 03:45:30 ║ 444 ║ ║ 04:45:40 ║ 623 ║ ║ 05:45:50 ║ 623 ║ ║ 06:45:00 ║ 444 ║ ╚══════════╩═════╝ Output: +----------+-----+ | time | id | +----------+-----+ | 01:45:10 | 623 | | 04:45:40 | 623 | | 05:45:50 | 623 | | 02:45:20 | 444 | | 03:45:30 | 444 | | 06:45:00 | 444 | +----------+-----+ The closest I've come is this: select time, id from test group by id, time +----------+-----+ | time | id | +----------+-----+ | 02:45:20 | 444 | | 03:45:30 | 444 | | 06:45:00 | 444 | | 01:45:10 | 623 | | 04:45:40 | 623 | | 05:45:50 | 623 | +----------+-----+ But this isn't exactly it because it's ordering by the id. I'm not sure what the proper syntax is to have all the '623' entries get listed first because the first '623' record came before the first '444' entry. Thanks in advance for any help.
0
11,567,534
07/19/2012 18:59:46
1,529,799
07/16/2012 18:53:36
26
0
Filtering integers out of python command line arguments
so I wrote a program and I want to pass it either a filename and an integer or just an integer. Whats the best way to determine which argument is the integer? This is what I have: import sys if len(sys.argv) > 1): for e in sys.argv: try: bio = map(e, int) except: pass thanks in advance
python
null
null
null
null
null
open
Filtering integers out of python command line arguments === so I wrote a program and I want to pass it either a filename and an integer or just an integer. Whats the best way to determine which argument is the integer? This is what I have: import sys if len(sys.argv) > 1): for e in sys.argv: try: bio = map(e, int) except: pass thanks in advance
0
11,567,535
07/19/2012 18:59:49
717,216
04/20/2011 13:23:08
35
0
How to write a Gemspec, when the gem's main class name is different?
I have a Gemfile as part of rails app, which I am converting to a gem. gem "jruby-openssl", "0.7.4" gem "nokogiri" gem 'xml-simple', :require => 'xmlsimple' gem "httpclient" How do I write, the .gemspec file, for the gem I create from this? The gemspec I wrote looks like this. Gem::Specification.new do |s| s.name = "my_gem" s.platform = Gem::Platform::RUBY s.authors = [""] s.email = [""] s.homepage = "" s.summary = %q{MyGem} s.description = %q{MyGem} s.files = Dir["{app,lib,config,public,db}/**/*"] + ["Rakefile", "Gemfile"] s.require_paths = ["lib"] s.add_dependency 'nokogiri', '>= 1.5.0' s.add_dependency('xml-simple') s.add_dependency 'httpclient' end However, the xmlsimple object is not called, because, the add dependency cannot take the same parameters as a regular gem call. How do I write the gemspec to call xmlsimple like its done in the Gemfile ?
ruby-on-rails
rubygems
gem
bundler
jrubyonrails
null
open
How to write a Gemspec, when the gem's main class name is different? === I have a Gemfile as part of rails app, which I am converting to a gem. gem "jruby-openssl", "0.7.4" gem "nokogiri" gem 'xml-simple', :require => 'xmlsimple' gem "httpclient" How do I write, the .gemspec file, for the gem I create from this? The gemspec I wrote looks like this. Gem::Specification.new do |s| s.name = "my_gem" s.platform = Gem::Platform::RUBY s.authors = [""] s.email = [""] s.homepage = "" s.summary = %q{MyGem} s.description = %q{MyGem} s.files = Dir["{app,lib,config,public,db}/**/*"] + ["Rakefile", "Gemfile"] s.require_paths = ["lib"] s.add_dependency 'nokogiri', '>= 1.5.0' s.add_dependency('xml-simple') s.add_dependency 'httpclient' end However, the xmlsimple object is not called, because, the add dependency cannot take the same parameters as a regular gem call. How do I write the gemspec to call xmlsimple like its done in the Gemfile ?
0
11,567,536
07/19/2012 18:59:55
321,894
04/21/2010 03:20:41
606
11
wait until command is finished batch
In my batch script I have the following: for /F "USEBACKQ tokens=4,6,8" %%a in (`systeminfo ^| qgrep -e "System Up Time:"`) do set days=%%a&set hours=%%b&set minutes=%%c set /A timepassed=%days%*24*60+%hours%*60+%minutes% is there any way to make sure that the first line runs before the second line is evaluated? At times, if this portion of code is run, timepassed seems to be evaluated at to be "" instead of what it is supposed to be. Thanks for the time
batch
null
null
null
null
null
open
wait until command is finished batch === In my batch script I have the following: for /F "USEBACKQ tokens=4,6,8" %%a in (`systeminfo ^| qgrep -e "System Up Time:"`) do set days=%%a&set hours=%%b&set minutes=%%c set /A timepassed=%days%*24*60+%hours%*60+%minutes% is there any way to make sure that the first line runs before the second line is evaluated? At times, if this portion of code is run, timepassed seems to be evaluated at to be "" instead of what it is supposed to be. Thanks for the time
0
11,567,446
07/19/2012 18:54:00
289,572
03/09/2010 10:59:02
1,771
44
car::Anova Way to have a covariate that does not interact with the within-subject factors
I would like to run an ANCOVA using `car::Anova` but cannot find out if there is a way to add the covariate only as a main effect (i.e., should not interact with anything). As far as I understand ANCOVA, covariates are just another main effect added to the model (i.e., one more effect) that do not interact with the variables. However, I cannot add a variable to `Anova` that does not interact with the within-subject factors. Let me illustrate my problem with an example from `?Anova`. The `OBrienKaiser` data set has 2 between (`treatment` and `gender`) and 2 within (`phase` and `hour`) factors. Now lets assume we also recorded the `age` of the participants and would like to add it as a covariate to the any analysis. require(car) set.seed(1) n.OBrienKaiser <- within(OBrienKaiser, age <- sample(18:35, size = 16, replace = TRUE)) # the next part is taken from ?Anova # I only modified the mod.ok <- ... call by adding + age phase <- factor(rep(c("pretest", "posttest", "followup"), c(5, 5, 5)), levels=c("pretest", "posttest", "followup")) hour <- ordered(rep(1:5, 3)) idata <- data.frame(phase, hour) mod.ok <- lm(cbind(pre.1, pre.2, pre.3, pre.4, pre.5, post.1, post.2, post.3, post.4, post.5, fup.1, fup.2, fup.3, fup.4, fup.5) ~ treatment + age, data=n.OBrienKaiser) (av.ok <- Anova(mod.ok, idata=idata, idesign=~phase*hour, type = 3)) As the results show, the results contain interaction with the covariate `age`, namely of the within-subject (or repeated-measures) factors `phase`, `hour` and their interaction `phase:hour`: Type III Repeated Measures MANOVA Tests: Pillai test statistic Df test stat approx F num Df den Df Pr(>F) (Intercept) 1 0.106 1.419 1 12 0.257 treatment 2 0.305 2.633 2 12 0.113 age 1 0.088 1.152 1 12 0.304 phase 1 0.241 1.742 2 11 0.220 treatment:phase 2 0.680 3.090 4 24 0.035 * age:phase 1 0.169 1.118 2 11 0.361 hour 1 0.500 2.249 4 9 0.144 treatment:hour 2 0.338 0.509 8 20 0.835 age:hour 1 0.364 1.286 4 9 0.345 phase:hour 1 0.569 0.824 8 5 0.616 treatment:phase:hour 2 0.590 0.314 16 12 0.984 age:phase:hour 1 0.550 0.763 8 5 0.651 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 My question is: Is there a way to specify this ANCOVA without any interaction of `age`?
r
anova
null
null
null
null
open
car::Anova Way to have a covariate that does not interact with the within-subject factors === I would like to run an ANCOVA using `car::Anova` but cannot find out if there is a way to add the covariate only as a main effect (i.e., should not interact with anything). As far as I understand ANCOVA, covariates are just another main effect added to the model (i.e., one more effect) that do not interact with the variables. However, I cannot add a variable to `Anova` that does not interact with the within-subject factors. Let me illustrate my problem with an example from `?Anova`. The `OBrienKaiser` data set has 2 between (`treatment` and `gender`) and 2 within (`phase` and `hour`) factors. Now lets assume we also recorded the `age` of the participants and would like to add it as a covariate to the any analysis. require(car) set.seed(1) n.OBrienKaiser <- within(OBrienKaiser, age <- sample(18:35, size = 16, replace = TRUE)) # the next part is taken from ?Anova # I only modified the mod.ok <- ... call by adding + age phase <- factor(rep(c("pretest", "posttest", "followup"), c(5, 5, 5)), levels=c("pretest", "posttest", "followup")) hour <- ordered(rep(1:5, 3)) idata <- data.frame(phase, hour) mod.ok <- lm(cbind(pre.1, pre.2, pre.3, pre.4, pre.5, post.1, post.2, post.3, post.4, post.5, fup.1, fup.2, fup.3, fup.4, fup.5) ~ treatment + age, data=n.OBrienKaiser) (av.ok <- Anova(mod.ok, idata=idata, idesign=~phase*hour, type = 3)) As the results show, the results contain interaction with the covariate `age`, namely of the within-subject (or repeated-measures) factors `phase`, `hour` and their interaction `phase:hour`: Type III Repeated Measures MANOVA Tests: Pillai test statistic Df test stat approx F num Df den Df Pr(>F) (Intercept) 1 0.106 1.419 1 12 0.257 treatment 2 0.305 2.633 2 12 0.113 age 1 0.088 1.152 1 12 0.304 phase 1 0.241 1.742 2 11 0.220 treatment:phase 2 0.680 3.090 4 24 0.035 * age:phase 1 0.169 1.118 2 11 0.361 hour 1 0.500 2.249 4 9 0.144 treatment:hour 2 0.338 0.509 8 20 0.835 age:hour 1 0.364 1.286 4 9 0.345 phase:hour 1 0.569 0.824 8 5 0.616 treatment:phase:hour 2 0.590 0.314 16 12 0.984 age:phase:hour 1 0.550 0.763 8 5 0.651 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 My question is: Is there a way to specify this ANCOVA without any interaction of `age`?
0
11,567,538
07/19/2012 18:59:57
702,948
04/11/2011 20:59:45
1,059
42
interrupt all threads in Java in shutdown hook
I have a simple java program that creates a series of temporary files stored in a local tmp directory. I have added a simple shutdown hook that walks through all files and deletes them, then deletes the tmp directory, before exiting the program. here is the code: Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { File tmpDir = new File("tmp/"); for (File f : tmpDir.listFiles()) { f.delete(); } tmpDir.delete(); } })); My problem is that the thread that creates these files may not have terminated upon launch of the shutdown hook, and therefore, there may be a file created after `listFiles()` is called. this causes the tmp dir not to get deleted. I have come up with 2 hacks around this: Hack # 1: Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { File tmpDir = new File("tmp/"); while (!tmp.delete()){ for (File f : tmpDir.listFiles()) { f.delete(); } } } })); Hack # 2: Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { try{ Thread.sleep(1000); } catch(InterruptedException e){ e.printStackTrace(); } File tmpDir = new File("tmp/"); for (File f : tmpDir.listFiles()) { f.delete(); } tmpDir.delete(); } })); Neither is a particularly good solution. What would be ideal is to have the shutdown hook wait until all threads have terminated before continuing. Does anyone know if this can be done?
java
multithreading
shutdown-hook
null
null
null
open
interrupt all threads in Java in shutdown hook === I have a simple java program that creates a series of temporary files stored in a local tmp directory. I have added a simple shutdown hook that walks through all files and deletes them, then deletes the tmp directory, before exiting the program. here is the code: Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { File tmpDir = new File("tmp/"); for (File f : tmpDir.listFiles()) { f.delete(); } tmpDir.delete(); } })); My problem is that the thread that creates these files may not have terminated upon launch of the shutdown hook, and therefore, there may be a file created after `listFiles()` is called. this causes the tmp dir not to get deleted. I have come up with 2 hacks around this: Hack # 1: Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { File tmpDir = new File("tmp/"); while (!tmp.delete()){ for (File f : tmpDir.listFiles()) { f.delete(); } } } })); Hack # 2: Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { try{ Thread.sleep(1000); } catch(InterruptedException e){ e.printStackTrace(); } File tmpDir = new File("tmp/"); for (File f : tmpDir.listFiles()) { f.delete(); } tmpDir.delete(); } })); Neither is a particularly good solution. What would be ideal is to have the shutdown hook wait until all threads have terminated before continuing. Does anyone know if this can be done?
0
11,567,540
07/19/2012 19:00:05
1,417,244
05/25/2012 11:15:03
360
3
How to create Sub Type Class of Type Class in haskell?
Can we create Sub Type of Type Class in haskell? Up to how many level sub-typing of Type Class can go?
haskell
types
typeclass
null
null
null
open
How to create Sub Type Class of Type Class in haskell? === Can we create Sub Type of Type Class in haskell? Up to how many level sub-typing of Type Class can go?
0
11,567,541
07/19/2012 19:00:09
1,497,428
07/03/2012 00:37:15
6
0
Center TextViews inside dynamically generated TableLayout
I am trying to create the layout below. The Table should be created dynamically and all TextViews should be centered horizontally inside the TableLayout. I know that I have to create layout parameters and apply them to the TextViews but for some reason it doesn't work. The TextViews are always justified to the left site. How can I center the TextViews horizonatlly inside the Table. Thank you. RelativeLayout LinearLayout ----------------------------------------------| | ----------- | ------------------------------| | |Button1| | TableLayout | | ----------- | ------------------------------| | ----------- | TextView | | |Button2| | ------------------------------| | ----------- | TextView | | ----------- | ------------------------------| | |Button3| | TextView | | ----------- | ------------------------------| | ----------- | TableLayout | | |Button4| | ------------------------------| | ----------- | | ----------- | | |Button5| | | ----------- | | ----------- | LinearLayout RelativeLayout Here is the code RelativeLayout mRelativeLayout = (RelativeLayout) findViewById(R.id.RelativeLayout); mLinearLayout1 = (LinearLayout) findViewById(R.id.LinearLayout1); mLinearLayout1.setId(45); TableLayout tableLayout = new TableLayout(TableLayoutActivity.this); TableRow tr1 = new TableRow(TableLayoutActivity.this); TextView tv11 = new TextView(TableLayoutActivity.this); tv11.setText("TEXT1"); tr1.addView(tv11); TextView tv12 = new TextView(TableLayoutActivity.this); tv12.setText("TEXT2"); tr1.addView(tv12); TextView tv13 = new TextView(TableLayoutActivity.this); tv13.setText("TEXT3"); tr1.addView(tv13); tableLayout.addView(tr1); RelativeLayout.LayoutParams relLayParam = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); relLayParam.addRule(RelativeLayout.RIGHT_OF, mLinearLayout1.getId()); mRelativeLayout.addView(tableLayout, relLayParam);
android
relativelayout
tablelayout
dynamically-generated
null
null
open
Center TextViews inside dynamically generated TableLayout === I am trying to create the layout below. The Table should be created dynamically and all TextViews should be centered horizontally inside the TableLayout. I know that I have to create layout parameters and apply them to the TextViews but for some reason it doesn't work. The TextViews are always justified to the left site. How can I center the TextViews horizonatlly inside the Table. Thank you. RelativeLayout LinearLayout ----------------------------------------------| | ----------- | ------------------------------| | |Button1| | TableLayout | | ----------- | ------------------------------| | ----------- | TextView | | |Button2| | ------------------------------| | ----------- | TextView | | ----------- | ------------------------------| | |Button3| | TextView | | ----------- | ------------------------------| | ----------- | TableLayout | | |Button4| | ------------------------------| | ----------- | | ----------- | | |Button5| | | ----------- | | ----------- | LinearLayout RelativeLayout Here is the code RelativeLayout mRelativeLayout = (RelativeLayout) findViewById(R.id.RelativeLayout); mLinearLayout1 = (LinearLayout) findViewById(R.id.LinearLayout1); mLinearLayout1.setId(45); TableLayout tableLayout = new TableLayout(TableLayoutActivity.this); TableRow tr1 = new TableRow(TableLayoutActivity.this); TextView tv11 = new TextView(TableLayoutActivity.this); tv11.setText("TEXT1"); tr1.addView(tv11); TextView tv12 = new TextView(TableLayoutActivity.this); tv12.setText("TEXT2"); tr1.addView(tv12); TextView tv13 = new TextView(TableLayoutActivity.this); tv13.setText("TEXT3"); tr1.addView(tv13); tableLayout.addView(tr1); RelativeLayout.LayoutParams relLayParam = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); relLayParam.addRule(RelativeLayout.RIGHT_OF, mLinearLayout1.getId()); mRelativeLayout.addView(tableLayout, relLayParam);
0
11,567,543
07/19/2012 19:00:28
788,252
06/07/2011 21:07:00
60
0
zend xoauth for Gmail-Imap
I am using the zend framework to fetch Gmail Inbox data using XOauth mechanism but my HTTP request is failing. Is there a way to view the response sent by XOauth in the Zend Framework as currently the function only returns true/false for success/failure. So I am unable to know if my request is failing beause of invalid-signature,invalid token or something else.
zend-framework
oauth
gmail-imap
null
null
null
open
zend xoauth for Gmail-Imap === I am using the zend framework to fetch Gmail Inbox data using XOauth mechanism but my HTTP request is failing. Is there a way to view the response sent by XOauth in the Zend Framework as currently the function only returns true/false for success/failure. So I am unable to know if my request is failing beause of invalid-signature,invalid token or something else.
0
11,567,547
07/19/2012 19:00:45
104,816
05/11/2009 14:12:54
365
29
C++: Any performance penalty for wrapping int in a class?
I have a complex (at least for me it is :) project. It has many vectors, sets and maps. In most cases the key/index is an integer. I am considering creating small classes like: class PhoneRepoIx //index into map {phone_number => pointer} { public: int n; }; class PersonIx //index into map {social_security_number => pointer} { public: int n; }; Would I incur any speed or memory penalty? With memory I am 90% sure that there would be no memory cost per instance, only per class-type. With speed I am not clear. Motivation: With the above approach, the compiler would do some extra type-checking for me. Also, with well chosen explicit type-names, the reader of my code will see more easily what I am doing. As of now I am using int everywhere and I chose the variable names to express what each index is. With the above, my variable names could be shorter.
c++
null
null
null
null
null
open
C++: Any performance penalty for wrapping int in a class? === I have a complex (at least for me it is :) project. It has many vectors, sets and maps. In most cases the key/index is an integer. I am considering creating small classes like: class PhoneRepoIx //index into map {phone_number => pointer} { public: int n; }; class PersonIx //index into map {social_security_number => pointer} { public: int n; }; Would I incur any speed or memory penalty? With memory I am 90% sure that there would be no memory cost per instance, only per class-type. With speed I am not clear. Motivation: With the above approach, the compiler would do some extra type-checking for me. Also, with well chosen explicit type-names, the reader of my code will see more easily what I am doing. As of now I am using int everywhere and I chose the variable names to express what each index is. With the above, my variable names could be shorter.
0
11,567,552
07/19/2012 19:01:05
1,464,098
06/18/2012 15:25:27
3
1
Bizarre jQuery UI behavior with datetimepicker
I am developing an app using the Google Maps API. A form is being updated dynamically within an infowindow using jQuery with a Django backend (see http://stellarchariot.com/blog/2011/02/dynamically-add-form-to-formset-using-javascript-and-django/). After being added, the text fields within the new form are being set to have datetimepickers, an extension of jQuery UI Datepicker (see http://trentrichardson.com/examples/timepicker). After the infowindow loads, event handlers for the links to add and delete a new form. When the link is clicked to add a new form, the text fields within that form have datetimepickers set to them so that the user can pick datetimes easily. However, I can only make this work for either the first form that is created by default, or for all the other ones that are added dynamically. If I set the datetimepicker when the infowindow loads, it will only work for the first form and not for any added forms. If I don't set it when it loads, it will work for dynamically added fields. **infoWindow** (code excecuted when infowindow loads) google.maps.event.addListener(eventFormInfoWindow, 'domready', function() { // DOM is ready // pass lat and lng $('#id_latitude').val(lat); $('#id_longitude').val(lng); $('#id_form_type').val("new_event"); // datetimepicker // IF I TAKE THIS OUT, THE DATETIMEPICKER WILL WORK FOR NEW TEXT FIELDS! $(".sched:first").find(":input").datetimepicker({ minDate: new Date() }); var formMan = new DynamicFormManager(); // Register the click event handlers to manage sched forms $("#add").click(function() { return formMan.addForm(this, "form"); }); $(".delete").click(function() { return formMan.deleteForm(this, "form"); }); // heading and submit button values $('#form_name').html("Create New Event"); $('#submit').val("Create"); }); **addForm()** function addForm(btn, prefix) { var formCount = parseInt($('#id_' + prefix + '-TOTAL_FORMS').val()); // You can only submit a maximum of 10 schedules if (formCount < 10) { // Clone a form (without event handlers) from the first form var row = $(".sched:first").clone(false).get(0); // Insert it after the last form $(row).removeAttr('id').hide().insertAfter(".sched:last").slideDown(300); // Remove the bits we don't want in the new row/form // e.g. error messages $(".errorlist", row).remove(); $(row).children().removeClass("error"); // Relabel or rename all the relevant bits $(row).children().children().each(function() { updateElementIndex(this, prefix, formCount); $(this).val(""); }); // Add an event handler for the delete sched/form link $(row).find(".delete").click(function() { return deleteForm(this, prefix); }); // Update the total form count $("#id_" + prefix + "-TOTAL_FORMS").val(formCount + 1); // add datetimepicker to new form inputs // THIS WILL NOT WORK SINCE PREVIOUSLY SET IN INFOWINDOW EVENT LISTENER CODE! $(row).find(":input").datetimepicker({ minDate: new Date() }); } // End if else { alert("Sorry, you can only enter a maximum of ten start and end date/time pairs."); } return false; } So, for some reason, setting the datepickers initially makes any ones set dynamically not work (and as long as I don't set them initially, the dynamically created ones will work). Can anyone help me figure out why that would be? Thanks very much, Peter
javascript
jquery
datetimepicker
null
null
null
open
Bizarre jQuery UI behavior with datetimepicker === I am developing an app using the Google Maps API. A form is being updated dynamically within an infowindow using jQuery with a Django backend (see http://stellarchariot.com/blog/2011/02/dynamically-add-form-to-formset-using-javascript-and-django/). After being added, the text fields within the new form are being set to have datetimepickers, an extension of jQuery UI Datepicker (see http://trentrichardson.com/examples/timepicker). After the infowindow loads, event handlers for the links to add and delete a new form. When the link is clicked to add a new form, the text fields within that form have datetimepickers set to them so that the user can pick datetimes easily. However, I can only make this work for either the first form that is created by default, or for all the other ones that are added dynamically. If I set the datetimepicker when the infowindow loads, it will only work for the first form and not for any added forms. If I don't set it when it loads, it will work for dynamically added fields. **infoWindow** (code excecuted when infowindow loads) google.maps.event.addListener(eventFormInfoWindow, 'domready', function() { // DOM is ready // pass lat and lng $('#id_latitude').val(lat); $('#id_longitude').val(lng); $('#id_form_type').val("new_event"); // datetimepicker // IF I TAKE THIS OUT, THE DATETIMEPICKER WILL WORK FOR NEW TEXT FIELDS! $(".sched:first").find(":input").datetimepicker({ minDate: new Date() }); var formMan = new DynamicFormManager(); // Register the click event handlers to manage sched forms $("#add").click(function() { return formMan.addForm(this, "form"); }); $(".delete").click(function() { return formMan.deleteForm(this, "form"); }); // heading and submit button values $('#form_name').html("Create New Event"); $('#submit').val("Create"); }); **addForm()** function addForm(btn, prefix) { var formCount = parseInt($('#id_' + prefix + '-TOTAL_FORMS').val()); // You can only submit a maximum of 10 schedules if (formCount < 10) { // Clone a form (without event handlers) from the first form var row = $(".sched:first").clone(false).get(0); // Insert it after the last form $(row).removeAttr('id').hide().insertAfter(".sched:last").slideDown(300); // Remove the bits we don't want in the new row/form // e.g. error messages $(".errorlist", row).remove(); $(row).children().removeClass("error"); // Relabel or rename all the relevant bits $(row).children().children().each(function() { updateElementIndex(this, prefix, formCount); $(this).val(""); }); // Add an event handler for the delete sched/form link $(row).find(".delete").click(function() { return deleteForm(this, prefix); }); // Update the total form count $("#id_" + prefix + "-TOTAL_FORMS").val(formCount + 1); // add datetimepicker to new form inputs // THIS WILL NOT WORK SINCE PREVIOUSLY SET IN INFOWINDOW EVENT LISTENER CODE! $(row).find(":input").datetimepicker({ minDate: new Date() }); } // End if else { alert("Sorry, you can only enter a maximum of ten start and end date/time pairs."); } return false; } So, for some reason, setting the datepickers initially makes any ones set dynamically not work (and as long as I don't set them initially, the dynamically created ones will work). Can anyone help me figure out why that would be? Thanks very much, Peter
0
11,323,685
07/04/2012 06:40:36
512,366
11/18/2010 16:02:12
451
33
MVC 2 - Binding of Control parameter returns NULL while using HTTP POST
I have a controller with a method that returns some response based on the value of a parameter. I am trying to POST Json data to this controller but somehow the binding is not working. I am using Fiddler to test my controller method: [AcceptVerbs(HttpVerbs.Post) ] public string Authenticate(string username) { //some logic return "value"; } now userName always returns null when I debug the application. To test this method I am using Fiddler. Raw data of the request is : POST http://localsite/Home/authenticate HTTP/1.1 User-Agent: Fiddler Host: localhost:52774 x-requested-with: XMLHttpRequest Content-Length: 20 Content-Type: application/json; charset=utf-8 Accept: application/json {"username":"kunal"} Any guesses where I am going wrong in this.
asp.net
.net
mvc
asp.net-mvc-2
null
null
open
MVC 2 - Binding of Control parameter returns NULL while using HTTP POST === I have a controller with a method that returns some response based on the value of a parameter. I am trying to POST Json data to this controller but somehow the binding is not working. I am using Fiddler to test my controller method: [AcceptVerbs(HttpVerbs.Post) ] public string Authenticate(string username) { //some logic return "value"; } now userName always returns null when I debug the application. To test this method I am using Fiddler. Raw data of the request is : POST http://localsite/Home/authenticate HTTP/1.1 User-Agent: Fiddler Host: localhost:52774 x-requested-with: XMLHttpRequest Content-Length: 20 Content-Type: application/json; charset=utf-8 Accept: application/json {"username":"kunal"} Any guesses where I am going wrong in this.
0
11,327,249
07/04/2012 10:27:31
1,428,622
05/31/2012 14:16:16
33
5
CGPoint to NSValue and reverse
I have code: NSMutableArray *vertices = [[NSMutableArray alloc] init]; //Getting mouse coordinates loc = [self convertPoint: [event locationInWindow] fromView:self]; [vertices addObject:loc]; // Adding coordinates to NSMutableArray //Converting from NSMutableArray to GLfloat to work with OpenGL int count = [vertices count] * 2; // * 2 for the two coordinates of a loc object GLFloat []glVertices = (GLFloat *)malloc(count * sizeof(GLFloat)); int currIndex = 0; for (YourLocObject *loc in vertices) { glVertices[currIndex++] = loc.x; glVertices[currIndex++] = loc.y; } `loc` is CGPoint, so i need somehow to change from CGPoint to NSValue to add it to NSMutableArray and after that convert it back to CGPoint. How could it be done?
objective-c
xcode
osx
cocoa
null
null
open
CGPoint to NSValue and reverse === I have code: NSMutableArray *vertices = [[NSMutableArray alloc] init]; //Getting mouse coordinates loc = [self convertPoint: [event locationInWindow] fromView:self]; [vertices addObject:loc]; // Adding coordinates to NSMutableArray //Converting from NSMutableArray to GLfloat to work with OpenGL int count = [vertices count] * 2; // * 2 for the two coordinates of a loc object GLFloat []glVertices = (GLFloat *)malloc(count * sizeof(GLFloat)); int currIndex = 0; for (YourLocObject *loc in vertices) { glVertices[currIndex++] = loc.x; glVertices[currIndex++] = loc.y; } `loc` is CGPoint, so i need somehow to change from CGPoint to NSValue to add it to NSMutableArray and after that convert it back to CGPoint. How could it be done?
0
11,327,250
07/04/2012 10:27:34
1,005,346
10/20/2011 13:55:53
534
9
Parse nsstring json valuses in iphone?
I have JSon Values in NSString. I am trying to parse the values from the NSString JSonValue. NSString Values like: result = [{"no":"01","send":"2010-05-03 01:26:48","from":"0000000000","to":"1111111111","text":"abcd"}] I have tried the below code to parse the values no, send, from, to, text. NSString *jsonString = result; NSDictionary *jsonArray = [jsonString jsonValue]; //Am trying to save the values from NSString to NSDictionary the app getting crash here. NSLog(@"JsonDic : %@", jsonArray); Can anyone please help to parse the JSon values from NSString? Thanks in advance.
iphone
ios
json
parsing
nsstring
null
open
Parse nsstring json valuses in iphone? === I have JSon Values in NSString. I am trying to parse the values from the NSString JSonValue. NSString Values like: result = [{"no":"01","send":"2010-05-03 01:26:48","from":"0000000000","to":"1111111111","text":"abcd"}] I have tried the below code to parse the values no, send, from, to, text. NSString *jsonString = result; NSDictionary *jsonArray = [jsonString jsonValue]; //Am trying to save the values from NSString to NSDictionary the app getting crash here. NSLog(@"JsonDic : %@", jsonArray); Can anyone please help to parse the JSon values from NSString? Thanks in advance.
0
11,327,252
07/04/2012 10:27:46
1,092,153
12/11/2011 11:27:57
8
0
Getting Initializing inflate state in log cat
it is a android widget and i am trying to add custom fonts to it This is my code public void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) { String currentTime = (String) df.format(new Date()); RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.widget1); updateViews.setImageViewBitmap(R.id.widget1label, buildUpdate(currentTime, context)); appWidgetManager.updateAppWidget(appWidgetId, updateViews); } public Bitmap buildUpdate(String time, Context context) { Bitmap myBitmap = Bitmap.createBitmap(160, 84, Bitmap.Config.ARGB_4444); Canvas myCanvas = new Canvas(myBitmap); Paint paint = new Paint(); Typeface clock = Typeface.createFromAsset(context.getAssets(),"batmfo.ttf"); paint.setAntiAlias(true); paint.setSubpixelText(true); paint.setTypeface(clock); paint.setStyle(Paint.Style.FILL); paint.setColor(Color.WHITE); paint.setTextSize(65); paint.setTextAlign(Align.CENTER); myCanvas.drawText(time, 80, 60, paint); return myBitmap; } i this there is something wrong with buildupdate() whats wrong here eclipse show no errors.
java
android
null
null
null
null
open
Getting Initializing inflate state in log cat === it is a android widget and i am trying to add custom fonts to it This is my code public void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) { String currentTime = (String) df.format(new Date()); RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.widget1); updateViews.setImageViewBitmap(R.id.widget1label, buildUpdate(currentTime, context)); appWidgetManager.updateAppWidget(appWidgetId, updateViews); } public Bitmap buildUpdate(String time, Context context) { Bitmap myBitmap = Bitmap.createBitmap(160, 84, Bitmap.Config.ARGB_4444); Canvas myCanvas = new Canvas(myBitmap); Paint paint = new Paint(); Typeface clock = Typeface.createFromAsset(context.getAssets(),"batmfo.ttf"); paint.setAntiAlias(true); paint.setSubpixelText(true); paint.setTypeface(clock); paint.setStyle(Paint.Style.FILL); paint.setColor(Color.WHITE); paint.setTextSize(65); paint.setTextAlign(Align.CENTER); myCanvas.drawText(time, 80, 60, paint); return myBitmap; } i this there is something wrong with buildupdate() whats wrong here eclipse show no errors.
0
11,327,256
07/04/2012 10:28:04
1,336,291
04/16/2012 12:27:49
46
0
Open HTML file in browser using C++
I am writing a program in C++ using Visual studio, what I need to do is create an HTML file and write data in it, and then I wish to get it opened in the browser. Right now I can create file, write stuff but I cannot open it, can anyone help?
c++
html
visual-studio-2010
null
null
null
open
Open HTML file in browser using C++ === I am writing a program in C++ using Visual studio, what I need to do is create an HTML file and write data in it, and then I wish to get it opened in the browser. Right now I can create file, write stuff but I cannot open it, can anyone help?
0
11,327,257
07/04/2012 10:28:07
1,395,782
05/15/2012 09:30:54
49
4
How to send an email notification about updating the status of the suggestion to its owner?
I am a new ASP.NET developer and I am developing a web-based suggestions box program for my company where the employees can submit any safety suggestions they have. Now, I am working on the Administration part of this system. The Admin will be able to see all suggestions listed in a GridView control with the username of the owner. In the last column of the GridView, the status will be listed there. When the Admin clicks on the status of one of these suggestion, a new pop-up window (asp.net ajax ModalPopUpExtender) will be appeared with listing all the possible status such as: actioned, approved... etc. And when the Admin selects one of these status, the status of the suggestion will be updated in the database. Everything works fine. What I want to do now is when the user updates the status of anyone of the suggestions, an email notfication will be sent to the owner regarding the update of status of his suggestion. **I already wrote the Mail function but I don't know how to get the username of that selected suggestion that its status has been updated. Could anyone help me with this?** I am really struggling with getting the username of that updated suggestion. FYI, I have the following database design: Employee Table: Username, Name... SafetySuggestionsLog: ID, Title, Description, Username, StatusID SafetySuggestionsStatus: ID, Status **ASP.NET code:** <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ID" width="900px" CssClass="mGrid" DataSourceID="SqlDataSource1" OnRowDataBound="GridView1_RowDataBound"> <AlternatingRowStyle BackColor="White" ForeColor="#284775" CssClass="alt" /> <HeaderStyle Font-Bold = "True" ForeColor="Black" Height="20px"/> <Columns> <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" /> <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" /> <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" /> <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /> <asp:BoundField DataField="Username" HeaderText="Username" SortExpression="Username" /> <asp:BoundField DataField="DivisionShortcut" HeaderText="DivisionShortcut" SortExpression="DivisionShortcut" /> <asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" /> <%-- This to make status be opened and edited through the Ajax ModalPopUp Window --%> <asp:TemplateField HeaderText="Status"> <ItemTemplate> <asp:LinkButton runat="server" ID="lnkSuggestionStatus" Text='<%#Eval("Status")%>' OnClick="lnkSuggestionStatus_Click"> </asp:LinkButton> </ItemTemplate> </asp:TemplateField> <%--<asp:HyperLinkField HeaderText="Status" SortExpression="Status" />--%> </Columns> <RowStyle HorizontalAlign="Center" /> </asp:GridView> <asp:Button runat="server" ID="btnModalPopUp" style="display:none" /> <AjaxToolkit:ModalPopUpExtender ID="modalPopUpExtender1" runat="server" TargetControlID="btnModalPopUp" PopupControlID="pnlPopUp" BackgroundCssClass="popUpStyle" PopupDragHandleControlID="panelDragHandle" OkControlID="OKButton"> </AjaxToolkit:ModalPopUpExtender> <asp:Panel runat="server" ID="pnlPopUp"> <asp:RadioButtonList ID="StatusList" runat="server" RepeatColumns="1" RepeatDirection="Vertical" RepeatLayout="Table" TextAlign="Left" DataSourceID="SuggestionStatusDataSource" DataTextField="Status" DataValueField="ID"> <asp:ListItem id="option1" runat="server" Value="ACTIONED" /> <asp:ListItem id="option2" runat="server" Value="APPROVED" /> <asp:ListItem id="option3" runat="server" Value="PENDING" /> <asp:ListItem id="option4" runat="server" Value="TRANSFERRED" /> </asp:RadioButtonList> <asp:SqlDataSource ID="SuggestionStatusDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:testConnectionString %>" SelectCommand="SELECT * FROM [SafetySuggestionsStatus]"></asp:SqlDataSource> <asp:Button ID="confirmButton" runat="server" Text="Confirm" OnClientClick="javascript:return confirm('Are you sure you want to send an email notification about the safety suggestion to the owner?')" OnClick="btnSendStatus_Click" /> <asp:Button ID="OKButton" runat="server" Text="Close" /> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> **Code-Behind:** protected void lnkSuggestionStatus_Click(object sender, EventArgs e) { LinkButton lnkSuggestionStatus = sender as LinkButton; //var safetySuggestionsId = //get reference to the row selected GridViewRow gvrow = (GridViewRow)lnkSuggestionStatus.NamingContainer; //set the selected index to the selected row so that the selected row will be highlighted GridView1.SelectedIndex = gvrow.RowIndex; //This HiddenField used to store the value of the ID HiddenField1.Value = GridView1.DataKeys[gvrow.RowIndex].Value.ToString(); //show the modalPopUp modalPopUpExtender1.Show(); } public void btnSendStatus_Click(object sender, EventArgs e) { var statusID = StatusList.SelectedValue; string connString = "Data Source=localhost\\sqlexpress;Initial Catalog=psspdbTest;Integrated Security=True"; //For updating the status of the safety suggestion string updateCommand = "UPDATE SafetySuggestionsLog SET StatusID= @statusID where ID=@SafetySuggestionsID"; using (SqlConnection conn = new SqlConnection(connString)) { conn.Open(); using (SqlCommand cmd = new SqlCommand(updateCommand, conn)) { cmd.Parameters.AddWithValue("@statusID", Convert.ToInt32(statusID)); cmd.Parameters.AddWithValue("@SafetySuggestionsID", Convert.ToInt32(HiddenField1.Value)); cmd.ExecuteNonQuery(); } //reset the value of hiddenfield HiddenField1.Value = "-1"; } GridView1.DataBind(); SendSuggestionStatusToUser(statusID); } protected void SendStatusByEmail(string toAddresses, string fromAddress, string MailSubject, string MessageBody, bool isBodyHtml) { SmtpClient sc = new SmtpClient("MAIL.Aramco.com"); try { MailMessage msg = new MailMessage(); msg.From = new MailAddress("[email protected]", "PMOD Safety Services Portal (PSSP)"); // In case the mail system doesn't like no to recipients. This could be removed //msg.To.Add("[email protected]"); msg.Bcc.Add(toAddresses); msg.Subject = MailSubject; msg.Body = MessageBody; msg.IsBodyHtml = isBodyHtml; sc.Send(msg); } catch (Exception ex) { throw ex; } } protected void SendSuggestionStatusToUser(string status) { string connString = "Data Source=localhost\\sqlexpress;Initial Catalog=psspdbTest;Integrated Security=True"; using (SqlConnection conn = new SqlConnection(connString)) { var sbEmailAddresses = new System.Text.StringBuilder(2000); string statusID = status; // Open DB connection. conn.Open(); string cmdText2 = "SELECT Username FROM dbo.SafetySuggestionsLog"; using (SqlCommand cmd = new SqlCommand(cmdText2, conn)) { SqlDataReader reader = cmd.ExecuteReader(); if (reader != null) { while (reader.Read()) { var sName = reader.GetString(0); if (!string.IsNullOrEmpty(sName)) { if (sbEmailAddresses.Length != 0) { sbEmailAddresses.Append(","); } // Just use the ordinal position for the user name since there is only 1 column sbEmailAddresses.Append(sName).Append("@aramco.com"); } } } reader.Close(); } string cmdText3 = "UPDATE dbo.SafetySuggestionsStatus SET ID .........."; using (SqlCommand cmd = new SqlCommand(cmdText3, conn)) { // Add the parameter to the command var oParameter = cmd.Parameters.Add("statusID", SqlDbType.Int); var sEMailAddresses = sbEmailAddresses.ToString(); string description = "SELECT Description FROM dbo.SafetySuggestionsLog"; string body = @"Good day, <br /><br /> <b> We just would like to notify you that your following safety suggestion: </b>" + description + @"<br /><br /> has been. <br /> <br /><br /> <br /> This email was generated using the <a href='http://pmv/pssp/Default.aspx'>PMOD Safety Services Portal (PSSP) </a>. Please do not reply to this email. "; int sendCount = 0; List<string> addressList = new List<string>(sEMailAddresses.Split(',')); StringBuilder addressesToSend = new StringBuilder(); if (!string.IsNullOrEmpty(statusID)) { SendStatusByEmail(addressesToSend.ToString(), "", "Notification of Your Safety Suggestion", body, true); addressesToSend.Clear(); } } conn.Close(); } } Note: I know that I should not post a lengthy code here, but because I want to explain to you my work and to get your help.
c#
asp.net
sql-server-2008-r2
null
null
null
open
How to send an email notification about updating the status of the suggestion to its owner? === I am a new ASP.NET developer and I am developing a web-based suggestions box program for my company where the employees can submit any safety suggestions they have. Now, I am working on the Administration part of this system. The Admin will be able to see all suggestions listed in a GridView control with the username of the owner. In the last column of the GridView, the status will be listed there. When the Admin clicks on the status of one of these suggestion, a new pop-up window (asp.net ajax ModalPopUpExtender) will be appeared with listing all the possible status such as: actioned, approved... etc. And when the Admin selects one of these status, the status of the suggestion will be updated in the database. Everything works fine. What I want to do now is when the user updates the status of anyone of the suggestions, an email notfication will be sent to the owner regarding the update of status of his suggestion. **I already wrote the Mail function but I don't know how to get the username of that selected suggestion that its status has been updated. Could anyone help me with this?** I am really struggling with getting the username of that updated suggestion. FYI, I have the following database design: Employee Table: Username, Name... SafetySuggestionsLog: ID, Title, Description, Username, StatusID SafetySuggestionsStatus: ID, Status **ASP.NET code:** <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ID" width="900px" CssClass="mGrid" DataSourceID="SqlDataSource1" OnRowDataBound="GridView1_RowDataBound"> <AlternatingRowStyle BackColor="White" ForeColor="#284775" CssClass="alt" /> <HeaderStyle Font-Bold = "True" ForeColor="Black" Height="20px"/> <Columns> <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" /> <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" /> <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" /> <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /> <asp:BoundField DataField="Username" HeaderText="Username" SortExpression="Username" /> <asp:BoundField DataField="DivisionShortcut" HeaderText="DivisionShortcut" SortExpression="DivisionShortcut" /> <asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" /> <%-- This to make status be opened and edited through the Ajax ModalPopUp Window --%> <asp:TemplateField HeaderText="Status"> <ItemTemplate> <asp:LinkButton runat="server" ID="lnkSuggestionStatus" Text='<%#Eval("Status")%>' OnClick="lnkSuggestionStatus_Click"> </asp:LinkButton> </ItemTemplate> </asp:TemplateField> <%--<asp:HyperLinkField HeaderText="Status" SortExpression="Status" />--%> </Columns> <RowStyle HorizontalAlign="Center" /> </asp:GridView> <asp:Button runat="server" ID="btnModalPopUp" style="display:none" /> <AjaxToolkit:ModalPopUpExtender ID="modalPopUpExtender1" runat="server" TargetControlID="btnModalPopUp" PopupControlID="pnlPopUp" BackgroundCssClass="popUpStyle" PopupDragHandleControlID="panelDragHandle" OkControlID="OKButton"> </AjaxToolkit:ModalPopUpExtender> <asp:Panel runat="server" ID="pnlPopUp"> <asp:RadioButtonList ID="StatusList" runat="server" RepeatColumns="1" RepeatDirection="Vertical" RepeatLayout="Table" TextAlign="Left" DataSourceID="SuggestionStatusDataSource" DataTextField="Status" DataValueField="ID"> <asp:ListItem id="option1" runat="server" Value="ACTIONED" /> <asp:ListItem id="option2" runat="server" Value="APPROVED" /> <asp:ListItem id="option3" runat="server" Value="PENDING" /> <asp:ListItem id="option4" runat="server" Value="TRANSFERRED" /> </asp:RadioButtonList> <asp:SqlDataSource ID="SuggestionStatusDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:testConnectionString %>" SelectCommand="SELECT * FROM [SafetySuggestionsStatus]"></asp:SqlDataSource> <asp:Button ID="confirmButton" runat="server" Text="Confirm" OnClientClick="javascript:return confirm('Are you sure you want to send an email notification about the safety suggestion to the owner?')" OnClick="btnSendStatus_Click" /> <asp:Button ID="OKButton" runat="server" Text="Close" /> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> **Code-Behind:** protected void lnkSuggestionStatus_Click(object sender, EventArgs e) { LinkButton lnkSuggestionStatus = sender as LinkButton; //var safetySuggestionsId = //get reference to the row selected GridViewRow gvrow = (GridViewRow)lnkSuggestionStatus.NamingContainer; //set the selected index to the selected row so that the selected row will be highlighted GridView1.SelectedIndex = gvrow.RowIndex; //This HiddenField used to store the value of the ID HiddenField1.Value = GridView1.DataKeys[gvrow.RowIndex].Value.ToString(); //show the modalPopUp modalPopUpExtender1.Show(); } public void btnSendStatus_Click(object sender, EventArgs e) { var statusID = StatusList.SelectedValue; string connString = "Data Source=localhost\\sqlexpress;Initial Catalog=psspdbTest;Integrated Security=True"; //For updating the status of the safety suggestion string updateCommand = "UPDATE SafetySuggestionsLog SET StatusID= @statusID where ID=@SafetySuggestionsID"; using (SqlConnection conn = new SqlConnection(connString)) { conn.Open(); using (SqlCommand cmd = new SqlCommand(updateCommand, conn)) { cmd.Parameters.AddWithValue("@statusID", Convert.ToInt32(statusID)); cmd.Parameters.AddWithValue("@SafetySuggestionsID", Convert.ToInt32(HiddenField1.Value)); cmd.ExecuteNonQuery(); } //reset the value of hiddenfield HiddenField1.Value = "-1"; } GridView1.DataBind(); SendSuggestionStatusToUser(statusID); } protected void SendStatusByEmail(string toAddresses, string fromAddress, string MailSubject, string MessageBody, bool isBodyHtml) { SmtpClient sc = new SmtpClient("MAIL.Aramco.com"); try { MailMessage msg = new MailMessage(); msg.From = new MailAddress("[email protected]", "PMOD Safety Services Portal (PSSP)"); // In case the mail system doesn't like no to recipients. This could be removed //msg.To.Add("[email protected]"); msg.Bcc.Add(toAddresses); msg.Subject = MailSubject; msg.Body = MessageBody; msg.IsBodyHtml = isBodyHtml; sc.Send(msg); } catch (Exception ex) { throw ex; } } protected void SendSuggestionStatusToUser(string status) { string connString = "Data Source=localhost\\sqlexpress;Initial Catalog=psspdbTest;Integrated Security=True"; using (SqlConnection conn = new SqlConnection(connString)) { var sbEmailAddresses = new System.Text.StringBuilder(2000); string statusID = status; // Open DB connection. conn.Open(); string cmdText2 = "SELECT Username FROM dbo.SafetySuggestionsLog"; using (SqlCommand cmd = new SqlCommand(cmdText2, conn)) { SqlDataReader reader = cmd.ExecuteReader(); if (reader != null) { while (reader.Read()) { var sName = reader.GetString(0); if (!string.IsNullOrEmpty(sName)) { if (sbEmailAddresses.Length != 0) { sbEmailAddresses.Append(","); } // Just use the ordinal position for the user name since there is only 1 column sbEmailAddresses.Append(sName).Append("@aramco.com"); } } } reader.Close(); } string cmdText3 = "UPDATE dbo.SafetySuggestionsStatus SET ID .........."; using (SqlCommand cmd = new SqlCommand(cmdText3, conn)) { // Add the parameter to the command var oParameter = cmd.Parameters.Add("statusID", SqlDbType.Int); var sEMailAddresses = sbEmailAddresses.ToString(); string description = "SELECT Description FROM dbo.SafetySuggestionsLog"; string body = @"Good day, <br /><br /> <b> We just would like to notify you that your following safety suggestion: </b>" + description + @"<br /><br /> has been. <br /> <br /><br /> <br /> This email was generated using the <a href='http://pmv/pssp/Default.aspx'>PMOD Safety Services Portal (PSSP) </a>. Please do not reply to this email. "; int sendCount = 0; List<string> addressList = new List<string>(sEMailAddresses.Split(',')); StringBuilder addressesToSend = new StringBuilder(); if (!string.IsNullOrEmpty(statusID)) { SendStatusByEmail(addressesToSend.ToString(), "", "Notification of Your Safety Suggestion", body, true); addressesToSend.Clear(); } } conn.Close(); } } Note: I know that I should not post a lengthy code here, but because I want to explain to you my work and to get your help.
0
11,327,258
07/04/2012 10:28:14
1,425,264
05/30/2012 06:00:19
16
0
svn copy command in windows bat file
Like we use following command for svn update in windows bat file : "%SVN%\TortoiseProc.exe" /command:update /path:"%SOURCE%" /closeonend:2 how can we use svn copy and svn rename commands ???
svn
script
batch-file
dos
null
null
open
svn copy command in windows bat file === Like we use following command for svn update in windows bat file : "%SVN%\TortoiseProc.exe" /command:update /path:"%SOURCE%" /closeonend:2 how can we use svn copy and svn rename commands ???
0
11,327,259
07/04/2012 10:28:17
782,252
06/03/2011 06:19:00
152
3
passing an object in the attribute of a unit test
how could i pass an object in my unit test? here's my code: [Test] [Row( new CustomField())] public void Test_Constructor( CustomField customField) { ..... } it returns an error: An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type
unit-testing
c#-4.0
mbunit
null
null
null
open
passing an object in the attribute of a unit test === how could i pass an object in my unit test? here's my code: [Test] [Row( new CustomField())] public void Test_Constructor( CustomField customField) { ..... } it returns an error: An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type
0
11,327,260
07/04/2012 10:28:17
1,128,922
01/04/2012 00:02:14
1
0
Importing a single row of excel data from
I am looking to do a slight variation on the below question and code. Overview: 1. I have a folder full of "Request Forms" in Excel from individual customers which will grow in number. 2. I have a request log, where the purpose is to consolidate all the request forms onto a single sheet. 3. I want to use some vba code to loop through the all the files in the folder (regardless if the file count changes) and pull out a single row of data from each (say a1:a20) and use the file title as the first column. 4. I will also be adding additional new columns to the log for each of the entries so I want to prevent the mismatch of the data being pulled in and the new columns in the case where someone changes a file name etc. Also this has to be compatible with Excel 2003 Appreciate any help anyone can give! John http://stackoverflow.com/questions/4610498/importing-data-from-many-excel-workbooks-and-sheets-into-a-single-workbook-table Sub ImportWorkbooks(destination as workbook) Dim objFSO As Object Dim objFolder As Object Dim objFile As Object Set objFSO = CreateObject("Scripting.FileSystemObject") 'Get the folder object associated with the directory Set objFolder = objFSO.GetFolder("C:\MyFolder") 'Loop through the Files collection and import each workbook For Each objFile In objFolder.Files Dim source As Workbook Set source = Application.Workbooks.Open(objFile.Path, ReadOnly:=True) ImportWorkbook source, destination wb.Close Set wb = Nothing Next Set objFolder = Nothing Set objFile = Nothing Set objFSO = Nothing End Sub Sub ImportWorkbook(source As Workbook, destination as Workbook) 'Import each worksheet For Each sheet In source.Sheets ImportWorksheet sheet, destination Next sheet End Sub Sub ImportWorksheet(sheet As Worksheet, destination as Workbook) 'Perform your import logic for each sheet here (i.e. Copy from sheet and paste into a 'sheet into the provided workbook) End Sub
excel
loops
data
excel-vba
import
null
open
Importing a single row of excel data from === I am looking to do a slight variation on the below question and code. Overview: 1. I have a folder full of "Request Forms" in Excel from individual customers which will grow in number. 2. I have a request log, where the purpose is to consolidate all the request forms onto a single sheet. 3. I want to use some vba code to loop through the all the files in the folder (regardless if the file count changes) and pull out a single row of data from each (say a1:a20) and use the file title as the first column. 4. I will also be adding additional new columns to the log for each of the entries so I want to prevent the mismatch of the data being pulled in and the new columns in the case where someone changes a file name etc. Also this has to be compatible with Excel 2003 Appreciate any help anyone can give! John http://stackoverflow.com/questions/4610498/importing-data-from-many-excel-workbooks-and-sheets-into-a-single-workbook-table Sub ImportWorkbooks(destination as workbook) Dim objFSO As Object Dim objFolder As Object Dim objFile As Object Set objFSO = CreateObject("Scripting.FileSystemObject") 'Get the folder object associated with the directory Set objFolder = objFSO.GetFolder("C:\MyFolder") 'Loop through the Files collection and import each workbook For Each objFile In objFolder.Files Dim source As Workbook Set source = Application.Workbooks.Open(objFile.Path, ReadOnly:=True) ImportWorkbook source, destination wb.Close Set wb = Nothing Next Set objFolder = Nothing Set objFile = Nothing Set objFSO = Nothing End Sub Sub ImportWorkbook(source As Workbook, destination as Workbook) 'Import each worksheet For Each sheet In source.Sheets ImportWorksheet sheet, destination Next sheet End Sub Sub ImportWorksheet(sheet As Worksheet, destination as Workbook) 'Perform your import logic for each sheet here (i.e. Copy from sheet and paste into a 'sheet into the provided workbook) End Sub
0
11,327,261
07/04/2012 10:28:25
610,157
02/09/2011 17:33:17
1
0
Which technology to choose for PubSub between java service and C# client
Which technology would you suggest for PubSub between Java Service and C# desktop client. What do you think about CometD? Is there any nice .net API for it? Server and client will run within the same organization so can use different protocols Is CometD a right choice at all or would it be better to use TCP instead of HTTP?
c#
java
comet
publish-subscribe
cometd.net
null
open
Which technology to choose for PubSub between java service and C# client === Which technology would you suggest for PubSub between Java Service and C# desktop client. What do you think about CometD? Is there any nice .net API for it? Server and client will run within the same organization so can use different protocols Is CometD a right choice at all or would it be better to use TCP instead of HTTP?
0
11,327,263
07/04/2012 10:28:38
7,918
09/15/2008 14:41:36
1,892
63
Using extra in django querystet combined with django lookups (not constant parameters in extra)
I want to call a postgresql function in django queryset and parameters of this function are related to current row. Lets assume I have following queryset: queryset = Baz.objects.filter(foo = 'foo', foo__bar = 'bar'). and I would like to add an extra argument that calls a function, and argument of this function should be name that django lookup `foo_baz` resolves to. In ideal world i would like to write: queryset.extra(were = "my_function(foo__baz)") that woul render to: my_function("FOO_TABLE".baz)
python
django
django-queryset
null
null
null
open
Using extra in django querystet combined with django lookups (not constant parameters in extra) === I want to call a postgresql function in django queryset and parameters of this function are related to current row. Lets assume I have following queryset: queryset = Baz.objects.filter(foo = 'foo', foo__bar = 'bar'). and I would like to add an extra argument that calls a function, and argument of this function should be name that django lookup `foo_baz` resolves to. In ideal world i would like to write: queryset.extra(were = "my_function(foo__baz)") that woul render to: my_function("FOO_TABLE".baz)
0
11,327,264
07/04/2012 10:28:41
1,501,260
07/04/2012 10:14:20
1
0
Compile-time defined storage order in Fortran using C++ preprocessor
I would like get a flexible (compile time defined) storage order in Fortran 90. For this I'm trying to use a C++ preprocessor including some boost pp headers. So, for example, instead of accessing a 3D-array like this: myArray(k,i,j) I'd like to have this: myArray(POINT3D(i,j,k)) and determine the order of accesses at compile time. Now what I've tried: #include "boost_pp_cat.hpp" #include "boost_pp_comma.hpp" ! ------ Define storage orders here --------- ! !Forward lookup {i,j,k} <- {1,2,3} #define KIJ_ORDER_ARG1 k #define KIJ_ORDER_ARG2 i #define KIJ_ORDER_ARG3 j ! ------ Switch between storage orders ------ ! #define CURR_ORDER KIJ_ORDER ! ------ Generate all required macros ------- ! #define STOR_ORDER_ARG(storOrder, argNum) BOOST_PP_CAT(BOOST_PP_CAT(storOrder, _ARG), argNum) #define CHOOSE_PARAM(storOrder, argNum) BOOST_PP_CAT(STOR_ORDER_ARG(storOrder, argNum), Param) #define POINT3D(iParam, jParam, kParam) POINT3D_WITH_STORORDER(CURR_ORDER, iParam, jParam, kParam) #define POINT3D_WITH_STORORDER(storOrder, iParam, jParam, kParam) POINT3D_WITH_STORORDER_PRE(storOrder) #define POINT3D_WITH_STORORDER_PRE(storOrder) CHOOSE_PARAM(storOrder, 1), CHOOSE_PARAM(storOrder, 2), CHOOSE_PARAM(storOrder, 3) This will expand myArray(POINT3D(i,j,k)) to myArray(kParam, iParam, jParam) . Almost there! Now my question: 1. Is it possible to do what I want using a C preprocessor? 2. If not - what technique would you use? (I'm thinking about making my own specialized "preprocessor" python script, but do you have another suggestion?)
c++
boost
preprocessor
fortran
null
null
open
Compile-time defined storage order in Fortran using C++ preprocessor === I would like get a flexible (compile time defined) storage order in Fortran 90. For this I'm trying to use a C++ preprocessor including some boost pp headers. So, for example, instead of accessing a 3D-array like this: myArray(k,i,j) I'd like to have this: myArray(POINT3D(i,j,k)) and determine the order of accesses at compile time. Now what I've tried: #include "boost_pp_cat.hpp" #include "boost_pp_comma.hpp" ! ------ Define storage orders here --------- ! !Forward lookup {i,j,k} <- {1,2,3} #define KIJ_ORDER_ARG1 k #define KIJ_ORDER_ARG2 i #define KIJ_ORDER_ARG3 j ! ------ Switch between storage orders ------ ! #define CURR_ORDER KIJ_ORDER ! ------ Generate all required macros ------- ! #define STOR_ORDER_ARG(storOrder, argNum) BOOST_PP_CAT(BOOST_PP_CAT(storOrder, _ARG), argNum) #define CHOOSE_PARAM(storOrder, argNum) BOOST_PP_CAT(STOR_ORDER_ARG(storOrder, argNum), Param) #define POINT3D(iParam, jParam, kParam) POINT3D_WITH_STORORDER(CURR_ORDER, iParam, jParam, kParam) #define POINT3D_WITH_STORORDER(storOrder, iParam, jParam, kParam) POINT3D_WITH_STORORDER_PRE(storOrder) #define POINT3D_WITH_STORORDER_PRE(storOrder) CHOOSE_PARAM(storOrder, 1), CHOOSE_PARAM(storOrder, 2), CHOOSE_PARAM(storOrder, 3) This will expand myArray(POINT3D(i,j,k)) to myArray(kParam, iParam, jParam) . Almost there! Now my question: 1. Is it possible to do what I want using a C preprocessor? 2. If not - what technique would you use? (I'm thinking about making my own specialized "preprocessor" python script, but do you have another suggestion?)
0
11,327,266
07/04/2012 10:28:57
1,099,312
12/15/2011 07:10:08
1
0
i have error with button share of facebook
I have link http://muabannhadaklak.com/group/profile/group/9.html, this link work well on my website, but when i share this link on facebook, facebook return error `Database Error http://muabannhadaklak.com/group/profile... Message: Cannot modify header information - headers already sent by (output started at /home/muabannh/public_html/group/system/core/Exceptions.php:185)` i don't know why and don't know how to fix this error. My framwork CodeIgniter
facebook
share
null
null
null
null
open
i have error with button share of facebook === I have link http://muabannhadaklak.com/group/profile/group/9.html, this link work well on my website, but when i share this link on facebook, facebook return error `Database Error http://muabannhadaklak.com/group/profile... Message: Cannot modify header information - headers already sent by (output started at /home/muabannh/public_html/group/system/core/Exceptions.php:185)` i don't know why and don't know how to fix this error. My framwork CodeIgniter
0
11,327,268
07/04/2012 10:29:14
406,990
07/30/2010 17:46:14
196
4
not able to addsubview in ipad
i have one homeview controller where i am adding one subview. that subview is subclass of uiview. but homeview controller not displaying subview. here is my code. #import "HomeViewController.h" @interface HomeViewController : UIViewController { DetailView *viewDetailFinal; } @property (nonatomic, retain) DetailView *viewDetailFinal; @implementation HomeViewController @synthesize viewDetailFinal; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization viewDetailFinal = [[DetailView alloc] initWithFrame:CGRectMake(0, 0, 588, 899)]; } return self; } - (void)viewDidLoad { [self.view addSubview:viewDetailFinal]; } #import "DetailView.h" @interface DetailView : UIView{ } -(void) loadView:(NSString *)str; @implementation DetailView - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code [self loadView:@"my test text"]; } return self; } -(void) loadView:(NSString *)str { UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 150, 25)]; [lbl setFont:[UIFont boldSystemFontOfSize:12.0]]; [lbl setTextColor:[UIColor blackColor]]; [lbl setTextAlignment:UITextAlignmentCenter]; [lbl setBackgroundColor:[UIColor blueColor]]; [lbl setText:str]; } Can any one suggest where i am wrong ? Any help will be appreciated.
iphone
ios
ipad
uiview
uiviewcontroller
null
open
not able to addsubview in ipad === i have one homeview controller where i am adding one subview. that subview is subclass of uiview. but homeview controller not displaying subview. here is my code. #import "HomeViewController.h" @interface HomeViewController : UIViewController { DetailView *viewDetailFinal; } @property (nonatomic, retain) DetailView *viewDetailFinal; @implementation HomeViewController @synthesize viewDetailFinal; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization viewDetailFinal = [[DetailView alloc] initWithFrame:CGRectMake(0, 0, 588, 899)]; } return self; } - (void)viewDidLoad { [self.view addSubview:viewDetailFinal]; } #import "DetailView.h" @interface DetailView : UIView{ } -(void) loadView:(NSString *)str; @implementation DetailView - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code [self loadView:@"my test text"]; } return self; } -(void) loadView:(NSString *)str { UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 150, 25)]; [lbl setFont:[UIFont boldSystemFontOfSize:12.0]]; [lbl setTextColor:[UIColor blackColor]]; [lbl setTextAlignment:UITextAlignmentCenter]; [lbl setBackgroundColor:[UIColor blueColor]]; [lbl setText:str]; } Can any one suggest where i am wrong ? Any help will be appreciated.
0
11,327,270
07/04/2012 10:29:18
1,494,215
07/01/2012 11:47:54
19
0
jQuery .on('click') even on a dinamically loaded page
I have a story uploading system on my webpage, which uploads stories in a specified folder, and from that it lists their content to the webpage. I made a split, so only 300 chars are shown of the text, when the user clicks it, the rest of it is shown. Here is my code: This one lists it: <?php foreach($dataArray as $data) { ?> <div class="visible"> <?php echo $data[0] . "<br/><center><a href='#' class='story_show'>Teljes Történet</a></center>"; ?> </div> <div class="hidden"> <?php echo $data[1]; ?> </div> <?php } ?> This is my jQuery: $('.hidden').css('display', 'none'); $('.visible').click(function () { $('.hidden').css('display', 'inline'); }); This page('tortenetek.php') is ajaxed to the main page ('blog.php'). I included Jquery in blog.php like this: <link href='http://fonts.googleapis.com/css?family=Niconne&subset=latin,latin-ext' rel='stylesheet' type='text/css'> <link rel="stylesheet" type="text/css" href="../css/stilus.css"/> <script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script> <script type="text/javascript" src="../js/tinybox.js"></script> <script type="text/javascript" src="../js/ajax.js"></script> <link href="../css/lightbox.css" rel="stylesheet" /> <script src="../js/lightbox.js"></script> <script src="../js/story.js"></script> Story.js is the script file i'm using. Thanks folks!ne
php
jquery
null
null
null
null
open
jQuery .on('click') even on a dinamically loaded page === I have a story uploading system on my webpage, which uploads stories in a specified folder, and from that it lists their content to the webpage. I made a split, so only 300 chars are shown of the text, when the user clicks it, the rest of it is shown. Here is my code: This one lists it: <?php foreach($dataArray as $data) { ?> <div class="visible"> <?php echo $data[0] . "<br/><center><a href='#' class='story_show'>Teljes Történet</a></center>"; ?> </div> <div class="hidden"> <?php echo $data[1]; ?> </div> <?php } ?> This is my jQuery: $('.hidden').css('display', 'none'); $('.visible').click(function () { $('.hidden').css('display', 'inline'); }); This page('tortenetek.php') is ajaxed to the main page ('blog.php'). I included Jquery in blog.php like this: <link href='http://fonts.googleapis.com/css?family=Niconne&subset=latin,latin-ext' rel='stylesheet' type='text/css'> <link rel="stylesheet" type="text/css" href="../css/stilus.css"/> <script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script> <script type="text/javascript" src="../js/tinybox.js"></script> <script type="text/javascript" src="../js/ajax.js"></script> <link href="../css/lightbox.css" rel="stylesheet" /> <script src="../js/lightbox.js"></script> <script src="../js/story.js"></script> Story.js is the script file i'm using. Thanks folks!ne
0
11,327,271
07/04/2012 10:29:18
818,951
06/28/2011 10:18:20
146
8
$(document).ready() doesn't seem to work properly with user control
I have made a user control, and placed some code in the $(document).ready() method, but when I place breakpoints, by the boxWidth value, and step through, I can visibly see that the html has not yet loaded, and that is why I am getting undefined values. I need the html to load first, so that I can get the width and height of an img element to calculate aspect rations etc. A screen shot is given below: ![enter image description here][1] [1]: http://i.stack.imgur.com/emMSK.png
jquery
asp.net
null
null
null
null
open
$(document).ready() doesn't seem to work properly with user control === I have made a user control, and placed some code in the $(document).ready() method, but when I place breakpoints, by the boxWidth value, and step through, I can visibly see that the html has not yet loaded, and that is why I am getting undefined values. I need the html to load first, so that I can get the width and height of an img element to calculate aspect rations etc. A screen shot is given below: ![enter image description here][1] [1]: http://i.stack.imgur.com/emMSK.png
0
11,541,273
07/18/2012 12:24:01
1,342,109
04/18/2012 17:36:37
100
0
Meta tag is not working in scrapy python
I am working scrapy framework below is my spider.py code class Example(BaseSpider): name = "example" allowed_domains = {"http://www.example.com"} start_urls = [ "http://www.example.com/servlet/av/search&SiteName=page1" ] def parse(self, response): hxs = HtmlXPathSelector(response) hrefs = hxs.select('//table[@class="knxa"]/tr/td/a/@href').extract() # href consists of all href tags and i am copying in to forwarding_hrefs by making them as a string forwarding_hrefs = [] for i in hrefs: forwarding_hrefs.append(i.encode('utf-8')) return Request('http://www.example.com/servlet/av/search&SiteName=page2', meta={'forwarding_hrefs': response.meta['forwarding_hrefs']}, callback=self.parseJob) def parseJob(self, response): print response,">>>>>>>>>>>" **Result:** 2012-07-18 17:29:15+0530 [example] DEBUG: Crawled (200) <GET http://www.example.com/servlet/av/search&SiteName=page1> (referer: None) 2012-07-18 17:29:15+0530 [MemorialReqionalHospital] ERROR: Spider error processing <GET http://www.example.com/servlet/av/search&SiteName=page2> Traceback (most recent call last): File "/usr/lib64/python2.7/site-packages/twisted/internet/base.py", line 1167, in mainLoop self.runUntilCurrent() File "/usr/lib64/python2.7/site-packages/twisted/internet/base.py", line 789, in runUntilCurrent call.func(*call.args, **call.kw) File "/usr/lib64/python2.7/site-packages/twisted/internet/defer.py", line 361, in callback self._startRunCallbacks(result) File "/usr/lib64/python2.7/site-packages/twisted/internet/defer.py", line 455, in _startRunCallbacks self._runCallbacks() --- <exception caught here> --- File "/usr/lib64/python2.7/site-packages/twisted/internet/defer.py", line 542, in _runCallbacks current.result = callback(current.result, *args, **kw) File "/home/local/user/project/example/example/spiders/example_spider.py", line 36, in parse meta={'forwarding_hrefs': response.meta['forwarding_hrefs']}, exceptions.KeyError: 'forwarding_hrefs' What i am trying to do is i am collecting all the href tags from http://www.example.com/servlet/av/search&SiteName=page1 and placing in to `forward_hrefs` and calling this `forward_hrefs` in the next request(want to use this `forward_urls` list in the next method) http://www.example.com/servlet/av/search&SiteName=page2 I want to also add the href tags from page2 in the forward_urls and loop in this `forward_hrefs` and yield request of each href tag, this is my idea but it is showing error as above, whats wrong in the above code, actually meta tag is meant to copy the items. Can anyone please let me know this how to copy `forward_hrefs` list from `parse` method to `parseJob` method. Finally my intension is to copy `forward_hrefs` list from `parse` method to `parseJob` method. hope i explained well sorry if not please let me know.... Thanks in advance
python
scrapy
meta
null
null
null
open
Meta tag is not working in scrapy python === I am working scrapy framework below is my spider.py code class Example(BaseSpider): name = "example" allowed_domains = {"http://www.example.com"} start_urls = [ "http://www.example.com/servlet/av/search&SiteName=page1" ] def parse(self, response): hxs = HtmlXPathSelector(response) hrefs = hxs.select('//table[@class="knxa"]/tr/td/a/@href').extract() # href consists of all href tags and i am copying in to forwarding_hrefs by making them as a string forwarding_hrefs = [] for i in hrefs: forwarding_hrefs.append(i.encode('utf-8')) return Request('http://www.example.com/servlet/av/search&SiteName=page2', meta={'forwarding_hrefs': response.meta['forwarding_hrefs']}, callback=self.parseJob) def parseJob(self, response): print response,">>>>>>>>>>>" **Result:** 2012-07-18 17:29:15+0530 [example] DEBUG: Crawled (200) <GET http://www.example.com/servlet/av/search&SiteName=page1> (referer: None) 2012-07-18 17:29:15+0530 [MemorialReqionalHospital] ERROR: Spider error processing <GET http://www.example.com/servlet/av/search&SiteName=page2> Traceback (most recent call last): File "/usr/lib64/python2.7/site-packages/twisted/internet/base.py", line 1167, in mainLoop self.runUntilCurrent() File "/usr/lib64/python2.7/site-packages/twisted/internet/base.py", line 789, in runUntilCurrent call.func(*call.args, **call.kw) File "/usr/lib64/python2.7/site-packages/twisted/internet/defer.py", line 361, in callback self._startRunCallbacks(result) File "/usr/lib64/python2.7/site-packages/twisted/internet/defer.py", line 455, in _startRunCallbacks self._runCallbacks() --- <exception caught here> --- File "/usr/lib64/python2.7/site-packages/twisted/internet/defer.py", line 542, in _runCallbacks current.result = callback(current.result, *args, **kw) File "/home/local/user/project/example/example/spiders/example_spider.py", line 36, in parse meta={'forwarding_hrefs': response.meta['forwarding_hrefs']}, exceptions.KeyError: 'forwarding_hrefs' What i am trying to do is i am collecting all the href tags from http://www.example.com/servlet/av/search&SiteName=page1 and placing in to `forward_hrefs` and calling this `forward_hrefs` in the next request(want to use this `forward_urls` list in the next method) http://www.example.com/servlet/av/search&SiteName=page2 I want to also add the href tags from page2 in the forward_urls and loop in this `forward_hrefs` and yield request of each href tag, this is my idea but it is showing error as above, whats wrong in the above code, actually meta tag is meant to copy the items. Can anyone please let me know this how to copy `forward_hrefs` list from `parse` method to `parseJob` method. Finally my intension is to copy `forward_hrefs` list from `parse` method to `parseJob` method. hope i explained well sorry if not please let me know.... Thanks in advance
0
11,541,275
07/18/2012 12:24:01
1,292,344
03/26/2012 06:46:44
139
16
Safari Browser How to detect when Block cookies from Privacy is NOT set to Never?
I developed a bookmarklet using Javascript and my bookmarklet does not work on Safari browser on Windows or Mac, when Block cookies is NOT set on Never. go to Settings, Preferences, Privacy, Block cookies How do i detect the value of this option ?
javascript
browser
safari
bookmarklet
null
null
open
Safari Browser How to detect when Block cookies from Privacy is NOT set to Never? === I developed a bookmarklet using Javascript and my bookmarklet does not work on Safari browser on Windows or Mac, when Block cookies is NOT set on Never. go to Settings, Preferences, Privacy, Block cookies How do i detect the value of this option ?
0
11,541,277
07/18/2012 12:24:12
1,007,076
10/21/2011 12:18:39
1,051
66
UIImagePickerController delegate is not calling
Iam using the following code for taking the picture automatically from IPAD front camera: UIImagePickerController *imgPkr = [[UIImagePickerController alloc] init]; imgPkr.sourceType = UIImagePickerControllerSourceTypeCamera; imgPkr.delegate = self; imgPkr.cameraDevice=UIImagePickerControllerCameraDeviceFront; [self presentModalViewController:imgPkr animated:YES]; imgPkr.showsCameraControls = NO; [imgPkr takePicture]; But this code Dont take any picture and dont call the delegate: -(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info Any idea what is wrong with the code
objective-c
ipad
null
null
null
null
open
UIImagePickerController delegate is not calling === Iam using the following code for taking the picture automatically from IPAD front camera: UIImagePickerController *imgPkr = [[UIImagePickerController alloc] init]; imgPkr.sourceType = UIImagePickerControllerSourceTypeCamera; imgPkr.delegate = self; imgPkr.cameraDevice=UIImagePickerControllerCameraDeviceFront; [self presentModalViewController:imgPkr animated:YES]; imgPkr.showsCameraControls = NO; [imgPkr takePicture]; But this code Dont take any picture and dont call the delegate: -(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info Any idea what is wrong with the code
0
11,541,279
07/18/2012 12:24:14
983,655
10/07/2011 08:53:59
3
0
Improving performance of an SQL view with many left joins
I'm new to performance enhancement of SQL queries and given a task to enhance it for a view. This view definition has about 20 left joins applied on it which I believe is hampering the performance - it takes around 9 seconds to retrieve 35K odd rows on a local server. What is the best way to enhance its performance? Thank you.
sql-server
left-join
database-performance
null
null
null
open
Improving performance of an SQL view with many left joins === I'm new to performance enhancement of SQL queries and given a task to enhance it for a view. This view definition has about 20 left joins applied on it which I believe is hampering the performance - it takes around 9 seconds to retrieve 35K odd rows on a local server. What is the best way to enhance its performance? Thank you.
0
11,541,058
07/18/2012 12:10:41
865,448
07/27/2011 13:13:09
68
12
plugin.xml externalize String (not found localization properties file)
I have externalized strings from plugin.xml to plugin.properties. Everything worked fine, but now Eclipse shows me error: > Key 'key-name.3' is not found localization properties file very strange is that key.name.1, key.name.2 ... are correct visible but one isn't. I tried clean, refresh and restart Eclipse but it didn't help. any Advice?
java
plugins
eclipse-rcp
null
null
null
open
plugin.xml externalize String (not found localization properties file) === I have externalized strings from plugin.xml to plugin.properties. Everything worked fine, but now Eclipse shows me error: > Key 'key-name.3' is not found localization properties file very strange is that key.name.1, key.name.2 ... are correct visible but one isn't. I tried clean, refresh and restart Eclipse but it didn't help. any Advice?
0
11,541,059
07/18/2012 12:10:46
488,506
09/24/2009 10:58:53
565
47
MGTwitterEngine reply to a tweet not working
I am using MGTwitterEngine using this code for reply a tweet `[[twitter sendUpdate:text inReplyTo:message_ID] retain];` But it works as a normal tweet. not as a reply of any specific tweet. Any idea.
objective-c
iphone-sdk-4.0
twitter-api
mgtwitterengine
reply
null
open
MGTwitterEngine reply to a tweet not working === I am using MGTwitterEngine using this code for reply a tweet `[[twitter sendUpdate:text inReplyTo:message_ID] retain];` But it works as a normal tweet. not as a reply of any specific tweet. Any idea.
0
11,541,060
07/18/2012 12:10:51
1,177,441
01/30/2012 06:00:47
787
54
Search algorithm
I have a JSON with a say 10k records in it. Each record has a **timestamp** of the form **'2011-04-29'**. Now I have a client side array (let's call it our **calendar**) with arrays of the form - ['2011-04-26', '2011-05-02', 'Week 1', '2010 - 11'] ... The goal is to assign a week number to each record's timestamp. I could use a classical linear search to accomplish this, but with 10k+ json records and close to 300 *weeks* in the calendar, this soon becomes tedious. What would you recommend? PS - I need the calendar because the *weeks* here are not the actual week of the year, but defined else where. Would there be a more efficient way of doing this if i converted the strings to `Date.getTime()`?
javascript
search
null
null
null
null
open
Search algorithm === I have a JSON with a say 10k records in it. Each record has a **timestamp** of the form **'2011-04-29'**. Now I have a client side array (let's call it our **calendar**) with arrays of the form - ['2011-04-26', '2011-05-02', 'Week 1', '2010 - 11'] ... The goal is to assign a week number to each record's timestamp. I could use a classical linear search to accomplish this, but with 10k+ json records and close to 300 *weeks* in the calendar, this soon becomes tedious. What would you recommend? PS - I need the calendar because the *weeks* here are not the actual week of the year, but defined else where. Would there be a more efficient way of doing this if i converted the strings to `Date.getTime()`?
0
11,541,280
07/18/2012 12:24:15
1,469,848
06/20/2012 16:06:36
69
1
Unable to open the C source code of Emacs functions
When I search for a function description [find-function] and I click on the link to the "--.c" file I cannot open it and I get Emacs C Source dir: ~/ in the Minibuf. I am stuck there and I don't know what to do.![enter image description here][1] [1]: http://i.stack.imgur.com/5GNG7.png
emacs
emacs23
emacs24
null
null
null
open
Unable to open the C source code of Emacs functions === When I search for a function description [find-function] and I click on the link to the "--.c" file I cannot open it and I get Emacs C Source dir: ~/ in the Minibuf. I am stuck there and I don't know what to do.![enter image description here][1] [1]: http://i.stack.imgur.com/5GNG7.png
0
11,541,281
07/18/2012 12:24:16
1,534,755
07/18/2012 12:18:33
1
0
Restfullyii limit and offset
Im trying to make use of yii and the restfullyii extension, iv managed to get the search working properly and now Im trying to limit the reults and include an offset, how would i make use of this module and its results, the search returns an array based on a json post, im using a rest controller aswell
search
yii
limit
offset
null
null
open
Restfullyii limit and offset === Im trying to make use of yii and the restfullyii extension, iv managed to get the search working properly and now Im trying to limit the reults and include an offset, how would i make use of this module and its results, the search returns an array based on a json post, im using a rest controller aswell
0
11,541,282
07/18/2012 12:24:16
162,832
08/25/2009 15:09:42
851
15
field selection within mongodb query using dot notation
I see a lot of similarly worded questions here, but none has soved my problem. I have a document like this: <pre>{'_id': ObjectId('5006916af9cf0e7126000000'),'data': [{'count': 0,'alis':'statsministeren','avis':'Ekstrabladet'}, {'count': 0,'alis':'thorning','avis':'Ekstrabladet'}, {'count': 0,'alis':'socialdemokratiets formand','avis':'Ekstrabladet'}, {'count': 0,'alis':'lars barfod','avis':'Ekstrabladet'}, {'count': 0,'alis':'formand for det konservative folkeparti','avis':'Ekstrabladet'}, {'count': 0,'alis':'s\xf8vndal','avis':'Ekstrabladet'}, {'count': 0,'alis': u"sf's formand",'avis':'Ekstrabladet'}, {'count': 0,'alis':'m\xf6ger','avis':'Ekstrabladet'}, {'count': 0,'alis':'lars l\xf8kke','avis':'Ekstrabladet'}, {'count': 0,'alis':'l\xf8kke rasmussen','avis':'Ekstrabladet'}, {'count': 0,'alis':'lederen af danmarks st\xf8rste parti','avis':'Ekstrabladet'}, {'count': 0,'alis':'Pia Kj\xe6rsgaard','avis':'Ekstrabladet'}, {'count': 0,'alis':'statsministeren','avis':'Information'}, {'count': 1,'alis':'thorning','avis':'Information'}, {'count': 0,'alis':'socialdemokratiets formand','avis':'Information'}, {'count': 0,'alis':'lars barfod','avis':'Information'}, {'count': 0,'alis':'formand for det konservative folkeparti','avis':'Information'}, {'count': 0,'alis':'s\xf8vndal','avis':'Information'}, {'count': 0,'alis': u"sf's formand",'avis':'Information'}, {'count': 0,'alis':'m\xf6ger','avis':'Information'}, {'count': 0,'alis':'lars l\xf8kke','avis':'Information'}, {'count': 0,'alis':'l\xf8kke rasmussen','avis':'Information'}, {'count': 0,'alis':'lederen af danmarks st\xf8rste parti','avis':'Information'}, {'count': 0,'alis':'Pia Kj\xe6rsgaard','avis':'Information'}, {'count': 0,'alis':'statsministeren','avis':'Berlingske'}, {'count': 0,'alis':'thorning','avis':'Berlingske'}, {'count': 0,'alis':'socialdemokratiets formand','avis':'Berlingske'}, {'count': 0,'alis':'lars barfod','avis':'Berlingske'}, {'count': 0,'alis':'formand for det konservative folkeparti','avis':'Berlingske'}, {'count': 1,'alis':'s\xf8vndal','avis':'Berlingske'}, {'count': 0,'alis': u"sf's formand",'avis':'Berlingske'}, {'count': 0,'alis':'m\xf6ger','avis':'Berlingske'}, {'count': 0,'alis':'lars l\xf8kke','avis':'Berlingske'}, {'count': 0,'alis':'l\xf8kke rasmussen','avis':'Berlingske'}, {'count': 0,'alis':'lederen af danmarks st\xf8rste parti','avis':'Berlingske'}, {'count': 0,'alis':'Pia Kj\xe6rsgaard','avis':'Berlingske'}, {'count': 0,'alis':'statsministeren','avis':'JP'}, {'count': 0,'alis':'thorning','avis':'JP'}, {'count': 0,'alis':'socialdemokratiets formand','avis':'JP'}, {'count': 0,'alis':'lars barfod','avis':'JP'}, {'count': 0,'alis':'formand for det konservative folkeparti','avis':'JP'}, {'count': 0,'alis':'s\xf8vndal','avis':'JP'}, {'count': 0,'alis': u"sf's formand",'avis':'JP'}, {'count': 1,'alis':'m\xf6ger','avis':'JP'}, {'count': 0,'alis':'lars l\xf8kke','avis':'JP'}, {'count': 0,'alis':'l\xf8kke rasmussen','avis':'JP'}, {'count': 0,'alis':'lederen af danmarks st\xf8rste parti','avis':'JP'}, {'count': 0,'alis':'Pia Kj\xe6rsgaard','avis':'JP'}, {'count': 0,'alis':'statsministeren','avis':'BT'}, {'count': 0,'alis':'thorning','avis':'BT'}, {'count': 0,'alis':'socialdemokratiets formand','avis':'BT'}, {'count': 0,'alis':'lars barfod','avis':'BT'}, {'count': 0,'alis':'formand for det konservative folkeparti','avis':'BT'}, {'count': 0,'alis':'s\xf8vndal','avis':'BT'}, {'count': 0,'alis': u"sf's formand",'avis':'BT'}, {'count': 0,'alis':'m\xf6ger','avis':'BT'}, {'count': 0,'alis':'lars l\xf8kke','avis':'BT'}, {'count': 0,'alis':'l\xf8kke rasmussen','avis':'BT'}, {'count': 0,'alis':'lederen af danmarks st\xf8rste parti','avis':'BT'}, {'count': 0,'alis':'Pia Kj\xe6rsgaard','avis':'BT'}, {'count': 0,'alis':'statsministeren','avis':'Politiken'}, {'count': 0,'alis':'thorning','avis':'Politiken'}, {'count': 0,'alis':'socialdemokratiets formand','avis':'Politiken'}, {'count': 0,'alis':'lars barfod','avis':'Politiken'}, {'count': 0,'alis':'formand for det konservative folkeparti','avis':'Politiken'}, {'count': 0,'alis':'s\xf8vndal','avis':'Politiken'}, {'count': 0,'alis': u"sf's formand",'avis':'Politiken'}, {'count': 0,'alis':'m\xf6ger','avis':'Politiken'}, {'count': 0,'alis':'lars l\xf8kke','avis':'Politiken'}, {'count': 0,'alis':'l\xf8kke rasmussen','avis':'Politiken'}, {'count': 0,'alis':'lederen af danmarks st\xf8rste parti','avis':'Politiken'}, {'count': 0,'alis':'Pia Kj\xe6rsgaard','avis':'Politiken'}],'time':'2012-07-18 12:35:22.241245'} </pre> I.e.: {_objectId : xxx, time: yyy, data :[ 72 similar dicts in this array ]} I want to retrieve values from within one of the 72 dicts. My first attempt was something along these lines: db.observations.find({'data.avis':'Ekstrabladet', 'data.alis':'thorning'}, {'data.count':1}) That would retrieve 72 `count` dicts, when what I really wanted was the count value for the array which satisfies both `avis:ekstrabladet`and `alis:thorning` (only one array). But instead mongo returns the whole document. I have foundt $elemMatch, but I get the same output. db.observations.find({'data' : {$elemMatch: {'alis':'thorning','avis':'Ekstrabladet'}}},{'data.count':1}) I guess I could iterate over the complete document in python (this is for a flask app), but it doesn't seem very elegant. So my question is: Hoe do I reach inside a document and grab values from a nested document of arrarys? Bonus: As I am new to all sorts of databases I only chose mongodb because it seemed very nice and flexible, and because I don't work with critcal data. But I have no need for scalability and could use e.g. sqlite instead. If you have strong opinions about me using the wrong tool for the job - then please abuse me.
python
mongodb
pymongo
mongokit
null
null
open
field selection within mongodb query using dot notation === I see a lot of similarly worded questions here, but none has soved my problem. I have a document like this: <pre>{'_id': ObjectId('5006916af9cf0e7126000000'),'data': [{'count': 0,'alis':'statsministeren','avis':'Ekstrabladet'}, {'count': 0,'alis':'thorning','avis':'Ekstrabladet'}, {'count': 0,'alis':'socialdemokratiets formand','avis':'Ekstrabladet'}, {'count': 0,'alis':'lars barfod','avis':'Ekstrabladet'}, {'count': 0,'alis':'formand for det konservative folkeparti','avis':'Ekstrabladet'}, {'count': 0,'alis':'s\xf8vndal','avis':'Ekstrabladet'}, {'count': 0,'alis': u"sf's formand",'avis':'Ekstrabladet'}, {'count': 0,'alis':'m\xf6ger','avis':'Ekstrabladet'}, {'count': 0,'alis':'lars l\xf8kke','avis':'Ekstrabladet'}, {'count': 0,'alis':'l\xf8kke rasmussen','avis':'Ekstrabladet'}, {'count': 0,'alis':'lederen af danmarks st\xf8rste parti','avis':'Ekstrabladet'}, {'count': 0,'alis':'Pia Kj\xe6rsgaard','avis':'Ekstrabladet'}, {'count': 0,'alis':'statsministeren','avis':'Information'}, {'count': 1,'alis':'thorning','avis':'Information'}, {'count': 0,'alis':'socialdemokratiets formand','avis':'Information'}, {'count': 0,'alis':'lars barfod','avis':'Information'}, {'count': 0,'alis':'formand for det konservative folkeparti','avis':'Information'}, {'count': 0,'alis':'s\xf8vndal','avis':'Information'}, {'count': 0,'alis': u"sf's formand",'avis':'Information'}, {'count': 0,'alis':'m\xf6ger','avis':'Information'}, {'count': 0,'alis':'lars l\xf8kke','avis':'Information'}, {'count': 0,'alis':'l\xf8kke rasmussen','avis':'Information'}, {'count': 0,'alis':'lederen af danmarks st\xf8rste parti','avis':'Information'}, {'count': 0,'alis':'Pia Kj\xe6rsgaard','avis':'Information'}, {'count': 0,'alis':'statsministeren','avis':'Berlingske'}, {'count': 0,'alis':'thorning','avis':'Berlingske'}, {'count': 0,'alis':'socialdemokratiets formand','avis':'Berlingske'}, {'count': 0,'alis':'lars barfod','avis':'Berlingske'}, {'count': 0,'alis':'formand for det konservative folkeparti','avis':'Berlingske'}, {'count': 1,'alis':'s\xf8vndal','avis':'Berlingske'}, {'count': 0,'alis': u"sf's formand",'avis':'Berlingske'}, {'count': 0,'alis':'m\xf6ger','avis':'Berlingske'}, {'count': 0,'alis':'lars l\xf8kke','avis':'Berlingske'}, {'count': 0,'alis':'l\xf8kke rasmussen','avis':'Berlingske'}, {'count': 0,'alis':'lederen af danmarks st\xf8rste parti','avis':'Berlingske'}, {'count': 0,'alis':'Pia Kj\xe6rsgaard','avis':'Berlingske'}, {'count': 0,'alis':'statsministeren','avis':'JP'}, {'count': 0,'alis':'thorning','avis':'JP'}, {'count': 0,'alis':'socialdemokratiets formand','avis':'JP'}, {'count': 0,'alis':'lars barfod','avis':'JP'}, {'count': 0,'alis':'formand for det konservative folkeparti','avis':'JP'}, {'count': 0,'alis':'s\xf8vndal','avis':'JP'}, {'count': 0,'alis': u"sf's formand",'avis':'JP'}, {'count': 1,'alis':'m\xf6ger','avis':'JP'}, {'count': 0,'alis':'lars l\xf8kke','avis':'JP'}, {'count': 0,'alis':'l\xf8kke rasmussen','avis':'JP'}, {'count': 0,'alis':'lederen af danmarks st\xf8rste parti','avis':'JP'}, {'count': 0,'alis':'Pia Kj\xe6rsgaard','avis':'JP'}, {'count': 0,'alis':'statsministeren','avis':'BT'}, {'count': 0,'alis':'thorning','avis':'BT'}, {'count': 0,'alis':'socialdemokratiets formand','avis':'BT'}, {'count': 0,'alis':'lars barfod','avis':'BT'}, {'count': 0,'alis':'formand for det konservative folkeparti','avis':'BT'}, {'count': 0,'alis':'s\xf8vndal','avis':'BT'}, {'count': 0,'alis': u"sf's formand",'avis':'BT'}, {'count': 0,'alis':'m\xf6ger','avis':'BT'}, {'count': 0,'alis':'lars l\xf8kke','avis':'BT'}, {'count': 0,'alis':'l\xf8kke rasmussen','avis':'BT'}, {'count': 0,'alis':'lederen af danmarks st\xf8rste parti','avis':'BT'}, {'count': 0,'alis':'Pia Kj\xe6rsgaard','avis':'BT'}, {'count': 0,'alis':'statsministeren','avis':'Politiken'}, {'count': 0,'alis':'thorning','avis':'Politiken'}, {'count': 0,'alis':'socialdemokratiets formand','avis':'Politiken'}, {'count': 0,'alis':'lars barfod','avis':'Politiken'}, {'count': 0,'alis':'formand for det konservative folkeparti','avis':'Politiken'}, {'count': 0,'alis':'s\xf8vndal','avis':'Politiken'}, {'count': 0,'alis': u"sf's formand",'avis':'Politiken'}, {'count': 0,'alis':'m\xf6ger','avis':'Politiken'}, {'count': 0,'alis':'lars l\xf8kke','avis':'Politiken'}, {'count': 0,'alis':'l\xf8kke rasmussen','avis':'Politiken'}, {'count': 0,'alis':'lederen af danmarks st\xf8rste parti','avis':'Politiken'}, {'count': 0,'alis':'Pia Kj\xe6rsgaard','avis':'Politiken'}],'time':'2012-07-18 12:35:22.241245'} </pre> I.e.: {_objectId : xxx, time: yyy, data :[ 72 similar dicts in this array ]} I want to retrieve values from within one of the 72 dicts. My first attempt was something along these lines: db.observations.find({'data.avis':'Ekstrabladet', 'data.alis':'thorning'}, {'data.count':1}) That would retrieve 72 `count` dicts, when what I really wanted was the count value for the array which satisfies both `avis:ekstrabladet`and `alis:thorning` (only one array). But instead mongo returns the whole document. I have foundt $elemMatch, but I get the same output. db.observations.find({'data' : {$elemMatch: {'alis':'thorning','avis':'Ekstrabladet'}}},{'data.count':1}) I guess I could iterate over the complete document in python (this is for a flask app), but it doesn't seem very elegant. So my question is: Hoe do I reach inside a document and grab values from a nested document of arrarys? Bonus: As I am new to all sorts of databases I only chose mongodb because it seemed very nice and flexible, and because I don't work with critcal data. But I have no need for scalability and could use e.g. sqlite instead. If you have strong opinions about me using the wrong tool for the job - then please abuse me.
0
11,541,288
07/18/2012 12:24:28
387,184
07/08/2010 21:42:48
2,272
151
xcode 4.3 with iOS5.1 pauses about 10secs when debug starts - simulator is much faster
I installed XCode 4.3 and debug my app on simulator and device. After this text: > GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Oct 17 16:52:01 > UTC 2011) Copyright 2004 Free Software Foundation, Inc. GDB is free > software, covered by the GNU General Public License, and you are > welcome to change it and/or distribute copies of it under certain > conditions. Type "show copying" to see the conditions. There is > absolutely no warranty for GDB. Type "show warranty" for details. > This GDB was configured as "--host=i386-apple-darwin > --target=arm-apple-darwin".tty /dev/ttys001 sharedlibrary apply-load-rules all target remote-mobile /tmp/.XcodeGDBRemote-160-66 > Switching to remote-macosx protocol mem 0x1000 0x3fffffff cache mem > 0x40000000 0xffffffff none mem 0x00000000 0x0fff none [Switching to > process 7171 thread 0x1c03] [Switching to process 7171 thread 0x1c03] on the device I have to wait about 10 secs for the app to start - while on simulator it starts immediately. On simulator the text is like this: GNU gdb 6.3.50-20050815 (Apple version gdb-1752) (Sat Jan 28 03:02:46 UTC 2012) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "x86_64-apple-darwin".sharedlibrary apply-load-rules all Attaching to process 11244. **Is this "normal" now? or is there a way to speed this up somehow?** Many thanks!
debugging
xcode4
null
null
null
null
open
xcode 4.3 with iOS5.1 pauses about 10secs when debug starts - simulator is much faster === I installed XCode 4.3 and debug my app on simulator and device. After this text: > GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Oct 17 16:52:01 > UTC 2011) Copyright 2004 Free Software Foundation, Inc. GDB is free > software, covered by the GNU General Public License, and you are > welcome to change it and/or distribute copies of it under certain > conditions. Type "show copying" to see the conditions. There is > absolutely no warranty for GDB. Type "show warranty" for details. > This GDB was configured as "--host=i386-apple-darwin > --target=arm-apple-darwin".tty /dev/ttys001 sharedlibrary apply-load-rules all target remote-mobile /tmp/.XcodeGDBRemote-160-66 > Switching to remote-macosx protocol mem 0x1000 0x3fffffff cache mem > 0x40000000 0xffffffff none mem 0x00000000 0x0fff none [Switching to > process 7171 thread 0x1c03] [Switching to process 7171 thread 0x1c03] on the device I have to wait about 10 secs for the app to start - while on simulator it starts immediately. On simulator the text is like this: GNU gdb 6.3.50-20050815 (Apple version gdb-1752) (Sat Jan 28 03:02:46 UTC 2012) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "x86_64-apple-darwin".sharedlibrary apply-load-rules all Attaching to process 11244. **Is this "normal" now? or is there a way to speed this up somehow?** Many thanks!
0
11,541,289
07/18/2012 12:24:31
559,144
12/31/2010 09:34:23
22,302
1,470
how to get current username instead of AppPool identity in a logfile with Log4Net
we are using Log4Net from our ASP.NET MVC3 application, all works fine but we would like to see the current username instead of the application pool's identity in the log files, this is the appender configuration we are using: <log4net> <appender name="FileAppender" type="log4net.Appender.RollingFileAppender"> <threshold value="ALL" /> <immediateFlush>true</immediateFlush> <lockingModel type="log4net.Appender.FileAppender+MinimalLock" /> <encoding value="utf-8" /> <file value="C:\Logs\MyLogs.log" /> <appendToFile value="true" /> <rollingStyle value="Date" /> <maxSizeRollBackups value="30" /> <maximumFileSize value="25MB" /> <staticLogFileName value="true" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="[%property{log4net:HostName}] - %username%newline%utcdate - %-5level - %message%newline" /> </layout> </appender> <root> <priority value="ALL" /> <appender-ref ref="FileAppender" /> </root> </log4net> so it seems like the property: `%username` is retrieving the value of: WindowsIdentity.GetCurrent().Name instead of what we would need: `HttpContext.Current.User` any idea on how we can solve this easily in the web.config without creating custom properties or additional log4net derived classes? if possible at all otherwise if custom property is the only way we can live with that I guess :) thanks!
c#
.net
asp.net-mvc-3
log4net
null
null
open
how to get current username instead of AppPool identity in a logfile with Log4Net === we are using Log4Net from our ASP.NET MVC3 application, all works fine but we would like to see the current username instead of the application pool's identity in the log files, this is the appender configuration we are using: <log4net> <appender name="FileAppender" type="log4net.Appender.RollingFileAppender"> <threshold value="ALL" /> <immediateFlush>true</immediateFlush> <lockingModel type="log4net.Appender.FileAppender+MinimalLock" /> <encoding value="utf-8" /> <file value="C:\Logs\MyLogs.log" /> <appendToFile value="true" /> <rollingStyle value="Date" /> <maxSizeRollBackups value="30" /> <maximumFileSize value="25MB" /> <staticLogFileName value="true" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="[%property{log4net:HostName}] - %username%newline%utcdate - %-5level - %message%newline" /> </layout> </appender> <root> <priority value="ALL" /> <appender-ref ref="FileAppender" /> </root> </log4net> so it seems like the property: `%username` is retrieving the value of: WindowsIdentity.GetCurrent().Name instead of what we would need: `HttpContext.Current.User` any idea on how we can solve this easily in the web.config without creating custom properties or additional log4net derived classes? if possible at all otherwise if custom property is the only way we can live with that I guess :) thanks!
0
11,541,290
07/18/2012 12:24:35
1,502,259
07/04/2012 18:21:35
3
0
Google Maps GMT timezone offset
been going through the docs , can find what im looking for, I need to find the timzone offset e.g gmt +2:00 . just need the the +2 part , clcik event is registered.
google
maps
null
null
null
null
open
Google Maps GMT timezone offset === been going through the docs , can find what im looking for, I need to find the timzone offset e.g gmt +2:00 . just need the the +2 part , clcik event is registered.
0
11,746,875
07/31/2012 18:44:25
1,542,594
07/21/2012 11:30:12
6
1
Android, How to make the task of the app unclosable? Only closable by task killing
I'm developing an app that have to be always running and be only closable with a task killer or similar. I have in the manifest: android:persistent="true" Although is not closing when pressing home button, I find it closed from time to time and I don't want this to happen. I user want, can close app by killing it from a custom launcher or using task killer. Any suggestions? thanks in advance P.D.: how can you exit the app with the back button, but not closing it, I mean stop showing the app or any of its activities but the app should continue running in background.
android
running
taskkill
closeable
null
null
open
Android, How to make the task of the app unclosable? Only closable by task killing === I'm developing an app that have to be always running and be only closable with a task killer or similar. I have in the manifest: android:persistent="true" Although is not closing when pressing home button, I find it closed from time to time and I don't want this to happen. I user want, can close app by killing it from a custom launcher or using task killer. Any suggestions? thanks in advance P.D.: how can you exit the app with the back button, but not closing it, I mean stop showing the app or any of its activities but the app should continue running in background.
0
11,337,358
07/05/2012 02:58:08
1,502,783
07/05/2012 02:21:52
1
0
Posting a picture on Facbook
I'm new to C# Facebook SDK so I want to know how things works. First I want to know how to post a picture with description on Facebook page like facebook.com/TennisHelper Picture is .png and I want of it to be posted on page's timeline wall. Thank you
c#
facebook
sdk
null
null
null
open
Posting a picture on Facbook === I'm new to C# Facebook SDK so I want to know how things works. First I want to know how to post a picture with description on Facebook page like facebook.com/TennisHelper Picture is .png and I want of it to be posted on page's timeline wall. Thank you
0
11,349,332
07/05/2012 17:20:13
1,440,196
06/06/2012 15:42:38
1
0
Recognize arbitrary file extensions in R?
I'm writing a function in R that will take the path name of a folder as its argument and return a vector containing the names of all the files in that folder which have the extension ".pvalues". myFunction <- function(path) { # return vector that contains the names of all files # in this folder that end in extension ".pvalues" } I know how to get the names of the files in the folder, like so: > list.files("/Users/me/myfolder/") [1] "myfile.txt" [2] "myfile.txt.a" [3] "myfile.txt.b" [4] "myfile.txt.a.pvalues" [5] "myfile.txt.b.pvalues" Is there an easy way to identify all the files in this folder that end in ".pvalues"? I cannot assume that the names will start with "myfile". They could start with "yourfile", for instance.
r
null
null
null
null
null
open
Recognize arbitrary file extensions in R? === I'm writing a function in R that will take the path name of a folder as its argument and return a vector containing the names of all the files in that folder which have the extension ".pvalues". myFunction <- function(path) { # return vector that contains the names of all files # in this folder that end in extension ".pvalues" } I know how to get the names of the files in the folder, like so: > list.files("/Users/me/myfolder/") [1] "myfile.txt" [2] "myfile.txt.a" [3] "myfile.txt.b" [4] "myfile.txt.a.pvalues" [5] "myfile.txt.b.pvalues" Is there an easy way to identify all the files in this folder that end in ".pvalues"? I cannot assume that the names will start with "myfile". They could start with "yourfile", for instance.
0
11,349,339
07/05/2012 17:20:31
27,305
10/13/2008 03:41:50
3,384
40
PDO query to return numeric array of result
I have the following code: $result = $pdo->query("SELECT * FROM t_user"); print_r($result); The result of print_r is an associative array of values. I want it to be a numeric array of values. How do I do this?
pdo
null
null
null
null
null
open
PDO query to return numeric array of result === I have the following code: $result = $pdo->query("SELECT * FROM t_user"); print_r($result); The result of print_r is an associative array of values. I want it to be a numeric array of values. How do I do this?
0
11,349,342
07/05/2012 17:20:55
767,523
05/24/2011 10:07:32
51
0
Android fading animation doesn't work on second toggle
The first animation which is from alpha 1.0 to 0.0 works. but the second one which is on the first if doesn't work. It just show up the toolbox with no animation. Can anyone here check my code? final View toolbox = layoutInflater.inflate(R.layout.toolbox, null); Button hideButton = (Button)findViewById(R.id.hide); hideButton.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { toolbox.clearAnimation(); if( toolbox.getAlpha() == 0.0f ) { Animation show = new AlphaAnimation(0.0f, 1.0f); show.setDuration(1000); show.setAnimationListener(new Animation.AnimationListener() { public void onAnimationEnd(Animation animation) { toolbox.setAlpha(1.0f); } public void onAnimationRepeat(Animation animation) { } public void onAnimationStart(Animation animation) { } }); toolbox.startAnimation(show); } else if( toolbox.getAlpha() == 1.0f ) { Animation hide = new AlphaAnimation(1.0f, 0.0f); hide.setDuration(1000); hide.setAnimationListener(new Animation.AnimationListener() { public void onAnimationEnd(Animation animation) { toolbox.setAlpha(0.0f); } public void onAnimationRepeat(Animation animation) { } public void onAnimationStart(Animation animation) { } }); toolbox.startAnimation(hide); } } }); Any idea?
android
animation
alpha
fading
null
null
open
Android fading animation doesn't work on second toggle === The first animation which is from alpha 1.0 to 0.0 works. but the second one which is on the first if doesn't work. It just show up the toolbox with no animation. Can anyone here check my code? final View toolbox = layoutInflater.inflate(R.layout.toolbox, null); Button hideButton = (Button)findViewById(R.id.hide); hideButton.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { toolbox.clearAnimation(); if( toolbox.getAlpha() == 0.0f ) { Animation show = new AlphaAnimation(0.0f, 1.0f); show.setDuration(1000); show.setAnimationListener(new Animation.AnimationListener() { public void onAnimationEnd(Animation animation) { toolbox.setAlpha(1.0f); } public void onAnimationRepeat(Animation animation) { } public void onAnimationStart(Animation animation) { } }); toolbox.startAnimation(show); } else if( toolbox.getAlpha() == 1.0f ) { Animation hide = new AlphaAnimation(1.0f, 0.0f); hide.setDuration(1000); hide.setAnimationListener(new Animation.AnimationListener() { public void onAnimationEnd(Animation animation) { toolbox.setAlpha(0.0f); } public void onAnimationRepeat(Animation animation) { } public void onAnimationStart(Animation animation) { } }); toolbox.startAnimation(hide); } } }); Any idea?
0
11,349,343
07/05/2012 17:21:00
1,439,473
06/06/2012 10:18:48
6
0
"Visiting a page" using a cron job
So I have this php script that sends an email every time someone visits it the page (opens browser, types in www.example.com/email.php and hits enter). I'm trying to find a way to trigger this on a regular basis with a cron job on a shared host. I can configure the cron to run this command: curl --dump http://www.example.com/email.php but it doesn't send the email. I've confirmed that the php script works (by manually visiting it) and that the cron job runs (I've set it on the host's control panel to 'send email everytime cron runs'), I just can't get them to work together. Any ideas?
linux
apache
cron
cron-task
null
null
open
"Visiting a page" using a cron job === So I have this php script that sends an email every time someone visits it the page (opens browser, types in www.example.com/email.php and hits enter). I'm trying to find a way to trigger this on a regular basis with a cron job on a shared host. I can configure the cron to run this command: curl --dump http://www.example.com/email.php but it doesn't send the email. I've confirmed that the php script works (by manually visiting it) and that the cron job runs (I've set it on the host's control panel to 'send email everytime cron runs'), I just can't get them to work together. Any ideas?
0
11,349,345
07/05/2012 17:21:03
1,369,622
05/02/2012 09:22:06
3
0
Extern unnamed struct object definition
I got a global object of type "unnamed-struct" and i'm trying to define it. I don't want to pollute my global namespace with such useless type (it will be used only once). **Global.h** extern struct { int x; } A; Is there any correct way to define such object?<br> I was trying this: **Global.cpp** struct { int x; } A = { 0 }; But VS2012 throws "error C2371: 'A' : redefinition; different basic types". Thanks.
c++
struct
global-variables
extern
null
null
open
Extern unnamed struct object definition === I got a global object of type "unnamed-struct" and i'm trying to define it. I don't want to pollute my global namespace with such useless type (it will be used only once). **Global.h** extern struct { int x; } A; Is there any correct way to define such object?<br> I was trying this: **Global.cpp** struct { int x; } A = { 0 }; But VS2012 throws "error C2371: 'A' : redefinition; different basic types". Thanks.
0
11,226,236
06/27/2012 12:30:04
247,245
01/09/2010 21:49:52
1,803
157
top- and bottom-border with 100% height - how?
How can I have a top-and bottom margin that's at absoulute top and bottom if main content is less than 100% and at "end of scroll" if content if larger than screen? Please see: http://jsfiddle.net/FGBZc/ (ie7 and up.) regards
css
null
null
null
null
null
open
top- and bottom-border with 100% height - how? === How can I have a top-and bottom margin that's at absoulute top and bottom if main content is less than 100% and at "end of scroll" if content if larger than screen? Please see: http://jsfiddle.net/FGBZc/ (ie7 and up.) regards
0
11,226,391
06/27/2012 12:37:09
1,445,314
06/08/2012 19:41:53
20
0
G++ ABI compatibility list
I have compiled my preload file on Ubuntu server (two files for x32 and x64), where i can get list, in which i will see with what OS my compiled files are compatible and with what i should recompile for compatibility? Thanks!
c++
linux
unix
g++
abi
null
open
G++ ABI compatibility list === I have compiled my preload file on Ubuntu server (two files for x32 and x64), where i can get list, in which i will see with what OS my compiled files are compatible and with what i should recompile for compatibility? Thanks!
0
11,226,392
06/27/2012 12:37:12
1,465,579
06/19/2012 06:44:00
55
4
when upload larger file, getting this error:Error 404 - File or directory not found
We are getting error when trying to upload a large size video file to our admin site. We are able to upload small size file without a problem, this error start happening when file size more then 10Mb, where as we already increase size by following configuration setting in web.config: <httpRuntime executionTimeout="2400" maxRequestLength="102400" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" enableVersionHeader="true" /> and Error message is when we upload larger file: Error 404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.
asp.net
web-config
null
null
null
null
open
when upload larger file, getting this error:Error 404 - File or directory not found === We are getting error when trying to upload a large size video file to our admin site. We are able to upload small size file without a problem, this error start happening when file size more then 10Mb, where as we already increase size by following configuration setting in web.config: <httpRuntime executionTimeout="2400" maxRequestLength="102400" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" enableVersionHeader="true" /> and Error message is when we upload larger file: Error 404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.
0
11,216,415
06/26/2012 21:45:15
303,479
03/28/2010 07:27:44
860
21
Msmq and sgen for xmlserialization utter failure
I 've been banging my head with this to to avail. Any ideas are much welcome! I have a client/listener application in vb.net using MSMQ and it works 100% fine when I do not use sgen.exe to generate the serializations on compile time. When using sgen, it fails on the listener part. qOrders.Formatter = New XmlMessageFormatter(New Type() {GetType(InfoMessage)}) m = qOrders.EndReceive(e.AsyncResult) It bombs on m. m.Body has the error `"Cannot deserialize the message passed as an argument. Cannot recognize the serialization format."` and the rest of the properties also have errors of not receiving a value. The assembly is strong named and the App.XmlSerializers.dll is also signed correctly. I know the dll is used because I can't delete it while the program is running. The InfoMessage class is a simple public class with 3 public string members. Inspecting the dll with Reflector, I do see that sgen has generated an InfoMessageSerializer class. The problem is not on the client side because I delete the dll and run the listener, it works as usual. So, what could be wrong here? :o Thanks, John
.net
vb.net
xml-serialization
msmq
xmlserializer
null
open
Msmq and sgen for xmlserialization utter failure === I 've been banging my head with this to to avail. Any ideas are much welcome! I have a client/listener application in vb.net using MSMQ and it works 100% fine when I do not use sgen.exe to generate the serializations on compile time. When using sgen, it fails on the listener part. qOrders.Formatter = New XmlMessageFormatter(New Type() {GetType(InfoMessage)}) m = qOrders.EndReceive(e.AsyncResult) It bombs on m. m.Body has the error `"Cannot deserialize the message passed as an argument. Cannot recognize the serialization format."` and the rest of the properties also have errors of not receiving a value. The assembly is strong named and the App.XmlSerializers.dll is also signed correctly. I know the dll is used because I can't delete it while the program is running. The InfoMessage class is a simple public class with 3 public string members. Inspecting the dll with Reflector, I do see that sgen has generated an InfoMessageSerializer class. The problem is not on the client side because I delete the dll and run the listener, it works as usual. So, what could be wrong here? :o Thanks, John
0
11,216,417
06/26/2012 21:45:18
722,114
04/23/2011 20:53:20
33
0
Understanding basic windows programming for vs2010
I'm coming from a unix background but I'm being asked to do some windows programming and I'm having trouble understanding the framework. What's the general hierarchy between win32, mfc, .NET, etc. Is there a decent tutorial online that goes over the general structure of Windows programming. I'm not exactly sure what I should be searching for.
.net
windows
winapi
mfc
null
06/26/2012 21:52:12
not a real question
Understanding basic windows programming for vs2010 === I'm coming from a unix background but I'm being asked to do some windows programming and I'm having trouble understanding the framework. What's the general hierarchy between win32, mfc, .NET, etc. Is there a decent tutorial online that goes over the general structure of Windows programming. I'm not exactly sure what I should be searching for.
1
11,226,400
06/27/2012 12:37:37
1,334,942
04/15/2012 18:49:51
133
3
Temporarily enlarge sql server command queue
Using SQL Server 2008 R2 Is it possible to enlarge the command queue and/or the wait time limit for a command to execute? I have this simple application which do not exhaust the SQL Server, but from time to time there are many concurrent similar request almost the same time, which some reach deadlocks. Reliability (being sure commands are executed) is much more important for me than performance (I do not mind if the commands will execute in a few seconds of delay). Is there a switch or a command to allow many more commands reside in a queue until executed or there is some way to make time limit before deadlocks [temporarily] much longer[, as soon as a specific type command is executed] (commands may programmed as stored procedures)?
sql-server
null
null
null
null
null
open
Temporarily enlarge sql server command queue === Using SQL Server 2008 R2 Is it possible to enlarge the command queue and/or the wait time limit for a command to execute? I have this simple application which do not exhaust the SQL Server, but from time to time there are many concurrent similar request almost the same time, which some reach deadlocks. Reliability (being sure commands are executed) is much more important for me than performance (I do not mind if the commands will execute in a few seconds of delay). Is there a switch or a command to allow many more commands reside in a queue until executed or there is some way to make time limit before deadlocks [temporarily] much longer[, as soon as a specific type command is executed] (commands may programmed as stored procedures)?
0
11,226,368
06/27/2012 12:36:25
1,485,520
06/27/2012 11:47:28
1
0
Force missing parameters in JavaScript
When you call a function in JavaScript and you miss to pass some parameter, nothing happens. This makes the code harder to debug, so I would like to change that behavior. I've seen http://stackoverflow.com/questions/411352/how-best-to-determine-if-an-argument-is-not-sent-to-the-javascript-function but I want a solution with a constant number of typed lines of code; not typing extra code for each function. I've thought about automatically prefixing the code of all functions with that code, by modifying the constructor of the ("first-class") Function object. Inspired by http://stackoverflow.com/questions/6529195/changing-constructor-in-javascript I've first tested whether I can change the constructor of the Function object, like this: function Function2 () { this.color = "white"; } Function.prototype = new Function2(); f = new Function(); alert(f.color); But it alerts "undefined" instead of "white", so it is not working, so I've don't further explored this technique. Do you know any solution for this problem at any level? Hacking the guts of JavaScript would be OK but any other practical tip on how to find missing arguments would be OK as well.
javascript
null
null
null
null
null
open
Force missing parameters in JavaScript === When you call a function in JavaScript and you miss to pass some parameter, nothing happens. This makes the code harder to debug, so I would like to change that behavior. I've seen http://stackoverflow.com/questions/411352/how-best-to-determine-if-an-argument-is-not-sent-to-the-javascript-function but I want a solution with a constant number of typed lines of code; not typing extra code for each function. I've thought about automatically prefixing the code of all functions with that code, by modifying the constructor of the ("first-class") Function object. Inspired by http://stackoverflow.com/questions/6529195/changing-constructor-in-javascript I've first tested whether I can change the constructor of the Function object, like this: function Function2 () { this.color = "white"; } Function.prototype = new Function2(); f = new Function(); alert(f.color); But it alerts "undefined" instead of "white", so it is not working, so I've don't further explored this technique. Do you know any solution for this problem at any level? Hacking the guts of JavaScript would be OK but any other practical tip on how to find missing arguments would be OK as well.
0
11,650,215
07/25/2012 12:56:08
415,784
08/10/2010 05:22:54
83,467
2,329
How to get the type argument to a generic method?
Suppose I've this generic method void ActivateView<T>(ViewCommand command) where T : IPresenter { //code } And I've an action as: Action<ViewCommand> action = this.ActivateView<DiagnosticPresenter>; Now given `action `, how can I know the type arument to the generic method `ActivateView`? In this case, it should be `DiagnosticPresenter`. So I'm expecting an instance of `Type` equal to `typeof(DiagnosticPresenter)` as: Type type = Magic(action); //what should Magic do? if ( type == typeof(DiagnosticPresenter)) { //I want to do something here! } Is that possible? How should I implement`Magic()`?
c#
generics
delegates
null
null
null
open
How to get the type argument to a generic method? === Suppose I've this generic method void ActivateView<T>(ViewCommand command) where T : IPresenter { //code } And I've an action as: Action<ViewCommand> action = this.ActivateView<DiagnosticPresenter>; Now given `action `, how can I know the type arument to the generic method `ActivateView`? In this case, it should be `DiagnosticPresenter`. So I'm expecting an instance of `Type` equal to `typeof(DiagnosticPresenter)` as: Type type = Magic(action); //what should Magic do? if ( type == typeof(DiagnosticPresenter)) { //I want to do something here! } Is that possible? How should I implement`Magic()`?
0
11,650,216
07/25/2012 12:56:20
1,550,311
07/25/2012 02:22:05
51
1
php application went red aws beanstalk
I have a PHP application which goes RED while deployment to Elstic BeanStalk. I simply zip my app folder and upload it. Do I need to check/change anything over here. I urgently need this app to be working. Would really appreciate if any one could look into it or provide me some pointers to solve the issue. Thanks
php
amazon-web-services
beanstalk
null
null
null
open
php application went red aws beanstalk === I have a PHP application which goes RED while deployment to Elstic BeanStalk. I simply zip my app folder and upload it. Do I need to check/change anything over here. I urgently need this app to be working. Would really appreciate if any one could look into it or provide me some pointers to solve the issue. Thanks
0
11,650,217
07/25/2012 12:56:20
1,550,884
07/25/2012 07:43:27
4
0
Is there a workaround for font-family: inherit for IE7
i have a css class: text_css in which i want to apply the inherit property.this is working fine for IE8 and IE9. i know inherit dont work for IE7. can anyone suggest any workaround for this?
css
ie7-bug
null
null
null
null
open
Is there a workaround for font-family: inherit for IE7 === i have a css class: text_css in which i want to apply the inherit property.this is working fine for IE8 and IE9. i know inherit dont work for IE7. can anyone suggest any workaround for this?
0
11,650,236
07/25/2012 12:56:58
1,551,653
07/25/2012 12:51:12
1
0
QtJambi QtWebKit in multiple threads
I'm developing a simple site scrapper that will also be able to fill some html forms in java, is it possible to use QtJambi QWebKit as an headless browser in multiple threads?, I read that QWebPage can only be used from the main thread.
java
qtwebkit
qt-jambi
null
null
null
open
QtJambi QtWebKit in multiple threads === I'm developing a simple site scrapper that will also be able to fill some html forms in java, is it possible to use QtJambi QWebKit as an headless browser in multiple threads?, I read that QWebPage can only be used from the main thread.
0
11,650,237
07/25/2012 12:57:05
333,486
05/05/2010 13:43:18
2,215
112
Cache MVC PartialView returned from ajax get
Is is possible to cache an MVC partial view being returned from an ajax get request? Here's my scenario. I'm calling a url which points to a controller method that returns a partial view: Controller method: public ActionResult SignIn() { return View("SignIn"); } Ajax request to get the view: $.get('/Home/SignIn', function (data) { $('.content').html(data); }); Is it possible to cache my "SignIn" view so that each time the user clicks it, it doesn't have to go back to the server to fetch the view from the controller again?
jquery
ajax
asp.net-mvc-3
mvc
jquery-ajax
null
open
Cache MVC PartialView returned from ajax get === Is is possible to cache an MVC partial view being returned from an ajax get request? Here's my scenario. I'm calling a url which points to a controller method that returns a partial view: Controller method: public ActionResult SignIn() { return View("SignIn"); } Ajax request to get the view: $.get('/Home/SignIn', function (data) { $('.content').html(data); }); Is it possible to cache my "SignIn" view so that each time the user clicks it, it doesn't have to go back to the server to fetch the view from the controller again?
0
11,650,239
07/25/2012 12:57:11
1,496,443
07/02/2012 15:14:20
179
9
Open Source Rich Text Editor for website
My company is currently looking for an open source text editor that we can place on our website that behaves a lot like Stack-overflow editor and one that denies html input.
jquery
html
richtexteditor
null
null
07/25/2012 13:18:20
not constructive
Open Source Rich Text Editor for website === My company is currently looking for an open source text editor that we can place on our website that behaves a lot like Stack-overflow editor and one that denies html input.
4
11,650,256
07/25/2012 12:58:05
1,551,679
07/25/2012 12:56:14
1
0
Subquery returned more than 1 value. This is not permitted when the subquery follows
I have the following script which has stopped working due the error in the title. Could someone please provide some assistance? SELECT DISTINCT TOP 100 percent Locs.lCustomerGroupPK, Locs.lCustomerID, Locs.Customer_Group_Name, Locs.Customer_Name, Locs.Location_Name, TY.ThisYearsSales, (SELECT ThisYearsSales FROM dbo.Vw_Level_3_Sales_This_Year WHERE (lLocationID = Locs.lLocationID2 OR lLocationID = Locs.llocationid) AND (Current_Read_Date = TY.Current_Read_Date - 364) AND (ThisYearsSales <= 400)) AS LastYearsSales, TY.Current_Read_Date - 1 AS Current_Read_Date into #tmplocationlflsales FROM dbo.Vw_Level_3_Sales_This_Year AS TY INNER JOIN dbo.vw_locations_Like_For_Like_Previous AS Locs ON TY.lLocationID = Locs.llocationid OR TY.lLocationID = Locs.lLocationID2 WHERE (TY.ThisYearsSales <= 400) AND (TY.Current_Read_Date = @RecordDate) and TY.ThisYearsSales is not null and (SELECT ThisYearsSales FROM dbo.Vw_Level_3_Sales_This_Year WHERE (lLocationID = Locs.lLocationID2 OR lLocationID = Locs.llocationid) AND (Current_Read_Date = TY.Current_Read_Date - 364) AND (ThisYearsSales <= 400)) is not null ORDER BY Locs.Customer_Group_Name, Locs.Customer_Name, Locs.Location_Name, Current_Read_Date
sql
null
null
null
null
null
open
Subquery returned more than 1 value. This is not permitted when the subquery follows === I have the following script which has stopped working due the error in the title. Could someone please provide some assistance? SELECT DISTINCT TOP 100 percent Locs.lCustomerGroupPK, Locs.lCustomerID, Locs.Customer_Group_Name, Locs.Customer_Name, Locs.Location_Name, TY.ThisYearsSales, (SELECT ThisYearsSales FROM dbo.Vw_Level_3_Sales_This_Year WHERE (lLocationID = Locs.lLocationID2 OR lLocationID = Locs.llocationid) AND (Current_Read_Date = TY.Current_Read_Date - 364) AND (ThisYearsSales <= 400)) AS LastYearsSales, TY.Current_Read_Date - 1 AS Current_Read_Date into #tmplocationlflsales FROM dbo.Vw_Level_3_Sales_This_Year AS TY INNER JOIN dbo.vw_locations_Like_For_Like_Previous AS Locs ON TY.lLocationID = Locs.llocationid OR TY.lLocationID = Locs.lLocationID2 WHERE (TY.ThisYearsSales <= 400) AND (TY.Current_Read_Date = @RecordDate) and TY.ThisYearsSales is not null and (SELECT ThisYearsSales FROM dbo.Vw_Level_3_Sales_This_Year WHERE (lLocationID = Locs.lLocationID2 OR lLocationID = Locs.llocationid) AND (Current_Read_Date = TY.Current_Read_Date - 364) AND (ThisYearsSales <= 400)) is not null ORDER BY Locs.Customer_Group_Name, Locs.Customer_Name, Locs.Location_Name, Current_Read_Date
0
11,650,257
07/25/2012 12:58:10
387,981
07/09/2010 17:21:44
2,361
94
Custom JSF EL function, date converter and current component
We use bookmarkable URLs and GET methods. We have some parameters which contains dates and are converted using the default DateTimeConverter. <f:viewParam name = "parameter" value = "#{model.parameter}" converter = "javax.faces.DateTime" /> This works flawlessly and parameters are converter to and from String When we have to generate links to these pages we need to convert the parameters to a correctly formatted string (as the `<f:param>` tag does not support a converter). I came up with the following solution but I have the feeling the it could be done more elegantly. I defined a custom EL function `convertDate` <f:param name="parameter" value="#{ func:convertDate( model.someDate, component ) }" /> with the following implementation public static String convertDate( Date date, UIComponent uiComponent ) { DateTimeConverter dateTimeConverter = new DateTimeConverter(); return dateTimeConverter.getAsString( FacesContext.getCurrentInstance(), uiComponent, date ); } The idea is to use the default `javax.faces.convert.DateTimeConverter` to convert the date but I need a reference to the corresponding `UIComponent`. Does the usage of `#{component}` make sense? Is there a better way?
jsf
el
null
null
null
null
open
Custom JSF EL function, date converter and current component === We use bookmarkable URLs and GET methods. We have some parameters which contains dates and are converted using the default DateTimeConverter. <f:viewParam name = "parameter" value = "#{model.parameter}" converter = "javax.faces.DateTime" /> This works flawlessly and parameters are converter to and from String When we have to generate links to these pages we need to convert the parameters to a correctly formatted string (as the `<f:param>` tag does not support a converter). I came up with the following solution but I have the feeling the it could be done more elegantly. I defined a custom EL function `convertDate` <f:param name="parameter" value="#{ func:convertDate( model.someDate, component ) }" /> with the following implementation public static String convertDate( Date date, UIComponent uiComponent ) { DateTimeConverter dateTimeConverter = new DateTimeConverter(); return dateTimeConverter.getAsString( FacesContext.getCurrentInstance(), uiComponent, date ); } The idea is to use the default `javax.faces.convert.DateTimeConverter` to convert the date but I need a reference to the corresponding `UIComponent`. Does the usage of `#{component}` make sense? Is there a better way?
0
11,650,258
07/25/2012 12:58:16
1,543,390
07/22/2012 00:52:05
3
0
Receiving CSRF failed. Request aborted
I followed the advice on the error response page, but it still does not work. here is my code; views.py from django.http import HttpResponse from django.template import RequestContext from django.shortcuts import render_to_response from forms import * from models import * def main_page(request): if request.method == 'POST': form = UserForm(request.POST) if form.is_valid(): username = form.cleaned_data['username'] icecream = form.cleaned_data['icecream'] output = ''' <html> <head> <title> Reading user data </title> </head> <body> <h1> Your ice cream is: %s </h1> </body> </html>''' %( icecream ) return HttpResponse(output) else: form = UserForm() variables = RequestContext(request, { 'form': form}) return render_to_response( 'icecream.html', variables, context_instance=RequestContext (request)) icecream.html (template) <html> <head> <title>Getting user input</title> </head> <body> <h1>Getting user input</h1> <form method="post" action="."> {% csrf_token %} {{ form.as_p }} <input type="submit" value="Submit"/> </form> </body> </html> urls.py from django.conf.urls.defaults import * from forms.views import * # Uncomment the next two lines to enable the admin: # from django.contrib import admin # admin.autodiscover() urlpatterns = patterns('', (r'^$', main_page), settings.py (pertinent section) MIDDLEWARE_CLASSES = ( 'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', # Uncomment the next line for simple clickjacking protection: # 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) I am in learning mode so this is just an internal site and I am accessing it using localhost. I have never had this problem before with the other chapters of the book I am learning from. This is the first time I am working with forms and posting. I have looked at a number of answered questions on this site, but nothing seems to help. All help is appreciated.
django
django-csrf
null
null
null
null
open
Receiving CSRF failed. Request aborted === I followed the advice on the error response page, but it still does not work. here is my code; views.py from django.http import HttpResponse from django.template import RequestContext from django.shortcuts import render_to_response from forms import * from models import * def main_page(request): if request.method == 'POST': form = UserForm(request.POST) if form.is_valid(): username = form.cleaned_data['username'] icecream = form.cleaned_data['icecream'] output = ''' <html> <head> <title> Reading user data </title> </head> <body> <h1> Your ice cream is: %s </h1> </body> </html>''' %( icecream ) return HttpResponse(output) else: form = UserForm() variables = RequestContext(request, { 'form': form}) return render_to_response( 'icecream.html', variables, context_instance=RequestContext (request)) icecream.html (template) <html> <head> <title>Getting user input</title> </head> <body> <h1>Getting user input</h1> <form method="post" action="."> {% csrf_token %} {{ form.as_p }} <input type="submit" value="Submit"/> </form> </body> </html> urls.py from django.conf.urls.defaults import * from forms.views import * # Uncomment the next two lines to enable the admin: # from django.contrib import admin # admin.autodiscover() urlpatterns = patterns('', (r'^$', main_page), settings.py (pertinent section) MIDDLEWARE_CLASSES = ( 'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', # Uncomment the next line for simple clickjacking protection: # 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) I am in learning mode so this is just an internal site and I am accessing it using localhost. I have never had this problem before with the other chapters of the book I am learning from. This is the first time I am working with forms and posting. I have looked at a number of answered questions on this site, but nothing seems to help. All help is appreciated.
0
11,650,259
07/25/2012 12:58:16
276,070
02/18/2010 12:59:37
11,191
406
Why does ExpandoObject not work as expected?
Currently, not even the simplest examples of using the 'ExpandoObject' work on my machine. Both dynamic obj = new ExpandoObject(); obj.Value = 10; var action = new Action<string>((line) => Console.WriteLine(line)); obj.WriteNow = action; obj.WriteNow(obj.Value.ToString()); [(from this website)][1] and dynamic sampleObject = new ExpandoObject(); sampleObject.test = "Dynamic Property"; Console.WriteLine(sampleObject.test); [(from the MSDN examples)][2] fail with a RuntimeBinderException. I presume I've misconfigured something, but I am at a loss about what it might be. I am using .NET v4.0.30319 and Visual Studio 2010 SP1 Premium. [1]: http://www.codeproject.com/Articles/62839/Adventures-with-C-4-0-dynamic-ExpandoObject-Elasti [2]: http://msdn.microsoft.com/en-us/library/system.dynamic.expandoobject.aspx
c#
.net
dynamic
null
null
07/26/2012 12:08:22
too localized
Why does ExpandoObject not work as expected? === Currently, not even the simplest examples of using the 'ExpandoObject' work on my machine. Both dynamic obj = new ExpandoObject(); obj.Value = 10; var action = new Action<string>((line) => Console.WriteLine(line)); obj.WriteNow = action; obj.WriteNow(obj.Value.ToString()); [(from this website)][1] and dynamic sampleObject = new ExpandoObject(); sampleObject.test = "Dynamic Property"; Console.WriteLine(sampleObject.test); [(from the MSDN examples)][2] fail with a RuntimeBinderException. I presume I've misconfigured something, but I am at a loss about what it might be. I am using .NET v4.0.30319 and Visual Studio 2010 SP1 Premium. [1]: http://www.codeproject.com/Articles/62839/Adventures-with-C-4-0-dynamic-ExpandoObject-Elasti [2]: http://msdn.microsoft.com/en-us/library/system.dynamic.expandoobject.aspx
3
11,650,263
07/25/2012 12:58:30
1,551,662
07/25/2012 12:53:03
1
0
How to implement a hover-over cursor tooltip dictionary?
I'm planning to write a program that will act like Stardict's scan feature, where the program runs in the background, and when the user selects a piece of text from anywhere on the screen, a tooltip pops up with a dictionary entry for that text. I'm targetting the Windows platform. I've had minimal experience with Win32 API, and I'm currently learning Qt. Could anyone just list some options I have, and possible functions to implement this? I just want to know how to get a tooltip-like thing to pop up. The dictionary stuff, I'll figure out myself. I'll take any answer that targets the windows platform, but here are the recommended implementation environments: - Java - .NET - Qt / C++ - Gtk+
dictionary
tooltip
null
null
null
null
open
How to implement a hover-over cursor tooltip dictionary? === I'm planning to write a program that will act like Stardict's scan feature, where the program runs in the background, and when the user selects a piece of text from anywhere on the screen, a tooltip pops up with a dictionary entry for that text. I'm targetting the Windows platform. I've had minimal experience with Win32 API, and I'm currently learning Qt. Could anyone just list some options I have, and possible functions to implement this? I just want to know how to get a tooltip-like thing to pop up. The dictionary stuff, I'll figure out myself. I'll take any answer that targets the windows platform, but here are the recommended implementation environments: - Java - .NET - Qt / C++ - Gtk+
0
11,471,419
07/13/2012 13:25:01
74,896
03/06/2009 21:55:17
1,433
83
android lunch another PreferenceScreen relative to the package
I am trying to lunch another PreferenceScreen from within a SreferenceScreen <PreferenceCategory android:title="Advanced" > <Preference android:key="mykey" android:persistent="false" android:title="Advanced settings"> <intent android:targetPackage="com.mypackage" android:targetClass="com.mypackage.SettingsAdvancedActivity"/> </Preference> It works fine but I want to change it so that it would be relative to the package, something like <<PreferenceCategory android:title="Advanced" > <Preference android:key="mykey" android:persistent="false" android:title="Advanced settings"> <intent android:targetPackage="." android:targetClass=".SettingsAdvancedActivity"/> </Preference> is it possible? You might ask why? In case I have to change package name life would be easier
android
preferencescreen
null
null
null
null
open
android lunch another PreferenceScreen relative to the package === I am trying to lunch another PreferenceScreen from within a SreferenceScreen <PreferenceCategory android:title="Advanced" > <Preference android:key="mykey" android:persistent="false" android:title="Advanced settings"> <intent android:targetPackage="com.mypackage" android:targetClass="com.mypackage.SettingsAdvancedActivity"/> </Preference> It works fine but I want to change it so that it would be relative to the package, something like <<PreferenceCategory android:title="Advanced" > <Preference android:key="mykey" android:persistent="false" android:title="Advanced settings"> <intent android:targetPackage="." android:targetClass=".SettingsAdvancedActivity"/> </Preference> is it possible? You might ask why? In case I have to change package name life would be easier
0
11,471,424
07/13/2012 13:25:22
599,970
02/02/2011 12:15:44
2,340
97
django/mod_wsgi unable to import module (which is in a directory on the python path)
I am running django with mod_wsgi/apache and receive this ImportError: Request Method: GET Django Version: 1.2.5 Exception Type: ImportError Exception Value: No module named adspygoogle.dfp.DfpClient This module is inside my django `app/libs` directory, which is included in the python path. Strangely, when using `./manage.py shell` or `./manage.py runserver` with `pdb.set_trace()`, dropping into the debugger just before the import, I am able to import the module without any problems. Does anyone have any idea what could be causing this?
python
django
mod-wsgi
null
null
null
open
django/mod_wsgi unable to import module (which is in a directory on the python path) === I am running django with mod_wsgi/apache and receive this ImportError: Request Method: GET Django Version: 1.2.5 Exception Type: ImportError Exception Value: No module named adspygoogle.dfp.DfpClient This module is inside my django `app/libs` directory, which is included in the python path. Strangely, when using `./manage.py shell` or `./manage.py runserver` with `pdb.set_trace()`, dropping into the debugger just before the import, I am able to import the module without any problems. Does anyone have any idea what could be causing this?
0
11,471,378
07/13/2012 13:22:20
1,477,749
06/24/2012 06:48:26
10
1
Including ajax based page in prime faces tab
I have included pages in prime faces tab. I have used id based form in each page. when I enable ajax for each page, then it is not working in the tab.
ajax
jsf-2.0
primefaces
null
null
null
open
Including ajax based page in prime faces tab === I have included pages in prime faces tab. I have used id based form in each page. when I enable ajax for each page, then it is not working in the tab.
0
11,471,379
07/13/2012 13:22:20
1,486,147
06/27/2012 15:29:33
36
0
Java: Escape character needed on *?
I am trying to search an ASCII file for *CELL_OPEN and *CELL_CLOSE with the * being itself (i.e. not an operator) I have this code: do { importstring++; numberline = ImportFiles.importarray.get(importstring); }while (!numberline.startsWith("*CELL_CLOSE")) This is identical other than an extra method for *CELL_OPEN. When I run this, it doesn't find *CELL_OPEN or *CELL_CLOSE. As such I get an index out of bounds error. Do I need an escape for * to be taken literally? I suspect so. If I do, what is the correct syntax for it? \* does not work. \\* has the same result as no escape. Thanks.
java
escaping
null
null
null
null
open
Java: Escape character needed on *? === I am trying to search an ASCII file for *CELL_OPEN and *CELL_CLOSE with the * being itself (i.e. not an operator) I have this code: do { importstring++; numberline = ImportFiles.importarray.get(importstring); }while (!numberline.startsWith("*CELL_CLOSE")) This is identical other than an extra method for *CELL_OPEN. When I run this, it doesn't find *CELL_OPEN or *CELL_CLOSE. As such I get an index out of bounds error. Do I need an escape for * to be taken literally? I suspect so. If I do, what is the correct syntax for it? \* does not work. \\* has the same result as no escape. Thanks.
0
11,471,425
07/13/2012 13:25:23
565,968
01/06/2011 19:34:37
4,288
89
javascript closure to remember initial state
I have a div in CSS that works like this: SomeDiv has another class, that's sometimes SomeRedDiv and other times SomeBlueDiv. When I mouseenter on SomeDiv, I want it to add the class SomeYellowDiv. But when I mouseleave, I want it each div to return to its initial state, either SomeRedDiv or SomeBlueDiv. This is what I have: <div class="SomeDiv SomeRedDiv"></div> <div class="SomeDiv SomeBlueDiv"></div> $('.SomeDiv').mouseenter(function () { // this makes all SomeDivs turn yellow $(this).removeClass().addClass('SomeDiv SomeYellowDiv'); }); $('.SomeDiv').mouseleave(function () { // here I want to use closure so that the function remembers // which class it initially was; SomeBlueDiv or SomeRedDiv $('this).removeClass().addClass('SomeDiv'); // add the initial color class }); I could do this with a global but I want to see if a closure would make my code better; I know the concept of closure that allows functions to remember their state but I'm not sure how to make it work here. Thanks for your suggestions.
javascript
null
null
null
null
null
open
javascript closure to remember initial state === I have a div in CSS that works like this: SomeDiv has another class, that's sometimes SomeRedDiv and other times SomeBlueDiv. When I mouseenter on SomeDiv, I want it to add the class SomeYellowDiv. But when I mouseleave, I want it each div to return to its initial state, either SomeRedDiv or SomeBlueDiv. This is what I have: <div class="SomeDiv SomeRedDiv"></div> <div class="SomeDiv SomeBlueDiv"></div> $('.SomeDiv').mouseenter(function () { // this makes all SomeDivs turn yellow $(this).removeClass().addClass('SomeDiv SomeYellowDiv'); }); $('.SomeDiv').mouseleave(function () { // here I want to use closure so that the function remembers // which class it initially was; SomeBlueDiv or SomeRedDiv $('this).removeClass().addClass('SomeDiv'); // add the initial color class }); I could do this with a global but I want to see if a closure would make my code better; I know the concept of closure that allows functions to remember their state but I'm not sure how to make it work here. Thanks for your suggestions.
0
11,471,426
07/13/2012 13:25:27
1,350,341
04/23/2012 01:56:27
35
1
Auto Email Database results
I need some help conceptualizing a project... I have to run 4 different queries and send the results as the body of an email to defined recipients. The problem is I will need to automate this process as I need to send the results every morning at 9am... My initial thought was to just setup a job in SQL Server and have that email the results, however this particular database is in SQL Server 2000... So I then thought I could create a C# or Visual Basic program and use windows scheduler to run and email the reports, however I again come back to the fact that it is SQL Server 2000 and there is not a Stored Procedure for send mail. I was able to find a Send Mail stored procedure online, but then couldn't figure out how to attach results to a parameter. Any insight on how others would handle this would be greatly appreciated. Thanks, AJ
c#
sql
sql-server
query
sql-server-2000
null
open
Auto Email Database results === I need some help conceptualizing a project... I have to run 4 different queries and send the results as the body of an email to defined recipients. The problem is I will need to automate this process as I need to send the results every morning at 9am... My initial thought was to just setup a job in SQL Server and have that email the results, however this particular database is in SQL Server 2000... So I then thought I could create a C# or Visual Basic program and use windows scheduler to run and email the reports, however I again come back to the fact that it is SQL Server 2000 and there is not a Stored Procedure for send mail. I was able to find a Send Mail stored procedure online, but then couldn't figure out how to attach results to a parameter. Any insight on how others would handle this would be greatly appreciated. Thanks, AJ
0
11,471,428
07/13/2012 13:25:28
961,148
09/23/2011 12:31:10
66
3
Find & Replace with a wildcard in Xcode 4.3.3
I'm trying to find all instances of text inside "" marks with a semi-colon directly after them, and replace the text inside the "" marks. So, for example: "FirstKey" = "First value"; "SecondKey" = "Second value"; "ThirdKey" = "Third value"; Would find only those values after the equals signs, and could replace them all (with a single string) at once, like so: "FirstKey" = "BLAH"; "SecondKey" = "BLAH"; "ThirdKey" = "BLAH"; How can I do this? I found some stuff referring to regular expressions in Xcode 3, but such functionality seems either gone or hidden in Xcode 4.
regex
xcode4
find-and-replace
null
null
null
open
Find & Replace with a wildcard in Xcode 4.3.3 === I'm trying to find all instances of text inside "" marks with a semi-colon directly after them, and replace the text inside the "" marks. So, for example: "FirstKey" = "First value"; "SecondKey" = "Second value"; "ThirdKey" = "Third value"; Would find only those values after the equals signs, and could replace them all (with a single string) at once, like so: "FirstKey" = "BLAH"; "SecondKey" = "BLAH"; "ThirdKey" = "BLAH"; How can I do this? I found some stuff referring to regular expressions in Xcode 3, but such functionality seems either gone or hidden in Xcode 4.
0
11,471,409
07/13/2012 13:24:09
1,522,125
07/12/2012 21:58:22
1
0
Best way to use custom Roles with Active Directory login
I looking for the best solution to my problem, what we are wanting to do is use active directory for our base login so we don't have to manage passwords ect. But instead of using AD groups we are wanting to create custom roles. So I might have one role that will equal 5 different AD groups. What I am thinking of doing is dumping all users in a specific group via c# to a custom user table that links to a roleid to userid table. Anyone have any thoughts on this? But I also need to manage the custom user table in a way if someone gets removed from one of these groups then they need to loose access, not sure how to handle that one. Currently my method looks something like this: using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "SETON")) { //Gets all Users in a AD Group using (GroupPrincipal grp = GroupPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, groupName)) { //Mkae sure group is not null if (grp != null) { foreach (Principal p in grp.GetMembers()) { //Sets up Variables to enter into Finance User Table string UserName = p.SamAccountName; string DisplayName = p.Name; string emailAddress = p.UserPrincipalName; //Get users detials by user using (UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, UserName)) { if (userPrincipal != null) { //Test to see if user is in AD Group bool inRole = userPrincipal.IsMemberOf(grp); if (inRole) { //Test to See if UserName already exists in Finance User Table var ds = User.GetUserList(UserName); //If don't exist add them and to the new Role if (ds.Tables[0].Rows.Count == 0) { //Add User to FinanceUSer Table Seton.Roster.User user = new User(); user.UserName = UserName; user.Name = DisplayName; int id = user.Save(); //Get RoleID by RoleName with Method var roleDS = SecurityRole.GetRoleList(roleName); if (roleDS.Tables[0].Rows.Count > 0) { var roleDR = roleDS.Tables[0].Rows[0]; int roleid = Convert.ToInt32(roleDR["roleid"].ToString()); SecurityRoleUserLink.AddNewLink(roleid, id); } } //if they exist just Get thier userid and add them to new Role else { //Get UserID of existing FinanceUser var userDR = ds.Tables[0].Rows[0]; int id = Convert.ToInt32(userDR["userid"].ToString()); //Get RoleID by RoleName with Method var roleDS = SecurityRole.GetRoleList(roleName); if (roleDS.Tables[0].Rows.Count > 0) { var roleDR = roleDS.Tables[0].Rows[0]; int roleid = Convert.ToInt32(roleDR["roleid"].ToString()); //Test to see if user already in this role if(!SecurityRoleUserLink.UserInRole(id,roleid)) SecurityRoleUserLink.AddNewLink(roleid, id);
c#
active-directory
roles
null
null
null
open
Best way to use custom Roles with Active Directory login === I looking for the best solution to my problem, what we are wanting to do is use active directory for our base login so we don't have to manage passwords ect. But instead of using AD groups we are wanting to create custom roles. So I might have one role that will equal 5 different AD groups. What I am thinking of doing is dumping all users in a specific group via c# to a custom user table that links to a roleid to userid table. Anyone have any thoughts on this? But I also need to manage the custom user table in a way if someone gets removed from one of these groups then they need to loose access, not sure how to handle that one. Currently my method looks something like this: using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "SETON")) { //Gets all Users in a AD Group using (GroupPrincipal grp = GroupPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, groupName)) { //Mkae sure group is not null if (grp != null) { foreach (Principal p in grp.GetMembers()) { //Sets up Variables to enter into Finance User Table string UserName = p.SamAccountName; string DisplayName = p.Name; string emailAddress = p.UserPrincipalName; //Get users detials by user using (UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, UserName)) { if (userPrincipal != null) { //Test to see if user is in AD Group bool inRole = userPrincipal.IsMemberOf(grp); if (inRole) { //Test to See if UserName already exists in Finance User Table var ds = User.GetUserList(UserName); //If don't exist add them and to the new Role if (ds.Tables[0].Rows.Count == 0) { //Add User to FinanceUSer Table Seton.Roster.User user = new User(); user.UserName = UserName; user.Name = DisplayName; int id = user.Save(); //Get RoleID by RoleName with Method var roleDS = SecurityRole.GetRoleList(roleName); if (roleDS.Tables[0].Rows.Count > 0) { var roleDR = roleDS.Tables[0].Rows[0]; int roleid = Convert.ToInt32(roleDR["roleid"].ToString()); SecurityRoleUserLink.AddNewLink(roleid, id); } } //if they exist just Get thier userid and add them to new Role else { //Get UserID of existing FinanceUser var userDR = ds.Tables[0].Rows[0]; int id = Convert.ToInt32(userDR["userid"].ToString()); //Get RoleID by RoleName with Method var roleDS = SecurityRole.GetRoleList(roleName); if (roleDS.Tables[0].Rows.Count > 0) { var roleDR = roleDS.Tables[0].Rows[0]; int roleid = Convert.ToInt32(roleDR["roleid"].ToString()); //Test to see if user already in this role if(!SecurityRoleUserLink.UserInRole(id,roleid)) SecurityRoleUserLink.AddNewLink(roleid, id);
0
11,471,431
07/13/2012 13:25:32
1,518,056
07/11/2012 14:17:44
1
0
Missing cleaned_data in forms (django)
I would like to create a form and the validation_forms that would check if some text apears in a box if another box has been checked correctly, class Contact_form(forms.Form): def __init__(self): TYPE_CHOICE = ( ('C', ('Client')), ('F', ('Facture')), ('V', ('Visite')) ) self.file_type = forms.ChoiceField(choices = TYPE_CHOICE, widget=forms.RadioSelect) self.file_name = forms.CharField(max_length=200) self.file_cols = forms.CharField(max_length=200, widget=forms.Textarea) self.file_date = forms.DateField() self.file_sep = forms.CharField(max_length=5, initial=';') self.file_header = forms.CharField(max_length=200, initial='0') def __unicode__(self): return self.name # Check if file_cols is correctly filled def clean_cols(self): # cleaned_data = super(Contact_form, self).clean() # Error apears here cleaned_file_type = self.cleaned_data.get(file_type) cleaned_file_cols = self.cleaned_data.get(file_cols) if cleaned_file_type == 'C': if 'client' not in cleaned_file_cols: raise forms.ValidationError("Mandatory fields aren't in collumn descriptor.") if cleaned_file_type == 'F': mandatory_field = ('fact', 'caht', 'fact_dat') for mf in mandatory_field: if mf not in cleaned_file_cols: raise forms.ValidationError("Mandatory fields aren't in collumn descriptor.") def contact(request): contact_form = Contact_form() contact_form.clean_cols() return render_to_response('contact.html', {'contact_form' : contact_form}) Infortunatly, django keeps saying me that he doesn't reconize cleaned_data. I know i've missed something about the doc or something but i cannot get the point on what. Please help !
python
django
forms
null
null
null
open
Missing cleaned_data in forms (django) === I would like to create a form and the validation_forms that would check if some text apears in a box if another box has been checked correctly, class Contact_form(forms.Form): def __init__(self): TYPE_CHOICE = ( ('C', ('Client')), ('F', ('Facture')), ('V', ('Visite')) ) self.file_type = forms.ChoiceField(choices = TYPE_CHOICE, widget=forms.RadioSelect) self.file_name = forms.CharField(max_length=200) self.file_cols = forms.CharField(max_length=200, widget=forms.Textarea) self.file_date = forms.DateField() self.file_sep = forms.CharField(max_length=5, initial=';') self.file_header = forms.CharField(max_length=200, initial='0') def __unicode__(self): return self.name # Check if file_cols is correctly filled def clean_cols(self): # cleaned_data = super(Contact_form, self).clean() # Error apears here cleaned_file_type = self.cleaned_data.get(file_type) cleaned_file_cols = self.cleaned_data.get(file_cols) if cleaned_file_type == 'C': if 'client' not in cleaned_file_cols: raise forms.ValidationError("Mandatory fields aren't in collumn descriptor.") if cleaned_file_type == 'F': mandatory_field = ('fact', 'caht', 'fact_dat') for mf in mandatory_field: if mf not in cleaned_file_cols: raise forms.ValidationError("Mandatory fields aren't in collumn descriptor.") def contact(request): contact_form = Contact_form() contact_form.clean_cols() return render_to_response('contact.html', {'contact_form' : contact_form}) Infortunatly, django keeps saying me that he doesn't reconize cleaned_data. I know i've missed something about the doc or something but i cannot get the point on what. Please help !
0
11,471,433
07/13/2012 13:25:38
1,417,814
05/25/2012 16:05:11
32
2
Dealing with filenames which have white spaces
My script here works fine: http://stackoverflow.com/questions/11455351/image-protection-in-codeigniter/11464734#11464734 However it displays a broken image if my filename has a space, so say it is "obama 1.jpg". To try and resolve this problem, I have used http://php.net/manual/en/function.escapeshellarg.php And replaced all the white spaces in the img_id with "%"s. But I have had no luck. I cannot strip the white spaces out, so will have to make due with the structure of the string. Thanks for your help.
php
codeigniter
null
null
null
null
open
Dealing with filenames which have white spaces === My script here works fine: http://stackoverflow.com/questions/11455351/image-protection-in-codeigniter/11464734#11464734 However it displays a broken image if my filename has a space, so say it is "obama 1.jpg". To try and resolve this problem, I have used http://php.net/manual/en/function.escapeshellarg.php And replaced all the white spaces in the img_id with "%"s. But I have had no luck. I cannot strip the white spaces out, so will have to make due with the structure of the string. Thanks for your help.
0
11,713,348
07/29/2012 22:01:48
1,298,803
03/28/2012 17:03:08
16
3
Stored procedure behaves differently from regular query
I had a problem where I executed a store procedure that does an update on a few tables in the database. The error was done such that only a single field (representing the same record id) is updated to a new id each time. This is the spoc: DROP PROCEDURE IF EXISTS feeds_transfer; DELIMITER $$ CREATE PROCEDURE feeds_transfer(IN original_owner INT, IN new_owner INT, IN feed_id INT) BEGIN UPDATE `events` SET `user_id` = new_owner WHERE `user_id` = original_owner AND `feed_id` = feed_id; UPDATE `feeds` SET `partner_id` = new_owner WHERE `partner_id` = original_owner AND `id` = feed_id; UPDATE `ics_uploads` SET `user_id` = new_owner WHERE `user_id` = original_owner AND `context_type` = 'feed' AND `context_id` = feed_id; UPDATE `images` SET `user_id` = new_owner WHERE `user_id` = original_owner AND `context` = 'feed' AND `context_id` = feed_id; UPDATE `private_feed_invitees` SET `user_id` = new_owner WHERE `user_id` = original_owner AND `feed_id` = feed_id; UPDATE `subscribed_feeds` SET `user_id` = new_owner WHERE `user_id` = original_owner AND `feed_id` = feed_id; END $$ DELIMITER ; What happens is that the subscribed_feeds table will update a every record where user_id = original_owner. Its like its ignoring the `feed_id` = feed_id
mysql
stored-procedures
null
null
null
null
open
Stored procedure behaves differently from regular query === I had a problem where I executed a store procedure that does an update on a few tables in the database. The error was done such that only a single field (representing the same record id) is updated to a new id each time. This is the spoc: DROP PROCEDURE IF EXISTS feeds_transfer; DELIMITER $$ CREATE PROCEDURE feeds_transfer(IN original_owner INT, IN new_owner INT, IN feed_id INT) BEGIN UPDATE `events` SET `user_id` = new_owner WHERE `user_id` = original_owner AND `feed_id` = feed_id; UPDATE `feeds` SET `partner_id` = new_owner WHERE `partner_id` = original_owner AND `id` = feed_id; UPDATE `ics_uploads` SET `user_id` = new_owner WHERE `user_id` = original_owner AND `context_type` = 'feed' AND `context_id` = feed_id; UPDATE `images` SET `user_id` = new_owner WHERE `user_id` = original_owner AND `context` = 'feed' AND `context_id` = feed_id; UPDATE `private_feed_invitees` SET `user_id` = new_owner WHERE `user_id` = original_owner AND `feed_id` = feed_id; UPDATE `subscribed_feeds` SET `user_id` = new_owner WHERE `user_id` = original_owner AND `feed_id` = feed_id; END $$ DELIMITER ; What happens is that the subscribed_feeds table will update a every record where user_id = original_owner. Its like its ignoring the `feed_id` = feed_id
0
11,713,356
07/29/2012 22:02:54
1,480,347
06/25/2012 14:57:37
17
0
TCL / Expect - Getting the Firmware Version from Cisco Show Version command
I need helpgetting the firmware version from the output of the Cisco "show version" command The following is the first line of the show version output (where "12.4(21a)JA1" is the firmware version): Cisco IOS Software, C1240 Software (C1240-K9W7-M), Version 12.4(21a)JA1, RELEASE SOFTWARE (fc1) The below code gives me the error: couldn't compile regular expression pattern: quantifier operand invalid expect "*#" {send "show version\n"} expect -re "(?<=Version/s)(.*)(?=/sRELEASE)" {set var1 $expect_out(1,string)} puts "Firmware Version: $var1" Thanks for the help
regex
tcl
expect
null
null
null
open
TCL / Expect - Getting the Firmware Version from Cisco Show Version command === I need helpgetting the firmware version from the output of the Cisco "show version" command The following is the first line of the show version output (where "12.4(21a)JA1" is the firmware version): Cisco IOS Software, C1240 Software (C1240-K9W7-M), Version 12.4(21a)JA1, RELEASE SOFTWARE (fc1) The below code gives me the error: couldn't compile regular expression pattern: quantifier operand invalid expect "*#" {send "show version\n"} expect -re "(?<=Version/s)(.*)(?=/sRELEASE)" {set var1 $expect_out(1,string)} puts "Firmware Version: $var1" Thanks for the help
0
11,713,363
07/29/2012 22:03:37
1,451,549
06/12/2012 14:57:51
14
0
I can not get registration ID from Android GCM
Although I try other answer about this problem, it can't be solved. Sender ID is correct, permissions are added, API key is true. I use this post for creating the project: http://developer.android.com/guide/google/gcm/gs.html#server-app GCMRegistrar.checkDevice(this); GCMRegistrar.checkManifest(this); String regId = GCMRegistrar.getRegistrationId(this); if (regId.equals("")) { GCMRegistrar.register(this, SENDER_ID); regId = GCMRegistrar.getRegistrationId(this); } else { Log.v(TAG, "Already registered"); } String did = getDeviceID(); it returns empty string.
android
android-gcm
null
null
null
null
open
I can not get registration ID from Android GCM === Although I try other answer about this problem, it can't be solved. Sender ID is correct, permissions are added, API key is true. I use this post for creating the project: http://developer.android.com/guide/google/gcm/gs.html#server-app GCMRegistrar.checkDevice(this); GCMRegistrar.checkManifest(this); String regId = GCMRegistrar.getRegistrationId(this); if (regId.equals("")) { GCMRegistrar.register(this, SENDER_ID); regId = GCMRegistrar.getRegistrationId(this); } else { Log.v(TAG, "Already registered"); } String did = getDeviceID(); it returns empty string.
0
11,713,367
07/29/2012 22:04:16
874,862
08/02/2011 14:47:59
43
0
Each loop Haml?
i have this each loop: (haml) - @deals.each do |a| .slide %a{:href => "#"} - a.attachments.each do |a| = image_tag(a.file.url, :height =>"325px", :width =>"650px" ) .caption{:style => "bottom:0"} = a.description Because @deals is combined query of 3 tabels(models) i use polymorphic_path to generate the links of the images. - @deals.each do |a| .slide %a{:href => "#"} - a.attachments.each do |a| = image_tag(a.file.url, :height =>"325px", :width =>"650px" ), polymorphic_path(@region, @city, a) .caption{:style => "bottom:0"} = a.description But this generates region_city_attachment_path which is not correct. The first each loop "a" variable store the correct value, but how can i "reach" the first "a" variable in the second each loop. Ciao..remco
ruby-on-rails
ruby-on-rails-3
haml
null
null
null
open
Each loop Haml? === i have this each loop: (haml) - @deals.each do |a| .slide %a{:href => "#"} - a.attachments.each do |a| = image_tag(a.file.url, :height =>"325px", :width =>"650px" ) .caption{:style => "bottom:0"} = a.description Because @deals is combined query of 3 tabels(models) i use polymorphic_path to generate the links of the images. - @deals.each do |a| .slide %a{:href => "#"} - a.attachments.each do |a| = image_tag(a.file.url, :height =>"325px", :width =>"650px" ), polymorphic_path(@region, @city, a) .caption{:style => "bottom:0"} = a.description But this generates region_city_attachment_path which is not correct. The first each loop "a" variable store the correct value, but how can i "reach" the first "a" variable in the second each loop. Ciao..remco
0
11,713,369
07/29/2012 22:04:32
871,910
07/31/2011 20:44:48
8,143
475
Centering divs inside parent divs on iOS
I have a page layout with two main panels (each panel is a `div`). The left panel has two child divs located one above the other. I want to center both divs horizontally in the parent div, without specifying the child divs' width at all. On Firefox the following CSS works quite nicely: #child1 { display: table; margin: 0 auto; } #child2 { display: table; margin: 0 auto; } On the iPad 2 browser, however, the two children are almost centered. There's a visible offset between the two. How can I overcome this? (Some previous answers, such as <a href="http://stackoverflow.com/questions/9109355/centering-variable-number-of-divs-inside-a-div-container">this one</a> suggested using `display: inline-block`. This works if I specify the child divs` width. If I don't, they are not centered on Firefox)
javascript
css
ios
html5
null
null
open
Centering divs inside parent divs on iOS === I have a page layout with two main panels (each panel is a `div`). The left panel has two child divs located one above the other. I want to center both divs horizontally in the parent div, without specifying the child divs' width at all. On Firefox the following CSS works quite nicely: #child1 { display: table; margin: 0 auto; } #child2 { display: table; margin: 0 auto; } On the iPad 2 browser, however, the two children are almost centered. There's a visible offset between the two. How can I overcome this? (Some previous answers, such as <a href="http://stackoverflow.com/questions/9109355/centering-variable-number-of-divs-inside-a-div-container">this one</a> suggested using `display: inline-block`. This works if I specify the child divs` width. If I don't, they are not centered on Firefox)
0
11,713,373
07/29/2012 22:04:58
1,398,384
05/16/2012 10:37:02
34
0
jquery dynamic height issue in -webkit- in xp only
update: Hi, I've created a site. I've used jquery .height() for getting dynamic height. its all working fine on all browsers in win7 even in chrome. But not on windows xp in chrome only. Here are the examples; note: I've tried it with .height & .css(height), but both methods isn't getting correct height in chrome in windows xp only. And its working fine in all browsers and in windows7 too including chrome but not in xp. http://jsfiddle.net/umairrazzaq/ucZrx/3/ - with .height() <br /> http://jsfiddle.net/umairrazzaq/ucZrx/4/ - with .css('height', getheightVar) any helpful advise will be greatly appreciable thanks...
jquery
dynamic
height
null
null
null
open
jquery dynamic height issue in -webkit- in xp only === update: Hi, I've created a site. I've used jquery .height() for getting dynamic height. its all working fine on all browsers in win7 even in chrome. But not on windows xp in chrome only. Here are the examples; note: I've tried it with .height & .css(height), but both methods isn't getting correct height in chrome in windows xp only. And its working fine in all browsers and in windows7 too including chrome but not in xp. http://jsfiddle.net/umairrazzaq/ucZrx/3/ - with .height() <br /> http://jsfiddle.net/umairrazzaq/ucZrx/4/ - with .css('height', getheightVar) any helpful advise will be greatly appreciable thanks...
0
11,713,375
07/29/2012 22:05:13
1,487,171
06/28/2012 00:03:58
20
0
ASP.NET MVC - Real time updates using Web Service
I'm trying to find examples on how to get real time updates using a web service in ASP.NET MVC (Version doesn't matter) and posting it back to a specific user's browser window. A perfect example would be a type of chat system like that of facebooks' where responses are send to the appropriate browser(client) whenever a message has been posted instead of creating a javascript timer on the page that checks for new messages every 5 seconds. I've heard tons of times about types of sync programs out there, but i'm looking for this in code, not using a third party software. What i'm looking to do specifically: I'm trying to create a web browser chat client that is SQL and Web Service based in ASP.NET MVC. When you have 2-4 different usernames logged into the system they chat and send messages to each other that is saved in an SQL database, then when there has been a new entry (or someone sent a new message) the Web Service see's this change and then shows the receiving user the new updated message. E.G Full Chat Synced Chat using a Web Service. The thing that really stomps me in general is I have no idea how to detect if something new is added to an SQL table, and also I have no idea how to send information from SQL to a specific user's web browser. So if there are people userA, userB, userC all on the website, i don't know how to only show a message to userC if they are all under the username "guest". I would love to know hot to do this feature not only for what i'm trying to create now, but for future projects as well. Can anyone point me into the right direction please? I know SQL pretty well, and web services i'm intermediate with.
asp.net
asp.net-mvc
web-services
null
null
null
open
ASP.NET MVC - Real time updates using Web Service === I'm trying to find examples on how to get real time updates using a web service in ASP.NET MVC (Version doesn't matter) and posting it back to a specific user's browser window. A perfect example would be a type of chat system like that of facebooks' where responses are send to the appropriate browser(client) whenever a message has been posted instead of creating a javascript timer on the page that checks for new messages every 5 seconds. I've heard tons of times about types of sync programs out there, but i'm looking for this in code, not using a third party software. What i'm looking to do specifically: I'm trying to create a web browser chat client that is SQL and Web Service based in ASP.NET MVC. When you have 2-4 different usernames logged into the system they chat and send messages to each other that is saved in an SQL database, then when there has been a new entry (or someone sent a new message) the Web Service see's this change and then shows the receiving user the new updated message. E.G Full Chat Synced Chat using a Web Service. The thing that really stomps me in general is I have no idea how to detect if something new is added to an SQL table, and also I have no idea how to send information from SQL to a specific user's web browser. So if there are people userA, userB, userC all on the website, i don't know how to only show a message to userC if they are all under the username "guest". I would love to know hot to do this feature not only for what i'm trying to create now, but for future projects as well. Can anyone point me into the right direction please? I know SQL pretty well, and web services i'm intermediate with.
0
11,280,186
07/01/2012 07:03:56
1,463,012
06/18/2012 07:29:20
1
0
Missing Index Sysname
When I used SQL Server Management Studio to display the estimated execution plan of a query it will sometimes suggest a missing index. My question is about the sysname in the following suggestion - What does sysname mean? I would normally just replace the firstline with CREATE NONCLUSTERED INDEX [IX_Users_Surname] so I don't understand the sysname reference. CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>] ON [dbo].[Users] ([Surname]) INCLUDE ([UserID],[Firstname],[Email],[Password])
sql
sql-server
tsql
null
null
null
open
Missing Index Sysname === When I used SQL Server Management Studio to display the estimated execution plan of a query it will sometimes suggest a missing index. My question is about the sysname in the following suggestion - What does sysname mean? I would normally just replace the firstline with CREATE NONCLUSTERED INDEX [IX_Users_Surname] so I don't understand the sysname reference. CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>] ON [dbo].[Users] ([Surname]) INCLUDE ([UserID],[Firstname],[Email],[Password])
0
11,280,231
07/01/2012 07:16:08
1,174,883
01/28/2012 06:42:27
11
3
Twiiter 4J Android Integration posts from developer account
I've made an app called Instacap on the Android Market which uses Signpost and twitter4j authentication and image upload. While testing it works fine and asks me for my name and password , however some tweets seem to appear directly from my account. I am saving the access token on the first authorization and making it expire after two days. Is there something wrong / missing in my code or is it a security breach? Please Help!
java
android
api
twitter
twitter4j
null
open
Twiiter 4J Android Integration posts from developer account === I've made an app called Instacap on the Android Market which uses Signpost and twitter4j authentication and image upload. While testing it works fine and asks me for my name and password , however some tweets seem to appear directly from my account. I am saving the access token on the first authorization and making it expire after two days. Is there something wrong / missing in my code or is it a security breach? Please Help!
0
11,280,232
07/01/2012 07:16:43
1,493,960
07/01/2012 07:04:28
1
0
Can not find declaration of element 'xml'
I'm getting a lot of parsing errors from python related to my xml file. I read elsewhere on stackoverflow that I should validate the xml file first. I can't understand why this xml will not validate: <xml><hive name="myprojectname"> XML validator says this Error: Can not find declaration of element 'xml'. Error Position: <xml><hive name="myprojectname"> Any help appreciated!
python
xml
validation
null
null
null
open
Can not find declaration of element 'xml' === I'm getting a lot of parsing errors from python related to my xml file. I read elsewhere on stackoverflow that I should validate the xml file first. I can't understand why this xml will not validate: <xml><hive name="myprojectname"> XML validator says this Error: Can not find declaration of element 'xml'. Error Position: <xml><hive name="myprojectname"> Any help appreciated!
0
11,280,236
07/01/2012 07:17:57
1,259,659
03/09/2012 15:49:44
1
0
Python: How to multiply all elements of a nested list
I'm just starting out with Python and need some help. I have the following list of dictionaries that contain a list: >>> series [{'data': [2, 4, 6, 8], 'name': 'abc'}, {'data': [5, 6, 7, 8], 'name': 'efg'}] >>> How can I multiply each elements of inner lists by a constant without using loops and do it in place. So if I have: >>> x = 100 The code should result in: >>> series [{'data': [200, 400, 600, 800], 'name': 'abc'}, {'data': [500, 600, 700, 800], 'name': 'efg'}] The best I could come up with my limited knowledge is this (and I don't even know what "[:]" is): >>> for s in series: ... s['data'][:] = [j*x for j in s['data']] ... >>> How can I remove the for loop? An explanation of the code or a pointer to docs would also be nice. Thanks!
python
python-2.7
null
null
null
null
open
Python: How to multiply all elements of a nested list === I'm just starting out with Python and need some help. I have the following list of dictionaries that contain a list: >>> series [{'data': [2, 4, 6, 8], 'name': 'abc'}, {'data': [5, 6, 7, 8], 'name': 'efg'}] >>> How can I multiply each elements of inner lists by a constant without using loops and do it in place. So if I have: >>> x = 100 The code should result in: >>> series [{'data': [200, 400, 600, 800], 'name': 'abc'}, {'data': [500, 600, 700, 800], 'name': 'efg'}] The best I could come up with my limited knowledge is this (and I don't even know what "[:]" is): >>> for s in series: ... s['data'][:] = [j*x for j in s['data']] ... >>> How can I remove the for loop? An explanation of the code or a pointer to docs would also be nice. Thanks!
0
11,280,239
07/01/2012 07:18:55
1,493,816
07/01/2012 03:42:33
1
0
python write can take 2 arguments
I have a question to make an "output.txt". I would like to write both word and prob(l.19) results into an "output.txt" file. When I write "model_file.write(word, prob)", the terminal scolds me with "TypeError: function takes exactly 1 argument (2 given)" message. I tried to add more arguments but it didn't work.. Could anybody help me with my question?? #####THIS IS A WORD COUNT.PY #### total_count = 0 train_file = open(sys.argv[1],"r") for line in train_file: words = line.strip().split(" ") words.append("</s>") for word in words:t counts[word] = counts.get(word, 0) + 1 total_count = total_count + 1 model_file = open('output.txt',"w") for word, count in sorted(counts.items(),reverse=True): prob = counts[word]*1.0/total_count print "%s --> %f" % (word, prob) model_file.write(word, prob) model_file.close() ########################################################
python
output
arguments
null
null
null
open
python write can take 2 arguments === I have a question to make an "output.txt". I would like to write both word and prob(l.19) results into an "output.txt" file. When I write "model_file.write(word, prob)", the terminal scolds me with "TypeError: function takes exactly 1 argument (2 given)" message. I tried to add more arguments but it didn't work.. Could anybody help me with my question?? #####THIS IS A WORD COUNT.PY #### total_count = 0 train_file = open(sys.argv[1],"r") for line in train_file: words = line.strip().split(" ") words.append("</s>") for word in words:t counts[word] = counts.get(word, 0) + 1 total_count = total_count + 1 model_file = open('output.txt',"w") for word, count in sorted(counts.items(),reverse=True): prob = counts[word]*1.0/total_count print "%s --> %f" % (word, prob) model_file.write(word, prob) model_file.close() ########################################################
0
11,280,240
07/01/2012 07:19:15
813,378
06/24/2011 02:57:40
5
0
why my trap doesn't work when the signal set as "DEBUG" fake signal?
#test code: #!/bin/bash #~/test/test.sh trap "echo 'testmessage'" DEBUG while : do echo abc sleep 6 done ------------------------------ #run it ~/test$sh test.sh ============================== #result => trap: DEBUG: bad trap ============================== ?[shell debug] why my trap doesn't work when the signal set as "DEBUG" fake signal,but report trap error?
linux
debugging
bash
shell
ubuntu
null
open
why my trap doesn't work when the signal set as "DEBUG" fake signal? === #test code: #!/bin/bash #~/test/test.sh trap "echo 'testmessage'" DEBUG while : do echo abc sleep 6 done ------------------------------ #run it ~/test$sh test.sh ============================== #result => trap: DEBUG: bad trap ============================== ?[shell debug] why my trap doesn't work when the signal set as "DEBUG" fake signal,but report trap error?
0
11,280,244
07/01/2012 07:20:48
576,116
01/14/2011 19:34:53
10
0
Devise User data that should not be able to log in
I think I looked around well enough to ask, though I still feel that I'm missing something obvious here. I have a User model that I use with Devise, though I also use the same model to store Recipients. Recipients belong to Users though they do not possess accounts and naturally shouldn't be able to log in. Recipients though have the same attributes name, address, phone, etc. so I wouldn't store them in a separate table. They would not however have passwords and email would not be required. My thought was to just make an Account class and sub-class a User model and a Recipient model. Trying this in a console (after rails g devise User and modifying the migration to for the parent), I expected to fail creating an empty User class (as devise makes email required) and succeed in creating a Recipient class. This so Account.all.count would equal 1, Recipient.all.count would equal 1, though User.all.count would be 0. The results were User.all.count equals 1. This would seem like a common scenario, so I was surprised that I didn't find a simple answer anywhere. Is STI the wrong way to go here? Should I just have a seperate table for the Recipient class (even though it has the same fields as a User)?
ruby-on-rails-3
devise
sti
null
null
null
open
Devise User data that should not be able to log in === I think I looked around well enough to ask, though I still feel that I'm missing something obvious here. I have a User model that I use with Devise, though I also use the same model to store Recipients. Recipients belong to Users though they do not possess accounts and naturally shouldn't be able to log in. Recipients though have the same attributes name, address, phone, etc. so I wouldn't store them in a separate table. They would not however have passwords and email would not be required. My thought was to just make an Account class and sub-class a User model and a Recipient model. Trying this in a console (after rails g devise User and modifying the migration to for the parent), I expected to fail creating an empty User class (as devise makes email required) and succeed in creating a Recipient class. This so Account.all.count would equal 1, Recipient.all.count would equal 1, though User.all.count would be 0. The results were User.all.count equals 1. This would seem like a common scenario, so I was surprised that I didn't find a simple answer anywhere. Is STI the wrong way to go here? Should I just have a seperate table for the Recipient class (even though it has the same fields as a User)?
0