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,472,831
07/13/2012 14:46:33
1,318,220
04/06/2012 20:37:47
26
0
HTTP connection resets after calling die() or exit() somewhere after RPC AMQP call
I have some kind of internal API which works with a DB and I'm doing calls to this API via AMQP. And when I do a synchronous (RPC) call and after that trying to redirect then HTTP connection resets. I'm redirecting like this: header("Location: some_url"); die; And I've found that the problem is in die() function. So I'm using PHP5.3, Apache2, RabbitMQ as AMQP broker. Also I'm using this extension http://pecl.php.net/package/amqp to work with AMQP. This is very confusing because if I remove die() everything is fine with the connection. But it's impossible to remove it because http://stackoverflow.com/questions/8665985/php-utilizing-exit-or-die-after-headerlocation I will really appreciate if somebody can give me clue. Thanks
php
rabbitmq
amqp
null
null
null
open
HTTP connection resets after calling die() or exit() somewhere after RPC AMQP call === I have some kind of internal API which works with a DB and I'm doing calls to this API via AMQP. And when I do a synchronous (RPC) call and after that trying to redirect then HTTP connection resets. I'm redirecting like this: header("Location: some_url"); die; And I've found that the problem is in die() function. So I'm using PHP5.3, Apache2, RabbitMQ as AMQP broker. Also I'm using this extension http://pecl.php.net/package/amqp to work with AMQP. This is very confusing because if I remove die() everything is fine with the connection. But it's impossible to remove it because http://stackoverflow.com/questions/8665985/php-utilizing-exit-or-die-after-headerlocation I will really appreciate if somebody can give me clue. Thanks
0
11,472,834
07/13/2012 14:46:36
1,487,780
06/28/2012 07:30:13
3
0
how to change SQL connection strings data source?
i'm beginner in c# and sql server currently i'm developing a program the problem is my database file is in DB folder inside project folder and when i try to detach database in SQL server management studio it will give error "Data Source=localhost;Initial Catalog=test;Integrated Security=true" when i change data source to this "Data Source=db/test.mdf;Initial Catalog=test;Integrated Security=true" it will give an error and i dont know how to insert database file with project to InstallShield to create setup file please please help thanks again
c#
sql
visual-studio-2010
null
null
null
open
how to change SQL connection strings data source? === i'm beginner in c# and sql server currently i'm developing a program the problem is my database file is in DB folder inside project folder and when i try to detach database in SQL server management studio it will give error "Data Source=localhost;Initial Catalog=test;Integrated Security=true" when i change data source to this "Data Source=db/test.mdf;Initial Catalog=test;Integrated Security=true" it will give an error and i dont know how to insert database file with project to InstallShield to create setup file please please help thanks again
0
11,472,836
07/13/2012 14:46:40
1,429,122
05/31/2012 18:01:09
1
1
thead, tbody and tfoot background images not displaying in chrome
table { margin: 0 auto; border-collapse: collapse; } thead { background: url('../images/theadimage.png') 365px bottom no-repeat; } tbody { background: url('../images/tbodyimage.png') 365px top repeat-y; } tfoot { background: url('../images/tfootimage1.png') 365px top no-repeat, url('../images/tfootimage2.png') 0px -8px repeat-x; } This is displaying the images correctly positioned in all browsers except chrome (oddly). If I change the tbody to repeat-x I see the image, but when set to no-repeat or repeat-y, the background images are completely disappearing. What am I missing here? Is there a solution or a workaround for chrome?
html
css
null
null
null
null
open
thead, tbody and tfoot background images not displaying in chrome === table { margin: 0 auto; border-collapse: collapse; } thead { background: url('../images/theadimage.png') 365px bottom no-repeat; } tbody { background: url('../images/tbodyimage.png') 365px top repeat-y; } tfoot { background: url('../images/tfootimage1.png') 365px top no-repeat, url('../images/tfootimage2.png') 0px -8px repeat-x; } This is displaying the images correctly positioned in all browsers except chrome (oddly). If I change the tbody to repeat-x I see the image, but when set to no-repeat or repeat-y, the background images are completely disappearing. What am I missing here? Is there a solution or a workaround for chrome?
0
11,472,837
07/13/2012 14:46:44
1,522,775
07/13/2012 06:42:00
1
0
Magento: Advanced Search to Show Bundle Products
I would like to be able to show Bundle Products on my Advanced Search result even if the searched attribute criteria is blank (not set) in the actual Bundle Product. For example: **I have 3 Simple Products:** Brand: Acme Color: Green **And 1 Bundle Product:** Brand: Acme Color: *--blank--* Associated Products: the 3 products above. My current Advanced Search Result is 3 Simple Products, but how can I also have the Bundle Product show up in my results even-thought the Color attribute is blank? Since the "child" products have the Color listed, I think it should also appear in search results, it does on the Layered Navigation.
magento
bundle
advanced-search
null
null
null
open
Magento: Advanced Search to Show Bundle Products === I would like to be able to show Bundle Products on my Advanced Search result even if the searched attribute criteria is blank (not set) in the actual Bundle Product. For example: **I have 3 Simple Products:** Brand: Acme Color: Green **And 1 Bundle Product:** Brand: Acme Color: *--blank--* Associated Products: the 3 products above. My current Advanced Search Result is 3 Simple Products, but how can I also have the Bundle Product show up in my results even-thought the Color attribute is blank? Since the "child" products have the Color listed, I think it should also appear in search results, it does on the Layered Navigation.
0
11,472,838
07/13/2012 14:46:45
1,407,378
05/21/2012 08:17:29
13
0
Creating Zwoptex Sheet in Windows
I am using Wiengine for making a game in android. For better resource utilization I am creating a zwoptex sheet but it can be made in MAC operating system, can any one guide me on how to make a zwoptex sheet in Windows.
android
null
null
null
null
null
open
Creating Zwoptex Sheet in Windows === I am using Wiengine for making a game in android. For better resource utilization I am creating a zwoptex sheet but it can be made in MAC operating system, can any one guide me on how to make a zwoptex sheet in Windows.
0
11,472,840
07/13/2012 14:46:52
322,558
04/21/2010 17:57:49
138
7
Busy/Wait Cursor in enthought traitsui
I am using the traitsui package from enthought. I'm launching a gui like this: appui = TestBenchUI() appui.configure_traits() Where `TestBenchUI` is a custom gui derived from `enthought.traits.api.HasTraits`. Some of the gui operations take some time to complete, and I would like the gui to display a wait/busy cursor. I've been unable to determine how to do this. Could someone please enlighten me? Thanks in advance.
python
enthought
null
null
null
null
open
Busy/Wait Cursor in enthought traitsui === I am using the traitsui package from enthought. I'm launching a gui like this: appui = TestBenchUI() appui.configure_traits() Where `TestBenchUI` is a custom gui derived from `enthought.traits.api.HasTraits`. Some of the gui operations take some time to complete, and I would like the gui to display a wait/busy cursor. I've been unable to determine how to do this. Could someone please enlighten me? Thanks in advance.
0
11,472,841
07/13/2012 14:47:05
1,452,060
06/12/2012 19:19:59
1
0
Pull XML nodeValue into php Variable
I am trying to assign the <'all> / <'avg> value in this XML code to a variable, so that I can use it for calculations. But when I do this, and try to print the value, I get a blank screen. Can someone please help? <stats> <type id="a"> <buy> <volume>698299009</volume> <avg>17.94</avg> <max>18.45</max> <min>1.00</min> </buy> <sell> <volume>16375234</volume> <avg>21.03</avg> <max>24.99</max> <min>20.78</min> </sell> <all> <volume>714674243</volume> <avg>18.01</avg> <max>24.99</max> <min>1.00</min> </all> </type> </stats> ======================= The php code I am using is as follows: ======================= $xml = simplexml_load_file("values.xml"); $unit_value = $xml->xpath("/stats/type[@id='a']/buy/avg/")->nodeValue; echo $unit_value; =======================
php
xml
xpath
nodevalue
null
null
open
Pull XML nodeValue into php Variable === I am trying to assign the <'all> / <'avg> value in this XML code to a variable, so that I can use it for calculations. But when I do this, and try to print the value, I get a blank screen. Can someone please help? <stats> <type id="a"> <buy> <volume>698299009</volume> <avg>17.94</avg> <max>18.45</max> <min>1.00</min> </buy> <sell> <volume>16375234</volume> <avg>21.03</avg> <max>24.99</max> <min>20.78</min> </sell> <all> <volume>714674243</volume> <avg>18.01</avg> <max>24.99</max> <min>1.00</min> </all> </type> </stats> ======================= The php code I am using is as follows: ======================= $xml = simplexml_load_file("values.xml"); $unit_value = $xml->xpath("/stats/type[@id='a']/buy/avg/")->nodeValue; echo $unit_value; =======================
0
11,472,776
07/13/2012 14:43:23
788,770
06/08/2011 07:41:42
247
13
API and Application authentication using Devise, Doorkeeper and OAuth2 token
I have both a Desktop application and a mobile application. I want to use the same rails application for both "devices". In another word, I want the mobile application to request contents on the Desktop application. I use Devise for authentications (email + password). I have implemented Doorkeeper on the Desktop app in order to generate an Oauth2 token for my mobile application. Here are my questions: I have before_filters sets in my desktop application controllers in order to secure them. - I am not sure how the mobile application should share the OAuth2 token with Devise in order to be authenticated and access my protected controllers ? In fact, right now, it is Doorkeeper who should check the mobile token in my controllers with the `doorkeeper_for :all` code. But to do that I have to unable the devise protection `before_filter :authenticate_user!`... Should I save the oauth token in devise too ? I am misunderstanding how mobile applications should authenticate with devise and OAuth2 protocole ? Thx
ruby-on-rails
ruby-on-rails-3
api
oauth
devise
null
open
API and Application authentication using Devise, Doorkeeper and OAuth2 token === I have both a Desktop application and a mobile application. I want to use the same rails application for both "devices". In another word, I want the mobile application to request contents on the Desktop application. I use Devise for authentications (email + password). I have implemented Doorkeeper on the Desktop app in order to generate an Oauth2 token for my mobile application. Here are my questions: I have before_filters sets in my desktop application controllers in order to secure them. - I am not sure how the mobile application should share the OAuth2 token with Devise in order to be authenticated and access my protected controllers ? In fact, right now, it is Doorkeeper who should check the mobile token in my controllers with the `doorkeeper_for :all` code. But to do that I have to unable the devise protection `before_filter :authenticate_user!`... Should I save the oauth token in devise too ? I am misunderstanding how mobile applications should authenticate with devise and OAuth2 protocole ? Thx
0
11,472,808
07/13/2012 14:45:05
617,779
02/15/2011 12:41:31
118
5
remove youtube branding logo with mediaelementjs
I'm using mediaelement.js library for videos to provide similar look and feel across browser s and devices. mediaelement.js has a youtube wrapper which allows us to use videos hosted on youtube. when I use this to display the videos, I see that youtube videos have a "youtube" logo on it. I tried appending modestbranding=1 to the url. when I add any parameter to the src url, the video does not play. Is there any solution to remove the youtube branding logo? <video style="width:100%;height:100%" id="player1" preload="none"> <source type="video/youtube" src="http://www.youtube.com/watch?v=nOEw9iiopwI" > </video> <script> // declare object for video var player = new MediaElementPlayer('#player1',{ features: ['playpause','progress','current','duration','tracks','volume'] }); </script>
video
youtube
mediaelement.js
null
null
null
open
remove youtube branding logo with mediaelementjs === I'm using mediaelement.js library for videos to provide similar look and feel across browser s and devices. mediaelement.js has a youtube wrapper which allows us to use videos hosted on youtube. when I use this to display the videos, I see that youtube videos have a "youtube" logo on it. I tried appending modestbranding=1 to the url. when I add any parameter to the src url, the video does not play. Is there any solution to remove the youtube branding logo? <video style="width:100%;height:100%" id="player1" preload="none"> <source type="video/youtube" src="http://www.youtube.com/watch?v=nOEw9iiopwI" > </video> <script> // declare object for video var player = new MediaElementPlayer('#player1',{ features: ['playpause','progress','current','duration','tracks','volume'] }); </script>
0
11,472,810
07/13/2012 14:45:09
383,405
07/05/2010 05:31:24
685
31
How to specify version ranges in install_requires (setuptools, distribute)
I want to make a package to depend the particular version range e.g. `>= 0.5.0, < 0.7.0`. Is it possible in `install_requires` option, and if so how should it be?
python
setuptools
null
null
null
null
open
How to specify version ranges in install_requires (setuptools, distribute) === I want to make a package to depend the particular version range e.g. `>= 0.5.0, < 0.7.0`. Is it possible in `install_requires` option, and if so how should it be?
0
11,628,250
07/24/2012 09:47:58
1,517,905
07/11/2012 13:20:23
6
0
The following classes could not be instantiated
I try to run my app , its a simple todoList example .. But when i want to view a ListView item, it crashes . In my Listview's .xml (Graphical Layout) is the following error : The following classes could not be instantiated: - com.paad.todolist.TodoListItemView (Open Class, Show Error Log) See the Error Log (Window > Show View) for more details. Tip: Use View.isInEditMode() in your custom views to skip code when shown in Eclipse What's wrong with it ?? Thanks in advance !
android
layout
null
null
null
null
open
The following classes could not be instantiated === I try to run my app , its a simple todoList example .. But when i want to view a ListView item, it crashes . In my Listview's .xml (Graphical Layout) is the following error : The following classes could not be instantiated: - com.paad.todolist.TodoListItemView (Open Class, Show Error Log) See the Error Log (Window > Show View) for more details. Tip: Use View.isInEditMode() in your custom views to skip code when shown in Eclipse What's wrong with it ?? Thanks in advance !
0
11,628,251
07/24/2012 09:48:02
1,274,219
03/16/2012 14:19:35
1
0
Which JS framework used for this site?
Can anyone tell which Javascript framework is being used for http://iphone.paulmillersubaru.com/index.htm#index_p_2Ehtm Is this based on jquerymobile.com or is it using some other framework? Thanks, Jatinder Thind
jquery-mobile
null
null
null
null
null
open
Which JS framework used for this site? === Can anyone tell which Javascript framework is being used for http://iphone.paulmillersubaru.com/index.htm#index_p_2Ehtm Is this based on jquerymobile.com or is it using some other framework? Thanks, Jatinder Thind
0
11,628,252
07/24/2012 09:48:02
1,146,775
01/13/2012 01:44:52
539
5
why the Controller classes inside an asp.net MVC web application are not considered a RESTfull web service
I have an asp.net web application ,, now let say a user send a POST action method to the application using following URL `Myapplication.com/Customer/Edit/120`, then this URL will update the customer who have ID=120 with the data send. So this is the same as calling a web service ,, since you are integrating with the application (in this case Update a customer) using URLs,, so why this is not consider as having a RESTfull web service!!!!! Best Regards
asp.net-mvc
rest
null
null
null
null
open
why the Controller classes inside an asp.net MVC web application are not considered a RESTfull web service === I have an asp.net web application ,, now let say a user send a POST action method to the application using following URL `Myapplication.com/Customer/Edit/120`, then this URL will update the customer who have ID=120 with the data send. So this is the same as calling a web service ,, since you are integrating with the application (in this case Update a customer) using URLs,, so why this is not consider as having a RESTfull web service!!!!! Best Regards
0
11,628,607
07/24/2012 10:09:21
1,432,358
06/02/2012 11:48:40
38
2
automatic replace with jquery regex
i have $("#text") and i want to make it so that when you type the word 'replace me' into $("text"), it is automatically replaced with the phrase 'replaced successfully' and 'goobye' with 'hello'<br/> i'm assuming the right way to go about doing this would be to find 'replace' with regex and replace it and this is about as far as i've gotten > $('#text').keydown(function(){ var text = $('#text').text(); var replaceCommand = ['replace me', 'goodbye']; var replaceOutput = ['replaced successfully', 'hello']; for (var i=0; i < replaceCommand.length; i++){ text.replace(replaceCommand[i]/i, replaceOutput[i]); } });
javascript
jquery
regex
null
null
null
open
automatic replace with jquery regex === i have $("#text") and i want to make it so that when you type the word 'replace me' into $("text"), it is automatically replaced with the phrase 'replaced successfully' and 'goobye' with 'hello'<br/> i'm assuming the right way to go about doing this would be to find 'replace' with regex and replace it and this is about as far as i've gotten > $('#text').keydown(function(){ var text = $('#text').text(); var replaceCommand = ['replace me', 'goodbye']; var replaceOutput = ['replaced successfully', 'hello']; for (var i=0; i < replaceCommand.length; i++){ text.replace(replaceCommand[i]/i, replaceOutput[i]); } });
0
11,628,433
07/24/2012 09:58:48
1,312,499
04/04/2012 09:52:51
16
0
call custom Activity as startActivityForResult
I am starting an Activity for result as startActivityForResult(new Intent(this,ActivityA.class),REQUEST_CODE) ActivityA is started. There is a gridview on ActivityA, I want to get the position of selected image in method onActivityResult(int requestCode, int resultCode, Intent data) of caller Activity but I am not getting the way to do that
android
android-activity
null
null
null
null
open
call custom Activity as startActivityForResult === I am starting an Activity for result as startActivityForResult(new Intent(this,ActivityA.class),REQUEST_CODE) ActivityA is started. There is a gridview on ActivityA, I want to get the position of selected image in method onActivityResult(int requestCode, int resultCode, Intent data) of caller Activity but I am not getting the way to do that
0
11,628,612
07/24/2012 10:09:46
1,087,087
12/08/2011 05:32:10
80
3
Access View State in ashx file
I am working on a project, i have on ashx handler file, I want to make some ViewState data in my ashx file and then check it on .cs file How can i achieve this as i can't access ViewState object in my ashx file Regards
c#
asp.net
null
null
null
null
open
Access View State in ashx file === I am working on a project, i have on ashx handler file, I want to make some ViewState data in my ashx file and then check it on .cs file How can i achieve this as i can't access ViewState object in my ashx file Regards
0
11,628,613
07/24/2012 10:09:53
1,202,227
02/10/2012 14:19:28
17
3
Converting Object received using SOAP from (C# .net) web service to a String array in Android
I am trying to send string array from web service to android application using kSOAP2. Using kSOAP2, I receive an response in Object format at android end. Now i want to convert this object in String Array format so that i can pass this array directly to GridView. My Web Service Method is as follows: [WebMethod] public string[] getit(string status) { string[] result; if (status == "blue") { result = new string[] { "One", "Two", "Three", "Four" }; } else { { result = new string[] { "five", "six", "Seven", "Eight" }; } } return result; } My Android Code is as follows: public void call(String status) { try { SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); request.addProperty("status",status.toString()); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet=true; envelope.setOutputSoapObject(request); HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); androidHttpTransport.call(SOAP_ACTION, envelope); Object result = (Object)envelope.getResponse(); array1=(String []) result; //This statement does not work } In android code array1 is globally declared string array. String array1[]; I want to convert Object result to be converted into array1 String array. Thanks in advance.
android
web-services
object
ksoap2
null
null
open
Converting Object received using SOAP from (C# .net) web service to a String array in Android === I am trying to send string array from web service to android application using kSOAP2. Using kSOAP2, I receive an response in Object format at android end. Now i want to convert this object in String Array format so that i can pass this array directly to GridView. My Web Service Method is as follows: [WebMethod] public string[] getit(string status) { string[] result; if (status == "blue") { result = new string[] { "One", "Two", "Three", "Four" }; } else { { result = new string[] { "five", "six", "Seven", "Eight" }; } } return result; } My Android Code is as follows: public void call(String status) { try { SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); request.addProperty("status",status.toString()); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet=true; envelope.setOutputSoapObject(request); HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); androidHttpTransport.call(SOAP_ACTION, envelope); Object result = (Object)envelope.getResponse(); array1=(String []) result; //This statement does not work } In android code array1 is globally declared string array. String array1[]; I want to convert Object result to be converted into array1 String array. Thanks in advance.
0
11,660,758
07/26/2012 00:36:15
434,305
08/29/2010 16:29:39
299
8
pcap_next occasionally losing packets on Linux
Yesterday, I asked if my [asynchronous use of libpcap was making me lose packets][1]. Today, I looked further and it seems that the problem is not on the asynchronous use of libpcap, but on the use of `pcap_next_ex`. Occasionally (10 runs out of a 1000), `pcap_next_ex` will return before the pcap handle timeout expired, telling the program that there were no packets to be read (even though they are there). The following proof-of-concept reproduces the problem. It depends on libpcap, pthread, boost and [libcrafter][2] (a nice C++ packet crafting library). Basically, it sends a set of TCP-SYN packets to a destination and tries to obtain the responses using libpcap. A thread calling `pcap_loop` is run in parallel - while the main program misses some responses (as described above), the thread captures all the packets. #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/format.hpp> #include <boost/make_shared.hpp> #include <boost/shared_ptr.hpp> #include <crafter.h> #include <netinet/ip.h> #include <netinet/tcp.h> #include <pcap.h> #include <sys/types.h> #include <sys/socket.h> using namespace boost; using namespace Crafter; using namespace std; int captureThreadCount = 0; typedef vector<pair<shared_ptr<Packet>, posix_time::time_duration> > PacketTimestamp; PacketTimestamp capturedThreadPackets; void captureThreadCallback(u_char* user, const struct pcap_pkthdr* h, const u_char* bytes) { shared_ptr<Packet> packet = make_shared<Packet>(); packet->PacketFromIP(bytes + 16, h->caplen - 16); posix_time::time_duration timestamp = posix_time::seconds(h->ts.tv_sec) + posix_time::microseconds(h->ts.tv_usec); capturedThreadPackets.push_back(make_pair(packet, timestamp)); ++captureThreadCount; } void* captureThread(void* arg) { pcap_t* pcap = (pcap_t*) arg; pcap_loop(pcap, -1, captureThreadCallback, NULL); } int main(int argc, char* argv[]) { if (argc != 5) { cout << "Usage: " << argv[0] << " <source ip> <destination ip> <port> <# tries>" << endl; exit(1); } InitCrafter(); // Parameters. string sourceIp = argv[1]; string destinationIp = argv[2]; int port = atoi(argv[3]); int nTries = atoi(argv[4]); char errorBuffer[1024]; // Socket for sending, int sd = socket(PF_INET, SOCK_RAW, IPPROTO_RAW); // And sockaddr_in to send to. struct sockaddr_in sin; sin.sin_family = AF_INET; sin.sin_port = htons(port); sin.sin_addr.s_addr = inet_addr(destinationIp.c_str()); // One pcap for the main thread (calling pcap_next), pcap_t* pcapForNext = pcap_open_live(NULL, BUFSIZ, false, 1000, errorBuffer); // Another pcap for a capture thread (calling pcap_loop), pcap_t* pcapCapture = pcap_open_live(NULL, BUFSIZ, false, 1000, errorBuffer); // Both filtered for SYN+ACK or RST+ACK from destination:port to source. string filterExpression = (boost::format("ip src %s and dst %s and src port %d and ((tcp[tcpflags] & (tcp-syn|tcp-ack) != 0) or (tcp[tcpflags] & (tcp-rst|tcp-ack) != 0))") % destinationIp % sourceIp % port).str(); struct bpf_program filter; pcap_compile(pcapForNext, &filter, filterExpression.c_str(), false, 0); pcap_setfilter(pcapForNext, &filter); pcap_setfilter(pcapCapture, &filter); pcap_freecode(&filter); // Don't forget the capture thread! pthread_t thread; pthread_create(&thread, NULL, captureThread, pcapCapture); // Some statistics. int packetsSent = 0; int packetsReceived = 0; int packetsTimeout = 0; int packetsFailed = 0; // Let's probe. for (int i = 0; i < nTries; ++i) { // Create packet, IP ipHeader; ipHeader.SetSourceIP(sourceIp); ipHeader.SetDestinationIP(destinationIp); TCP tcpHeader; tcpHeader.SetSrcPort(12345 + i); tcpHeader.SetDstPort(port); tcpHeader.SetFlags(TCP::SYN); shared_ptr<Packet> packet = make_shared<Packet>(ipHeader / tcpHeader); // Check the time, struct timeval tv; gettimeofday(&tv, NULL); posix_time::time_duration sentTime = posix_time::seconds(tv.tv_sec) + posix_time::microseconds(tv.tv_usec); // And send it. if (packet->SocketSend(sd) > 0) { cerr << "Sent packet " << i << " at " << sentTime << "." << endl; ++packetsSent; } else { cerr << "Sending packet " << i << " failed." << endl; continue; } struct pcap_pkthdr* pktHeader; const u_char* pktData; int r; // Wait for the response. if ((r = pcap_next_ex(pcapForNext, &pktHeader, &pktData)) > 0) { posix_time::time_duration timestamp = posix_time::seconds(pktHeader->ts.tv_sec) + posix_time::microseconds(pktHeader->ts.tv_usec); cerr << "Response " << i << " received at " << timestamp << "." << endl; ++packetsReceived; } else if (r == 0) { cerr << "Timeout receiving response for " << i << "." << endl; ++packetsTimeout; } else { cerr << "Failed receiving response for " << i << "." << endl; ++packetsFailed; } } // Wait (to ensure "fast packets" are captured by the capture thread), usleep(500000); // 500 ms. for (PacketTimestamp::iterator i = capturedThreadPackets.begin(); i != capturedThreadPackets.end(); ++i) { TCP* tcpLayer = GetTCP(*i->first); cout << "Captured packet " << (tcpLayer->GetDstPort() - 12345) << " at " << i->second << "." << endl; } cout << "SNT=" << packetsSent << ", RCV=" << packetsReceived << ", TIM=" << packetsTimeout << ", FLD=" << packetsFailed << ", CAP=" << captureThreadCount << "." << endl; CleanCrafter(); } [1]: http://stackoverflow.com/questions/11637063/ [2]: http://code.google.com/p/libcrafter/
c++
libpcap
null
null
null
null
open
pcap_next occasionally losing packets on Linux === Yesterday, I asked if my [asynchronous use of libpcap was making me lose packets][1]. Today, I looked further and it seems that the problem is not on the asynchronous use of libpcap, but on the use of `pcap_next_ex`. Occasionally (10 runs out of a 1000), `pcap_next_ex` will return before the pcap handle timeout expired, telling the program that there were no packets to be read (even though they are there). The following proof-of-concept reproduces the problem. It depends on libpcap, pthread, boost and [libcrafter][2] (a nice C++ packet crafting library). Basically, it sends a set of TCP-SYN packets to a destination and tries to obtain the responses using libpcap. A thread calling `pcap_loop` is run in parallel - while the main program misses some responses (as described above), the thread captures all the packets. #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/format.hpp> #include <boost/make_shared.hpp> #include <boost/shared_ptr.hpp> #include <crafter.h> #include <netinet/ip.h> #include <netinet/tcp.h> #include <pcap.h> #include <sys/types.h> #include <sys/socket.h> using namespace boost; using namespace Crafter; using namespace std; int captureThreadCount = 0; typedef vector<pair<shared_ptr<Packet>, posix_time::time_duration> > PacketTimestamp; PacketTimestamp capturedThreadPackets; void captureThreadCallback(u_char* user, const struct pcap_pkthdr* h, const u_char* bytes) { shared_ptr<Packet> packet = make_shared<Packet>(); packet->PacketFromIP(bytes + 16, h->caplen - 16); posix_time::time_duration timestamp = posix_time::seconds(h->ts.tv_sec) + posix_time::microseconds(h->ts.tv_usec); capturedThreadPackets.push_back(make_pair(packet, timestamp)); ++captureThreadCount; } void* captureThread(void* arg) { pcap_t* pcap = (pcap_t*) arg; pcap_loop(pcap, -1, captureThreadCallback, NULL); } int main(int argc, char* argv[]) { if (argc != 5) { cout << "Usage: " << argv[0] << " <source ip> <destination ip> <port> <# tries>" << endl; exit(1); } InitCrafter(); // Parameters. string sourceIp = argv[1]; string destinationIp = argv[2]; int port = atoi(argv[3]); int nTries = atoi(argv[4]); char errorBuffer[1024]; // Socket for sending, int sd = socket(PF_INET, SOCK_RAW, IPPROTO_RAW); // And sockaddr_in to send to. struct sockaddr_in sin; sin.sin_family = AF_INET; sin.sin_port = htons(port); sin.sin_addr.s_addr = inet_addr(destinationIp.c_str()); // One pcap for the main thread (calling pcap_next), pcap_t* pcapForNext = pcap_open_live(NULL, BUFSIZ, false, 1000, errorBuffer); // Another pcap for a capture thread (calling pcap_loop), pcap_t* pcapCapture = pcap_open_live(NULL, BUFSIZ, false, 1000, errorBuffer); // Both filtered for SYN+ACK or RST+ACK from destination:port to source. string filterExpression = (boost::format("ip src %s and dst %s and src port %d and ((tcp[tcpflags] & (tcp-syn|tcp-ack) != 0) or (tcp[tcpflags] & (tcp-rst|tcp-ack) != 0))") % destinationIp % sourceIp % port).str(); struct bpf_program filter; pcap_compile(pcapForNext, &filter, filterExpression.c_str(), false, 0); pcap_setfilter(pcapForNext, &filter); pcap_setfilter(pcapCapture, &filter); pcap_freecode(&filter); // Don't forget the capture thread! pthread_t thread; pthread_create(&thread, NULL, captureThread, pcapCapture); // Some statistics. int packetsSent = 0; int packetsReceived = 0; int packetsTimeout = 0; int packetsFailed = 0; // Let's probe. for (int i = 0; i < nTries; ++i) { // Create packet, IP ipHeader; ipHeader.SetSourceIP(sourceIp); ipHeader.SetDestinationIP(destinationIp); TCP tcpHeader; tcpHeader.SetSrcPort(12345 + i); tcpHeader.SetDstPort(port); tcpHeader.SetFlags(TCP::SYN); shared_ptr<Packet> packet = make_shared<Packet>(ipHeader / tcpHeader); // Check the time, struct timeval tv; gettimeofday(&tv, NULL); posix_time::time_duration sentTime = posix_time::seconds(tv.tv_sec) + posix_time::microseconds(tv.tv_usec); // And send it. if (packet->SocketSend(sd) > 0) { cerr << "Sent packet " << i << " at " << sentTime << "." << endl; ++packetsSent; } else { cerr << "Sending packet " << i << " failed." << endl; continue; } struct pcap_pkthdr* pktHeader; const u_char* pktData; int r; // Wait for the response. if ((r = pcap_next_ex(pcapForNext, &pktHeader, &pktData)) > 0) { posix_time::time_duration timestamp = posix_time::seconds(pktHeader->ts.tv_sec) + posix_time::microseconds(pktHeader->ts.tv_usec); cerr << "Response " << i << " received at " << timestamp << "." << endl; ++packetsReceived; } else if (r == 0) { cerr << "Timeout receiving response for " << i << "." << endl; ++packetsTimeout; } else { cerr << "Failed receiving response for " << i << "." << endl; ++packetsFailed; } } // Wait (to ensure "fast packets" are captured by the capture thread), usleep(500000); // 500 ms. for (PacketTimestamp::iterator i = capturedThreadPackets.begin(); i != capturedThreadPackets.end(); ++i) { TCP* tcpLayer = GetTCP(*i->first); cout << "Captured packet " << (tcpLayer->GetDstPort() - 12345) << " at " << i->second << "." << endl; } cout << "SNT=" << packetsSent << ", RCV=" << packetsReceived << ", TIM=" << packetsTimeout << ", FLD=" << packetsFailed << ", CAP=" << captureThreadCount << "." << endl; CleanCrafter(); } [1]: http://stackoverflow.com/questions/11637063/ [2]: http://code.google.com/p/libcrafter/
0
11,660,760
07/26/2012 00:36:20
613,483
02/11/2011 18:30:59
349
8
Detect property selection in propertyGrid
Is it possible to detect when a property in a propertyGrid is selected? And if so, how? In the following picture, I would like to know which of the properties is selected at runtime. ![enter image description here][1] For example, The Grid knows that MyBool is selected, what can I do to get that information programatically instead of visually [1]: http://i.stack.imgur.com/9iOS5.png
c#
properties
selection
detect
propertygrid
null
open
Detect property selection in propertyGrid === Is it possible to detect when a property in a propertyGrid is selected? And if so, how? In the following picture, I would like to know which of the properties is selected at runtime. ![enter image description here][1] For example, The Grid knows that MyBool is selected, what can I do to get that information programatically instead of visually [1]: http://i.stack.imgur.com/9iOS5.png
0
11,660,762
07/26/2012 00:36:37
1,114,664
12/24/2011 15:08:24
101
2
C++ Ram usage going up. Memory not being reused
I'm using [debug_new][1] to find memory leaks . I'm deleting my objects and debug_new doesn't show any trace of me leaking them. I've read several threads on memory fragmentation. But I'm still confused. At this point I'm testing my framework and I'm doing a simple test. I create a new objects like so: if(sf::Keyboard::isKeyPressed(sf::Keyboard::Space)){ artemis::Entity& e = world->createEntity(); e.addComponent(new PositionComponent(posX,posY)); e.addComponent(new MovementComponent(500,0)); e.addComponent(new SpriteComponent(TextureManager::getInstance().getTexture("bullet.png"))); e.addComponent(new ColliderComponent(10,10)); e.refresh(); e.setGroup("BULLET"); } These "components" are managed in a manager called "EntityManager" which reuses the Entity objects but destroys the components when the Entity is send back to the "pool". I've tested this, and only new entities are made if no available entity is in the pool. As you can see by the code above. In this simple test the patterns are the same. Yet the allocator keeps using new memory instead of reusing any previously used memory. Creating a few thousands per space-bar hit( per 1/60 a frame) caused my memory to go into the 2 gig spectrum. The components aren't even that big. For example: class ColliderComponent : public artemis::Component{ public: int width,height,collidionsId; ColliderComponent(int width, int height){ this->width = width; this->height = height; } }; Most components are simple "collections" of ints so far. They are pretty lightweight. It should most definitely reuse some of the previously allocated/released memory. But it just doesn't. Maybe I'm missing something. Does anyone have a different idea of what might be going on? And are there any good( free ) memory profilers? If it's not because of my components, the flaw must be somewhere else. I simply can not see it at this point and it's frustrating to say the least. [1]: http://wyw.dcweb.cn/leakage.htm
memory
ram
null
null
null
null
open
C++ Ram usage going up. Memory not being reused === I'm using [debug_new][1] to find memory leaks . I'm deleting my objects and debug_new doesn't show any trace of me leaking them. I've read several threads on memory fragmentation. But I'm still confused. At this point I'm testing my framework and I'm doing a simple test. I create a new objects like so: if(sf::Keyboard::isKeyPressed(sf::Keyboard::Space)){ artemis::Entity& e = world->createEntity(); e.addComponent(new PositionComponent(posX,posY)); e.addComponent(new MovementComponent(500,0)); e.addComponent(new SpriteComponent(TextureManager::getInstance().getTexture("bullet.png"))); e.addComponent(new ColliderComponent(10,10)); e.refresh(); e.setGroup("BULLET"); } These "components" are managed in a manager called "EntityManager" which reuses the Entity objects but destroys the components when the Entity is send back to the "pool". I've tested this, and only new entities are made if no available entity is in the pool. As you can see by the code above. In this simple test the patterns are the same. Yet the allocator keeps using new memory instead of reusing any previously used memory. Creating a few thousands per space-bar hit( per 1/60 a frame) caused my memory to go into the 2 gig spectrum. The components aren't even that big. For example: class ColliderComponent : public artemis::Component{ public: int width,height,collidionsId; ColliderComponent(int width, int height){ this->width = width; this->height = height; } }; Most components are simple "collections" of ints so far. They are pretty lightweight. It should most definitely reuse some of the previously allocated/released memory. But it just doesn't. Maybe I'm missing something. Does anyone have a different idea of what might be going on? And are there any good( free ) memory profilers? If it's not because of my components, the flaw must be somewhere else. I simply can not see it at this point and it's frustrating to say the least. [1]: http://wyw.dcweb.cn/leakage.htm
0
11,660,774
07/26/2012 00:37:56
541,686
12/14/2010 08:54:07
33,859
844
Must size() == end() - begin()? What about the cast?
From what I understand, the purpose of `size_type` and `difference_type` is **not** merely the sign -- it was also meant to address e.g. segmented architectures and such, where they might be of different sizes. With that context, if I have a container with random-access iterators, is it safe for me to perform a `static_cast` between its `difference_type` and `size_type` values at will, on the grounds that `end() - begin()` *must* always be equal to `size()`, when either is casted? (The use case, for example, is to create a container whose size is equal to the number of elements between two iterators, or the reverse: to copy a container of a certain size onto a range delimited by iterators.) Anything I should watch out for before casting (e.g. loss of data)?
c++
iterator
null
null
null
null
open
Must size() == end() - begin()? What about the cast? === From what I understand, the purpose of `size_type` and `difference_type` is **not** merely the sign -- it was also meant to address e.g. segmented architectures and such, where they might be of different sizes. With that context, if I have a container with random-access iterators, is it safe for me to perform a `static_cast` between its `difference_type` and `size_type` values at will, on the grounds that `end() - begin()` *must* always be equal to `size()`, when either is casted? (The use case, for example, is to create a container whose size is equal to the number of elements between two iterators, or the reverse: to copy a container of a certain size onto a range delimited by iterators.) Anything I should watch out for before casting (e.g. loss of data)?
0
11,568,061
07/19/2012 19:37:56
1,538,916
07/19/2012 19:24:41
1
0
How to send email from a spreadsheet
I have a spreadsheet on Google Docs with tasks for a job that we are working on at work. What I am wanting it to do is to send the whole row to the intended recipient but I can only get it to send the info from the first column after the email address. Everything has a due date on it and I would like to get it to send a reminder when it gets close to that date but I do not know how to do that. Any help would be greatly appreciated. Here is the code I have right now: function sendEmails() { var sheet = SpreadsheetApp.getActiveSheet(); var startRow = 3; // First row of data to process var numRows = 2; // Number of rows to process // Fetch the range of cells A2:B3 var dataRange = sheet.getRange(startRow, 1, numRows, 2) // Fetch values for each row in the Range. var data = dataRange.getValues(); for (i in data) { var row = data[i]; var emailAddress = row[0]; // First column var message = row[1]; // Column B, Column C, Column D, Column E, Column F, Column G var subject = "Email Test Spreadsheet"; MailApp.sendEmail(emailAddress, subject, message); } }
google-apps-script
null
null
null
null
null
open
How to send email from a spreadsheet === I have a spreadsheet on Google Docs with tasks for a job that we are working on at work. What I am wanting it to do is to send the whole row to the intended recipient but I can only get it to send the info from the first column after the email address. Everything has a due date on it and I would like to get it to send a reminder when it gets close to that date but I do not know how to do that. Any help would be greatly appreciated. Here is the code I have right now: function sendEmails() { var sheet = SpreadsheetApp.getActiveSheet(); var startRow = 3; // First row of data to process var numRows = 2; // Number of rows to process // Fetch the range of cells A2:B3 var dataRange = sheet.getRange(startRow, 1, numRows, 2) // Fetch values for each row in the Range. var data = dataRange.getValues(); for (i in data) { var row = data[i]; var emailAddress = row[0]; // First column var message = row[1]; // Column B, Column C, Column D, Column E, Column F, Column G var subject = "Email Test Spreadsheet"; MailApp.sendEmail(emailAddress, subject, message); } }
0
11,568,062
07/19/2012 19:38:09
37,078
11/12/2008 20:03:05
1,734
47
Custom python widgets in glade 3
I would like to subclass an existing Gtk widget and get it to work with Glade3. The code is all python, and I'm using PyGObject. What I want to do is extend Gtk.TextView and be able to add it to my glade UI as if it were a native widget. I read that it was possible with Glade 2, but I'm not sure how to do this with Glade 3, and I can't seem to find any examples or documentation on this. Any help would be appreciated. Thanks.
python
glade
pygobject
null
null
null
open
Custom python widgets in glade 3 === I would like to subclass an existing Gtk widget and get it to work with Glade3. The code is all python, and I'm using PyGObject. What I want to do is extend Gtk.TextView and be able to add it to my glade UI as if it were a native widget. I read that it was possible with Glade 2, but I'm not sure how to do this with Glade 3, and I can't seem to find any examples or documentation on this. Any help would be appreciated. Thanks.
0
11,568,048
07/19/2012 19:37:11
1,524,644
07/13/2012 21:02:46
1
0
iOS custom splash screen
I need to load a bunch of things in the beginning of my application, so I would like to implement a splash screen. I know about the Default.png screen, and I dont think that works. Does iOS have something built-in for this? If not what is the easiest way to do so?
iphone
ios
cocoa-touch
splash-screen
null
null
open
iOS custom splash screen === I need to load a bunch of things in the beginning of my application, so I would like to implement a splash screen. I know about the Default.png screen, and I dont think that works. Does iOS have something built-in for this? If not what is the easiest way to do so?
0
11,568,066
07/19/2012 19:38:22
1,489,001
06/28/2012 15:16:42
1
0
Updating HelloJni example
This is probably a very easy question but since I am new to Cygwin and Ant, this annoyed me a lot. Basically, I am trying to test hello-jni example that comes with NDK ( I use r8 currently). I have set my paths and everything is working fine. However, when I simply cd to the sample directory and try to update the project, I get the following error. $ android.bat update project -p . Error: The project either has no target set or the target is invalid. Please provide a --target to the 'android.bat update' command. ndk-build is working fine but whenever I try to install using Ant, I get the build.xml is missing error inevitably. Thanks.
android
ant
android-ndk
cygwin
null
null
open
Updating HelloJni example === This is probably a very easy question but since I am new to Cygwin and Ant, this annoyed me a lot. Basically, I am trying to test hello-jni example that comes with NDK ( I use r8 currently). I have set my paths and everything is working fine. However, when I simply cd to the sample directory and try to update the project, I get the following error. $ android.bat update project -p . Error: The project either has no target set or the target is invalid. Please provide a --target to the 'android.bat update' command. ndk-build is working fine but whenever I try to install using Ant, I get the build.xml is missing error inevitably. Thanks.
0
11,568,067
07/19/2012 19:38:29
1,150,534
01/15/2012 15:48:17
187
2
ipad media query bootstrap dropdown
I am using the following media query in my bootstrap app. @media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: landscape) { .nav li { width: 100%; } .nav .dropdown ul {display:none; } .nav .open ul { display: block; } .nav-collapse .nav > li > a, .nav-collapse .dropdown-menu a { text-align: center; background-color:#211256; } .nav-collapse .nav > li > a:hover, .nav-collapse .dropdown-menu a:hover { background-color: #211256; color:white; } .navbar .nav > li a:hover{ color:white; } .navbar .nav .active > a, .navbar .nav .active > a:hover { background: #211256; color: white; text-decoration: none; } .nav-collapse .nav > li > a, .nav-collapse .dropdown-menu a { border-radius: 3px 3px 3px 3px; color: white; font-weight: bold; padding: 6px 15px; margin-bottom:2px; } .navbar .nav li.dropdown .dropdown-toggle .caret, .navbar .nav li.dropdown.open .caret { border-bottom-color: white; border-top-color: white; } .navbar .nav li.dropdown.open > .dropdown-toggle, .navbar .nav li.dropdown.active > .dropdown-toggle, .navbar .nav li.dropdown.open.active > .dropdown-toggle { background-color: transparent; color: #211256; } .accordion-inner { border-top: 1px solid #E5E5E5; padding: 9px 15px; } } When viewing the page in landscape mode http://46.32.253.11/ the dropdown navbar is open by default and I cant see the bootstrap button, I use exactly the same media query for max-width 979px and the button appears and is closed. Can anyone advise what selector i need to target to have the ipad show the bootstrap button and hide the dropdown menu until the button is pressed. Any help appreciated
css
twitter-bootstrap
media-queries
null
null
null
open
ipad media query bootstrap dropdown === I am using the following media query in my bootstrap app. @media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: landscape) { .nav li { width: 100%; } .nav .dropdown ul {display:none; } .nav .open ul { display: block; } .nav-collapse .nav > li > a, .nav-collapse .dropdown-menu a { text-align: center; background-color:#211256; } .nav-collapse .nav > li > a:hover, .nav-collapse .dropdown-menu a:hover { background-color: #211256; color:white; } .navbar .nav > li a:hover{ color:white; } .navbar .nav .active > a, .navbar .nav .active > a:hover { background: #211256; color: white; text-decoration: none; } .nav-collapse .nav > li > a, .nav-collapse .dropdown-menu a { border-radius: 3px 3px 3px 3px; color: white; font-weight: bold; padding: 6px 15px; margin-bottom:2px; } .navbar .nav li.dropdown .dropdown-toggle .caret, .navbar .nav li.dropdown.open .caret { border-bottom-color: white; border-top-color: white; } .navbar .nav li.dropdown.open > .dropdown-toggle, .navbar .nav li.dropdown.active > .dropdown-toggle, .navbar .nav li.dropdown.open.active > .dropdown-toggle { background-color: transparent; color: #211256; } .accordion-inner { border-top: 1px solid #E5E5E5; padding: 9px 15px; } } When viewing the page in landscape mode http://46.32.253.11/ the dropdown navbar is open by default and I cant see the bootstrap button, I use exactly the same media query for max-width 979px and the button appears and is closed. Can anyone advise what selector i need to target to have the ipad show the bootstrap button and hide the dropdown menu until the button is pressed. Any help appreciated
0
11,568,068
07/19/2012 19:38:31
1,035,576
11/08/2011 12:26:35
294
18
App for Magazines
Im making an app that is for presenting the old versions of a magazine that my family runs.. Right now, each magazine is sold in the stores.. but the older versions, like 2005, are not in the streets anymore. I want to make an app that simply has 12 buttons, one for each magazine edition in a full year, and sell this app as the editions of my magazine for the specific year.. like, an app for 2005, another for 2006 and so on. I couldn't present this magazine in a browser for example, because i don't want the users to download the magazines and share it.. its supposed to be only for who buys the app. Would Apple reject my app?
objective-c
ios
xcode
pdf
magazine
null
open
App for Magazines === Im making an app that is for presenting the old versions of a magazine that my family runs.. Right now, each magazine is sold in the stores.. but the older versions, like 2005, are not in the streets anymore. I want to make an app that simply has 12 buttons, one for each magazine edition in a full year, and sell this app as the editions of my magazine for the specific year.. like, an app for 2005, another for 2006 and so on. I couldn't present this magazine in a browser for example, because i don't want the users to download the magazines and share it.. its supposed to be only for who buys the app. Would Apple reject my app?
0
11,572,025
07/20/2012 02:26:47
392,258
07/15/2010 03:00:43
26
5
How to create ActiveX control with menu bar?
Is there anybody knows how to create activeX control with menu bar and toolbars? or Is that possible?
c++
atl
null
null
null
null
open
How to create ActiveX control with menu bar? === Is there anybody knows how to create activeX control with menu bar and toolbars? or Is that possible?
0
11,572,030
07/20/2012 02:27:30
534,722
12/08/2010 08:33:41
1
0
save into another table
can i do like this I select SO name 'SO013' from table sale_order and I want save it into table procurement.order this my code def action_ship_create(self, cr, uid, ids, context=None): cr.execute('select name from sale_order where name = 'SO013' ') ads = cr.fetchone() name = ads and ads [0] or None print name val = { 'name': name, } return {'value': val } proc_id = self.pool.get('procurement.order').create(cr, uid, { 'name':name, }) proc_ids.append(proc_id) but it doesn't work, can you help me please
openerp
null
null
null
null
null
open
save into another table === can i do like this I select SO name 'SO013' from table sale_order and I want save it into table procurement.order this my code def action_ship_create(self, cr, uid, ids, context=None): cr.execute('select name from sale_order where name = 'SO013' ') ads = cr.fetchone() name = ads and ads [0] or None print name val = { 'name': name, } return {'value': val } proc_id = self.pool.get('procurement.order').create(cr, uid, { 'name':name, }) proc_ids.append(proc_id) but it doesn't work, can you help me please
0
11,572,032
07/20/2012 02:27:53
1,126,462
01/02/2012 15:34:23
5
0
Update multiple records mysql
Hi Guys my code is below. What I'm trying to do is to update all of the value in mysql that satisfy a specific a specific condition. Now when I just type in the mysql query: UPDATE `$DBNAME`.`video` SET `Secret_key` = '0' The query works fine but I can't seem to write php code that will do this. Any help is welcomed <?php // Part 1 (works fine) include("/home3/kintest2/public_html/include/config.local.php"); $connect= mysql_connect ($DBHOST,$DBUSER,$DBPASSWORD); $select= mysql_select_db($DBNAME, $connect); // End of Part 1 // Part 2 (works fine) $test2= "SELECT * FROM `video`"; $results= mysql_query($test2, $connect); $num_rows = mysql_num_rows($results); // End of part 2 // Part 3 ( Not too sure about this part) for ($num_rows= $count; $count >= 0; $count--) { mysql_query("UPDATE `$DBNAME`.`video` SET `Secret_key` = '0'",$connect); } // End of part 3 ( Not too sure about this part) ?>
php
mysql
null
null
null
null
open
Update multiple records mysql === Hi Guys my code is below. What I'm trying to do is to update all of the value in mysql that satisfy a specific a specific condition. Now when I just type in the mysql query: UPDATE `$DBNAME`.`video` SET `Secret_key` = '0' The query works fine but I can't seem to write php code that will do this. Any help is welcomed <?php // Part 1 (works fine) include("/home3/kintest2/public_html/include/config.local.php"); $connect= mysql_connect ($DBHOST,$DBUSER,$DBPASSWORD); $select= mysql_select_db($DBNAME, $connect); // End of Part 1 // Part 2 (works fine) $test2= "SELECT * FROM `video`"; $results= mysql_query($test2, $connect); $num_rows = mysql_num_rows($results); // End of part 2 // Part 3 ( Not too sure about this part) for ($num_rows= $count; $count >= 0; $count--) { mysql_query("UPDATE `$DBNAME`.`video` SET `Secret_key` = '0'",$connect); } // End of part 3 ( Not too sure about this part) ?>
0
11,572,034
07/20/2012 02:28:12
1,294,207
03/26/2012 23:01:39
288
17
Find indices of elements in an array based on a search from another array
Imagine that i have two arrays: a = [1, 2, 5, 7, 6, 9, 8, 3, 4, 7, 0]; b = [5, 9, 6]; I want to find the indices of the values of b in a (only the first hit) ie: c = [3, 6, 5]; Is there an easy Matlab native way to do this without looping and searching. I have tried to use find() with: find(a == b) and it would work if you did this: for i = 1:length(b) index = find(a == b(i)); c = [c, index(0)] end But it would be ideal for it to be easier then this. Thanks for the Help, Ben.
arrays
matlab
null
null
null
null
open
Find indices of elements in an array based on a search from another array === Imagine that i have two arrays: a = [1, 2, 5, 7, 6, 9, 8, 3, 4, 7, 0]; b = [5, 9, 6]; I want to find the indices of the values of b in a (only the first hit) ie: c = [3, 6, 5]; Is there an easy Matlab native way to do this without looping and searching. I have tried to use find() with: find(a == b) and it would work if you did this: for i = 1:length(b) index = find(a == b(i)); c = [c, index(0)] end But it would be ideal for it to be easier then this. Thanks for the Help, Ben.
0
11,572,035
07/20/2012 02:28:25
235,588
12/20/2009 18:51:42
554
2
Check if button was clicked in PHP from serialize() jquery
I'm building a form to allow someone to change the color of buttons, to be used on a webpage, via a web GUI. It's set up to submit the changes via ajax, with jquery, for preview prior to the user clicking the save submit button so they can make sure they like the changes before saving them. I understand that .serialize() will not send the value of a button click or even tell you that a button was clicked. I have googled and searched stackoverflow but I can't make any of the solutions work with my set up. **How can the PHP script tell if the save button was clicked?** HTML: <div id="preview"></div> <form id="build_form" class="build_form" action="button_preview.php" method="post"> <input name="color" type="radio" value="red" /> red <input name="color" type="radio" value="blue" /> blue <input name="save" type="submit" value="Save" class="button" /> </form> Javascript: <script type="text/javascript"> $(document).ready(function() { $(function() { $(".build_form").change(function() { $("form").submit(); }); }); $('#build_form').submit(function() { $.ajax({ data: $(this).serialize(), type: $(this).attr('method'), url: $(this).attr('action'), success: function(response) { $('#preview').html(response); } }); return false; }); }); </script> PHP: <?php print_r($_POST); ?>
php
javascript
jquery
null
null
null
open
Check if button was clicked in PHP from serialize() jquery === I'm building a form to allow someone to change the color of buttons, to be used on a webpage, via a web GUI. It's set up to submit the changes via ajax, with jquery, for preview prior to the user clicking the save submit button so they can make sure they like the changes before saving them. I understand that .serialize() will not send the value of a button click or even tell you that a button was clicked. I have googled and searched stackoverflow but I can't make any of the solutions work with my set up. **How can the PHP script tell if the save button was clicked?** HTML: <div id="preview"></div> <form id="build_form" class="build_form" action="button_preview.php" method="post"> <input name="color" type="radio" value="red" /> red <input name="color" type="radio" value="blue" /> blue <input name="save" type="submit" value="Save" class="button" /> </form> Javascript: <script type="text/javascript"> $(document).ready(function() { $(function() { $(".build_form").change(function() { $("form").submit(); }); }); $('#build_form').submit(function() { $.ajax({ data: $(this).serialize(), type: $(this).attr('method'), url: $(this).attr('action'), success: function(response) { $('#preview').html(response); } }); return false; }); }); </script> PHP: <?php print_r($_POST); ?>
0
11,572,051
07/20/2012 02:30:43
1,420,480
05/27/2012 18:51:39
3
0
Adding arraylist to Jlist
I have an arraylist in my metod receiveArrayLists which i want to add to a JList. How can i do this? import java.awt.Dimension; import java.awt.Scrollbar; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.net.InetSocketAddress; import java.net.Socket; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollBar; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; public class GUI implements Runnable { private Server server; private JFrame frame = new JFrame(); private JTextField jtf = new JTextField(); private JList jl = new JList(); private JTextArea jl1 = new JTextArea(); private JScrollPane pane = new JScrollPane(jl); private Socket socket; private DataInputStream dis; private ObjectInputStream ois = null; private DataOutputStream dos; public GUI() { socket = new Socket(); InetSocketAddress ipPort = new InetSocketAddress("127.0.0.1", 4444); try { socket.connect(ipPort); dis = new DataInputStream(socket.getInputStream()); dos = new DataOutputStream(socket.getOutputStream()); } catch (Exception e) { } new Thread(this).start(); frame.getContentPane().setLayout(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(50, 300, 420, 400); frame.setResizable(false); frame.setVisible(true); pane.add(jl); pane.add(jl1); jl1.setEditable(false); jtf.setBounds(50, 40, 150, 40); jl.setBounds(50, 90, 150, 200); jl1.setBounds(210, 90, 150, 200); jtf.addKeyListener(new KeyListener() { public void keyTyped(KeyEvent e) { } public void keyPressed(KeyEvent e) { } public void keyReleased(KeyEvent e) { if (dos != null) { if(jtf.getText().length() >0){ try { dos.writeUTF(jtf.getText()); } catch (IOException ex) { Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex); } }else{ jl1.setText(""); } } } }); frame.add(jtf); frame.add(jl); frame.add(jl1); frame.add(pane); } public void run() { String fromServer; try { while ((fromServer = dis.readUTF()) != null) { if (fromServer.equals("read")) { receiveArrayList(); } } } catch (Exception e) { } } Here is my metod, as you can see, i try to use append which obviously wont work to add an arraylist to a JList public void receiveArrayList() { try { jl1.setText(""); ois = new ObjectInputStream(socket.getInputStream()); @SuppressWarnings("unchecked") ArrayList<String> a = (ArrayList<String>) (ois.readObject()); for (int i = 0; i < a.size(); i++) { jl.append(a.get(i) + " \n"); } dis = new DataInputStream(socket.getInputStream()); } catch (ClassNotFoundException ex) { System.out.println(ex); } catch (IOException ex) { System.out.println(ex); } } public static void main(String[] args) { GUI g = new GUI(); } }
java
sql-server
gui
client
jlist
null
open
Adding arraylist to Jlist === I have an arraylist in my metod receiveArrayLists which i want to add to a JList. How can i do this? import java.awt.Dimension; import java.awt.Scrollbar; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.net.InetSocketAddress; import java.net.Socket; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollBar; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; public class GUI implements Runnable { private Server server; private JFrame frame = new JFrame(); private JTextField jtf = new JTextField(); private JList jl = new JList(); private JTextArea jl1 = new JTextArea(); private JScrollPane pane = new JScrollPane(jl); private Socket socket; private DataInputStream dis; private ObjectInputStream ois = null; private DataOutputStream dos; public GUI() { socket = new Socket(); InetSocketAddress ipPort = new InetSocketAddress("127.0.0.1", 4444); try { socket.connect(ipPort); dis = new DataInputStream(socket.getInputStream()); dos = new DataOutputStream(socket.getOutputStream()); } catch (Exception e) { } new Thread(this).start(); frame.getContentPane().setLayout(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(50, 300, 420, 400); frame.setResizable(false); frame.setVisible(true); pane.add(jl); pane.add(jl1); jl1.setEditable(false); jtf.setBounds(50, 40, 150, 40); jl.setBounds(50, 90, 150, 200); jl1.setBounds(210, 90, 150, 200); jtf.addKeyListener(new KeyListener() { public void keyTyped(KeyEvent e) { } public void keyPressed(KeyEvent e) { } public void keyReleased(KeyEvent e) { if (dos != null) { if(jtf.getText().length() >0){ try { dos.writeUTF(jtf.getText()); } catch (IOException ex) { Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex); } }else{ jl1.setText(""); } } } }); frame.add(jtf); frame.add(jl); frame.add(jl1); frame.add(pane); } public void run() { String fromServer; try { while ((fromServer = dis.readUTF()) != null) { if (fromServer.equals("read")) { receiveArrayList(); } } } catch (Exception e) { } } Here is my metod, as you can see, i try to use append which obviously wont work to add an arraylist to a JList public void receiveArrayList() { try { jl1.setText(""); ois = new ObjectInputStream(socket.getInputStream()); @SuppressWarnings("unchecked") ArrayList<String> a = (ArrayList<String>) (ois.readObject()); for (int i = 0; i < a.size(); i++) { jl.append(a.get(i) + " \n"); } dis = new DataInputStream(socket.getInputStream()); } catch (ClassNotFoundException ex) { System.out.println(ex); } catch (IOException ex) { System.out.println(ex); } } public static void main(String[] args) { GUI g = new GUI(); } }
0
11,351,246
07/05/2012 19:29:41
1,069,254
11/28/2011 11:44:42
145
7
Handling json with $.ajax() in Jquery
Ok, here's the problem. I've an api that will give me back a json. With success I'll have back a nice list with some values, with an error I'll receive a json containing sone information about the error. I still haven't tried the "success" case because I still have to deploy the api but I think should work. The problem for now is the "error" case. Using $.ajax in case of error I'm going to receive three parameters, a xhrequest (or similar), a message and I don't remember.. How can I handle this? In the response body shoulde be a json, where can I find it? Thanks for any help, sorry for no code or the poor indentantion but I'm writing from my mobile!
jquery
ajax
json
null
null
null
open
Handling json with $.ajax() in Jquery === Ok, here's the problem. I've an api that will give me back a json. With success I'll have back a nice list with some values, with an error I'll receive a json containing sone information about the error. I still haven't tried the "success" case because I still have to deploy the api but I think should work. The problem for now is the "error" case. Using $.ajax in case of error I'm going to receive three parameters, a xhrequest (or similar), a message and I don't remember.. How can I handle this? In the response body shoulde be a json, where can I find it? Thanks for any help, sorry for no code or the poor indentantion but I'm writing from my mobile!
0
11,351,249
07/05/2012 19:29:55
118,110
06/05/2009 15:50:52
679
15
Granting authorization for WebDeploy
I'm able to 'one-click' publish to my remote (server 08) when using the native 'Administrator' account. I'm trying to grant a different windows account ability to remote deploy. Attempting to 'connect to site' from IIS's Start page to test the account's access will always return: Cannot connect to the specified computer. The remote server returned 401 Unauthorized. For sake of testing I have this user as a member of Admin Group. What else should I be trying?
webdeploy
null
null
null
null
null
open
Granting authorization for WebDeploy === I'm able to 'one-click' publish to my remote (server 08) when using the native 'Administrator' account. I'm trying to grant a different windows account ability to remote deploy. Attempting to 'connect to site' from IIS's Start page to test the account's access will always return: Cannot connect to the specified computer. The remote server returned 401 Unauthorized. For sake of testing I have this user as a member of Admin Group. What else should I be trying?
0
11,351,228
07/05/2012 19:28:36
529,382
12/03/2010 12:48:18
1
0
how to get downloaded image in GeckoFX browser?
How to get image from the page in GeckoFX browser? I know i can simply get value of 'src' attribute and then use WebClient to donwload the file, but I need to get it from the browser, because otherwise picture will be changed on the next download.
c#
.net
geckofx
null
null
null
open
how to get downloaded image in GeckoFX browser? === How to get image from the page in GeckoFX browser? I know i can simply get value of 'src' attribute and then use WebClient to donwload the file, but I need to get it from the browser, because otherwise picture will be changed on the next download.
0
11,351,231
07/05/2012 19:28:41
979,483
10/04/2011 23:53:16
61
1
I have this jquery function...that slides up. I want it to slide left
Here's a working example of my function. Works as it should. However, how do I make it slide left, instead of sliding up/down? http://jsfiddle.net/QWQYS/24/
jquery
null
null
null
null
null
open
I have this jquery function...that slides up. I want it to slide left === Here's a working example of my function. Works as it should. However, how do I make it slide left, instead of sliding up/down? http://jsfiddle.net/QWQYS/24/
0
11,351,257
07/05/2012 19:30:31
1,040,259
11/10/2011 17:28:51
295
4
JQuery get selected value from selected dropdowns and add to total
How would I begin, I would like to select the value enclosed in "[]" of each of the selected and add it to #theFinalPrice? <div ID="theFinalPrice">$20.00</div> <p>Hotel:<br /> <select name="variation1" class="eStore_variation"> <option value="King Bed [+ $50.00]">King Bed</option> <option value="Double Bed">Double Bed</option> </select></p> <p>Add a Guest:<br /> <select name="variation2" class="eStore_variation"> <option value="no added guests">no added guests</option> <option value="+1 guest [+ $35.00]">+1 guest [+ $35.00]</option> </select></p> <p>Additional Fun:<br /> <select name="variation3" class="eStore_variation"> <option value="no additional fun">no additional fun</option> <option value="1 game of golf [+ $35.00]">+1 game of golf [+ $35.00]</option> </select></p>
jquery
jquery-selectors
null
null
null
null
open
JQuery get selected value from selected dropdowns and add to total === How would I begin, I would like to select the value enclosed in "[]" of each of the selected and add it to #theFinalPrice? <div ID="theFinalPrice">$20.00</div> <p>Hotel:<br /> <select name="variation1" class="eStore_variation"> <option value="King Bed [+ $50.00]">King Bed</option> <option value="Double Bed">Double Bed</option> </select></p> <p>Add a Guest:<br /> <select name="variation2" class="eStore_variation"> <option value="no added guests">no added guests</option> <option value="+1 guest [+ $35.00]">+1 guest [+ $35.00]</option> </select></p> <p>Additional Fun:<br /> <select name="variation3" class="eStore_variation"> <option value="no additional fun">no additional fun</option> <option value="1 game of golf [+ $35.00]">+1 game of golf [+ $35.00]</option> </select></p>
0
11,351,261
07/05/2012 19:31:00
1,260,028
03/09/2012 19:08:12
243
20
"data bit" capacity vs "overhead bit" size?
I am a little stuck because I cannot find anything which covers the "data" part of the cache, everything that I have googled deals 99.9% with the addressing of cache. The question I was asked is worded as such Contrast the difference between "data bit" capacity and "overhead bit" size for the two caches. I don't want the answer so I am not going to post the actual set sizes and what not, I am just looking for a direction to maybe a website or an explanation of how to "contrast" the two. Any possible help is well appreciated!
c
homework
computer-science
computer-architecture
null
null
open
"data bit" capacity vs "overhead bit" size? === I am a little stuck because I cannot find anything which covers the "data" part of the cache, everything that I have googled deals 99.9% with the addressing of cache. The question I was asked is worded as such Contrast the difference between "data bit" capacity and "overhead bit" size for the two caches. I don't want the answer so I am not going to post the actual set sizes and what not, I am just looking for a direction to maybe a website or an explanation of how to "contrast" the two. Any possible help is well appreciated!
0
11,351,264
07/05/2012 19:31:03
814,354
06/24/2011 15:47:30
725
18
Change numpy.seterr defaults?
I'd like to change my seterr *defaults* to be either all 'warn' or all 'ignore'. This can be done interactively by doing `np.seterr(all='ignore')`. Is there a way to make it a system default? There is no `.numpyrc` as far as I can tell; is there some other configuration file where these defaults can be changed? (I'm using numpy 1.6.1)
numpy
null
null
null
null
null
open
Change numpy.seterr defaults? === I'd like to change my seterr *defaults* to be either all 'warn' or all 'ignore'. This can be done interactively by doing `np.seterr(all='ignore')`. Is there a way to make it a system default? There is no `.numpyrc` as far as I can tell; is there some other configuration file where these defaults can be changed? (I'm using numpy 1.6.1)
0
11,351,265
07/05/2012 19:31:09
486,132
10/25/2010 07:02:36
11
0
Can I control the order of JSF2 partial render update processing?
I have a particular set of components (primefaces lazy loaded data table, and a p:messages) which are being updated via partial rendering in an ajax request. I have configured the messages component to be updated on the datatable's page event, but it seems that the messages component is always updated before the datatable, unless I place it below the datatable component within it's respective form. Here's a summary of the jsf page configuration; I also have a bit of code which adds a message to the faces context within the "load" method of the `#{lazyDataModel}` backing bean, and on inspecting the partial response (and screen results), this message is added to the update for 'msgsAfter', but not to 'msgsBefore'. <h:form id="reviewRoomsForm"> <p:messages id="msgsBefore" globalOnly="true" showDetail="true" /> <p:dataTable id="hotelRooms" var="room" value="#{lazyDataModel}" paginator="true" rows="10" emptyMessage="#{msg.noRecordsFound}"> <p:ajax event="sort" update=":reviewRoomsForm:msgsBefore :reviewRoomsForm:msgsAfter" /> <p:ajax event="page" update=":reviewRoomsForm:msgsBefore :reviewRoomsForm:msgsAfter" /> ... </p:dataTable> <p:messages id="msgsAfter" globalOnly="true" showDetail="true" /> <br /> </h:form> I'm wondering, is there any way (JSF2 or Primfaces-specific) to control the order in which components are updated on a partial render? Alternatively, if I can't explicitly specify the order of updates, is there a way to convey that one component depends on another (and so should be updated after the other one)? **Things I've tried:** - Re-ordering the component IDs in the "update" attribute; doesn't seem to matter. It looks like the order of iteration is controlled by the parent component's getFacetsAndChildren() - Adding a p:remoteCommand to be fired in the "oncomplete" client event for the page event to update the messages manually; fires in the correct order, but the message is no longer in FacesContext at this point.
jsf
jsf-2.0
primefaces
null
null
null
open
Can I control the order of JSF2 partial render update processing? === I have a particular set of components (primefaces lazy loaded data table, and a p:messages) which are being updated via partial rendering in an ajax request. I have configured the messages component to be updated on the datatable's page event, but it seems that the messages component is always updated before the datatable, unless I place it below the datatable component within it's respective form. Here's a summary of the jsf page configuration; I also have a bit of code which adds a message to the faces context within the "load" method of the `#{lazyDataModel}` backing bean, and on inspecting the partial response (and screen results), this message is added to the update for 'msgsAfter', but not to 'msgsBefore'. <h:form id="reviewRoomsForm"> <p:messages id="msgsBefore" globalOnly="true" showDetail="true" /> <p:dataTable id="hotelRooms" var="room" value="#{lazyDataModel}" paginator="true" rows="10" emptyMessage="#{msg.noRecordsFound}"> <p:ajax event="sort" update=":reviewRoomsForm:msgsBefore :reviewRoomsForm:msgsAfter" /> <p:ajax event="page" update=":reviewRoomsForm:msgsBefore :reviewRoomsForm:msgsAfter" /> ... </p:dataTable> <p:messages id="msgsAfter" globalOnly="true" showDetail="true" /> <br /> </h:form> I'm wondering, is there any way (JSF2 or Primfaces-specific) to control the order in which components are updated on a partial render? Alternatively, if I can't explicitly specify the order of updates, is there a way to convey that one component depends on another (and so should be updated after the other one)? **Things I've tried:** - Re-ordering the component IDs in the "update" attribute; doesn't seem to matter. It looks like the order of iteration is controlled by the parent component's getFacetsAndChildren() - Adding a p:remoteCommand to be fired in the "oncomplete" client event for the page event to update the messages manually; fires in the correct order, but the message is no longer in FacesContext at this point.
0
11,351,267
07/05/2012 19:31:09
486,805
10/25/2010 19:01:21
201
4
Twitter Bootstrap carousel sharing a horizontal row
I want to set up a carousel that is 400x400 px and shares a horizontal row with another element that is to it's left. For example, I have row class which contains a span4 class and then the carousel in the code below. However, the navigation controls aren't aligned with the carousel image (the controls don't move over to the right with the carousel, instead remaining on the left side where the span4 class is). <div class="row"> <div class="span4"> <h2>Heading</h2> <p>Some Text</p> </div> <div id="this-carousel-id" class="carousel slide" style="max-width: 400px"> <div class="carousel-inner"> <div class="item active"><img src="http://placehold.it/400x400" alt="" /> </div> <div class="item"><img src="http://placehold.it/400x400" alt="" /> </div> </div> <!-- Carousel Controls --> <a class="carousel-control left" href="#this-carousel-id" data-slide="prev">&lsaquo;</a> <a class="carousel-control right" href="#this-carousel-id" data-slide="next">&rsaquo;</a> </div> </div>
javascript
css
twitter-bootstrap
carousel
null
null
open
Twitter Bootstrap carousel sharing a horizontal row === I want to set up a carousel that is 400x400 px and shares a horizontal row with another element that is to it's left. For example, I have row class which contains a span4 class and then the carousel in the code below. However, the navigation controls aren't aligned with the carousel image (the controls don't move over to the right with the carousel, instead remaining on the left side where the span4 class is). <div class="row"> <div class="span4"> <h2>Heading</h2> <p>Some Text</p> </div> <div id="this-carousel-id" class="carousel slide" style="max-width: 400px"> <div class="carousel-inner"> <div class="item active"><img src="http://placehold.it/400x400" alt="" /> </div> <div class="item"><img src="http://placehold.it/400x400" alt="" /> </div> </div> <!-- Carousel Controls --> <a class="carousel-control left" href="#this-carousel-id" data-slide="prev">&lsaquo;</a> <a class="carousel-control right" href="#this-carousel-id" data-slide="next">&rsaquo;</a> </div> </div>
0
11,542,670
07/18/2012 13:34:34
1,511,693
07/09/2012 10:26:00
13
0
how to manage code in appdelegate?
I have converted my application to a static link library.there are few function and variables that are in appdelegate.h and .m files due to this reason i have added appdelegate.h also to the static library. when i include this library in another project ,i am able to access the viewcontrollers separately from that library, but i am not able to navigate from one view to another from the library itself due to variables in appdelegate. viewcontroller1->viewcontroller2->viewcontroller3 viewcontroller1 = is called from my project which is inturn library's viewcontroller. viewcontroller2 should be cald from viewcontroller1. how should i manage this ,so that the app runs.
iphone
iphone-sdk-4.0
null
null
null
null
open
how to manage code in appdelegate? === I have converted my application to a static link library.there are few function and variables that are in appdelegate.h and .m files due to this reason i have added appdelegate.h also to the static library. when i include this library in another project ,i am able to access the viewcontrollers separately from that library, but i am not able to navigate from one view to another from the library itself due to variables in appdelegate. viewcontroller1->viewcontroller2->viewcontroller3 viewcontroller1 = is called from my project which is inturn library's viewcontroller. viewcontroller2 should be cald from viewcontroller1. how should i manage this ,so that the app runs.
0
11,542,679
07/18/2012 13:35:18
1,430,112
06/01/2012 07:18:14
1
0
Dynamically assigning objects 2d array lua
Below is the code i am trying to write? local diceClass = require( "dice" ) grid={} for i =1,5 do grid[i]= {} for j =1,5 do grid[i][j]=diceclass.new( ((i+2)/10),((j+2)/10)) end end --dice class local dice = {} local dice_mt = { __index = dice } function dice.new( posx, posy) a=math.random(1,6) local newdice = display.newText(a, display.contentWidth*posx, display.contentHeight*posy, nil, 60) return setmetatable( newdice, dice_mt ) end return dice
lua
null
null
null
null
null
open
Dynamically assigning objects 2d array lua === Below is the code i am trying to write? local diceClass = require( "dice" ) grid={} for i =1,5 do grid[i]= {} for j =1,5 do grid[i][j]=diceclass.new( ((i+2)/10),((j+2)/10)) end end --dice class local dice = {} local dice_mt = { __index = dice } function dice.new( posx, posy) a=math.random(1,6) local newdice = display.newText(a, display.contentWidth*posx, display.contentHeight*posy, nil, 60) return setmetatable( newdice, dice_mt ) end return dice
0
11,542,684
07/18/2012 13:35:36
890,489
08/11/2011 18:15:30
16
0
Log content size of servlet requests and response with a filter in java
I'm working on a java project, and now I have been asked to track how much data is sent to and from our server. So I've written a filter and mapped it to all the calls it should be monitoring as other people told me to do. This filter works as it should, but i'm having problems getting the size of the response. This is my basic implementation of the doFilter and i'm using a wrapper for the response. DoFilter: public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (filterConfig == null) return; LogResponseWrapper logResponseWrapper = new LogResponseWrapper((HttpServletResponse) response); chain.doFilter(request, logResponseWrapper); } Wrapper based upon examples online: public class LogResponseWrapper extends HttpServletResponseWrapper { public long size = 0; public PrintWriter myWriter = null; public OutputStream myOutputStream = null; LogResponseWrapper(HttpServletResponse response) { super(response); } @Override public PrintWriter getWriter() { PrintWriter writer = null; try { System.out.println("calling the writer"); writer = super.getWriter(); myWriter = writer; } catch (Exception e) { e.printStackTrace(); } return writer; } @Override public ServletOutputStream getOutputStream() { ServletOutputStream os = null; try { System.out.println("calling the getOutputStream"); os = super.getOutputStream(); myOutputStream = os; } catch (Exception e) { e.printStackTrace(); } return os; } } So, you see, this is very basic and does what it should do. But I seem to be unable to find out how many bytes have been transfered to the response after the chain.doFilter has been called. I've tried converting it to a DataOutputStream and ByteArrayOutputStream as others have suggested, but that didn't work either. So If anyone has any pointers on how to do this, feel free to help me out. Thank you in advance.
java
servlets
filter
size
response
null
open
Log content size of servlet requests and response with a filter in java === I'm working on a java project, and now I have been asked to track how much data is sent to and from our server. So I've written a filter and mapped it to all the calls it should be monitoring as other people told me to do. This filter works as it should, but i'm having problems getting the size of the response. This is my basic implementation of the doFilter and i'm using a wrapper for the response. DoFilter: public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (filterConfig == null) return; LogResponseWrapper logResponseWrapper = new LogResponseWrapper((HttpServletResponse) response); chain.doFilter(request, logResponseWrapper); } Wrapper based upon examples online: public class LogResponseWrapper extends HttpServletResponseWrapper { public long size = 0; public PrintWriter myWriter = null; public OutputStream myOutputStream = null; LogResponseWrapper(HttpServletResponse response) { super(response); } @Override public PrintWriter getWriter() { PrintWriter writer = null; try { System.out.println("calling the writer"); writer = super.getWriter(); myWriter = writer; } catch (Exception e) { e.printStackTrace(); } return writer; } @Override public ServletOutputStream getOutputStream() { ServletOutputStream os = null; try { System.out.println("calling the getOutputStream"); os = super.getOutputStream(); myOutputStream = os; } catch (Exception e) { e.printStackTrace(); } return os; } } So, you see, this is very basic and does what it should do. But I seem to be unable to find out how many bytes have been transfered to the response after the chain.doFilter has been called. I've tried converting it to a DataOutputStream and ByteArrayOutputStream as others have suggested, but that didn't work either. So If anyone has any pointers on how to do this, feel free to help me out. Thank you in advance.
0
11,542,685
07/18/2012 13:35:37
1,534,934
07/18/2012 13:32:39
1
0
SharePoint Audit Entries
In my application i process audit logs to get the items that have been changed. Once audit entry is got, then i run SPSiteDataQuery to be able to get ListId of particular item, as SPAuditEntry does not expose that property. This works ok, however for big number of audit entries it works very slow,e.g. 10K audit logs take around 12 mins to run all this data queries. I am wondering is there a way to extend out of box audit log writing, so right in the process of logging it writes also ListId in the log? Thanks, Hrayr
sharepoint2010
null
null
null
null
null
open
SharePoint Audit Entries === In my application i process audit logs to get the items that have been changed. Once audit entry is got, then i run SPSiteDataQuery to be able to get ListId of particular item, as SPAuditEntry does not expose that property. This works ok, however for big number of audit entries it works very slow,e.g. 10K audit logs take around 12 mins to run all this data queries. I am wondering is there a way to extend out of box audit log writing, so right in the process of logging it writes also ListId in the log? Thanks, Hrayr
0
11,542,687
07/18/2012 13:35:39
805,284
06/19/2011 11:44:34
369
16
git: How to ignore all present untracked files?
Is there a handy way to ignore all untracked files and folders in a git repository?<br/> (I know about the `.gitignore`.) So `git status` would provide a clean result again. Thanks for any input on this.
git
gitignore
null
null
null
null
open
git: How to ignore all present untracked files? === Is there a handy way to ignore all untracked files and folders in a git repository?<br/> (I know about the `.gitignore`.) So `git status` would provide a clean result again. Thanks for any input on this.
0
11,542,689
07/18/2012 13:35:44
35,026
11/06/2008 10:58:37
2,521
22
How is the 'name' attribute calculated in ASP.NET?
Im trying to understand how the 'name' attribute works for elements in markup rendered via ASP.NET I.e. `<select id="lblxyz" name="ctl00$c$ctl341$lblxyz">` What are `ctl00`, `c` and `ctl1341`? If I create a `WebControl`, give it an arbitrary id, then place a `Button` inside its `Controls` collection, the `name` attribute does not seem to reflect the container's id?
asp.net
null
null
null
null
null
open
How is the 'name' attribute calculated in ASP.NET? === Im trying to understand how the 'name' attribute works for elements in markup rendered via ASP.NET I.e. `<select id="lblxyz" name="ctl00$c$ctl341$lblxyz">` What are `ctl00`, `c` and `ctl1341`? If I create a `WebControl`, give it an arbitrary id, then place a `Button` inside its `Controls` collection, the `name` attribute does not seem to reflect the container's id?
0
11,542,694
07/18/2012 13:35:56
1,433,826
06/03/2012 17:27:11
73
4
If the child activity calls parent activity, does a new instance gets opened?
If an activity calls it parent activity by `startActivity(intent) // Here intent is parent activity`, Then, will a new instance of the parent activty will be opened or the same background activity will come in front? I'm asking because my parent activity contains a `ListView` & my child activity is performing an operation that is updating the ListView in parent activity. As soon as the user presses the Done button in child activity, the list needs to be updated. That's why I'm using `startActivity`.
android
activity
null
null
null
null
open
If the child activity calls parent activity, does a new instance gets opened? === If an activity calls it parent activity by `startActivity(intent) // Here intent is parent activity`, Then, will a new instance of the parent activty will be opened or the same background activity will come in front? I'm asking because my parent activity contains a `ListView` & my child activity is performing an operation that is updating the ListView in parent activity. As soon as the user presses the Done button in child activity, the list needs to be updated. That's why I'm using `startActivity`.
0
11,542,699
07/18/2012 13:36:08
766,570
05/23/2011 19:25:27
35
3
Can android directly play Dynamic HTTP streaming using flash manifest file (.f4m)
I'm trying to make an app that plays live http streaming on android (i already did the same in [iphone](http://stackoverflow.com/questions/11473381/trying-to-live-stream-from-aws-fms-to-iphone-using-hls)). The Android official tutorial shows a sample [code](http://developer.android.com/guide/topics/media/mediaplayer.html) on how to do http live streaming, which i followed: public class liveStream extends Activity implements OnClickListener { Button streamButton; MediaPlayer mediaPlayer = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_live_stream); streamButton = (Button) findViewById(R.id.streamButton); streamButton.setOnClickListener(this); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_live_stream, menu); return true; } public void onClick(View v) { String url = "http://d2233avv69kunu.cloudfront.net/hds-live/livepkgr/_definst_/liveevent/livestream.f4m"; mediaPlayer = new MediaPlayer(); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { mediaPlayer.setDataSource(url); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } try { mediaPlayer.prepare(); } catch (IOException e) { e.printStackTrace(); } mediaPlayer.start(); } } thing is I keep on getting an IOException when i try to prepare the player.. I did some research and it appears that I will need to play this off a flash client from my android? If that's so, how can I play live http streaming directly without the third party flash player? Similar to [iphone](http://stackoverflow.com/questions/11473381/trying-to-live-stream-from-aws-fms-to-iphone-using-hls)
android
http
live-streaming
null
null
null
open
Can android directly play Dynamic HTTP streaming using flash manifest file (.f4m) === I'm trying to make an app that plays live http streaming on android (i already did the same in [iphone](http://stackoverflow.com/questions/11473381/trying-to-live-stream-from-aws-fms-to-iphone-using-hls)). The Android official tutorial shows a sample [code](http://developer.android.com/guide/topics/media/mediaplayer.html) on how to do http live streaming, which i followed: public class liveStream extends Activity implements OnClickListener { Button streamButton; MediaPlayer mediaPlayer = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_live_stream); streamButton = (Button) findViewById(R.id.streamButton); streamButton.setOnClickListener(this); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_live_stream, menu); return true; } public void onClick(View v) { String url = "http://d2233avv69kunu.cloudfront.net/hds-live/livepkgr/_definst_/liveevent/livestream.f4m"; mediaPlayer = new MediaPlayer(); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { mediaPlayer.setDataSource(url); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } try { mediaPlayer.prepare(); } catch (IOException e) { e.printStackTrace(); } mediaPlayer.start(); } } thing is I keep on getting an IOException when i try to prepare the player.. I did some research and it appears that I will need to play this off a flash client from my android? If that's so, how can I play live http streaming directly without the third party flash player? Similar to [iphone](http://stackoverflow.com/questions/11473381/trying-to-live-stream-from-aws-fms-to-iphone-using-hls)
0
11,542,701
07/18/2012 13:36:09
1,436,685
06/05/2012 06:46:17
2
0
Dynamically change button font color c#
I want to change the font color of a button dynamically to red. How can i do this?
c#
button
fonts
colors
null
07/18/2012 13:39:17
not a real question
Dynamically change button font color c# === I want to change the font color of a button dynamically to red. How can i do this?
1
11,542,703
07/18/2012 13:36:14
1,534,926
07/18/2012 13:28:21
1
0
Saving MATLAB figures as PDF with quality 300dpi, centered
I want to save a matlab figure as PDF, with quality 300dpi, and centered. So far I managed to save it, but the image appears cropped. I changed the page type to A3 and kind of solves the problem, but I am looking for something more elegant. I am doing it form the GUI, but maybe from the command line is easier in MATLAB. Is there any package or script that makes this (fundamental task for publications and papaers) a bit easier?
matlab
pdf
matlab-figure
null
null
null
open
Saving MATLAB figures as PDF with quality 300dpi, centered === I want to save a matlab figure as PDF, with quality 300dpi, and centered. So far I managed to save it, but the image appears cropped. I changed the page type to A3 and kind of solves the problem, but I am looking for something more elegant. I am doing it form the GUI, but maybe from the command line is easier in MATLAB. Is there any package or script that makes this (fundamental task for publications and papaers) a bit easier?
0
11,542,710
07/18/2012 13:36:37
286,878
03/05/2010 06:23:31
154
10
SyncAdapter configuration UI
I'm working on implementation of SyncAdapter for my APP. And I'd like to add settings for periodic sync configuration. Here an example of thing, I'm trying to achieve. As you see - in this Account there 2 custom elements: - "Update when openened" checkbox - "Update schedule" with popup I'm able to add only item similia to "Sync news", as it is just a configuration for my Syncable ContentProvider. Colleagues, can you advice how to implement custom elements? ![enter image description here][1] [1]: http://i.stack.imgur.com/OQlem.jpg
android
android-syncadapter
null
null
null
null
open
SyncAdapter configuration UI === I'm working on implementation of SyncAdapter for my APP. And I'd like to add settings for periodic sync configuration. Here an example of thing, I'm trying to achieve. As you see - in this Account there 2 custom elements: - "Update when openened" checkbox - "Update schedule" with popup I'm able to add only item similia to "Sync news", as it is just a configuration for my Syncable ContentProvider. Colleagues, can you advice how to implement custom elements? ![enter image description here][1] [1]: http://i.stack.imgur.com/OQlem.jpg
0
11,411,348
07/10/2012 10:26:44
1,514,436
07/10/2012 10:13:01
1
0
Making Newstand IOS Apps in CS5.5
I have built a couple of apps in Adobe Cs5.5 and find it useful for small projects we want to convert over to android. I know its not as powerful as native obj C but there we go. My question is regarding Newstand. I want to make iMags and have subscriptions for them and need to know how to firstly edit the app for Newstand (I suspect it requires an edit to the info.plist after publishing) We then need to set up the subscription in app purchase and I wonder if this is the same for native apps or specific for one build using adobes cs5.5... I know we could use the publishing suite but it seems expensive when you have paid for the whole Creative suite and then £200 odd quid after that.
ios
air
adobe
flash-cs5.5
null
null
open
Making Newstand IOS Apps in CS5.5 === I have built a couple of apps in Adobe Cs5.5 and find it useful for small projects we want to convert over to android. I know its not as powerful as native obj C but there we go. My question is regarding Newstand. I want to make iMags and have subscriptions for them and need to know how to firstly edit the app for Newstand (I suspect it requires an edit to the info.plist after publishing) We then need to set up the subscription in app purchase and I wonder if this is the same for native apps or specific for one build using adobes cs5.5... I know we could use the publishing suite but it seems expensive when you have paid for the whole Creative suite and then £200 odd quid after that.
0
11,411,349
07/10/2012 10:26:49
1,514,464
07/10/2012 10:22:41
1
0
jQueryMobile : how to use seperate html and js files to do pageinit and postdata?
consider this case: login.html: contain login page, do login and post user data to next page which is a seperate file named main.html; main.html: contain main page which will show my todo list by using account data from login.html; now, I want to do some things in main.html, such as get data from prepage, and request todo list from server, and bind some event to list items. now, I use $.mobile.changepage forward to main.html, and bind pagechange event to mainPage in login.js, I could do these things. but how can I do this in main.js which include by main.html ? maybe is not good to put every page to seperate html files and js files, but if I need to do like these, how ? Thanks.
jquery-mobile
null
null
null
null
null
open
jQueryMobile : how to use seperate html and js files to do pageinit and postdata? === consider this case: login.html: contain login page, do login and post user data to next page which is a seperate file named main.html; main.html: contain main page which will show my todo list by using account data from login.html; now, I want to do some things in main.html, such as get data from prepage, and request todo list from server, and bind some event to list items. now, I use $.mobile.changepage forward to main.html, and bind pagechange event to mainPage in login.js, I could do these things. but how can I do this in main.js which include by main.html ? maybe is not good to put every page to seperate html files and js files, but if I need to do like these, how ? Thanks.
0
11,411,284
07/10/2012 10:22:39
1,294,478
03/27/2012 02:46:43
1
1
How to launch jar code by using exec app_process on android 4.0
The following code works well on Android 2.x, but it can not launch jar code on Android 4.0, any suggestion will be appreciate String fullCmd = "export CLASSPATH=" + "/data/data/com.test.myproject/files/test.jar"; fullCmd += "; exec app_process /system/bin " + AGENT_MAIN_CLASS + " " + cmdList; Process exeEcho = Runtime.getRuntime().exec("su"); exeEcho.getOutputStream().write(fullCmd.getBytes()); exeEcho.getOutputStream().flush(); exeEcho.getOutputStream().write("exit\n".getBytes()); exeEcho.getOutputStream().flush(); try { exeEcho.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); }
android
jar
ics
null
null
null
open
How to launch jar code by using exec app_process on android 4.0 === The following code works well on Android 2.x, but it can not launch jar code on Android 4.0, any suggestion will be appreciate String fullCmd = "export CLASSPATH=" + "/data/data/com.test.myproject/files/test.jar"; fullCmd += "; exec app_process /system/bin " + AGENT_MAIN_CLASS + " " + cmdList; Process exeEcho = Runtime.getRuntime().exec("su"); exeEcho.getOutputStream().write(fullCmd.getBytes()); exeEcho.getOutputStream().flush(); exeEcho.getOutputStream().write("exit\n".getBytes()); exeEcho.getOutputStream().flush(); try { exeEcho.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); }
0
11,411,352
07/10/2012 10:26:57
1,306,589
04/01/2012 17:08:40
12
0
XSS sanitizer removes html tags like <br>,<div> etc. Is there any alternative provided by other than Microsoft?
I tried AntiXSSLibrary, HTMLAgilitypack, SantizerProviders and HTMLSanitizationLibrary but all of these are removing `<br>` and `<div>` tags from input html and that's why i am using htmleditors without XSS sanitizers, Can you please tell is there any alternate XSS Sanitizer Provider provided by any trusted organization other than Microsoft for asp.net. Please help I can't live my htmleditors open for XSS attacks.
asp.net
ajax
html-agility-pack
sanitization
antixsslibrary
null
open
XSS sanitizer removes html tags like <br>,<div> etc. Is there any alternative provided by other than Microsoft? === I tried AntiXSSLibrary, HTMLAgilitypack, SantizerProviders and HTMLSanitizationLibrary but all of these are removing `<br>` and `<div>` tags from input html and that's why i am using htmleditors without XSS sanitizers, Can you please tell is there any alternate XSS Sanitizer Provider provided by any trusted organization other than Microsoft for asp.net. Please help I can't live my htmleditors open for XSS attacks.
0
11,401,522
07/09/2012 19:12:05
344,527
05/18/2010 21:41:54
606
46
DojoX Flash streaming
When I use jwplayer with following config everything is OK. jwplayer('someId').setup({ 'flashplayer': '/js/jwplayer/player.swf', 'file': 'awesome.flv', 'streamer': 'rtmp://some.server.com:1934/vod', 'width': '220', 'height': '190' }); When I use dojo with following config: new Flash({ path: 'rtmp://some.server.com:1934/vod?file=awesome.flv' , width: 220, height: 190 }, this.someId); Flash place holder is visible, but no controls to play stream and in the console I can see error that have no meaning for me... Building SWF failed. [Break On This Error] comboPendingTimer = null; dojo.js (line 648) What is wrong with dojo flash config? Another thing is how to tell dojo to use `object` tag? Right now it uses some strange `embed` tag...
flash
dojo
dojox
null
null
null
open
DojoX Flash streaming === When I use jwplayer with following config everything is OK. jwplayer('someId').setup({ 'flashplayer': '/js/jwplayer/player.swf', 'file': 'awesome.flv', 'streamer': 'rtmp://some.server.com:1934/vod', 'width': '220', 'height': '190' }); When I use dojo with following config: new Flash({ path: 'rtmp://some.server.com:1934/vod?file=awesome.flv' , width: 220, height: 190 }, this.someId); Flash place holder is visible, but no controls to play stream and in the console I can see error that have no meaning for me... Building SWF failed. [Break On This Error] comboPendingTimer = null; dojo.js (line 648) What is wrong with dojo flash config? Another thing is how to tell dojo to use `object` tag? Right now it uses some strange `embed` tag...
0
11,411,337
07/10/2012 10:25:55
1,425,711
05/30/2012 09:50:10
1
1
Dragging and dropping images within multiple boundries in HTML5 canvas.
I am new with HTML5. I have to implement such a functionality that I want images to be dropped within a canvas from outside, then there are visible boundaries within canvas and the images can be moved from one boundary to another. It is the same as in the following link, http://custom.case-mate.com/diy?bypassLandingPage=true As, in the site, user selects the pattern and drags images into that. Then he can drag the images between the boundaries. please give some solution for implementing such a functionality.
javascript
html5
css3
null
null
null
open
Dragging and dropping images within multiple boundries in HTML5 canvas. === I am new with HTML5. I have to implement such a functionality that I want images to be dropped within a canvas from outside, then there are visible boundaries within canvas and the images can be moved from one boundary to another. It is the same as in the following link, http://custom.case-mate.com/diy?bypassLandingPage=true As, in the site, user selects the pattern and drags images into that. Then he can drag the images between the boundaries. please give some solution for implementing such a functionality.
0
11,411,357
07/10/2012 10:27:16
1,005,030
10/20/2011 10:55:08
748
19
Sort a list to place an element at the top
I have a `List<Vehicles>` which contains 4 items: My `Vehicles` object has 2 properties: `VehId`, `VehName` The 4 items in my list are: 1) `VehId : "LOR", VehName : "Lorry"` 2) `VehId : "CAR", VehName : "Car"` 3) `VehId : "BOA", VehName : "Boat"` 4) `VehId : "PLN", VehName : "Plane"` What I'd like to do is put `Car` vehicle to the top of the list. How would I do this? By using `.OrderBy()` or `.Sort()`?
c#
null
null
null
null
null
open
Sort a list to place an element at the top === I have a `List<Vehicles>` which contains 4 items: My `Vehicles` object has 2 properties: `VehId`, `VehName` The 4 items in my list are: 1) `VehId : "LOR", VehName : "Lorry"` 2) `VehId : "CAR", VehName : "Car"` 3) `VehId : "BOA", VehName : "Boat"` 4) `VehId : "PLN", VehName : "Plane"` What I'd like to do is put `Car` vehicle to the top of the list. How would I do this? By using `.OrderBy()` or `.Sort()`?
0
11,411,358
07/10/2012 10:27:19
1,514,463
07/10/2012 10:22:30
1
0
Codeigniter Native Session Issue with URL helper function redirect
Guyes i have just used Native Session Library from here http://codeigniter.com/forums/viewthread/93200/ for Codeigniter 2.1.2 and my redirect function stops working. Any idea?
codeigniter
session
url
native
helper
07/11/2012 11:09:30
not a real question
Codeigniter Native Session Issue with URL helper function redirect === Guyes i have just used Native Session Library from here http://codeigniter.com/forums/viewthread/93200/ for Codeigniter 2.1.2 and my redirect function stops working. Any idea?
1
11,411,362
07/10/2012 10:27:43
1,140,204
01/10/2012 06:17:37
25
1
Facebook Single Sign On is not working in iOS 5
I have looked through and implemented it in my codes. What i am trying to achieve here is that the landing page will show a Facebook login button, and when i click on it it will direct me to the FB auth page and after authentication, FB will direct me back to the next view as according to my storyboard. However, the method, fbDidLogin did not run and hence no data was saved. Does anyone know what should I include in my codes to ensure that Facebook calls that fbDidLogin method? Codes of my LoginViewcontroller is below. - (IBAction)loginViaFacebook:(id)sender { NSLog(@"login started"); facebook = [[Facebook alloc] initWithAppId:@"415397998499562" andDelegate:self]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) { facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"]; NSLog(@"%@",facebook.accessToken); facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"]; } NSLog(@"FB Login in progress"); if (![facebook isSessionValid]) { //This sets the permissions required by our app NSArray *permissions = [[NSArray alloc] initWithObjects: @"user_likes", @"read_stream", nil]; NSLog(@"Permissions set"); [facebook authorize:permissions]; } NSLog(@"FB Login has ended"); }
facebook
ios5
sso
null
null
null
open
Facebook Single Sign On is not working in iOS 5 === I have looked through and implemented it in my codes. What i am trying to achieve here is that the landing page will show a Facebook login button, and when i click on it it will direct me to the FB auth page and after authentication, FB will direct me back to the next view as according to my storyboard. However, the method, fbDidLogin did not run and hence no data was saved. Does anyone know what should I include in my codes to ensure that Facebook calls that fbDidLogin method? Codes of my LoginViewcontroller is below. - (IBAction)loginViaFacebook:(id)sender { NSLog(@"login started"); facebook = [[Facebook alloc] initWithAppId:@"415397998499562" andDelegate:self]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) { facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"]; NSLog(@"%@",facebook.accessToken); facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"]; } NSLog(@"FB Login in progress"); if (![facebook isSessionValid]) { //This sets the permissions required by our app NSArray *permissions = [[NSArray alloc] initWithObjects: @"user_likes", @"read_stream", nil]; NSLog(@"Permissions set"); [facebook authorize:permissions]; } NSLog(@"FB Login has ended"); }
0
11,650,940
07/25/2012 13:33:22
1,275,937
03/17/2012 15:50:04
327
11
sed - how to do regex match group using sed
Is there anyway you can do regex match group using sed like java regex pattern/match/group? if i have string like test-artifact-201251-balbal-0.1-SNAPSHOT.jar how do I use sed just to get the result like: test-artifact-0.1-SNASHOT.jar I am wondering does sed allow you to do something like java regex, you define the pattern like: ([a-z]*-[a-z]*-)([0-9]*-)([a-z]*-)([.]*SNAPSHOT.jar) and then you can get the results as an array as below: test-artifact- 201251- balbal- 0.1-SNAPSHOT.jar
regex
linux
sed
null
null
null
open
sed - how to do regex match group using sed === Is there anyway you can do regex match group using sed like java regex pattern/match/group? if i have string like test-artifact-201251-balbal-0.1-SNAPSHOT.jar how do I use sed just to get the result like: test-artifact-0.1-SNASHOT.jar I am wondering does sed allow you to do something like java regex, you define the pattern like: ([a-z]*-[a-z]*-)([0-9]*-)([a-z]*-)([.]*SNAPSHOT.jar) and then you can get the results as an array as below: test-artifact- 201251- balbal- 0.1-SNAPSHOT.jar
0
11,650,941
07/25/2012 13:33:23
589,840
01/25/2011 22:41:32
56
1
Best pratice to show that a function parameter is (or is not) inteded to be modified
Functions parameters tend to have different purposes : in most case they are just readonly indications used by the internal logic to produce a result/effect, but sometimes they are modified by the calling function (initialisation function, sorting algorithm, etc.) I was wondering if there is a best pratice to show in the code that the function is going to modify a parameter (a part from writing a comment above stating this explicitly) ? Like a widely recognized coding convention. With C++ I use the 'const' keyword for every parameter which is not going to be modified by the function, but C# does not allow 'const' or 'readonly' to be used that way. And a lack of 'const' does not really mean that the parameter is intended to be updated by the function anyway. Thanks
function
coding-style
parameters
null
null
null
open
Best pratice to show that a function parameter is (or is not) inteded to be modified === Functions parameters tend to have different purposes : in most case they are just readonly indications used by the internal logic to produce a result/effect, but sometimes they are modified by the calling function (initialisation function, sorting algorithm, etc.) I was wondering if there is a best pratice to show in the code that the function is going to modify a parameter (a part from writing a comment above stating this explicitly) ? Like a widely recognized coding convention. With C++ I use the 'const' keyword for every parameter which is not going to be modified by the function, but C# does not allow 'const' or 'readonly' to be used that way. And a lack of 'const' does not really mean that the parameter is intended to be updated by the function anyway. Thanks
0
11,651,222
07/25/2012 13:48:08
343,957
05/18/2010 11:44:53
1,547
96
What is the point of auto generate instvar?
Since C# 3.0 there is the new syntax to autogenerate the instance variable from a propertie: public string Foo { get; set; } But there is no way to access the underlying backing field. So I don't really see the point of it because declaring the same instance variable would produce the same effect without the overhead of calling the "getter" and "setter". public string Foo; Declaring the property like: public string Foo { get; } or public string Foo { set; } is totally useless since we are not able to write resp. read the content of the field. Does someone have a good explanation for why in C# they have put all this effort to introduce this syntactic sugar? Thanks
c#
properties
auto-generate
null
null
null
open
What is the point of auto generate instvar? === Since C# 3.0 there is the new syntax to autogenerate the instance variable from a propertie: public string Foo { get; set; } But there is no way to access the underlying backing field. So I don't really see the point of it because declaring the same instance variable would produce the same effect without the overhead of calling the "getter" and "setter". public string Foo; Declaring the property like: public string Foo { get; } or public string Foo { set; } is totally useless since we are not able to write resp. read the content of the field. Does someone have a good explanation for why in C# they have put all this effort to introduce this syntactic sugar? Thanks
0
11,651,231
07/25/2012 13:48:35
413,910
08/07/2010 16:10:29
7,344
347
Formfields added using javascript dont get posted?
I have simple input fields inside a table inside a form. I want the user to be able to edit the form contents and add a row to the table, to submit a new dataset. I have a function that takes an id of a table. It gets the last tr-element, clones it, and appends it to the table. This should correctly modify the dom, so that the new form fields get recognised. The very same method works for other tables on the same page. However for this specific table it adds table row and the fields, but the content does not get posted when the form is submitted. I dont get them in the PHP $_POST variable and they also do not show up if I examine the sent body using chrome developement tools. Any hint is welcomed, this is the code: <table id="reviewtable"> <tr> <th>type</th> <th>source</th> <th>author</th> <th>lang</th> <th>date (YYYY-MM-DD)</th> <th>text</th> </tr> <? if(!isset($data["review"])) { $data["review"] = array(); } foreach($data["review"] as $m) { ?> <tr> <td><input type="text" name="review[review_type][]" value="<?=$m["review_type"]; ?>"/></td> <td><input type="text" name="review[review_source][]" value="<?=$m["review_source"]; ?>"/></td> <td><input type="text" name="review[review_author][]" value="<?=$m["review_author"]; ?>"/></td> <td><input type="text" name="review[review_lang][]" value="<?=$m["review_lang"]; ?>"/></td> <td><textarea name="review[review_date][]"><?=$m["review_date"]; ?></textarea></td> <td><textarea name="review[review_text][]"><?=$m["review_text"]; ?></textarea></td> </tr> <? } ?> <tr> <td><input type="text" name="review[review_type][]" value=""/></td> <td><input type="text" name="review[review_source][]" value=""/></td> <td><input type="text" name="review[review_author][]" value=""/></td> <td><input type="text" name="review[review_lang][]" value=""/></td> <td><input type="text" name="review[review_date][]" value=""/></td> <td><textarea name="review[review_text][]"></textarea></td> </tr> </table> <a href="javascript:addone('reviewtable');">add one</a> <script type="text/javascript"> function addone(id) { var newline = document.getElementById(id).getElementsByTagName("tr")[document.getElementById(id).getElementsByTagName("tr").length-1].cloneNode(true); document.getElementById(id).appendChild(newline); } </script>
javascript
html
forms
dom
manipulation
null
open
Formfields added using javascript dont get posted? === I have simple input fields inside a table inside a form. I want the user to be able to edit the form contents and add a row to the table, to submit a new dataset. I have a function that takes an id of a table. It gets the last tr-element, clones it, and appends it to the table. This should correctly modify the dom, so that the new form fields get recognised. The very same method works for other tables on the same page. However for this specific table it adds table row and the fields, but the content does not get posted when the form is submitted. I dont get them in the PHP $_POST variable and they also do not show up if I examine the sent body using chrome developement tools. Any hint is welcomed, this is the code: <table id="reviewtable"> <tr> <th>type</th> <th>source</th> <th>author</th> <th>lang</th> <th>date (YYYY-MM-DD)</th> <th>text</th> </tr> <? if(!isset($data["review"])) { $data["review"] = array(); } foreach($data["review"] as $m) { ?> <tr> <td><input type="text" name="review[review_type][]" value="<?=$m["review_type"]; ?>"/></td> <td><input type="text" name="review[review_source][]" value="<?=$m["review_source"]; ?>"/></td> <td><input type="text" name="review[review_author][]" value="<?=$m["review_author"]; ?>"/></td> <td><input type="text" name="review[review_lang][]" value="<?=$m["review_lang"]; ?>"/></td> <td><textarea name="review[review_date][]"><?=$m["review_date"]; ?></textarea></td> <td><textarea name="review[review_text][]"><?=$m["review_text"]; ?></textarea></td> </tr> <? } ?> <tr> <td><input type="text" name="review[review_type][]" value=""/></td> <td><input type="text" name="review[review_source][]" value=""/></td> <td><input type="text" name="review[review_author][]" value=""/></td> <td><input type="text" name="review[review_lang][]" value=""/></td> <td><input type="text" name="review[review_date][]" value=""/></td> <td><textarea name="review[review_text][]"></textarea></td> </tr> </table> <a href="javascript:addone('reviewtable');">add one</a> <script type="text/javascript"> function addone(id) { var newline = document.getElementById(id).getElementsByTagName("tr")[document.getElementById(id).getElementsByTagName("tr").length-1].cloneNode(true); document.getElementById(id).appendChild(newline); } </script>
0
11,651,232
07/25/2012 13:48:34
318,722
04/16/2010 16:51:22
36
2
how to stub or mock authlogic current_user in view specs
i am trying to write some views specs for my rails app, but i stumble on this error: ActionView::Template::Error: undefined local variable or method `current_user' for #<#<Class:0x007fa47d2612d0>:0x007fa47e267710> Here is how i wrote my view spec : describe "/newsletters/index.html.erb" do include NewslettersHelper include Authlogic::TestCase def current_user(stubs = {}) @current_user ||= mock_model(User, stubs) end def user_session(stubs = {}, user_stubs = {}) @current_user_session ||= mock_model(UserSession, {:user => current_user(user_stubs)}.merge(stubs)) end def login(session_stubs = {}, user_stubs = {}) UserSession.stub!(:find).and_return(user_session(session_stubs, user_stubs)) end def logout @user_session = nil end context "without a logged-in user" do before(:each) do activate_authlogic logout() assigns[:newsletters] = @newsletters = [ mock_model(Newsletter, :titre => "value for titre", :sommaire => "value for sommaire", :content => "value for content") ] end it "renders a list of newsletters" do # pending("find how to mock authlogic current user in views spec") render rendered.should have_selector("tr>td") do |row| row.should have_content("value for titre") end rendered.should have_selector("tr>td") do |row| row.should have_content("value for sommaire") end rendered.should have_selector("tr>td") do |row| row.should have_content("value for content") end end end
ruby-on-rails-3
authlogic
rspec-rails
null
null
null
open
how to stub or mock authlogic current_user in view specs === i am trying to write some views specs for my rails app, but i stumble on this error: ActionView::Template::Error: undefined local variable or method `current_user' for #<#<Class:0x007fa47d2612d0>:0x007fa47e267710> Here is how i wrote my view spec : describe "/newsletters/index.html.erb" do include NewslettersHelper include Authlogic::TestCase def current_user(stubs = {}) @current_user ||= mock_model(User, stubs) end def user_session(stubs = {}, user_stubs = {}) @current_user_session ||= mock_model(UserSession, {:user => current_user(user_stubs)}.merge(stubs)) end def login(session_stubs = {}, user_stubs = {}) UserSession.stub!(:find).and_return(user_session(session_stubs, user_stubs)) end def logout @user_session = nil end context "without a logged-in user" do before(:each) do activate_authlogic logout() assigns[:newsletters] = @newsletters = [ mock_model(Newsletter, :titre => "value for titre", :sommaire => "value for sommaire", :content => "value for content") ] end it "renders a list of newsletters" do # pending("find how to mock authlogic current user in views spec") render rendered.should have_selector("tr>td") do |row| row.should have_content("value for titre") end rendered.should have_selector("tr>td") do |row| row.should have_content("value for sommaire") end rendered.should have_selector("tr>td") do |row| row.should have_content("value for content") end end end
0
11,651,236
07/25/2012 13:48:52
1,281,067
03/20/2012 13:47:52
6
0
Is it possible to translate/localize Android in different language?
Is it possible to translate/localize Android (OS itself) in different languages? For example, Windows is in German, Russian etc. Your ideas/solutions are greatly appreciated Thanks, G
android
localization
translate
null
null
07/25/2012 14:56:55
off topic
Is it possible to translate/localize Android in different language? === Is it possible to translate/localize Android (OS itself) in different languages? For example, Windows is in German, Russian etc. Your ideas/solutions are greatly appreciated Thanks, G
2
11,401,586
07/09/2012 19:16:37
1,512,908
07/09/2012 19:06:36
1
0
Scrolling a list view
I have a list view which loads data from database each time 30 records i.e first hit list will contain 30 item then clicking on view more it will contain 60 item and so on.Now i want that after clicking view more list position will start from 31st position and second hit list position shoould be from 61 and so on. List will contain all value but the start position will be different on every click of view more.
android
null
null
null
null
null
open
Scrolling a list view === I have a list view which loads data from database each time 30 records i.e first hit list will contain 30 item then clicking on view more it will contain 60 item and so on.Now i want that after clicking view more list position will start from 31st position and second hit list position shoould be from 61 and so on. List will contain all value but the start position will be different on every click of view more.
0
11,401,592
07/09/2012 19:16:57
1,332,495
04/13/2012 21:18:37
80
4
How can I Give a JTextPane a different width than the main JFrame?
So, when I create a JTextPane and add it to a JFrame, it fills up the frame, moving with it. How do I stop this so I can do pane.setSize?
java
swing
jframe
jtextpane
null
null
open
How can I Give a JTextPane a different width than the main JFrame? === So, when I create a JTextPane and add it to a JFrame, it fills up the frame, moving with it. How do I stop this so I can do pane.setSize?
0
11,401,594
07/09/2012 19:17:13
1,512,884
07/09/2012 18:55:58
1
0
How to change all like cells based on edit to one cell?
I have 17,000 rows, and cells E:E have specific values (30,45,60,90,180,365,etc.) I want to change E10 from 45 to 50, find all values in B:B like B10, and change all corresponding values in E:E to 50?
vlookup
null
null
null
null
null
open
How to change all like cells based on edit to one cell? === I have 17,000 rows, and cells E:E have specific values (30,45,60,90,180,365,etc.) I want to change E10 from 45 to 50, find all values in B:B like B10, and change all corresponding values in E:E to 50?
0
11,401,596
07/09/2012 19:17:27
1,449,919
06/11/2012 21:17:38
26
0
combine PCA, LDA and LBP
Now the FaceRecognizer works fine with my OpenCV 2.3.1 and I can see the predicted class is correct. What I'm thinking is to combine PCA features, LDA features and LBP features together to get a higher accuracy, since I think the three features are all kind of histogram vectors and when we decide the label of a test image, we compare the histogram of the test image to the histograms of existing images. So is it possible to combine the feature vectors together? However I think the feature histogram of LBP is very long. If we use 8 by 8 grids then the histogram will be 8*8*256 = 16384 long. And the eigenface weight vectors are of the length of how many eigenface components we choose, say 80. So I'm not sure whether we can do this. I'll keep thinking on this and any help is highly appreciated.
algorithm
opencv
face-recognition
null
null
07/10/2012 18:32:44
off topic
combine PCA, LDA and LBP === Now the FaceRecognizer works fine with my OpenCV 2.3.1 and I can see the predicted class is correct. What I'm thinking is to combine PCA features, LDA features and LBP features together to get a higher accuracy, since I think the three features are all kind of histogram vectors and when we decide the label of a test image, we compare the histogram of the test image to the histograms of existing images. So is it possible to combine the feature vectors together? However I think the feature histogram of LBP is very long. If we use 8 by 8 grids then the histogram will be 8*8*256 = 16384 long. And the eigenface weight vectors are of the length of how many eigenface components we choose, say 80. So I'm not sure whether we can do this. I'll keep thinking on this and any help is highly appreciated.
2
11,401,597
07/09/2012 19:17:27
317,889
04/15/2010 19:15:12
284
8
Resize bitmap to create icon
I am resizing a bimap image of a view I create. Bitmap image = imageCreate( getMeasuredWidth(), getMeasuredHeight() ); image = imageResize( image, 62, 62 ); imageSave(image,"test.png"); The resizing takes place inside my custom view. protected Bitmap imageCreate( int width, int height ) { Bitmap image = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(image); draw(canvas); return image; } protected Bitmap imageResize(Bitmap image, int newWidth, int newHeight) { int width = image.getWidth(); int height = image.getHeight(); float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; // CREATE A MATRIX FOR THE MANIPULATION Matrix matrix = new Matrix(); // RESIZE THE BIT MAP matrix.postScale(scaleWidth, scaleHeight); // RECREATE THE NEW BITMAP Bitmap resizedImage = Bitmap.createBitmap(image, 0, 0, width, height, matrix, false); return resizedImage; } Finally I save the image: protected boolean imageSave( Bitmap image, String filename, Context context ) { try { FileOutputStream fos = context.openFileOutput(filename, Context.MODE_PRIVATE); image.compress(Bitmap.CompressFormat.PNG, 90, fos); fos.close(); return true; } catch (Exception e) { e.printStackTrace(); } return false; } My question is, why is the image quality so god damn awful!??? The image is kind of pixelated. The original image is fantastic. Also is there a better way?
android
bitmap
null
null
null
null
open
Resize bitmap to create icon === I am resizing a bimap image of a view I create. Bitmap image = imageCreate( getMeasuredWidth(), getMeasuredHeight() ); image = imageResize( image, 62, 62 ); imageSave(image,"test.png"); The resizing takes place inside my custom view. protected Bitmap imageCreate( int width, int height ) { Bitmap image = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(image); draw(canvas); return image; } protected Bitmap imageResize(Bitmap image, int newWidth, int newHeight) { int width = image.getWidth(); int height = image.getHeight(); float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; // CREATE A MATRIX FOR THE MANIPULATION Matrix matrix = new Matrix(); // RESIZE THE BIT MAP matrix.postScale(scaleWidth, scaleHeight); // RECREATE THE NEW BITMAP Bitmap resizedImage = Bitmap.createBitmap(image, 0, 0, width, height, matrix, false); return resizedImage; } Finally I save the image: protected boolean imageSave( Bitmap image, String filename, Context context ) { try { FileOutputStream fos = context.openFileOutput(filename, Context.MODE_PRIVATE); image.compress(Bitmap.CompressFormat.PNG, 90, fos); fos.close(); return true; } catch (Exception e) { e.printStackTrace(); } return false; } My question is, why is the image quality so god damn awful!??? The image is kind of pixelated. The original image is fantastic. Also is there a better way?
0
11,401,599
07/09/2012 19:17:33
1,512,914
07/09/2012 19:09:40
1
0
Selenium IEDriverServer unable to configure protected mode due to security policy
The [IEDriverServer Wiki page][1] has the following listed as a requirement: > On IE 7 or higher on Windows Vista or Windows 7, you must set the > Protected Mode settings for each zone to be the same value. The value > can be on or off, as long as it is the same for every zone. Unfortunately, where I work, corporate security policy has the protected mode setting locked down, so I'm unable to make changes to the setting. Is there a way to work around this issue and get the IEDriverServer working? Or is Selenium just not an option for corporate environments that run IE 7+ on Windows 7 where the users are prevented from changing the Protected Mode settings? Thanks, Dave [1]: http://code.google.com/p/selenium/wiki/InternetExplorerDriver
selenium
internet-explorer-7
selenium2
protected-mode
security-policy
null
open
Selenium IEDriverServer unable to configure protected mode due to security policy === The [IEDriverServer Wiki page][1] has the following listed as a requirement: > On IE 7 or higher on Windows Vista or Windows 7, you must set the > Protected Mode settings for each zone to be the same value. The value > can be on or off, as long as it is the same for every zone. Unfortunately, where I work, corporate security policy has the protected mode setting locked down, so I'm unable to make changes to the setting. Is there a way to work around this issue and get the IEDriverServer working? Or is Selenium just not an option for corporate environments that run IE 7+ on Windows 7 where the users are prevented from changing the Protected Mode settings? Thanks, Dave [1]: http://code.google.com/p/selenium/wiki/InternetExplorerDriver
0
11,401,600
07/09/2012 19:17:41
228,898
12/10/2009 15:12:39
610
4
Is "use" in perl transitive?
package AA; package BB; use AA; package CC; use BB; Do i have to put "use AA" in CC, or is that implicit ? Thanks, Trinity
perl
use
null
null
null
null
open
Is "use" in perl transitive? === package AA; package BB; use AA; package CC; use BB; Do i have to put "use AA" in CC, or is that implicit ? Thanks, Trinity
0
11,397,105
07/09/2012 14:27:56
218,635
11/25/2009 14:12:24
459
6
How come I get a "must have accepted TOS" error for test users with app installed?
I'm writing integration tests and creating and registering some test users for my app in my test by using the graph API to create the users with the installed flag set to true. This should create a user that is an app user, therefore I assume the test user has agreed to the TOS already. Is I switch to the test users then the app is listed in the users history in the app center. However when I try and send an app request to this user from another test user then I get the TOS error.
facebook
facebook-graph-api
testing
integration-testing
restfb
null
open
How come I get a "must have accepted TOS" error for test users with app installed? === I'm writing integration tests and creating and registering some test users for my app in my test by using the graph API to create the users with the installed flag set to true. This should create a user that is an app user, therefore I assume the test user has agreed to the TOS already. Is I switch to the test users then the app is listed in the users history in the app center. However when I try and send an app request to this user from another test user then I get the TOS error.
0
11,401,609
07/09/2012 19:18:02
1,408,564
05/21/2012 18:18:44
175
1
is memmove necessary for trim function in C?
I was reading a [wikipedia article on Trimming][1] and saw this implementation of ltrim (left trim) char * ltrim(char *str) { char *ptr; int len; for (ptr = str; *ptr && isspace((int)*ptr); ++ptr); len = strlen(ptr); memmove(str, ptr, len + 1); return str; } Would bad things happen if I skip memmove and return ptr isntead? char * ltrim(char *str) { char *ptr; int len; for (ptr = str; *ptr && isspace((int)*ptr); ++ptr); return ptr; } [1]: http://en.wikipedia.org/wiki/Trimming_%28computer_programming%29
c
trim
memmove
null
null
null
open
is memmove necessary for trim function in C? === I was reading a [wikipedia article on Trimming][1] and saw this implementation of ltrim (left trim) char * ltrim(char *str) { char *ptr; int len; for (ptr = str; *ptr && isspace((int)*ptr); ++ptr); len = strlen(ptr); memmove(str, ptr, len + 1); return str; } Would bad things happen if I skip memmove and return ptr isntead? char * ltrim(char *str) { char *ptr; int len; for (ptr = str; *ptr && isspace((int)*ptr); ++ptr); return ptr; } [1]: http://en.wikipedia.org/wiki/Trimming_%28computer_programming%29
0
11,472,842
07/13/2012 14:47:06
825,574
07/01/2011 21:56:46
16
1
Chaning elements of DOMStyleSheet in obj c app
I am using a webview from <WebKit/WebKit.h> in my cocoa app. I need to change elements of a style sheet that is used in the webview. I can get the style sheet with the code below, but alas my attempts to access and change elements have failed. Any ideas? DOMDocument *d=[_webview mainFrameDocument]; DOMStyleSheetList *s=[d styleSheets]; DOMStyleSheet *ss=[s item:0];
objective-c
webview
null
null
null
null
open
Chaning elements of DOMStyleSheet in obj c app === I am using a webview from <WebKit/WebKit.h> in my cocoa app. I need to change elements of a style sheet that is used in the webview. I can get the style sheet with the code below, but alas my attempts to access and change elements have failed. Any ideas? DOMDocument *d=[_webview mainFrameDocument]; DOMStyleSheetList *s=[d styleSheets]; DOMStyleSheet *ss=[s item:0];
0
11,472,843
07/13/2012 14:47:08
1,159,747
01/20/2012 00:44:45
153
4
Set up Python on Windows to not type python in cmd
How do I have to configure so that I don't have to type `python script.py` but simply `script.py` in CMD on Windows? I added my python directory to %PATH% that contains python.exe but still scripts are not run correctly. I tried it with django-admin.py Running `django-admin.py startproject mysite` gives me ` Type 'django-admin.py help <subcommand>' for help on a specific subcommand.` Using python in front of it processes the command correctly. What's the problem here?
python
windows
path
cmd
null
null
open
Set up Python on Windows to not type python in cmd === How do I have to configure so that I don't have to type `python script.py` but simply `script.py` in CMD on Windows? I added my python directory to %PATH% that contains python.exe but still scripts are not run correctly. I tried it with django-admin.py Running `django-admin.py startproject mysite` gives me ` Type 'django-admin.py help <subcommand>' for help on a specific subcommand.` Using python in front of it processes the command correctly. What's the problem here?
0
11,472,847
07/13/2012 14:47:21
55,787
01/16/2009 10:01:44
2,852
102
Razor partial view prefix field names
When using Razor to render a form for a complex Model that has sub-models, we'd usually use Partial Views to render the sub-models. Simple example Model: public class BlogPost { public string Content { get; set; } public List<Comment> Comments { get; set; } } public class Comment { public string Content { get; set; } } BlogPost.cshtml: @model BlogPost @Html.TextAreaFor(x => x.Content) @for (int i = 0; i < Model.Comments.Count; i++) { @Html.Partial('Comment', Model.Comments[i]) } Comment.cshtml: @model Comment @Html.TextAreaFor(x => x.Content) **Now for the issue:** Say we want to send the values of all fields to a controller action that takes `BlogPost` as a parameter. The fields are going to be posted back to the controller like so: Content=The+content+of+the+BlogPost&Content=The+first+Comment&Content=The+second+Comment But what we need to have MVC map them correctly to the `BlogPost` view model, we need this naming convention: Content=The+content+of+the+BlogPost&Comments[0].Content=The+first+Comment&Comments[1].Content=The+second+Comment How can this be achieved in a clean way? We can only think of two ways which both seem to compromise the design: * Either we pass the `BlogPost` as a model to the partial view such that we can define the text area like so: `@Html.TextAreaFor(x => x.Comments[i].Content)`. But this means we couple the partial view for comments to the parent view model - you could think of a scenario where the same partial view should be used in a different context, which is not possible if the partial view depends on the parent view model. Futhermore, the `i` would have to be passed to the partial view somehow. * Or we fall back to explicitely defining the name of every single field with strings: `@Html.TextArea(ViewBag.Prefix + ".Content")`. Is there any way to tell the partial view to apply a certain prefix to *all* field names?
asp.net-mvc-3
razor
partial-views
null
null
null
open
Razor partial view prefix field names === When using Razor to render a form for a complex Model that has sub-models, we'd usually use Partial Views to render the sub-models. Simple example Model: public class BlogPost { public string Content { get; set; } public List<Comment> Comments { get; set; } } public class Comment { public string Content { get; set; } } BlogPost.cshtml: @model BlogPost @Html.TextAreaFor(x => x.Content) @for (int i = 0; i < Model.Comments.Count; i++) { @Html.Partial('Comment', Model.Comments[i]) } Comment.cshtml: @model Comment @Html.TextAreaFor(x => x.Content) **Now for the issue:** Say we want to send the values of all fields to a controller action that takes `BlogPost` as a parameter. The fields are going to be posted back to the controller like so: Content=The+content+of+the+BlogPost&Content=The+first+Comment&Content=The+second+Comment But what we need to have MVC map them correctly to the `BlogPost` view model, we need this naming convention: Content=The+content+of+the+BlogPost&Comments[0].Content=The+first+Comment&Comments[1].Content=The+second+Comment How can this be achieved in a clean way? We can only think of two ways which both seem to compromise the design: * Either we pass the `BlogPost` as a model to the partial view such that we can define the text area like so: `@Html.TextAreaFor(x => x.Comments[i].Content)`. But this means we couple the partial view for comments to the parent view model - you could think of a scenario where the same partial view should be used in a different context, which is not possible if the partial view depends on the parent view model. Futhermore, the `i` would have to be passed to the partial view somehow. * Or we fall back to explicitely defining the name of every single field with strings: `@Html.TextArea(ViewBag.Prefix + ".Content")`. Is there any way to tell the partial view to apply a certain prefix to *all* field names?
0
11,472,849
07/13/2012 14:47:31
874,689
08/02/2011 13:16:46
17
2
Dynamic appending constraints in SQL query
I have this SQL SELECT devudp1.deviceoid,**devudp1.valueType** FROM DeviceUdpValues devUDP1 WHERE devudp1.udpname='TestUDP' and <<either bdvalue or string value based on user selected value datatype>> Here in the Query based on the **devudp1.valueType** I want to append below attribute If the valueType is 3 then I want to append my above select clause with **devudp1.bdvalue ='10'** else it should be appended by **devudp1.bdvalue = 'Hello'** SO the above query when valueType is 3 will look like SELECT devudp1.deviceoid,devudp1.valueType FROM DeviceUdpValues devUDP1 WHERE devudp1.udpname='TestUDP' and **devudp1.bdvalue = '10'** else it will look like SELECT devudp1.deviceoid,**devudp1.valueType** FROM DeviceUdpValues devUDP1 WHERE devudp1.udpname='TestUDP' and **devudp1.stringValue = 'Hello'** Can anyone suggest me how to put this logic in place
sql
oracle
null
null
null
null
open
Dynamic appending constraints in SQL query === I have this SQL SELECT devudp1.deviceoid,**devudp1.valueType** FROM DeviceUdpValues devUDP1 WHERE devudp1.udpname='TestUDP' and <<either bdvalue or string value based on user selected value datatype>> Here in the Query based on the **devudp1.valueType** I want to append below attribute If the valueType is 3 then I want to append my above select clause with **devudp1.bdvalue ='10'** else it should be appended by **devudp1.bdvalue = 'Hello'** SO the above query when valueType is 3 will look like SELECT devudp1.deviceoid,devudp1.valueType FROM DeviceUdpValues devUDP1 WHERE devudp1.udpname='TestUDP' and **devudp1.bdvalue = '10'** else it will look like SELECT devudp1.deviceoid,**devudp1.valueType** FROM DeviceUdpValues devUDP1 WHERE devudp1.udpname='TestUDP' and **devudp1.stringValue = 'Hello'** Can anyone suggest me how to put this logic in place
0
11,472,856
07/13/2012 14:48:01
1,506,686
07/06/2012 12:00:50
1
0
R ggplot2 Graph: Month-Year bar graph plot faceted and filled on year; with data input as date in char format
## Environment: Win 7 HP, R v2.15.1 ## What I wish to get to - Plot y (numeric) vs x (date) with + labels month-year abbrev, sorted mon+year, las2 vertically aligned + colours filled by year + facet-grid by year Tried different approaches after reading up different threads in this forum, but unable to get what I need. Need help. Attaching sample data and results. ## MySample Data x <- c("04-01-10","05-01-10","06-01-10","07-01-10","08-01-10","09-01-10","10-01-10","11-01-10","12-01-10","01-01-11","02-01-11","03-01-11","04-01-11","05-01-11","06-01-11","07-01-11","08-01-11","09-01-11","10-01-11","11-01-11","12-01-11","01-01-12","02-01-12","03-01-12","04-01-12","05-01-12","06-01-12") y <- c(120,210,130,160,190,210,80,70,110,120,140,160,130,200,110,180,210,200,90,60,100,100,120,170,100,180,120) x is date (character) in mm-dd-yy format tz:IST (Calcutta / Asia) data has only single y value per month which is on the start date of the month ## Convert to Data Frame MySample <- data.frame(x) ## convert to dataframe MySample$y <- y ## load required libraries require(lubridate) require(ggplot2) ## MySample Base Plot ## 1. Plot x vs y ggplot(MySample, aes(MySample$x, MySample$y)) + geom_bar(y=MySample$y,stat="identity") Gave me base plot results ## 2. Plot x vs y + fill=year ggplot(MySample, aes(MySample$x, MySample$y, fill=year(MySample$x))) + geom_bar(y=MySample$y,stat="identity") gave me fills but have 5 fill years with 2010,2010.5,2011,2011.5,2012 i have tried different approaches but running into one error or another. ## 3. Plot x vs y + fill=year + facet_grid(year) ggplot(MySample, aes(x, y, fill=year(x))) + geom_bar(y=MySample$y,stat="identity") + facet_grid(. ~ year(MySample$x)) Get : Error in layout_base(data, cols, drop = drop) : At least one layer must contain all variables used for facetting ## 4. Plot x vs y + fill=year + facet_grid(year) + labels-month (abbr) ggplot(MySample, aes(x, y, fill=year(x))) + geom_bar(y=MySample$y,stat="identity") + scale_x_date(labels=month(MySample$x,label=TRUE,abbr=TRUE)) Get : Error in scale_labels.continuous(scale, major) : Breaks and labels are different lengths Stuck and need help to move forward. Need solutions to address the following requirements: 1. 3 fill years only - 2010,2011,2012 2. xlabels - %b%y format; sorted on month-year sequence; las2 positioned (vertical) 3. facet_grid by year with only that year's xlabels and bars in the appropriate facet-grid thanks in advance. [1]: http://i.stack.imgur.com/Typ6o.jpg [2]: http://i.stack.imgur.com/Ewcw6.jpg
r
ggplot2
null
null
null
null
open
R ggplot2 Graph: Month-Year bar graph plot faceted and filled on year; with data input as date in char format === ## Environment: Win 7 HP, R v2.15.1 ## What I wish to get to - Plot y (numeric) vs x (date) with + labels month-year abbrev, sorted mon+year, las2 vertically aligned + colours filled by year + facet-grid by year Tried different approaches after reading up different threads in this forum, but unable to get what I need. Need help. Attaching sample data and results. ## MySample Data x <- c("04-01-10","05-01-10","06-01-10","07-01-10","08-01-10","09-01-10","10-01-10","11-01-10","12-01-10","01-01-11","02-01-11","03-01-11","04-01-11","05-01-11","06-01-11","07-01-11","08-01-11","09-01-11","10-01-11","11-01-11","12-01-11","01-01-12","02-01-12","03-01-12","04-01-12","05-01-12","06-01-12") y <- c(120,210,130,160,190,210,80,70,110,120,140,160,130,200,110,180,210,200,90,60,100,100,120,170,100,180,120) x is date (character) in mm-dd-yy format tz:IST (Calcutta / Asia) data has only single y value per month which is on the start date of the month ## Convert to Data Frame MySample <- data.frame(x) ## convert to dataframe MySample$y <- y ## load required libraries require(lubridate) require(ggplot2) ## MySample Base Plot ## 1. Plot x vs y ggplot(MySample, aes(MySample$x, MySample$y)) + geom_bar(y=MySample$y,stat="identity") Gave me base plot results ## 2. Plot x vs y + fill=year ggplot(MySample, aes(MySample$x, MySample$y, fill=year(MySample$x))) + geom_bar(y=MySample$y,stat="identity") gave me fills but have 5 fill years with 2010,2010.5,2011,2011.5,2012 i have tried different approaches but running into one error or another. ## 3. Plot x vs y + fill=year + facet_grid(year) ggplot(MySample, aes(x, y, fill=year(x))) + geom_bar(y=MySample$y,stat="identity") + facet_grid(. ~ year(MySample$x)) Get : Error in layout_base(data, cols, drop = drop) : At least one layer must contain all variables used for facetting ## 4. Plot x vs y + fill=year + facet_grid(year) + labels-month (abbr) ggplot(MySample, aes(x, y, fill=year(x))) + geom_bar(y=MySample$y,stat="identity") + scale_x_date(labels=month(MySample$x,label=TRUE,abbr=TRUE)) Get : Error in scale_labels.continuous(scale, major) : Breaks and labels are different lengths Stuck and need help to move forward. Need solutions to address the following requirements: 1. 3 fill years only - 2010,2011,2012 2. xlabels - %b%y format; sorted on month-year sequence; las2 positioned (vertical) 3. facet_grid by year with only that year's xlabels and bars in the appropriate facet-grid thanks in advance. [1]: http://i.stack.imgur.com/Typ6o.jpg [2]: http://i.stack.imgur.com/Ewcw6.jpg
0
11,472,857
07/13/2012 14:48:13
1,523,836
07/13/2012 14:28:30
1
0
How to set default values of a custom column in sharepoint for a custom list?
I have a list that i am using in SharePoint for a news feed. I have created a custom column called Page Article, which is a Hyperlink type, that i made required to make an item in the list. I am using a modified list view so that the Page Article is showing in the feed so people can click on it and go to the article. The name of the link is also the same name as the title of the object in the list. How can i use the title they make for the list object and set that as the default value for the link description?
sharepoint2010
sharepoint-list
null
null
null
null
open
How to set default values of a custom column in sharepoint for a custom list? === I have a list that i am using in SharePoint for a news feed. I have created a custom column called Page Article, which is a Hyperlink type, that i made required to make an item in the list. I am using a modified list view so that the Page Article is showing in the feed so people can click on it and go to the article. The name of the link is also the same name as the title of the object in the list. How can i use the title they make for the list object and set that as the default value for the link description?
0
11,472,826
07/13/2012 14:46:21
426,344
08/20/2010 12:38:19
703
10
How to align tab text at center in android
can anybody tell How to align tab text at center in android ?.I had given android:gravity="center" for linear layout and tabwidget .Still its not working can anybody tell how to do? Thanks
android
null
null
null
null
null
open
How to align tab text at center in android === can anybody tell How to align tab text at center in android ?.I had given android:gravity="center" for linear layout and tabwidget .Still its not working can anybody tell how to do? Thanks
0
11,472,828
07/13/2012 14:46:22
1,313,328
04/04/2012 16:13:29
4
1
Android TCP Smartphone to PC with USB no wifi
Hi I have managed some code but its not working I want to control send message from PC To Android over my application via USB not by **WIFI** i tried this code But it's giving me error that 07-13 20:08:28.530: W/System.err(8990): java.net.ConnectException: localhost/127.0.0.1:383 - Connection refused I have done port forward by ***adb*** For Desktop import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; public class comunicate { public static void main(String[] args){ ServerSocket serverSocket = null; Socket socket = null; DataInputStream dataInputStream = null; DataOutputStream dataOutputStream = null; try { serverSocket = new ServerSocket(383); System.out.println("Listening :8888"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } while(true){ try { socket = serverSocket.accept(); dataInputStream = new DataInputStream(socket.getInputStream()); dataOutputStream = new DataOutputStream(socket.getOutputStream()); System.out.println("ip: " + socket.getInetAddress()); System.out.println("message: " + dataInputStream.readUTF()); dataOutputStream.writeUTF("Hello!"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally{ if( socket!= null){ try { socket.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if( dataInputStream!= null){ try { dataInputStream.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if( dataOutputStream!= null){ try { dataOutputStream.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } } } For Mobile package demo.app.org; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.net.Socket; import java.net.UnknownHostException; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class DemoAppActivity extends Activity { EditText textOut; TextView textIn; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); textOut = (EditText)findViewById(R.id.textout); Button buttonSend = (Button)findViewById(R.id.send); textIn = (TextView)findViewById(R.id.textin); buttonSend.setOnClickListener(buttonSendOnClickListener); } Button.OnClickListener buttonSendOnClickListener = new Button.OnClickListener(){ @Override public void onClick(View arg0) { // TODO Auto-generated method stub Socket socket = null; DataOutputStream dataOutputStream = null; DataInputStream dataInputStream = null; try { socket = new Socket("localhost", 383); dataOutputStream = new DataOutputStream(socket.getOutputStream()); dataInputStream = new DataInputStream(socket.getInputStream()); dataOutputStream.writeUTF(textOut.getText().toString()); textIn.setText(dataInputStream.readUTF()); } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally{ if (socket != null){ try { socket.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (dataOutputStream != null){ try { dataOutputStream.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (dataInputStream != null){ try { dataInputStream.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }}; }
android
null
null
null
null
null
open
Android TCP Smartphone to PC with USB no wifi === Hi I have managed some code but its not working I want to control send message from PC To Android over my application via USB not by **WIFI** i tried this code But it's giving me error that 07-13 20:08:28.530: W/System.err(8990): java.net.ConnectException: localhost/127.0.0.1:383 - Connection refused I have done port forward by ***adb*** For Desktop import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; public class comunicate { public static void main(String[] args){ ServerSocket serverSocket = null; Socket socket = null; DataInputStream dataInputStream = null; DataOutputStream dataOutputStream = null; try { serverSocket = new ServerSocket(383); System.out.println("Listening :8888"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } while(true){ try { socket = serverSocket.accept(); dataInputStream = new DataInputStream(socket.getInputStream()); dataOutputStream = new DataOutputStream(socket.getOutputStream()); System.out.println("ip: " + socket.getInetAddress()); System.out.println("message: " + dataInputStream.readUTF()); dataOutputStream.writeUTF("Hello!"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally{ if( socket!= null){ try { socket.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if( dataInputStream!= null){ try { dataInputStream.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if( dataOutputStream!= null){ try { dataOutputStream.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } } } For Mobile package demo.app.org; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.net.Socket; import java.net.UnknownHostException; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class DemoAppActivity extends Activity { EditText textOut; TextView textIn; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); textOut = (EditText)findViewById(R.id.textout); Button buttonSend = (Button)findViewById(R.id.send); textIn = (TextView)findViewById(R.id.textin); buttonSend.setOnClickListener(buttonSendOnClickListener); } Button.OnClickListener buttonSendOnClickListener = new Button.OnClickListener(){ @Override public void onClick(View arg0) { // TODO Auto-generated method stub Socket socket = null; DataOutputStream dataOutputStream = null; DataInputStream dataInputStream = null; try { socket = new Socket("localhost", 383); dataOutputStream = new DataOutputStream(socket.getOutputStream()); dataInputStream = new DataInputStream(socket.getInputStream()); dataOutputStream.writeUTF(textOut.getText().toString()); textIn.setText(dataInputStream.readUTF()); } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally{ if (socket != null){ try { socket.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (dataOutputStream != null){ try { dataOutputStream.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (dataInputStream != null){ try { dataInputStream.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }}; }
0
11,472,822
07/13/2012 14:46:08
1,523,843
07/13/2012 14:30:46
1
0
XSL: Reorder/ Sort Child element from node to node
I'm working on an assignment, where I need to reorder some child elements from node to other node...without changing the other elements. Can somebody help me by telling me how I can reorder the <ID> element without changing the other elements inside the <Description> nodes? This is what I have now, but I guess I'm way out of the solution. XSL: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.`0`"> <xsl:output indent="yes"/> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match="/XML/Request/Assign/PD"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:apply-templates select="Description/ID"> <xsl:sort select="local-name()"/> </xsl:apply-templates> </xsl:copy> </xsl:template> </xsl:stylesheet> **XML INPUT:** <XML> <Control> <RequestID>1234</RequestID> <ResponseID>4321</ResponseID> </Control> <Request> <Assign> <PD> <Description> **<ID>1</ID>** <DateOfBirth>1970-07-09</DateOfBirth> <Gender>M</Gender> <Nationality>NL</Nationality> </Description> <Description> **<ID>3</ID>** <DateOfBirth>1977-07-09</DateOfBirth> <Gender>M</Gender> <Nationality>NL</Nationality> </Description> <Description> **<ID>4</ID>** <DateOfBirth>1967-07-09</DateOfBirth> <Gender>M</Gender> <Nationality>NL</Nationality> </Description> <Description> **<ID>2</ID>** <DateOfBirth>1981-07-09</DateOfBirth> <Gender>M</Gender> <Nationality>NL</Nationality> </Description> <Home> <Name>Test</Name> <TelHome>0123456789</TelHome> </Home> </PD> </Assign> .................... .................... </XML> **XML OUTPUT (wich I would like to have):** <XML> <Control> <RequestID>1234</RequestID> <ResponseID>4321</ResponseID> </Control> <Request> <Assign> <PD> <Description> **<ID>1</ID>** <DateOfBirth>1970-07-09</DateOfBirth> <Gender>M</Gender> <Nationality>NL</Nationality> </Description> <Description> **<ID>2</ID>** <DateOfBirth>1977-07-09</DateOfBirth> <Gender>M</Gender> <Nationality>NL</Nationality> </Description> <Description> **<ID>3</ID>** <DateOfBirth>1967-07-09</DateOfBirth> <Gender>M</Gender> <Nationality>NL</Nationality> </Description> <Description> **<ID>4</ID>** <DateOfBirth>1981-07-09</DateOfBirth> <Gender>M</Gender> <Nationality>NL</Nationality> </Description> <Home> <Name>Test</Name> <TelHome>0123456789</TelHome> </Home> </PD> </Assign> .................... .................... </XML>
sorting
element
child
null
null
null
open
XSL: Reorder/ Sort Child element from node to node === I'm working on an assignment, where I need to reorder some child elements from node to other node...without changing the other elements. Can somebody help me by telling me how I can reorder the <ID> element without changing the other elements inside the <Description> nodes? This is what I have now, but I guess I'm way out of the solution. XSL: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.`0`"> <xsl:output indent="yes"/> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match="/XML/Request/Assign/PD"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:apply-templates select="Description/ID"> <xsl:sort select="local-name()"/> </xsl:apply-templates> </xsl:copy> </xsl:template> </xsl:stylesheet> **XML INPUT:** <XML> <Control> <RequestID>1234</RequestID> <ResponseID>4321</ResponseID> </Control> <Request> <Assign> <PD> <Description> **<ID>1</ID>** <DateOfBirth>1970-07-09</DateOfBirth> <Gender>M</Gender> <Nationality>NL</Nationality> </Description> <Description> **<ID>3</ID>** <DateOfBirth>1977-07-09</DateOfBirth> <Gender>M</Gender> <Nationality>NL</Nationality> </Description> <Description> **<ID>4</ID>** <DateOfBirth>1967-07-09</DateOfBirth> <Gender>M</Gender> <Nationality>NL</Nationality> </Description> <Description> **<ID>2</ID>** <DateOfBirth>1981-07-09</DateOfBirth> <Gender>M</Gender> <Nationality>NL</Nationality> </Description> <Home> <Name>Test</Name> <TelHome>0123456789</TelHome> </Home> </PD> </Assign> .................... .................... </XML> **XML OUTPUT (wich I would like to have):** <XML> <Control> <RequestID>1234</RequestID> <ResponseID>4321</ResponseID> </Control> <Request> <Assign> <PD> <Description> **<ID>1</ID>** <DateOfBirth>1970-07-09</DateOfBirth> <Gender>M</Gender> <Nationality>NL</Nationality> </Description> <Description> **<ID>2</ID>** <DateOfBirth>1977-07-09</DateOfBirth> <Gender>M</Gender> <Nationality>NL</Nationality> </Description> <Description> **<ID>3</ID>** <DateOfBirth>1967-07-09</DateOfBirth> <Gender>M</Gender> <Nationality>NL</Nationality> </Description> <Description> **<ID>4</ID>** <DateOfBirth>1981-07-09</DateOfBirth> <Gender>M</Gender> <Nationality>NL</Nationality> </Description> <Home> <Name>Test</Name> <TelHome>0123456789</TelHome> </Home> </PD> </Assign> .................... .................... </XML>
0
11,680,558
07/27/2012 02:10:13
556,622
12/29/2010 01:32:05
5
0
Will the asp.net webform how to use AutoFac
I read the official documents, for example as follows: public class Global : System.Web.HttpApplication { static IContainerProvider _containerProvider; public IContainerProvider ContainerProvider { get { return _containerProvider; } } protected void Application_Start(object sender, EventArgs e) { var builder = new ContainerBuilder(); builder.RegisterType<Foo>().As<IFoo>().HttpRequestScoped(); _containerProvider = new ContainerProvider(builder.Build()); } This is what I do in accordance with the official examples, but the problem is the method HttpRequestScoped does not exist, why is this? Also, I would like to ask how to obtain an instance of the interface and the Singleton Pattern in the page.
c#
autofac
null
null
null
null
open
Will the asp.net webform how to use AutoFac === I read the official documents, for example as follows: public class Global : System.Web.HttpApplication { static IContainerProvider _containerProvider; public IContainerProvider ContainerProvider { get { return _containerProvider; } } protected void Application_Start(object sender, EventArgs e) { var builder = new ContainerBuilder(); builder.RegisterType<Foo>().As<IFoo>().HttpRequestScoped(); _containerProvider = new ContainerProvider(builder.Build()); } This is what I do in accordance with the official examples, but the problem is the method HttpRequestScoped does not exist, why is this? Also, I would like to ask how to obtain an instance of the interface and the Singleton Pattern in the page.
0
11,693,405
07/27/2012 18:16:17
663,148
03/16/2011 19:31:05
1,101
5
sh is not an identifier when trying to invoke shell scripts using plink
Below is my shell script that I am trying to execute using `PLINK` on `MachineB` from `MachineA`(Windows Machine). #!/bin/bash export HIVE_OPTS="$HIVE_OPTS -hiveconf mapred.job.queue.name=hdmi-technology" hive -S -e 'SELECT count(*) from testingtable1' > attachment22.txt I am using `plink` to execute the shell script like below, C:\PLINK>plink uname@MachineB -m test.sh Using keyboard-interactive authentication. Password: Using keyboard-interactive authentication. Your Kerberos password will expire in 73 days. And this is the below error I always get whenever I try to run like above. sh: HIVE_OPTS= -hiveconf mapred.job.queue.name=hdmi-technology: is not an identifier Something wrong with my shell script? or some trailing spaces? I am not able to figure it out. I am running `PLINK` from windows machine
bash
shell
unix
script
plink
null
open
sh is not an identifier when trying to invoke shell scripts using plink === Below is my shell script that I am trying to execute using `PLINK` on `MachineB` from `MachineA`(Windows Machine). #!/bin/bash export HIVE_OPTS="$HIVE_OPTS -hiveconf mapred.job.queue.name=hdmi-technology" hive -S -e 'SELECT count(*) from testingtable1' > attachment22.txt I am using `plink` to execute the shell script like below, C:\PLINK>plink uname@MachineB -m test.sh Using keyboard-interactive authentication. Password: Using keyboard-interactive authentication. Your Kerberos password will expire in 73 days. And this is the below error I always get whenever I try to run like above. sh: HIVE_OPTS= -hiveconf mapred.job.queue.name=hdmi-technology: is not an identifier Something wrong with my shell script? or some trailing spaces? I am not able to figure it out. I am running `PLINK` from windows machine
0
11,693,347
07/27/2012 18:10:51
637,364
02/28/2011 08:34:57
1,134
0
How to see if database is installed
I'm using Visual Studio 2010 Premium and I just wonder if there is a way to see if the database SQL Server 2008 Express is already installed? I read somewhere that if you have the Professional version of Visual Studio it's installed!? Simple question, but just want to check before I download and install the database. Thanks!
visual-studio-2010
null
null
null
null
null
open
How to see if database is installed === I'm using Visual Studio 2010 Premium and I just wonder if there is a way to see if the database SQL Server 2008 Express is already installed? I read somewhere that if you have the Professional version of Visual Studio it's installed!? Simple question, but just want to check before I download and install the database. Thanks!
0
11,693,350
07/27/2012 18:11:07
990,099
10/11/2011 18:20:56
13
0
Have an error from someone elses code.. not understanding it
Got this error when deploying a web app from CentOS to RHEL is the only difference and I am sure there is other differences but that is the major one that gave this error. The rest of the webapp is fine. The error is: pstmnts) && count($this->pstmnts)) foreach ($this->pstmnts as $stmnt_name => $stmnt) $stmnt->close(); } static function get_instance() { static $object; if (!$object) $object = new self(); return $object; } function create_pstmnt($name, $query) { return $this->pstmnts[$name] = $this->prepare($query); } function get_pstmnt($name, $query) { if (isset($this->pstmnts[$name])) return $this->pstmnts[$name]; else return $this->create_pstmnt($name, $query); } } to = $to; $this->from = $from; $this->subject = $subject; $this->body = $message_body; $this->html = $html; //ADD HEADERS IF SUPPLIED if(!is_null($headers)) { if(!is_array($headers)) throw new Exception("Invalid headers array!"); foreach($headers as $key => $value) $this->set_header($key, $value); } } function __get($key) { switch ($key) { case 'to': case 'from': case 'subject': case 'body': case 'html': case 'mime_boundary': return $this->params[$key]; default: throw new Exception("No such email parameter($key)!"); } } function __set($key, $value) { switch ($key) { case 'to': case 'from': case 'subject': case 'body': case 'html': case 'mime_boundary': $this->params[$key] = $value; break; default: throw new Exception("Invalid email parameter($key)!"); } } public static function method_name_xlate($method_name, $static = false) { return "$method_name" .($static ? '__S' : ''); } public function set_header($key, $value) { $this->headers[$key] = $value; return true; } public function clear_header($key) { unset($this->headers[$key]); return true; } public function add_attachment_file($file_path, $content_type = 'application/octet-stream') { $fh = fopen($file_path, 'rb'); $data = fread($fh, filesize($file_path)); fclose($fh); $this->add_attachment_data(basename($file_path), $content_type, $data); return true; } public function add_attachment_data($filename, $data, $content_type = 'application/octet-stream') { $this->attachments[] = array( 'filename' => $filename, 'content_type' => $content_type, 'data' => $data ); return true; } public function send() { if (empty($this->mime_boundary)) $this->mime_boundary = $this->generate_mime_boundary(); if (!is_null($this->from)) $this->set_header('From', $this->from); $this->set_header('MIME-Version', '1.0'); $this->set_header('Content-Type', 'multipart/mixed; boundary='.$this->mime_boundary); if(!@ mail($this->to, $this->subject, $this->compile_body($this->body, $this->mime_boundary, $this->html, $this->attachments), $this->compile_headers($this->headers))) throw new Exception("Email not successfully sent!"); return true; } public static function generate_mime_boundary($prefix=null) { $rand_entropy = md5(time()); if (is_null($prefix)) $prefix = md5($rand_entropy); return uniqid($prefix, $rand_entropy); } public static function compile_body($email_body, $mime_boundary, $html_format=false, $attachments=array()) { $ret = "" . "This is a multi-part message in MIME format.\n" . "\n" . "--$mime_boundary\n" . "Content-Type:text/" .($html_format ? 'html' : 'plain') . "; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n" . "\n" . "$email_body\n" . ""; if(count($attachments)) foreach($attachments as $file) $ret .= "\n" . "--$mime_boundary\n" . "Content-Type: " . $file['content_type'] . "; name=\"".$file['filename']."\"\n" . "Content-Disposition: attachment;\n" . "Content-Transfer-Encoding: base64\n" . "\n" . "" . chunk_split(base64_encode($file['data'])) . "\n" . "\n" . "--$mime_boundary--\n" . ""; return $ret; } public static function compile_headers($headers) { $ret = ''; foreach ($headers as $key => $value) $ret .= "$key: $value\n"; return $ret; } } ×$mesg "; } function error_div($mesg){ return " $mesg "; } ?>args[$name]; } public function __construct($file, $args = array()) { $this->file = $file; $this->args = $args; } public function render() { include $this->file; } } ?> Which to me it looks like it is cropping some of it off but this is what is displayed. I have tried checking the apache error logs and such but this error never comes up in them
php
jscript
rhel
null
null
07/27/2012 18:16:36
too localized
Have an error from someone elses code.. not understanding it === Got this error when deploying a web app from CentOS to RHEL is the only difference and I am sure there is other differences but that is the major one that gave this error. The rest of the webapp is fine. The error is: pstmnts) && count($this->pstmnts)) foreach ($this->pstmnts as $stmnt_name => $stmnt) $stmnt->close(); } static function get_instance() { static $object; if (!$object) $object = new self(); return $object; } function create_pstmnt($name, $query) { return $this->pstmnts[$name] = $this->prepare($query); } function get_pstmnt($name, $query) { if (isset($this->pstmnts[$name])) return $this->pstmnts[$name]; else return $this->create_pstmnt($name, $query); } } to = $to; $this->from = $from; $this->subject = $subject; $this->body = $message_body; $this->html = $html; //ADD HEADERS IF SUPPLIED if(!is_null($headers)) { if(!is_array($headers)) throw new Exception("Invalid headers array!"); foreach($headers as $key => $value) $this->set_header($key, $value); } } function __get($key) { switch ($key) { case 'to': case 'from': case 'subject': case 'body': case 'html': case 'mime_boundary': return $this->params[$key]; default: throw new Exception("No such email parameter($key)!"); } } function __set($key, $value) { switch ($key) { case 'to': case 'from': case 'subject': case 'body': case 'html': case 'mime_boundary': $this->params[$key] = $value; break; default: throw new Exception("Invalid email parameter($key)!"); } } public static function method_name_xlate($method_name, $static = false) { return "$method_name" .($static ? '__S' : ''); } public function set_header($key, $value) { $this->headers[$key] = $value; return true; } public function clear_header($key) { unset($this->headers[$key]); return true; } public function add_attachment_file($file_path, $content_type = 'application/octet-stream') { $fh = fopen($file_path, 'rb'); $data = fread($fh, filesize($file_path)); fclose($fh); $this->add_attachment_data(basename($file_path), $content_type, $data); return true; } public function add_attachment_data($filename, $data, $content_type = 'application/octet-stream') { $this->attachments[] = array( 'filename' => $filename, 'content_type' => $content_type, 'data' => $data ); return true; } public function send() { if (empty($this->mime_boundary)) $this->mime_boundary = $this->generate_mime_boundary(); if (!is_null($this->from)) $this->set_header('From', $this->from); $this->set_header('MIME-Version', '1.0'); $this->set_header('Content-Type', 'multipart/mixed; boundary='.$this->mime_boundary); if(!@ mail($this->to, $this->subject, $this->compile_body($this->body, $this->mime_boundary, $this->html, $this->attachments), $this->compile_headers($this->headers))) throw new Exception("Email not successfully sent!"); return true; } public static function generate_mime_boundary($prefix=null) { $rand_entropy = md5(time()); if (is_null($prefix)) $prefix = md5($rand_entropy); return uniqid($prefix, $rand_entropy); } public static function compile_body($email_body, $mime_boundary, $html_format=false, $attachments=array()) { $ret = "" . "This is a multi-part message in MIME format.\n" . "\n" . "--$mime_boundary\n" . "Content-Type:text/" .($html_format ? 'html' : 'plain') . "; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n" . "\n" . "$email_body\n" . ""; if(count($attachments)) foreach($attachments as $file) $ret .= "\n" . "--$mime_boundary\n" . "Content-Type: " . $file['content_type'] . "; name=\"".$file['filename']."\"\n" . "Content-Disposition: attachment;\n" . "Content-Transfer-Encoding: base64\n" . "\n" . "" . chunk_split(base64_encode($file['data'])) . "\n" . "\n" . "--$mime_boundary--\n" . ""; return $ret; } public static function compile_headers($headers) { $ret = ''; foreach ($headers as $key => $value) $ret .= "$key: $value\n"; return $ret; } } ×$mesg "; } function error_div($mesg){ return " $mesg "; } ?>args[$name]; } public function __construct($file, $args = array()) { $this->file = $file; $this->args = $args; } public function render() { include $this->file; } } ?> Which to me it looks like it is cropping some of it off but this is what is displayed. I have tried checking the apache error logs and such but this error never comes up in them
3
11,693,410
07/27/2012 18:16:35
1,155,908
01/18/2012 10:02:23
72
1
Web service for android social networking app?
I am developing social networking app on android.Rough idea of my app is that when user launches an app it will get all users of this app in near by location.So for storage purpose of users data I want to use web server. I don't have an idea what is best way to start with.Should i use Amazon web services ? (S3,Ec2) I was surfing internet got these buzz words. Please guide me what is best approach for database storage ? Should i write my own server api ? or What ?
android
web-services
amazon
social-networking
null
null
open
Web service for android social networking app? === I am developing social networking app on android.Rough idea of my app is that when user launches an app it will get all users of this app in near by location.So for storage purpose of users data I want to use web server. I don't have an idea what is best way to start with.Should i use Amazon web services ? (S3,Ec2) I was surfing internet got these buzz words. Please guide me what is best approach for database storage ? Should i write my own server api ? or What ?
0
11,693,414
07/27/2012 18:16:47
812,959
06/23/2011 19:40:22
116
2
.Net Strong Name Key File Guidance
I am looking for general recommendations regarding use of strong name key files for .Net solutions within our organization. I have seen several questions regarding key file usage, but I don't feel they addressed my specific concerns. My team is currently implementing BizTalk Server solutions, in which each of the artifacts must be signed and GAC'd on the target servers. We currently utilize a single .snk file for our development group to utilize. We still have a potential for conflicting assembly names within our group. Beyond following prescribed project assembly naming conventions, which relies on human judgment, generating a different .snk for each solution would guarantee uniqueness. My questions are: 1. Is a single key file for individual development groups within an organization considered best practice? 2. Would using a separate key file for each Visual Studio solution violate best practice or throw any red flags to anyone? Any recommendations that can be generated would be greatly appreciated.
.net
.net-assembly
strongname
null
null
null
open
.Net Strong Name Key File Guidance === I am looking for general recommendations regarding use of strong name key files for .Net solutions within our organization. I have seen several questions regarding key file usage, but I don't feel they addressed my specific concerns. My team is currently implementing BizTalk Server solutions, in which each of the artifacts must be signed and GAC'd on the target servers. We currently utilize a single .snk file for our development group to utilize. We still have a potential for conflicting assembly names within our group. Beyond following prescribed project assembly naming conventions, which relies on human judgment, generating a different .snk for each solution would guarantee uniqueness. My questions are: 1. Is a single key file for individual development groups within an organization considered best practice? 2. Would using a separate key file for each Visual Studio solution violate best practice or throw any red flags to anyone? Any recommendations that can be generated would be greatly appreciated.
0
11,693,415
07/27/2012 18:16:48
1,558,431
07/27/2012 18:06:51
1
0
Disable telephone number links in facebook like iframe
I recently added a facebook like button to one of our pages. Everything works fine except ios sees the number of facebook likes, thinks it's a phone number, and turns it into a link. I've read around and <meta name = "format-detection" content = "telephone=no"> should disable automatic phone links. The problem is, the like button is added as an iframe so I have no way to insert the above meta tag into the document. Adding it to the containing document does nothing. Has anyone found a way around this issue?
ios
web
facebook-like
mobile-safari
null
null
open
Disable telephone number links in facebook like iframe === I recently added a facebook like button to one of our pages. Everything works fine except ios sees the number of facebook likes, thinks it's a phone number, and turns it into a link. I've read around and <meta name = "format-detection" content = "telephone=no"> should disable automatic phone links. The problem is, the like button is added as an iframe so I have no way to insert the above meta tag into the document. Adding it to the containing document does nothing. Has anyone found a way around this issue?
0
11,693,417
07/27/2012 18:17:03
1,558,443
07/27/2012 18:11:35
1
0
ATM finder application in android
I am trying to develop ATM finder application in Android. I am equipped with how to get my location and to access map. Can someone help me to find out ATMs on map?
android
null
null
null
null
null
open
ATM finder application in android === I am trying to develop ATM finder application in Android. I am equipped with how to get my location and to access map. Can someone help me to find out ATMs on map?
0
11,693,418
07/27/2012 18:17:06
1,393,002
05/14/2012 04:59:04
13
2
How to use client_side_validations and Twitter Bootstrap?
I found [this blog post][1] that talks about how to incorporate `client_side_validations` along with Twitter Bootstrap. But in the blog post, the author is using SimpleForm. **Anyone know how I can achieve the same results but without using `SimpleForm`?** On my application, I'm using `form_for` and don't want to convert the entire project over to `SimpleForm` since it'll take a lot of time. [1]: http://www.ddarrensmith.com/blog/2012/05/17/ruby-on-rails-client-side-validation-with-validation-helpers-and-twitter-bootstrap/
ruby-on-rails
twitter-bootstrap
form-validation
null
null
null
open
How to use client_side_validations and Twitter Bootstrap? === I found [this blog post][1] that talks about how to incorporate `client_side_validations` along with Twitter Bootstrap. But in the blog post, the author is using SimpleForm. **Anyone know how I can achieve the same results but without using `SimpleForm`?** On my application, I'm using `form_for` and don't want to convert the entire project over to `SimpleForm` since it'll take a lot of time. [1]: http://www.ddarrensmith.com/blog/2012/05/17/ruby-on-rails-client-side-validation-with-validation-helpers-and-twitter-bootstrap/
0
11,693,419
07/27/2012 18:17:13
1,285,533
03/22/2012 09:43:48
480
22
c# make if statements look better
Okai, how can I make this look better: lblTotalWorldSize.Text = GetDirectorySize(_worldsDirectory + selectedItem) * 1024 + " kb"; // Total world size if (Directory.Exists(_worldsDirectory + selectedItem + "\\" + selectedItem)) // World itself { lblWorldSize.Text = GetDirectorySize(_worldsDirectory + selectedItem + "\\" + selectedItem) * 1024 + " kb"; } else { lblWorldSize.Text = "Couldn't find world."; } if (Directory.Exists(_worldsDirectory + selectedItem + "\\" + selectedItem + "_nether")) // Nether { lblNetherSize.Text = GetDirectorySize(_worldsDirectory + selectedItem + "\\" + selectedItem + "_nether") * 1024 + " kb"; } else { lblWorldSize.Text = "Couldn't find world."; } if (Directory.Exists(_worldsDirectory + selectedItem + "\\" + selectedItem + "_the_end")) // The End { lblTheEndSize.Text = GetDirectorySize(_worldsDirectory + selectedItem + "\\" + selectedItem + "_the_end") * 1024 + " kb"; } else { lblWorldSize.Text = "Couldn't find world."; } It really looks like a mess and I can't seem to find any questions like this :(.
c#
if-statement
null
null
null
null
open
c# make if statements look better === Okai, how can I make this look better: lblTotalWorldSize.Text = GetDirectorySize(_worldsDirectory + selectedItem) * 1024 + " kb"; // Total world size if (Directory.Exists(_worldsDirectory + selectedItem + "\\" + selectedItem)) // World itself { lblWorldSize.Text = GetDirectorySize(_worldsDirectory + selectedItem + "\\" + selectedItem) * 1024 + " kb"; } else { lblWorldSize.Text = "Couldn't find world."; } if (Directory.Exists(_worldsDirectory + selectedItem + "\\" + selectedItem + "_nether")) // Nether { lblNetherSize.Text = GetDirectorySize(_worldsDirectory + selectedItem + "\\" + selectedItem + "_nether") * 1024 + " kb"; } else { lblWorldSize.Text = "Couldn't find world."; } if (Directory.Exists(_worldsDirectory + selectedItem + "\\" + selectedItem + "_the_end")) // The End { lblTheEndSize.Text = GetDirectorySize(_worldsDirectory + selectedItem + "\\" + selectedItem + "_the_end") * 1024 + " kb"; } else { lblWorldSize.Text = "Couldn't find world."; } It really looks like a mess and I can't seem to find any questions like this :(.
0
11,693,423
07/27/2012 18:17:24
1,558,445
07/27/2012 18:12:06
1
0
is there a difference between embedded and nested loops in javascript?
are embedded and nested loops just synonyms? Im new at programming so an example of each would be greatly appreciated! JJXN
javascript
loops
embedded
nested
null
null
open
is there a difference between embedded and nested loops in javascript? === are embedded and nested loops just synonyms? Im new at programming so an example of each would be greatly appreciated! JJXN
0
11,693,432
07/27/2012 18:18:16
252,253
01/16/2010 16:53:08
2,041
18
When using Jira, how do I ensure each team member has enough work in a sprint?
While doing planning sessions using Rapid Board what are some reasonable ways to make sure each person on the team has a decent enough amount of work for the length of the sprint? e.g. if you have 10 people on the team, how can you quickly see if 1 person only has 2 hours worth of work? Are you supposed to wait for them to speak up or can this be done through Greenhopper somehow?
project-management
agile
jira
scrum
greenhopper
null
open
When using Jira, how do I ensure each team member has enough work in a sprint? === While doing planning sessions using Rapid Board what are some reasonable ways to make sure each person on the team has a decent enough amount of work for the length of the sprint? e.g. if you have 10 people on the team, how can you quickly see if 1 person only has 2 hours worth of work? Are you supposed to wait for them to speak up or can this be done through Greenhopper somehow?
0
11,351,277
07/05/2012 19:31:48
142,540
07/22/2009 05:14:07
75
1
Faster way of fetching data from database or from List?
Can anyone please elaborate which is the faster way of fetching data. Fetching it from the database directly or fetching it from a List? Suppose, in a java web application some data need to be operated on which are in databas, and they are also in a list and saved in a session or context. Now when the user sends a request it send some parameter as well, now on the basis of that parameter some data need to be fetched, which are in the list or in the database. As the application is a multi user application there will be lots of request coming towards the server, so interacting with database for each request is not seem like a good option, and fetching it from the list seems like a slow way. Anyone please help me to solve this confusion.
database
list
java-ee
fetching-strategy
fetching
null
open
Faster way of fetching data from database or from List? === Can anyone please elaborate which is the faster way of fetching data. Fetching it from the database directly or fetching it from a List? Suppose, in a java web application some data need to be operated on which are in databas, and they are also in a list and saved in a session or context. Now when the user sends a request it send some parameter as well, now on the basis of that parameter some data need to be fetched, which are in the list or in the database. As the application is a multi user application there will be lots of request coming towards the server, so interacting with database for each request is not seem like a good option, and fetching it from the list seems like a slow way. Anyone please help me to solve this confusion.
0
11,351,281
07/05/2012 19:32:13
1,011,956
10/25/2011 02:02:04
565
37
SlimDX DX9 Shared Surfaces between processes. (C#)
**Problem:** Need to share a SlimDx.Direct3D9.Surface with another process so it can show the render output. I can create the Surface, but I have not found a way to share it between processes. **Available Code** I have access to both sides of the application, but the application providing the render output is limited. I have no access to the creation of the devices. I can reference the Direct3D9 device, create a render target, and successfully capture the output. **More details** I have a feeling I will be accused of not looking first, but I can assure you I have to the best of my ability. But, I'm trying to share a DirectX 9 Surface to another process so I can capture the render output within an external form. I have found several things on Shared Surfaces, but haven't seemed to figure out how to do it with a DirectX 9 device sharing surfaces between 2 process. My access to the DirectX device itself is limited. I am accessing it through a built in scripting module embeded in the application. I do not have the option of knowing creation properties or parameters that aren't public variables but I do have complete access to the Device itself. **So with the code below (to demonstrate exactly what I have to work with for the most part) I'm trying to figure out how I could share that Surface with another process so I can get the renderer's output on that Form.** Basically, I have code that looks like this: **(simplified)** byte[] ARGB; //Getting internal access to renderer's Direct3D9.Device (Already created) SlimDx.Direct3D9.Device dev = renderer.Device.Device; //Surface I create to capture the devices output SlimDx.Direct3D9.Surface destination; //Create render target to device destination = Surface.CreateRenderTarget(this.dev, this.w, this.h, Format.A8R8G8B8, MultisampleType.None, 0, true); // 1. Render, // 2. then grab snapshot (internal call), // 3. convert to byte array (not relevant to what I'm currently doing) if (this.renderer.Render()) { board.Snapshot(this.destination); //some internal logic to get surface try { using (DataStream data = destination.LockRectangle(LockFlags.ReadOnly).Data) { data.Read(ARGB, 0, (int) data.Length); } } finally { this.destination.UnlockRectangle(); } }
c#
winforms
directx
directx-9
slimdx
null
open
SlimDX DX9 Shared Surfaces between processes. (C#) === **Problem:** Need to share a SlimDx.Direct3D9.Surface with another process so it can show the render output. I can create the Surface, but I have not found a way to share it between processes. **Available Code** I have access to both sides of the application, but the application providing the render output is limited. I have no access to the creation of the devices. I can reference the Direct3D9 device, create a render target, and successfully capture the output. **More details** I have a feeling I will be accused of not looking first, but I can assure you I have to the best of my ability. But, I'm trying to share a DirectX 9 Surface to another process so I can capture the render output within an external form. I have found several things on Shared Surfaces, but haven't seemed to figure out how to do it with a DirectX 9 device sharing surfaces between 2 process. My access to the DirectX device itself is limited. I am accessing it through a built in scripting module embeded in the application. I do not have the option of knowing creation properties or parameters that aren't public variables but I do have complete access to the Device itself. **So with the code below (to demonstrate exactly what I have to work with for the most part) I'm trying to figure out how I could share that Surface with another process so I can get the renderer's output on that Form.** Basically, I have code that looks like this: **(simplified)** byte[] ARGB; //Getting internal access to renderer's Direct3D9.Device (Already created) SlimDx.Direct3D9.Device dev = renderer.Device.Device; //Surface I create to capture the devices output SlimDx.Direct3D9.Surface destination; //Create render target to device destination = Surface.CreateRenderTarget(this.dev, this.w, this.h, Format.A8R8G8B8, MultisampleType.None, 0, true); // 1. Render, // 2. then grab snapshot (internal call), // 3. convert to byte array (not relevant to what I'm currently doing) if (this.renderer.Render()) { board.Snapshot(this.destination); //some internal logic to get surface try { using (DataStream data = destination.LockRectangle(LockFlags.ReadOnly).Data) { data.Read(ARGB, 0, (int) data.Length); } } finally { this.destination.UnlockRectangle(); } }
0