Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
3,724,471
3,724,472
What is the Fastest way to split ':' seperated string into given number of chunks where result/record length is variable
<p>I have a large string accepted from TCP listner which is in following format</p> <p>"1,7620257787,0123456789,99,0922337203,9223372036,32.5455,87,12.7857,1/1/2012,9223372036:1,7620257787,0123456789,99,0922337203,9223372036,32.5455,87,12.7857:2/1/2012,234234234:3,7620257787,01234343456789,99,0922337203,9223372036,32.5455,87,12.7857,1/1/2012,9223372036:34,76202343457787,012434343456789,93339,34340922337203,9223372036,32.5455,87,12.7857,1/1/2012,9223372036"</p> <p>You can see that this is a : seperated string which contains Records which are comma seperated fields.</p> <p>I am looking for the best (fastest) way that split the string in given number of chunks and take care that one chunk should contain full record (string upto ':')</p> <p>or other way of saying , there should not be any chunck which is not ending with :</p> <p>e.g. 20 MB string to 4 chunks of 5 MB each with proper records (thus size of each chunk may not be exactly 5 MB but very near to it and total of all 4 chunks will be 20 MB) </p> <p>I hope you can understand my question (sorry for the bad english)</p> <p>I like the following link , but it does not take care of full record while spliting also don't know if that is the best and fastest way.</p> <p><a href="http://stackoverflow.com/questions/3008718/split-string-into-smaller-strings-by-length-variable">Split String into smaller Strings by length variable</a></p>
c#
[0]
930,781
930,782
Delete folder with C# code?
<p>I am trying to delete a folder but i can manage to get it right?</p> <p>The folder i am trying to delete is called <strong>ExtractedFiles</strong> and it is inside a folder called <strong>FormValue</strong>.</p> <p>I can delete a spreadsheet in the same <strong>FormValue</strong> folder but cant delete the folder.</p> <p>I think the problem might be that i don't have the right file extension for the folder</p> <p>This works:</p> <pre><code>if (File.Exists(tempFolderPathAlt + saveas + ".xls")) { File.Delete(tempFolderPathAlt + saveas + ".xls"); } </code></pre> <p>This does not work:</p> <pre><code> if (File.Exists(tempFolderPathAlt + "ExtractedFiles")) { File.Delete(tempFolderPathAlt + "ExtractedFiles"); } </code></pre> <p>Could someone please tell me the file extension of a folder or how to delete one?</p>
c#
[0]
4,964,293
4,964,294
Does it code like conditional operation in php?
<pre><code>var src = $(this_image).attr('src') || '' ; </code></pre> <p>Does the above code look like conditional operation in php ?</p>
jquery
[5]
389,198
389,199
Stop Work My Android Application When The Admin Sends Request From my Server to His Androidapp?
<p>I have a doubt i.e how to stop my application when i send the request from my server to my android application .The application should not work in that android device on receiving such command from server.</p>
android
[4]
2,686,331
2,686,332
Why do python .pyc files contain the absolute path of their source code?
<p>Why do python <code>.pyc</code> files contain the absolute path of their source code, instead of a relative path or something else?</p> <p>A typical <code>__init__.pyc</code> from Python 2.7 on Ubuntu:</p> <p><code> \ufffd\ufffd\ufffdOc@sddlTdS(i\ufffd\ufffd\ufffd\ufffd(t*N(tdbapi2(((s&amp;/usr/lib/python2.7/sqlite3/__init__.py&lt;module&gt;s</code></p>
python
[7]
192,089
192,090
how to replace text in the body using javascript
<p>I have the following code to replace all instances of "onAppDeactivate" with "onAppActivate" in the entire body of the document, but it doesn't seem to be working at all. Any ideas?</p> <pre><code>var pageSource = document.body.getElementsByTagName("script"); var replaceWithThis = "onAppActivate"; for(var i=0, l=pageSource.length; i&lt;l; i++) { pageSource[i].innerHTML.replace(/onAppDeactivate/gi, replaceWithThis) } </code></pre>
javascript
[3]
1,092,928
1,092,929
How to reduce "each" steps?
<p>This is my <a href="http://jsfiddle.net/2hJPH/" rel="nofollow">code</a> :</p> <pre><code>&lt;div class="parent"&gt; &lt;div class="child"&gt;&amp;nbsp;&lt;/div&gt; &lt;div class="child"&gt;&amp;nbsp;&lt;/div&gt; &lt;div class="child"&gt;&amp;nbsp;&lt;/div&gt; &lt;div class="child"&gt;&amp;nbsp;&lt;/div&gt; &lt;/div&gt; &lt;div class="parent"&gt; &lt;div class="child"&gt;&amp;nbsp;&lt;/div&gt; &lt;div class="child"&gt;&amp;nbsp;&lt;/div&gt; &lt;div class="child"&gt;&amp;nbsp;&lt;/div&gt; &lt;/div&gt; $('.child').each(function() { $(this).parent().addClass('childParent'); console.log("step"); });? </code></pre> <p>but as you can see, it <code>addClass</code> 7 times, which is not necessary. Is it possible reduce each step? In fact, on this example, is sufficent <code>addClass</code> only twice.</p>
jquery
[5]
3,234,583
3,234,584
Get a part of string from another string?
<p>I need to get a part of string from a string from another webpage.</p> <p><a href="http://jaipur.fiitjee.com/UI/TestResultSr.aspx?RollNO=1151271130152&amp;Test=203" rel="nofollow">http://jaipur.fiitjee.com/UI/TestResultSr.aspx?RollNO=1151271130152&amp;Test=203</a></p> <p>Look at this URL, here you will see my rank mentioned. It's updated daily. I want it to be displayed on my website. So i am using this code.</p> <pre><code>$a = file_get_contents('http://jaipur.fiitjee.com/UI/TestResultSr.aspx?RollNO=1151271130152&amp;Test=203'); echo stristr($a,'Rank'); </code></pre> <p>But it prints everything after the word Rank. I just want my rank and not other things. Please help me find the proper code.</p>
php
[2]
1,311,661
1,311,662
Remove single quote character escaping
<p>I have a string like this</p> <pre><code>This is\' it </code></pre> <p>I would like it to look like this</p> <pre><code>This is' it </code></pre> <p>Nothing I do seems to work</p> <pre><code>&gt; "This is\' it".replace(/\\'/,"'"); 'This is\' it' &gt; "This is\' it".replace("'",/\\'/); 'This is/\\\\\'/ it' &gt; "This is\' it".replace("\'","'"); 'This is\' it' &gt; "This is\' it".replace("'","\'"); 'This is\' it' </code></pre> <p>UPDATE: This is a little hard to wrap my head around but I had my example string inside an array something like.</p> <pre><code>&gt; ["hello world's"] [ 'hello world\'s' ] </code></pre> <p>It automatically happens like so:</p> <pre><code>&gt; var a = ["hello world's"] undefined &gt; a [ 'hello world\'s' ] &gt; a[0] 'hello world\'s' &gt; console.log(a[0]) hello world's undefined &gt; console.log(a) [ 'hello world\'s' ] undefined &gt; </code></pre>
javascript
[3]
2,828,881
2,828,882
If android restarts a Service is onCreate called again?
<p>From my little android knowledge I understand that android OS can kill my service under extreme memory conditions. </p> <p>I have created a service that returns START_STICKY. The service is meant to run in background.</p> <p>So my questions are..</p> <p>If android is about to kill my service, will it call onDestroy ?</p> <p>and when restarts it would it call onCreate ?</p> <p>Thanks, </p>
android
[4]
1,018,733
1,018,734
strip () and get value
<p>I have a html list that looks like this:</p> <ul> <li>animals (45)</li> <li>houses (36)</li> <li>computers (96)</li> </ul> <p>I want to get all the values inside those <code>()</code> and make like <code>$sum = 45+36+96;</code></p> <p>How can I do that? Thanks</p>
php
[2]
1,669,782
1,669,783
What does this mean in jquery $('#id', javascript_object);
<p>what does this <code>$('#id', javascript_object);</code> mean in jquery . I know that we can pass a context in the second parameter to the selector . But what happens when the second parameter is a javascript object . </p> <p>Thanks in advance for the help .</p>
jquery
[5]
5,009,729
5,009,730
How do i color a specific part of text in a richTextBox?
<pre><code>private void LoadKeys(Dictionary&lt;string,List&lt;string&gt;&gt; dictionary, string FileName) { string line = System.String.Empty; using (StreamReader sr = new StreamReader(keywords)) { while ((line = sr.ReadLine()) != null) { string[] tokens = line.Split(','); dictionary.Add(tokens[0], tokens.Skip(1).ToList()); richTextBox2.AppendText("Url: " + tokens[0] + " --- " + "Localy KeyWord: " + tokens[1]+Environment.NewLine); ColorText(richTextBox2, Color.Red); } } } </code></pre> <p>And the function ColorText:</p> <pre><code>public void ColorText(RichTextBox box, Color color) { box.SelectionStart = box.TextLength; box.SelectionLength = 0; box.SelectionColor = color; box.SelectionColor = box.ForeColor; } </code></pre> <p>But it didnt color anything in Red. Nothing changed. I want to be able to color in Red for exmaple only the tokens[0] and in Green tokens[1] for example.</p> <p>How can i do it ?</p>
c#
[0]
602,492
602,493
how to dynamically allocate the array of pointers in c++?
<p>I have the following class </p> <pre><code>class Node { int key; Node**Nptr; public: Node(int maxsize,int k); }; Node::Node(int maxsize,int k) { //here i want to dynamically allocate the array of pointers of maxsize key=k; } </code></pre> <p>Please tell me how I can dynamically allocate an array of pointers in the constructor -- the size of this array would be maxsize.</p>
c++
[6]
5,447,475
5,447,476
Comparing string elements stored in ArrayList
<p>I have a string arraylist</p> <pre><code>ArrayList&lt;String&gt; data = new ArrayList&lt;String&gt;(); </code></pre> <p>and I have stored string values inside. Now i want to do something like</p> <pre><code>data.get(0) == "a" // (need to compare) </code></pre> <p>How can I do? please help out.</p>
java
[1]
5,416,138
5,416,139
Voodoo Code In Python
<p>I was going through Zed Shaw's Learn Python The Hard Way and something in Chapter 15 struck me. In the extra credit exercises he asks us to delete the latter part of the code [everything after print txt.read() ] and then execute it, but the interpreter behaves as if nothing has happened. Yes, I saved the file and when I modified it by adding print statements then the changes still showed up, but the same voodoo code was executed. Why?</p> <p>What's going on over here?</p> <pre><code>from sys import argv script, filename = argv txt = open(filename) print "Here's your file %r:" % filename print txt.read() print "I'll also ask you to type it again:" file_again = raw_input("&gt; ") txt_again = open(file_again) print txt_again.read() </code></pre>
python
[7]
2,810,896
2,810,897
In iPhone development how to access a method in the ParentViewController
<p>I am a newbie iPhone Programmer and have a question regarding how to access methods of a Parent View Controller. In my program when the program first loads (applicationDidFinishLaunching) I do the following code:</p> <pre><code>[window addSubview:rootViewController.view]; [window makeKeyAndVisible]; </code></pre> <p>which basically calls this</p> <pre><code>- (void)viewDidLoad { HomeViewController *homeController=[[HomeViewController alloc] initWithNibName:@"HomeView" bundle:nil]; self.homeViewController=homeController; [self.view insertSubview:homeController.view atIndex:0]; [homeController release]; [super viewDidLoad]; } </code></pre> <p>Now, I have an IBAction call on HomeViewController that I want to have it call a method in root View Controller</p> <p>I want to call this method</p> <pre><code>- (void)loadNewGame { self.questionViewController = [[QuestionViewController alloc] initWithNibName:@"QuestionView" bundle:nil]; //[homeViewController.view removeFromSuperview]; [self.view insertSubview:questionViewController.view atIndex:0]; } </code></pre> <p>So my question is how do I call a method from the Parent View controller?</p> <p>I've tried</p> <pre><code> [self.view removeFromSuperview]; [self.parentViewController loadNewGame]; </code></pre> <p>but that doesn't seem to work. Could someone please ploint me in the right direction.</p> <p>Thanks in advance</p> <p>Scott</p>
iphone
[8]
438,448
438,449
animation with sprite 2D android
<p>I am building a virtual store with the effect same like this</p> <p><a href="http://www.htc.com/au/smartphones/" rel="nofollow">enter link description here</a></p> <p>The user can freely rotate the image from left to right and top to bottom or vice versa. I suppose to use sprite 2D to implement that animation. There are some tutorials I found but because Im pretty new about graphic programming so could anyone point me to the correct way that approach my expected performance. Thanks a lot.</p>
android
[4]
680,867
680,868
jquery: get descendants of a parent with hiearchy intact
<p>consider the following example</p> <pre><code>div &gt; h1 &gt; p &gt; a </code></pre> <p><code>div.children()</code> gives the immediate children which is <code>h1</code></p> <p>of course i use <code>find('*')</code> to get all descendants.</p> <p>however, i need <code>div.find( h1 &gt; p &gt; a)</code> <strong>not</strong> <code>div.find(h1,p,a)</code>, which is what the default find('*') is doing: it is simply ignoring the original hiearchy.</p> <p><em>please note that div can be anything. the whole hiearchy can vary in depth.</em> ie) div > h1 > span > b > i > a and etc....</p>
jquery
[5]
1,507,947
1,507,948
Java return statement confusion
<p>I just want to ask, what is the meaning to (--a,b)? Can somebody explain to me. Currently i just want to trace the calculation manually, but i was stuck.</p> <p>This part of the code:</p> <blockquote> <p>else if (a%2 == 0) return (-a) * b + print_it(--a, b);</p> </blockquote>
java
[1]
5,431,959
5,431,960
Delegate declration
<p>Hi I have summarized my problem in following code snippet. In the first code i have declared a delegate and event in the same class while in <strong>Code 2</strong> i have declared delegate and event in separate class.</p> <p><strong>Code 1</strong></p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { delegate void Greeting(string s); event Greeting myEvent; void OnFire(string s) { if (myEvent != null) myEvent(s); } static void Main(string[] args) { Program obj = new Program(); obj.myEvent += new Greeting(obj_myEvent); obj.OnFire("World"); } static void obj_myEvent(string s) { Console.WriteLine("Hello " + s + "!"); } } } </code></pre> <p><strong>code 2</strong></p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { DelegateDemo obj = new DelegateDemo(); obj.myEvent+=new DelegateDemo.Greeting(obj_myEvent); obj.OnFire("World"); } static void obj_myEvent(string s) { Console.WriteLine("Hello "+s +"!"); } } } </code></pre> <p><strong>DelegateDemo.cs</strong></p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { public class DelegateDemo { public delegate void Greeting(string s); public event Greeting myEvent; public void OnFire(string s) { if (myEvent != null) myEvent(s); } } } </code></pre> <p>Now i have one question.Is there any diffrence (like thread safe ,performance) between these two code snippets?</p>
c#
[0]
3,919,900
3,919,901
how to fill an int array from textbox in c#
<p>hello I asked this question a few minutes ago! but Before any reactionو My question is closed.</p> <p>This textBox contain number only. i want to Separating textBox value figure figure and fill one array cell with one figure.</p> <p>my english is very bad i am sory </p> <p><strong>UPDATE:</strong></p> <p>I would like to take a text box that contains the string: <code>1234567890</code> and create the following array:</p> <pre><code>int[] arr = {1,2,3,4,5,6,7,8,9,0}; </code></pre> <p>(i think)</p>
c#
[0]
1,487,101
1,487,102
Colorize options from a select form
<p>I have a select form filled with following data:</p> <pre><code>&lt;select id="attachments[32][color][]" name="attachments[32][color][]"&gt; &lt;option value=""&gt;-- Select a color --&lt;/option&gt; &lt;option value="AliceBlue"&gt;AliceBlue&lt;/option&gt; &lt;option value="Amethyst"&gt;Amethyst&lt;/option&gt; &lt;option value="AntiqueWhite"&gt;AntiqueWhite&lt;/option&gt; &lt;option value="Aquamarine"&gt;Aquamarine&lt;/option&gt; &lt;/select&gt; </code></pre> <p>Theres a way to colorize options backgrounds from select with their own value?</p> <p>Im using colors from: <a href="http://secure.wikimedia.org/wikipedia/en/wiki/Web_colors#X11_color_names" rel="nofollow">http://secure.wikimedia.org/wikipedia/en/wiki/Web_colors#X11_color_names</a></p> <p>More at: <a href="http://www.456bereastreet.com/lab/styling-form-controls-revisited/select-single/" rel="nofollow">http://www.456bereastreet.com/lab/styling-form-controls-revisited/select-single/</a></p> <p>Thanks in advance.</p>
jquery
[5]
525,368
525,369
How to detect printer is connect or not using c# 2008?
<p>How to detect the printer is installed in my PC or not &amp; the printer connection is active or not? using c# winfrom 2008.</p> <p>Thanks in advance.</p>
c#
[0]
5,035,481
5,035,482
.call() is not a function
<p>I have made a CSS3 animation plugin for jquery that works perfectly in JS Fiddle: <a href="http://jsfiddle.net/backflip/BqFsM/" rel="nofollow">http://jsfiddle.net/backflip/BqFsM/</a> </p> <p>but when i use it in my context i get "TypeError: Result of expression '$fnStop.call' [undefined] is not a function."</p> <p>here is my code: <a href="http://meodai.ch/alainbenoit/" rel="nofollow">http://meodai.ch/alainbenoit/</a></p> <p>but i can't figure out why. Any idea?</p> <p>This is how i overwrite the jquery native Stop function:</p> <pre><code>if (Modernizr.csstransitions) { $fnStop = $.fn.stop(); $.fn.stop = function(clearQueue, jumpToEnd) { if (this.data("css3animate")) { return methods.stop.apply(this, arguments); } else { return $fnStop.call(this, arguments); } }; } </code></pre>
jquery
[5]
83,329
83,330
Posting form to an aspx page in another application
<p>I need to submit the form to another web application.</p> <p>I have hosted 2 websites in my IIS. In website1 I have a page "Register.aspx" and I set PostBackUrl for the submit button to a page(Receiver.aspx) in website2. But I couldn't get the posted values in Receiver.aspx. If I set the PostBack url to a page which is in website1, I could get the posted values using Request.Form["tbUserName"]. Please suggest me.</p>
asp.net
[9]
780,266
780,267
Restart an if else construct
<p>Let's take a look at the following code:</p> <pre><code>if ($a == 1) { echo "this is stage 1"; } else if ($a == 2) { echo "this is stage 2"; } else if ($a == 3) { $a = 1; // at this point I want something that restarts the if-else construct so // that the output will be "this is stage 1" } </code></pre> <p>I'm working on an if else construct at the moment and let's say that I have three stages and the if-else construct checks which stage I'm in. </p> <p>Now it happens that some activities in stage 3 lead to a jump back to stage 1. Now I've already passed the code for stage one, which is why I want to somehow restart the if-else construct. Is there a way to do that? And even more important: Is there a better way to do what I want? Because my idea doesn't seem to be good practice.</p>
php
[2]
465,308
465,309
Writing certain lines to a file in python
<p>I have a large file called <code>fulldataset</code>. I would like to write lines from fulldataset to a new file called newdataset. I only want to write the lines from fulldataset though that contain the id numbers present in the listfile. Also all the id numbers start with XY. The id numbers occur in the middle of each line though. </p> <p>Here is an example line from list file:</p> <pre><code>Robert, Brown, "XY-12344343", 1929232, 324934923, </code></pre> <p>Here is the program I have so far. It runs fine, but doesn't write anything into the new file. </p> <pre><code>datafile = open('C:\\listfile.txt', 'r') completedataset = open('C:\\fulldataset.txt', 'r') smallerdataset = open('C:\\newdataset.txt', 'w') matchedLines = [] for line in datafile: if line.find("XY"): matchedLines.append( line ) counter = 1 for line in completedataset: print counter counter +=1 for t in matchedLines: if t in line: fulldataset.write(line) del line break datafile.close() completedataset.close() fulldataset.close() </code></pre> <p>EDIT:</p> <p>Ok here is the new program:</p> <pre><code>datafile = open('C:\\tryexcel33.txt', 'r') completedataset = open('C:\\fulldataset.txt', 'r') smallerdataset = open('C:\\newdataset.txt', 'w') counter = 1 for line in completedataset: print counter counter +=1 if any( id in line for id in datafile ): smallerdataset.write( line ) break datafile.close() completedataset.close() fulldataset.close() </code></pre> <p>I still don't have anything being written to the new file. I think a problem might be that in the full file the id numbers have a " in front of them but this doesn't exist in the listfile. Any thoughts?</p>
python
[7]
1,190,413
1,190,414
how to get only time from date time
<p>suppose i have 6/22/2009 10:00:00 AM.. then how to get only 10:00 Am from this date time</p>
c#
[0]
3,964,717
3,964,718
the animation is not work
<p>i have made the following animation xml file in my android project:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator = "true" android:interpolator="@android:anim/linear_interpolator"&gt; &lt;scale android:fromXScale = "1.0" android:toXScale = "0.0" android:pivotX="50%" android:pivotY="50%" android:duration="40000"&gt; &lt;/scale&gt; &lt;/set&gt; </code></pre> <p>what this is basically doing is making a view dissappear starting from its center.</p> <p>Now in my code i am doing the following to start the animation:</p> <pre><code>overridePendingTransition (0,R.anim,myanimation); </code></pre> <p>but nothing is happening.</p> <p>what am i doing wrong?</p> <p>thank you in advance.</p>
android
[4]
5,530,628
5,530,629
value not fetch from sql server 2008 r2 on asp.net page
<p>Page runs properly but no record display on web page.</p> <p><code>web.cofig</code> file:</p> <pre><code>&lt;connectionStrings&gt; &lt;add name="myConnectionString" connectionString="Data Source=AMIT-PC\R2;Initial Catalog=amit;Integrated Security=True" /&gt; &lt;/connectionStrings&gt; </code></pre> <p><strong>.vb page</strong></p> <pre><code>Imports System.Data.SqlClient Public Class Desired_Username Inherits System.Web.UI.Page Dim connString As String connString=ConfigurationManager.ConnectionStrings("myConnectionString").ConnectionString Dim cmd As New SqlCommand Dim sqlcnn As New SqlConnection(connString) Dim oleda As New SqlDataAdapter Dim ds As New DataSet() Dim dr As SqlDataReader Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim sel As String = "select * from emp" Response.Write(sel) sqlcnn.Open() 'cmd.Connection = sqlcnn 'cmd.CommandText = sel cmd = New SqlCommand(sel, sqlcnn) dr = cmd.ExecuteReader() While dr.Read() Label1.Text = "xcdsfdffsfd" End While sqlcnn.Close() End Sub End Class </code></pre>
asp.net
[9]
3,913,769
3,913,770
How can i check that the NSString ends with the certain character(.jpg)?
<p>I have NSString object which is assign by this ("http://vspimages.vsp.virginia.gov/images/024937-02.jpg"). Can anybody tell me how can i check that string ends with ".jpg" character? </p>
iphone
[8]
3,184,526
3,184,527
How to calculate the height of a dynamic div/
<p>I have a hidden div with lengthy content in it. But onload iam applying the jquery to hide the div. The thing is onload the height is taking the full content and after that the div is hide it is resizing.</p> <p>I have to do some calculation based on the height, so is it possible to trigger something constanly when ever there is a change in height using jquery?</p>
jquery
[5]
1,876,494
1,876,495
jQuery: Call function periodically while click is held
<p>When an element is clicked, I want to call a function every n seconds until the mouse button is released.</p> <p>How should I do this?</p> <p>EDIT:</p> <pre><code> var interval, i = 0; $("a").on("mousedown", function(){ interval = setInterval(function(){ $(".results").append(i++); }, 250); }); $(document.body).on("mouseup", function(){ clearInterval(interval) });​ </code></pre>
jquery
[5]
1,688,421
1,688,422
How can I print all arguments passed to a python script?
<p>How can I print all arguments passed to a python script?</p> <p>This is what I was trying:</p> <pre><code>#!/usr/bin/python print(sys.argv[1:]); </code></pre> <p><strong>update</strong></p> <p>How can I save them to a file?</p> <pre><code>#!/usr/bin/python import sys print sys.argv[1:] file = open("/tmp/test.txt", "w") file.write(sys.argv[1:]) </code></pre> <p>I get</p> <pre><code>TypeError: expected a character buffer object </code></pre>
python
[7]
176,214
176,215
CURLOPT_FOLLOWLOCATION
<p>I looked up google for more information. But the more I read, the more I am confused or wonder</p> <p>CURLOPT_FOLLOWLOCATION() - I understand that it follows the location but which is the location? Is it the url that is initialized? </p> <pre><code> curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, false); </code></pre> <p>I only need to post data into icontact mailing list - so would this snippet above prevent the data from going in the mailing list? </p> <p>I printed <code>$result</code> and see that the data went in the correct mailing list although I cannot see whether the data are the correct ones which are from form. </p> <p>I am sorry if it is stupid question and I will be grateful for the guide or explanation. </p>
php
[2]
2,218,021
2,218,022
Validate email address textbox using JavaScript
<p>I have requirement i.e validating entered email address when user comeout from the textbox. I have googled for this but i got form validatation jscript i don't want form validatation. I want textbox validatation i have writen below jscript but "if email invalid it's not returning the same page" </p> <pre><code> function validate(email) { var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; //var address = document.getElementById[email].value; if (reg.test(email) == false) { alert('Invalid Email Address'); return (false); } } </code></pre>
javascript
[3]
4,136,766
4,136,767
Change file.encoding to show umlauts
<p>I'm showing an about text from a text file with the following code. But I have problems to show german umlauts ä, ü, ö correctly. How can I change or set the encoding? Androis says:</p> <blockquote> <p>public InputStreamReader (InputStream in) Since: API Level 1</p> <p>Constructs a new InputStreamReader on the InputStream in. This constructor sets the character converter to the encoding specified in the "file.encoding" property and falls back to ISO 8859_1 (ISO-Latin-1) if the property doesn't exist.</p> </blockquote> <pre class="lang-java prettyprint-override"><code>public void onCreate(Bundle savedInstanceState) { setContentView(R.layout.help); TextView tv = (TextView)findViewById(R.id.help_text); //tv.setText(readRawTextFile(R.raw.help)); tv.setText(Html.fromHtml(readRawTextFile(R.raw.help))); } public static String readRawTextFile(int id) { InputStream inputStream = mContext.getResources().openRawResource(id); InputStreamReader in = new InputStreamReader(inputStream); BufferedReader buf = new BufferedReader(in); String line; StringBuilder text = new StringBuilder(); try { while (( line = buf.readLine()) != null) text.append(line); //text.append("&lt;br&gt;" ); } catch (IOException e) { return null; } return text.toString(); } </code></pre> <p>Thanks in advance!</p>
android
[4]
2,714,015
2,714,016
Selecting Elements with more than one Class in jQuery
<p>I have some message elements like this...</p> <pre><code>&lt;span class="error message"&gt;Whoops! Don't forget your name.&lt;/span&gt; </code></pre> <p>And...</p> <pre><code>&lt;span class="success message"&gt;All done! Thank you very much.&lt;/span&gt; </code></pre> <p>You'll notice that two classes are being applied to a single <code>span</code> element. This is valid markup. How can I select elements with two classes like this?</p> <p>Note: I don't want all elements that have a class attribute containing "message". I need the elements that have both "error" and "message" (and nothing else).</p>
jquery
[5]
2,264,647
2,264,648
Add text to unlocked screen on iPhone
<p>How I can add some text to unlocked screen on iPhone? I saw some application, that write text on unlocked screen.</p>
iphone
[8]
3,510,650
3,510,651
Touchscreen sensitivity
<p>I'm trying to make an android app only for <strong>tablets</strong>, which will draw the lines as and where the user touches the screen. It is very simple and there are lot more apps like this. I have a doubt regarding the touch-screen technology. Is there any possibility that if the user touch the screen <strong>soft</strong> then the lines will be dull and if the user touch the screen <strong>harder</strong> then the lines drawn will be thicker? Is it even possible to do such things in tablet? I don't have info about the hardware and technology used in tablets, please guide me with a valid answers and please refer me to any blogs or docs which says about the touch sense technology. Thank you</p>
android
[4]
3,956,011
3,956,012
how to compare two files and extract the difference?
<p>I created a video recorder which stores recording to a file. I would like to implement a method which would read the file each second, compare the current file with the old value (1 second older) and write the difference to a separate file.</p> <p>I would be very thankful if anyone could explain how to do that or write a simple example. I guess there has to be a thread which compares the new value with the old one by calling a custom method compareFiles(File currentFile, File oldFile) on a given period of time. The old file could also be saved as a temporary file and the current file at the original path could be compared with temporary file.</p> <p>Any suggestion about the improvement of the described logic is more than welcome!</p>
java
[1]
5,423,314
5,423,315
Why is no qualification necessary?
<p>OK, I'll just post the complete program even though it has extraneous stuff and the code in question is the dead code&hellip;</p> <pre><code>#include &lt;iostream&gt; #include &lt;fstream&gt; namespace detail { // Solution by Johannes Schaub alias litb // http://groups.google.com/group/comp.std.c++/browse_thread/thread/b567617bfccabcad template&lt;int&gt; struct D {}; typedef char yes[1]; typedef char no[2]; template&lt; class T, class U &gt; yes&amp; f( int, D&lt; sizeof T(*(U*)0) &gt;* = 0 ); template&lt; class T, class U &gt; no&amp; f( ... ); template&lt; class To, class From &gt; struct IsExplicitlyConvertible { enum{ yes = (sizeof detail::f&lt; To, From &gt;(0) == sizeof( detail::yes ) ) }; }; bool const streamsSupportWindows = IsExplicitlyConvertible&lt; std::ofstream, wchar_t const* &gt;::yes; } class InFStream : public std::ifstream { public: InFStream() {} explicit InFStream( char const* filename, ios_base::openmode mode = ios_base::in | ios_base::out ) : std::ifstream( filename, mode ) {} }; int main() { using namespace std; cout &lt;&lt; (detail::streamsSupportWindows ? "Windows-enabled" : "Ach, no Windows support" ) &lt;&lt; endl; } </code></pre> <p>This compiles fine with MSVC and g++. But in the <code>InFStream</code> class, why do I not need to qualify <code>ios_base</code>? Or, same question really, why do I need to use <code>std::</code> qualification of <code>ifstream</code> in the constructor initializer list?</p>
c++
[6]
3,076,615
3,076,616
special characters in url - htmlspecialcharacters()
<p>I have wasted about an hour, on my server for some reason htmlspecialcharacters() doesn't seem to work. If my url is</p> <p><a href="http://site.com/phpfile/it" rel="nofollow">http://site.com/phpfile/it</a>'s-my-life</p> <p>if I get this using $_GET['var'] it shows</p> <p>it?s-my-life</p> <p>now I have tried converting it from htmlspecialcharactedrs(), urlencode(), urldecode() etc but it doesn't seem to work.. what I am doing wrong, how can I get the exact queryString from the url so that it will display as exactly as it is..</p> <p>it's-my-life</p> <p>regards</p>
php
[2]
1,031,919
1,031,920
Parsing sequential ASCII file for editing - Visual C#
<p>I have been recently assigned a task in which I need to create a program to edit files in Visual C#. The file is a sequential ASCII text file with multiple fixed character width rows, and the basic structure looks like this: </p> <p>Each group is a single parameter, and there can be hundreds of these within a file. Each PA has a set number of columns, but each PA varies in column numbers. Additionally, there are some optional fields within each record, so that accounts for the extra spaces between some of the fields. Each field also has a separator of 1 space. I am unsure if I am being too thorough, but I figure the more information I give, the easier it will be for someone to help me.</p> <p>Essentially, I want to create a GUI in which the user can select one a parameter mnemonic and then be able to edit any of the fields within the entire group of parameters</p> <p>I have a little C# experience, but I am having trouble figuring out what would be the best way to accomplish this. My initial thinking was to parse the file into an array, search for each parameter name (maybe using regular expressions?), display all the parameter names in a browser. From there the user would be able to select which parameter they wish to edit. The program would then search the array again for the selected parameter, and then parse the records into text boxes, to allow for editing. </p> <p>I am unsure if this is the most efficient way of accomplishing this, and I am somewhat stuck on how to actually parse the file to read the fields into the text boxes. I have searched many different forums for file parsing, but most of the topics I find related to comma delimited files which does not really apply to the file type I am working with. Any help would be greatly appreciated, and if you need me to elaborate on anything, please feel free to ask me. Thank for the help.</p>
c#
[0]
3,344,226
3,344,227
How to find out browser's user agent in Android
<p>Can I find out from my Android app, what is the browser's user agent string?</p>
android
[4]
658,132
658,133
Append a radio button in place of Hidden checkbox
<p>I am trying to hide a checkbox and inplace of that want to show a radio button.. Here you can see in jsfiddle: <a href="http://jsfiddle.net/KGRvz/" rel="nofollow">http://jsfiddle.net/KGRvz/</a> </p> <p>But it appending in a different way.. somebody help me please </p>
jquery
[5]
1,268,618
1,268,619
Reset some input in a Form
<p>How I need to RESET a form without touching "hidden" input and "submit", I tried the follow but doesn't works,</p> <pre><code>$("#myForm textarea input[type!='submit'] input[type!='hidden']").val(''); </code></pre> <p>How can I do it using Jquery?</p>
jquery
[5]
4,233,325
4,233,326
PHP - Where should I call ini_set?
<p>I am looking for a best practice for where I should place the statement ini_set.</p> <p>For example,</p> <pre><code>ini_set('session.use_only_cookies', 1); </code></pre> <p>Thank you</p>
php
[2]
5,609,446
5,609,447
Redirect console progress percentage to Form
<p>I'm building a batch processing GUI around <a href="http://rtmpdump.mplayerhq.hu/" rel="nofollow">rtmpdump</a> and I'd like to redirect the progress percentage that is outputted in the console window to a <code>ProgressBar</code> control.</p> <p>Is this in any way possible? Thanks in advance.</p>
c#
[0]
3,090,807
3,090,808
Error when trying to refer to a field by name
<p>I am getting an error (<code>document.my_formm.fieldName.value is null or not an object</code>) from the below code:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;(Type a title for your page here)&lt;/title&gt; &lt;script language=JavaScript&gt; function check_length(my_formm,fieldName) { alert(fieldName); alert(document.my_formm.fieldName.value); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form name=my_form method=post&gt; &lt;input type="text" onChange=check_length("my_form","my_text"); name=my_text rows=4 cols=30 value=""&gt; &lt;br&gt; &lt;input size=1 value=50 name=text_num&gt; Characters Left &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]
1,324,686
1,324,687
How to find installed software using python
<p>How to get control panel info using wmi using python</p>
python
[7]
5,382,400
5,382,401
asp.net create user control
<p>I have used the create user control of asp.net toolbox , and customized it to be in the style that I want but the problem now that I want to remove the default Create User button and use my own button , and I want my button to behave like the default button , please I need help as soon as you can </p> <p>Thanks in Advance</p>
asp.net
[9]
3,130,752
3,130,753
Does foreach do its work on a copy of the input array?
<p>I've been studying some test questions. One of the questions about array iteration. Here it is : </p> <blockquote> <p>What is the best way to iterate through the $myarray array, assuming you want to modify the value of each element as you do?</p> <pre><code>&lt;?php $myarray = array ("My String", "Another String", "Hi, Mom!"); ?&gt; </code></pre> <p>A. Using a for loop</p> <p>B. Using a foreach loop</p> <p>C. Using a while loop</p> <p>D. Using a do…while loop</p> <p>E. There is no way to accomplish this goals</p> </blockquote> <p>My answer is "of course foreach loop". But according to the answer sheet :</p> <blockquote> <p>Normally, the foreach statement is the most appropriate construct for iterating through an array. However, because we are being asked to modify each element in the array, this option is not available, since foreach works on a copy of the array and would therefore result in added overhead. Although a while loop or a do…while loop might work, because the array is sequentially indexed a for statement is best suited for the task, making Answer A correct.</p> </blockquote> <p>I still think foreach is the best. And as long as I use it with key I can modify values.</p> <pre><code>&lt;?php foreach($myarray as $k=&gt;$v){ $myarray[$k] = "Modified ".$v; } ?&gt; </code></pre> <p>Do I miss something?</p>
php
[2]
1,671,803
1,671,804
Collision between 2 lines - Math
<p>Alright, I'm doing some excersice. The question is: I have distances of those 2 lines, I can also get the gradient if needed. I need to write if there is collision between those lines, I need to know how am I doing it? Thanks in advanced.</p>
c#
[0]
2,483,113
2,483,114
Converting EMF format to PNG or JPG.
<p>Hi i am trying to make a android document viewer. I need to convert Emf format to jpg or png format. If anyone knows how to do it or if there is any open source project for this then please let me know.</p> <p>Thanks</p>
android
[4]
526,347
526,348
How to vocally interfere with a call programatically?
<p>Is there a way for my application to interfere with the audio channel of a call? I want my application to play sounds to the caller and maybe talk instead of the user. Can I do that?</p>
android
[4]
3,081,129
3,081,130
jquery delegate not working with list item
<p>I'm using an older version of jquery (1.6.2) and can't seem to get delegate working. I have a list that I'm trying to use delegate on a click event but it fails after the list is reloaded.</p> <p>Here is my current code:</p> <pre><code>$(".image_result").delegate("li", "click", function() { //$('.image_result li').click(function() { var imgInfo = $(this).attr('id').split(':'); if(confirm('Are you sure you want to delete this image?')) { $.post('delete_image.php?image_id=' + imgInfo[0] + '&amp;user_id=' + imgInfo[1], function(data) { if (data.st) { var resp = data.html.split("|"); $('#imageStats').html(resp[0]); $('#imageTable').html(resp[1]); } else { alert("Yikes, something went wrong"); } }, "json"); } }); </code></pre> <p>The imageTable div now holds the new list items (image_result)</p> <p>What am I missing?</p>
jquery
[5]
2,508,602
2,508,603
user browse web site history data
<p>I would like to list user connect web site link,get all history data where can i got those data. thanks</p>
c++
[6]
3,782,676
3,782,677
Find string in another string using python
<p>Lets say that you have an email address xxx@yyy.com and you want to create something like this in python:</p> <pre><code>email = 'mystuff@yyy.com' try: if "@yyy.com": #do something if "@zzz.com": #do something else except: #do something </code></pre> <p>How would I do this?</p>
python
[7]
4,949,009
4,949,010
file with a string that is hex. need to format it so i can use it in program
<p>i have a hex valued string that is saved in a text file. I want to get it into a c style include format to just copy and paste into my code. i tried using xxd that has a feature to do that but for some reason when i use my file it takes that string (it considers it non hex) and further converts it into hexadecimal. </p> <p>anyway around this or an easier way to do this in c++. I am not sure. pretty new to c++ and just learning here.</p> <p>sample of the contents of the file are as follows:</p> <pre><code>AFAB2591CFB70E77C7C417D8C389507A541D0350752EE9E8C12D76E8674677C166A5ACA65ECFDE7EC90DC8E7D6D621438FEF7DD38B0EDEA3D44BDB9D6E7E1CA0FBA30B507EA70B2A52434F64092EC13BD12F8F1C2BED6EE1ADE7 </code></pre> <p>so getting it like 0xAF, 0xAB etc is what i am looking for.</p> <p>i also noticed that when i use xxd even if i just put A in the file...its result is 410a. I don't understand that either. is it showing a word rather than just a byte?</p>
c++
[6]
126,174
126,175
fastest way to search and delete files inside a directory
<p>I've got a array of class in which one member is the full path to a file. I need to delete all those files from the directory which is not included in the array. As Usual, I am using the convential compare and delete method. I need to know if there any fast way to accomplish this. I heard it can be done using Linq, but i dont have knowledge on linq.</p> <p>My class struct is like below.</p> <pre><code>Class ImageDetails { public string Title; public Boolean CanShow; public String PathToFile; } </code></pre> <p>I have an array of ImageDetails. The PathToFile contains full path</p> <p>}</p>
c#
[0]
1,040,038
1,040,039
How to reduce height of list item in dialog box?
<p>I have list in AlertDialog. I used setItems to show array for each list item. But, the height of each item in the list is too big. Is there anyway to reduce height of the list item in dialog box?</p>
android
[4]
1,773,810
1,773,811
showing shopping card buttons and the count of items in top of all pages
<p>i want to put a button of shopping card in top of all page and when any on add product to shopping card the count of products in shopping card displayed near the button in top ,i want to know the idea of it please can any one help me </p>
asp.net
[9]
4,821,302
4,821,303
Can you explain why Google Closure Templates uses so many pointless intermediate objects?
<p>Ladies, gentlemen.</p> <p>I was reading <a href="https://developers.google.com/closure/templates/docs/helloworld_java" rel="nofollow">Google's documentation for Closure Templates.</a></p> <p>There's not that much code in there, but it represents what I'm having trouble understanding (in Java, in particular). I'll go line by line:</p> <pre><code>// Bundle the Soy files for your project into a SoyFileSet. SoyFileSet sfs = new SoyFileSet.Builder().add(new File("simple.soy")).build(); </code></pre> <p>I get this. An object to gather multiple template files. Fine. But why the <code>.Builder()</code>? Why not just <code>new SoyFileSet().add(...).build()</code>?</p> <pre><code>// Compile the template into a SoyTofu object. // SoyTofu's newRenderer method returns an object that can render any template in file set. SoyTofu tofu = sfs.compileToJavaObj(); </code></pre> <p>Fine. But why do I want this? After I have the files gathered, I was expecting just something like <code>sfs.render(Map&lt;&gt; data)</code>. Why do I need to compile this to a Java object?</p> <p>And finally...</p> <pre><code>// Call the template with no data. System.out.println(tofu.newRenderer("examples.simple.helloWorld").render()); </code></pre> <p>Great, why do I have to create an intermediate object just so I can call a method od it? Why couldn't the <code>sfs</code> object have a <code>.render()</code> method? Why do I need a <code>Renderer</code> object?</p> <p>Java is frustrating, why aren't things done in a straightforward way? </p>
java
[1]
1,217,379
1,217,380
Get bottom and right position of an element
<p>I'm trying to get the position of an element within the window like so:</p> <pre><code>var link = $(element); var offset = link.offset(); var top = offset.top; var left = offset.left; var bottom = $(window).height() - link.height(); bottom = offset.top - bottom; var right = $(window).width() - link.width(); right = offset.left - right; </code></pre> <p>However the bottom and right have <code>-</code> in front of them... Why is this? as the numbers are correct just they should NOT be minus.</p>
jquery
[5]
674,211
674,212
Editor to pull Title
<p>Dynamic pages on my site automatically have their own Title.</p> <p>I'd like to tell these pages to pull certain fields to load into the Title tag and thus display on the Title to the viewer.</p> <p>Is this possible to do through the Theme Editor? I see certain templates listed in the Theme Editor. Taxonomy.php or single-listing.php which sounds like the listing pages that I want to set up these Title tags for.</p> <p>THANKS</p>
php
[2]
4,238,459
4,238,460
how to read a value from a xml document based on the user input
<p>how to read a value from a xml document based on the user input ( for example if user enter id value then all the related values display from xml document)</p>
c#
[0]
1,889,886
1,889,887
Browsing files within iphone application
<p>I have problem to browse different types of file.</p> <p>I know browse music file and Photo from iPhone but i want to browse all typs of file doc,zip,ppt,xls,pdf files within a application. like music and photo library.</p> <p>Is there any way to browse all types of files?</p> <p>Thanks you,</p>
iphone
[8]
338,814
338,815
Can outside developers access closure variables during runtime?
<p>Essentially I want to store a variable in the client that I don't want people viewing or changing.</p> <p>In the following code example:</p> <pre><code>(function () { var foo = 'bar'; })(); </code></pre> <p>Can anybody use tools or the browser to access and/or (more importantly) change the value of foo? Links to more information or tools that might do this would be appreciated. I'll be researching more in the mean time.</p> <p>Thanks in advance</p>
javascript
[3]
949,632
949,633
OO Javascript and this keyword. Object Literals
<p>I'm having issues with Javascript properties and "this" keyword. Forgive me here for asking my third and final JS OOP question. OOP in Javascript has been a headache for me today.</p> <p>I'm trying to set the property 'source' but the error console is saying it's undefined in parseSource method.</p> <p>After a little research I believe this.source is is referring to window.source? The code is a boilerplate from Mozilla. When creating extensions init is called by FireFox when the plugin is initialized.</p> <p>What's the best way to go about setting the properties when creating objects using literal notation?</p> <pre><code>var myExtension = { source: null, init: function() { // The event can be DOMContentLoaded, pageshow, pagehide, load or unload. if(gBrowser) { gBrowser.addEventListener("DOMContentLoaded", this.onPageLoad, false); } }, onPageLoad: function(aEvent) { doc = aEvent.originalTarget; // doc is document that triggered the event win = doc.defaultView; // win is the window for the doc // Skip frames and iFrames if (win.frameElement) return; this.source = win.document.getElementById('facebook').innerHTML; myExtension.parseSource(); }, parseSource: function() { if(this.source == null) { // So something } else { // Do something else } } } window.addEventListener("load", function() { myExtension.init(); }, false); </code></pre>
javascript
[3]
4,871,785
4,871,786
if map.insert fails how check its failure without using bad_alloc
<p>If inside my code i am having a </p> <pre><code>class A; A ob; pair&lt;map&lt;int,A&gt;::iterator,bool&gt; ret; ret=map.insert(pair&lt;int,A&gt;(1,ob)); </code></pre> <p>If map fails to insert the ob because of out of memory, it will throw bad_alloc but is there any other way to check whether insert failed or not because i have a restriction to not use namespace and exception handling. Can't we use some kind of NULL pointer comparision statement?</p>
c++
[6]
5,855,571
5,855,572
php function variable scope
<p>I was wondering if i have a function like this:</p> <pre><code>function isAdmin ($user_id) { $admin_arr = array(1, 2); foreach ($admin_arr as $value) { if ($value == $user_id) { return true; } } return false; } </code></pre> <p>Could i make an array outside of that function as a global array and use it inside the function without sending it through as a parameter, also instead declaring a new admin array inside the function as i just did above? How would i do this? </p> <p>Regards, Alexander</p>
php
[2]
5,141,163
5,141,164
jquery not running from <body>
<p>I'm calling a function that's loaded in custom js file in the header.</p> <pre><code>&lt;head&gt; &lt;script type="text/javascript" src="/js/jquery-1.5.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="/js/my.js"&gt;&lt;/script&gt; </code></pre> <p>my.js has </p> <pre><code>$(document).ready(function(){ function testFunction(){ alert("inside testfunction"); } }); </code></pre> <p>after a few clicks, this is loaded in the <code>&lt;body&gt;</code>:</p> <pre><code>$("#someid").live($.myapp.event.play, function(event) { alert("this works"); testFunction(); }); </code></pre> <p>the alert "this works", fires, but then nothing happens, what am I doing wrong?</p>
jquery
[5]
5,436,603
5,436,604
Short toHexString
<p>There are methods <code>Integer.toHexString()</code> and <code>Long.toHexString()</code>. For some reason they didn't implement <code>Short.toHexString()</code>. </p> <p>What is the canonical method converting Short to a hex string? </p> <p>It's not possible to use <code>Integer.toHexString()</code> because <code>Integer.toHexString(-33)</code> equals <code>ffffffdf</code> which is not a short value.</p>
java
[1]
57,267
57,268
Unable to restore state in android application
<p>I have an application which works with services and activities.</p> <ol> <li>Called service from first activity and then second activity is called from service.</li> <li>Pressed Home button and opened the same application again.</li> <li>Now, I can see first activity but i am expecting to see second activity.</li> </ol> <p>Note: using network service </p> <p>I did the same scenario in test project with local service but it is working. But, it is not working with my network service, may i know the solution for this.</p>
android
[4]
790,750
790,751
How to get a static version of my site?
<p>I need to save a static version of my site by using the sitemap which has about 400 URLs. What is the best way to do that?</p>
php
[2]
3,658,408
3,658,409
Explode PHP string by new line
<p>Simple, right? Well, this isn't working :-\</p> <pre><code>$skuList = explode('\n\r', $_POST['skuList']); </code></pre>
php
[2]
3,217,178
3,217,179
Detecting </span> in PHP?
<p>I have a script that checks the source of another page, I'm having my code search for</p> <pre><code> &lt;span class="item-header"&gt; </code></pre> <p>in the source. When it finds it, I wan't to print everything that is in the span, but I am not sure how I would do that in PHP? How do I check when to stop printing everything after the span until it finds <code>&lt;/span&gt;</code> Here is my code:</p> <pre><code> if (stristr($source, '&lt;span class="item-header"&gt;')){ // What to do here? } </code></pre> <p>Any Ideas? :)</p>
php
[2]
4,221,565
4,221,566
Whats the smallest way to say this:
<p>What is the most elegant way to say this in JS?:</p> <pre><code>search_keyword = search_keyword.toLowerCase(); search_keyword = search_keyword.replace(/[^\w\s]/gi, ''); search_keyword = search_keyword.replace(' and ', '&amp;all='); search_keyword = search_keyword.replace(' or ', '&amp;any='); search_keyword = search_keyword.replace(' ', '&amp;all='); search_keyword = '&amp;all=' + search_keyword; </code></pre> <p>Many Thanks</p>
javascript
[3]
2,426,055
2,426,056
US phone number validation for four textbox with extension[optional] using jquery validate.js
<p>I have one form which contains four textbox phone,phone1,phone2 &amp; ext. For validation I used jquery validate.js. Its working fine but one issue is there, its allowing invalid numbers also like 000-000-0000 or 001-000-0000 </p> <p><em><strong>Below is my script for validation:</em></strong></p> <pre><code>$params['rules'][$phone] = {"required": true,"minlength": 3,"digits":true }; $params['messages'][$phone] = {"required":"&lt;div class='error-message'&gt;*This is required &lt;/div&gt; &lt;div class='error-arrow'&gt;&lt;/div&gt; ", "minlength":"&lt;div class='error-message'&gt;* Numbers should be 3 digits&lt;/div&gt; &lt;div class='error-arrow'&gt;&lt;/div&gt;","digits":" &lt;div class='error-message'&gt;* Numbers only&lt;/div&gt; &lt;div class='error-arrow'&gt;&lt;/div&gt; "}; $params['rules'][$phone2] = {"required": true,"minlength": 3,"digits":true }; $params['messages'][$phone2] = {"required":"&lt;div class='error-message'&gt;* This is required&lt;/div&gt; &lt;div class='error-arrow'&gt;&lt;/div&gt; ", "minlength":"&lt;div class='error-message'&gt;* Numbers should be 3 digits&lt;/div&gt; &lt;div class='error-arrow'&gt;&lt;/div&gt;", "digits":" &lt;div class='error-message'&gt;* Numbers only&lt;/div&gt; &lt;div class='error-arrow'&gt;&lt;/div&gt; "}; </code></pre>
jquery
[5]
4,388,962
4,388,963
Filtering binding source in C#
<p>My code is like this</p> <pre><code>BindingSource bs=new BindingSource(); List&lt;Items&gt; lstItems= ListItems(); bs.DataSource=lstItems; </code></pre> <p>I bind this bindingsouce to a gridview.</p> <pre><code>grd.DaataSource=bs; </code></pre> <p>Then I copy this original BindingSource to a separate BindngSource</p> <pre><code>BindingSource filterBs=new BindingSource(); </code></pre> <p>Then I use a filter condition to Bindingsource</p> <pre><code>filterBs.Filter= "ItemCode='1' and cost&gt;'200'"; grd.DataSource=null; </code></pre> <p>Re binding the datasouce of the grid to the filtered bindingsource.</p> <pre><code>grd.DataSource=filterBs; </code></pre> <p>But now also it shows all records in the grid.</p>
c#
[0]
402,583
402,584
How to link to iTunes page of my app from within the very same app even before I submit the app to the store?
<p>I am having an app. I am going to submit it to the store. In that app I am having a button that should go to iTunes page of the very same app. I guess there should be a way to do that using app bundle or plist or something..</p> <ol> <li>If I can do it, How I can do it?</li> <li>Is it possible to get the link of an app in itunes store even before it is submitted to the store?</li> </ol> <p>Thank you..</p>
iphone
[8]
5,446,830
5,446,831
Sending Mail using MailSender
<p>I am using SimpleMailMessage and MailSender in Spring to send mail. I have configured .xml file as </p> <pre><code>&lt;bean id="mailSender" class ="org.springframework.mail.javamail.JavaMailSenderImpl" &gt; &lt;property name="host" value="smtp.gmail.com" /&gt; &lt;property name="port" value="465" /&gt; &lt;property name="protocol" value="smtps"&gt;&lt;/property&gt; &lt;property name="username" value="userId@gmail.com" /&gt; &lt;property name="password" value="passward" /&gt; &lt;property name="endoding" value="UTF-8"&gt;&lt;/property&gt; &lt;property name="javaMailProperties"&gt; &lt;props&gt; &lt;prop key="mail.smtp.starttls.enable"&gt;true&lt;/prop&gt; &lt;prop key="mail.smtps.auth"&gt;true&lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; &lt;bean id="userRegistrationService" class="UserRegistrationService"&gt; &lt;property name="mailSender" ref="mailSender" /&gt; &lt;property name="userEmailIds"&gt; &lt;set&gt; &lt;value&gt;abc@gmail.com&lt;/value&gt; &lt;value&gt;abc@yahoo.co.in&lt;/value&gt; &lt;/set&gt; &lt;/property&gt; &lt;/bean&gt; &lt;/bean&gt; </code></pre> <p>but I get error : </p> <pre><code>Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://mail.google.com/support/bin/answer.py?answer=14257 i7sm235670pbj.90 </code></pre> <p>What could be the reason?</p>
java
[1]
1,770,446
1,770,447
Memory corruption in a small ref-counted buffer class
<p>I have a simple reference counted class that holds a memory buffer. It looks like this:</p> <pre><code>#include &lt;algorithm&gt; template&lt;typename T&gt; struct buffer { // create a buffer of length n buffer(unsigned n) : rc(*(new unsigned(1))), data(new T[n]) { } buffer(const buffer&lt;T&gt; &amp; rhs) : rc(++rhs.rc), data(rhs.data) { } buffer&lt;T&gt;&amp; operator=(buffer&lt;T&gt; rhs) { std::swap(rc, rhs.rc); std::swap(data, rhs.data); return *this; } ~buffer() { if (--rc == 0) { delete [] data; delete (&amp;rc); } } private: mutable unsigned &amp; rc; T * data; }; int main() { typedef buffer&lt;int&gt; numbers; numbers n1(10); numbers n2(20); numbers n3(30); n1 = n2 = n3 = n2; } </code></pre> <p>I don't see anything wrong with the code. However Visual Studio and valgrind complain about memory corruption.</p> <p>I've stared at this code for way too long now. Can anyone spot the error?</p>
c++
[6]
3,509,003
3,509,004
Loading activities from external dex/jar
<p><a href="http://android-developers.blogspot.in/2011/07/custom-class-loading-in-dalvik.html" rel="nofollow">http://android-developers.blogspot.in/2011/07/custom-class-loading-in-dalvik.html</a></p> <p>This link refers loading of classes from Second Dex, this is working fine</p> <p>Instead of calling a simple method available in Second Dex, I tried to add an activity in Second dex, and Tried to access from my MainActivity, I'm getting Classnotfound error when I try to access/start the activity using startActivity() from My MainActivity</p> <p>I also tried using PathClassLoader - its also showing same error</p> <p>Can we access/load that Activity present in Second Dex from MainActivity?</p> <p>What it the proper way to keep activities in multiple Dex file?</p> <p>Thanks in Advance</p>
android
[4]
4,309,800
4,309,801
How can I create button which clears an EditText?
<p>How can I create a button which resets/deletes all text in an <code>EditText</code>.</p> <p>This is some code I've written:</p> <pre><code>private View.OnClickListener onRes =new View.OnClickListener(){ public void onClick(View v) { // TODO Auto-generated method stub // Here i wanna put some code to clear the EditText } }; </code></pre> <p>I don't have any idea how to do that.</p>
android
[4]
3,760,710
3,760,711
What is the object owner referred to in the Google C++ Style Guide?
<p>The <a href="http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Smart_Pointers" rel="nofollow">Google Style Guide for C++</a> says, in the section about smart pointers:</p> <ul> <li>We prefer designs in which objects have single, fixed owners.</li> </ul> <p>I don't fully understand the sentence.</p> <ul> <li>What is the object owner?</li> <li>Is it just the pointer?</li> </ul>
c++
[6]
617,595
617,596
Playing an audio file while on the call in android / send a voice prompt so that other person can hear it?
<p>I am new to android and I have read a few blogs about playing audio file so that other person can hear it but they are quiet a bit old. I was wondering if there were any updates/workarounds for this issue. If any help will be greatly appreciated. </p> <p>Thanks in advance. </p>
android
[4]
347,109
347,110
Can't change the background of an iframe
<p>I'm simply trying to change the background of an iframe that contains Google. But I can't. Any suggestions ?</p> <pre><code>&lt;script&gt; function changeFrame() { var oIframe = document.getElementById("myframe"); var oDoc = oIframe.contentWindow || oIframe.contentDocument; if (oDoc.document) { oDoc = oDoc.document; } oDoc.body.style.backgroundColor = "#00f"; return true; } &lt;/script&gt; &lt;iframe id="myframe" src="http://www.google.com/"&gt;&lt;/iframe&gt; </code></pre>
javascript
[3]
1,515,447
1,515,448
How to get context from onStartCommand
<p>I have a service and I need to get access to context from the service onStartCommand.</p> <p>How could I do that. I'm new to Android.</p>
android
[4]
3,601,239
3,601,240
Android: display the contacts' list with one contact selected/active
<p>I have an application that stores the Contact_ID of contacts. I managed to retrieve the contact_id-s from the phone's Contacts. In some cases I want to make it possible to the user to either call or send a message to the given person behind that contact_id. I don't want to store phone numbers if possible. </p> <p>So I have a contact_id and I'm wondering whether it is possible to display the list of the contacts with the name behind my contact_id preselected ?</p> <p>cheers</p>
android
[4]
3,142,764
3,142,765
Newlines are missing after downloading txt file through the browser
<p>I have a txt file that is generated on the server and contains newlines. If I view the file in my ftp editor, they are here. If I download it through my ftp client and open in it windows with notepad, I also see the newlines.</p> <p>But when I try to download it through the browser by forcing a download window, and then open the file, all the new lines are suddenly gone.</p> <p>This is the code I have now. I also tried to set the content type to application/force-download, but that also made no difference.</p> <pre><code>header('Content-Type: text/plain'); header('Content-Disposition: attachment; filename="'.$myFile.'"'); header("Content-Transfer-Encoding: binary"); </code></pre> <p>Any idea why the new lines are only missing when I download it through the browser? But are intact when I view the file on the server, or download it from the ftp and the open in notepad?</p>
php
[2]
72,155
72,156
Android:Back key functionality
<p>In my android device there is no back key. So that I want to implement back button functionality using proximity sensor. When user tap on proximity of a device so that user should get previous activity. I implemented like this :</p> <pre><code>SensorEventListener proxySensorEventListener = new SensorEventListener() { @Override public void onSensorChanged(SensorEvent event) { // TODO Auto-generated method stub if(event.sensor.getType()==Sensor.TYPE_PROXIMITY){ //backByProxy(); KeyEvent e = new KeyEvent(KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_BACK); onKeyDown(KeyEvent.KEYCODE_BACK,e); } } </code></pre> <p>In the above code I am explicitily calling Action_Down.</p> <pre><code>@Override public boolean onKeyDown(int keyCode, KeyEvent event) { // TODO Auto-generated method stub System.out.println("inside onKeyDown"); if (keyCode == KeyEvent.KEYCODE_BACK) { moveTaskToBack(true); System.out.println("if****"); return true; } return super.onKeyDown(keyCode, event); } </code></pre> <p>But problem is it is only working in my application. I want to work it globally means whichever the application activity is on foreground when user tap on proximity the previous activity should come to front(back button function). Is it possible. how to do this in android.</p>
android
[4]
2,627,272
2,627,273
Problem with date() and strtotime
<p>Here is what I have:</p> <pre><code>$str = '12-25-2009'; echo date('Y-m-d', strtotime($str)); </code></pre> <p>This produces 1969-12-31 instead of 2009-12-25. If I set the $str var to 01-01-2009, I will get 2009-01-01 which is correct. Why is this happening?</p>
php
[2]
4,823,459
4,823,460
How to bind Dataset to DataGridView in windows application
<p>I have create windows Application.In this , I have multiple tables in dataset now i want to bind that to a single DataGridView.Can anybodt help me?</p>
c#
[0]
1,368,148
1,368,149
"nice" keyword in c++?
<p>So I was doing some simple C++ exercises and I noticed an interesting feat. Boiled down to bare metal one could try out compiling the following code:</p> <pre><code>class nice { public: nice() {} }; int main() { nice n; return 0; }; </code></pre> <p>The result is a compilation error that goes something like this:</p> <pre><code>&lt;file&gt;.cpp: In function ‘int main()’: &lt;file&gt;.cpp:11: error: expected `;' before ‘n’ &lt;file&gt;.cpp:11: warning: statement is a reference, not call, to function ‘nice’ &lt;file&gt;.cpp:11: warning: statement has no effect </code></pre> <p>And this was using regular g++ on Max OS X, some of my friends have tried in on Ubuntu as well, yielding the same result.</p> <p>The feat seems to lie in the word "nice", because refactoring it allows us to compile. Now, I can't find the "nice" in the keyword listings for C++ or C, so I was wondering if anyone here had an idea?</p> <p>Also, putting</p> <pre><code>class nice n; </code></pre> <p>instead of</p> <pre><code>nice n; </code></pre> <p>fixes the problem.</p> <p>P.S. I'm a relative C++ newbie, and come from the ActionScript/.NET/Java/Python world.</p> <p><strong>Update:</strong></p> <p>Right, my bad, I also had an</p> <pre><code>#include &lt;iostream&gt; </code></pre> <p>at the top, which seems to be the root of the problem, because without it everything works just fine.</p>
c++
[6]
627,451
627,452
onchange not getting triggered
<p>I have a calendar which comprise of an input tag and an image on click of image calendar popups comes and sets the value for input tag using javascript.</p> <p>now i have added onchange event on input tag which doesnt gets triggered since m changing the value using javascript, so what should be done to trigger it i dont want to trigger it explcitly</p> <p>i tried focusing on input on click of image and focus out on setting the data(into input element) but it didnt worked any workaround?</p>
javascript
[3]
676,274
676,275
jQuery programmatically Slideshow
<p>I have a div, with a img tag inside. How can I programmatically slide show diferent images inside the div? I dont want to reinvent the wheel, but I prefer not to use a plugin.</p> <p>Edit: I do have a list of images.</p>
jquery
[5]
3,199,830
3,199,831
PHP image resize script?
<p>Okay I'm really new to PHP I found the following script below. But I dont know how to use it I was wondering where do I put the link to the image for example <b>images/photo.jpg</b> inorder to get me started in learning this script thanks.</p> <p>Here is the code.</p> <pre><code>&lt;?php function resizeImage($originalImage,$toWidth,$toHeight){ // Get the original geometry and calculate scales list($width, $height) = getimagesize($originalImage); $xscale=$width/$toWidth; $yscale=$height/$toHeight; // Recalculate new size with default ratio if ($yscale&gt;$xscale){ $new_width = round($width * (1/$yscale)); $new_height = round($height * (1/$yscale)); } else { $new_width = round($width * (1/$xscale)); $new_height = round($height * (1/$xscale)); } // Resize the original image $imageResized = imagecreatetruecolor($new_width, $new_height); $imageTmp = imagecreatefromjpeg ($originalImage); imagecopyresampled($imageResized, $imageTmp, 0, 0, 0, 0, $new_width, $new_height, $width, $height); return $imageResized; } ?&gt; </code></pre>
php
[2]