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
997,782
997,783
Detecting gestures using python
<p>I thought to use my macbook's trackpad gestures to interact with my python programs,for example trigger a particular function for two finger tap or three finger swipe etc.Are there any python modules for detecting mac's trackpad gestures?</p>
python
[7]
1,350,812
1,350,813
How do I attach an event to a hidden element in javascript
<p>There is an element on the page that is set to display: none in CSS but I want to attach an event to it so that when I make it visible I can click on the element. I keep getting a strange error with it. Thanks for any help you could give me. </p> <p>Edit: The strange error is that I can't seem to get the event to attach to the element.</p> <p>Edit: I am no longer getting an error but I am not sure why I am not getting the error anymore. In any case, thanks for your help.</p>
javascript
[3]
4,342,792
4,342,793
Java equivalent for Python's 'x in (a, b, c)'?
<p>In Python, I can check if a value exists in a container with <code>1 in (2, 3)</code> which returns False. How do I do this in Java?</p>
java
[1]
5,852,013
5,852,014
Convert date in php
<p>How to convert "Thu Oct 28 16:33:29 +0000 2010 " to like "Oct 28,2010 at 10:33PM"</p>
php
[2]
3,741,523
3,741,524
Truncate additional tags from an image URL
<p>I want image urls to be auto embedded when post in post/comment field in a wordpress theme.</p> <p>I already got this code to work in functions.php:</p> <pre><code>function content_magic($content) { $content = get_the_content(); $m= preg_match_all('!http://[a-z0-9\-\.\/]+\.(?:jpe?g|png|gif)!Ui' , $content , $matches); if ($m) { $links=$matches[0]; for ($j=0;$j&lt;$m;$j++) { $content=str_replace($links[$j],'&lt;img src="'.$links[$j].'"&gt;',$content); } } return $content; } add_filter('the_content','content_magic'); </code></pre> <p>BUT: as soon as you post via wordpress iphone app it doesn't work anymore because image posts from the iphone app automatically add the tags <strong>alt="20121108-172156.jpg" class="alignnone size-full" /></strong> at the end after" <p>how can I truncate the "alt" and "class" tags after the end of the url starting from ?:jpe?g|png|gif" to "/> with the code above?</p>
php
[2]
2,471,122
2,471,123
difference between Stopwatch.ElapsedMilliseconds and (stopDateTime - startDateTime).TotalMilliseconds
<p>I have:</p> <pre><code>Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); DateTime start = DateTime.Now; Thread.Sleep(5000); stopWatch.Stop(); DateTime stop = DateTime.Now; //stopWatch.ElapsedMilliseconds approximately equals to (stop - start).TotalMilliseconds </code></pre> <p>So is there a difference in these measurement methods?</p>
c#
[0]
3,133,159
3,133,160
JS variable starting with "@"
<p>I've come across someone's old code that has variables identified like: @user_id@, @reference_id@, and so forth. Wikipedia says "In certain JavaScript implementations, the at sign (@) can be used in an identifier..." In what JS implementations does this work? I can't get it to work.</p>
javascript
[3]
238,995
238,996
How to create an Executor which can execute boiler code before running task?
<p>I'm trying to setup a concurrency structure where some boiler plate code should be executed (to check pre-conditions) before a certain type of task. In other words, I would like to run code after an Executor has dequeued a task, but before it invokes execute on it. How can this be done?</p>
java
[1]
4,774,962
4,774,963
First split then slice value
<p>I know how to split a value using deliminators. I also know how to slice a value to remove the last couple chars. I need to combine these now, which is the part I can't figure out.</p> <pre><code> $("#product").val(value.split('|')[0]); </code></pre> <p>How would I add <code>slice(0,-1)</code> to this function above? I want it to first split, then slice.</p> <p>So the result would be everything before the '|' and minus one char</p> <p><strong>Solved:</strong></p> <pre><code>$("#product").val(value.split('|')[0].slice(0, -1)) </code></pre>
jquery
[5]
3,201,059
3,201,060
Why is this statement not working in java x ^= y ^= x ^= y;
<pre><code>int x=1; int y=2; x ^= y ^= x ^= y; </code></pre> <p>I am expecting the values to be swapped.But it gives x=0 and y=1. when i tried in C language it gives the correct result.</p>
java
[1]
1,055,912
1,055,913
Control an swf file using JavaScript
<p>I have an swf file embedded into my webpage and I want to control it. I know that the controls are not available for an swf file, so I'm controlling it using JavaScript. I've managed get a Play and Pause button, but I really need to Stop button which will Stop the movie and rewind it to the beginning.</p> <pre><code> &lt;a style="color: #ffffff;" href="javascript:document.movie.Play()"&gt;►&lt;/a&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a style="color: #ffffff;" href="javascript:document.movie.StopPlay()"&gt;║&lt;/a&gt; </code></pre> <p>This is code I'm using so far. I'm using ASCII codes to get the Play and Pause symbol and I can easily get a stop one but is there a way I can Stop and reset the movie?</p>
javascript
[3]
3,416,619
3,416,620
Mapping Object from file in java
<p>I want map my object from text file, the text file contents are like this :</p> <pre><code>~ attribute1value attribute2value attribute3value attribute4value attribute5value attribute6value ~ attribute1value attribute2value attribute3value attribute4value attribute5value attribute6value ...continued same </code></pre> <p>So for each 5 attributes I want to create new object and map those 6 properties to it(that is not issue), the issue is how can I distinguish lines while reading, how can I get the first group, second group etc . thank you</p>
java
[1]
2,602,921
2,602,922
Incorporating several basic ideas in C++ issue
<p>Code;</p> <pre><code># include &lt;iostream&gt; # include &lt;windows.h&gt; using namespace std; int main () { int var1 = 1; int var2 = 1; bool while1 = true; int x = 0; while (x &lt; 999) { x = x+var1; x = x+var2; cout &lt;&lt; x &lt;&lt; " Is the current value of x, how much would you like to add to it?\n"; Sleep(1000); while (while1) { int var3; cin&gt;&gt; var3; if (var3 &gt; 100) { cout &lt;&lt; "Too large, between 10 and 100\n"; while1 = true; } else if (var3 &lt; 10) { cout &lt;&lt; "Too small, between 10 and 100\n"; while1 = true; } else{ cout &lt;&lt; "Adding " &lt;&lt; var3 &lt;&lt; " to " &lt;&lt; x &lt;&lt; "\n"; x = x + var3; cout &lt;&lt; "x is now " &lt;&lt; x &lt;&lt; "\n"; while1 = false; } } } } </code></pre> <p>Now, the problem is after it loops back up the first time it completely skips over the second while statement and proceeds to continue adding just var1 and var2 to x.</p> <p>What is the problem here?</p>
c++
[6]
1,819,765
1,819,766
Customize Date Picker: How to change width & height of datepicker in iphone?
<p>Is there any way to customize the datepicker used in iphone?</p> <p>I want to change height &amp; width of it. Can we change the background color, font color of it?</p> <p>Please help if anybody has done before.</p> <p>Thanks in advance ...</p>
iphone
[8]
4,033,986
4,033,987
Scrollbar click in safari browser not Collapsing opened dropdowns
<p>When iam clicking on the scrollbar when dropdown is displaying[opened] its is not collapsing the opened drop down in safari browser.Can anybody plz provide Javascript code to fix this issue.</p>
javascript
[3]
5,156,637
5,156,638
How to override the long key press functionality in android?
<p>can anyone tell me how can we overide the long key press functionalty of menu key? I have to call an activity on long press on menu key for device samsung galaxy S. Please tell me how can implement that...some sample code is appreciable.</p>
android
[4]
4,551,532
4,551,533
passin information to a jQuery modal that loads dynamic content
<p>I have a main page with a js variable. I want to open a modal on that main page and load html content from a different page. I need to pass that variable to the modal that is opening and use it inside the loaded html content. I have seen several questions similar to that in these forums but i don't see any that explain how I can tease that variable out of the loaded html content. I know that i can make a GET request for that external html content, and I know that i can include the variable in the query string. But how do i get it out of the query string inside the modal? All of the examples i see for getting things out of query string involve using window.location.href or something similar. Well that won't work for me because that returns the url of the main page I am on and not my modal popup. Any suggestions?</p>
jquery
[5]
4,315,124
4,315,125
dynamic web forms using asp.net
<p>I am creating a convention website for agents using VS 2010. The agents can bring upto 6 guests if they want. I am creating a form to store basic info on these guests. Instead of creating six forms with the same repeated info, I want to use the same form upto six times. I want to store the info on session variables before calling a store proc to insert them in the database.</p> <p>Can you help?</p>
asp.net
[9]
4,286,383
4,286,384
Android-passing value from form login to new atcivity using data from MySQL
<p>i'm new in android, how make passing value from form login to new activity, the value from MySQL....</p> <p>please help me...</p>
android
[4]
983,992
983,993
Get the previous upgradecode that was used to install the application
<p>C# 2005 SP3</p> <p>Is it possible to retrieve the pervious upgradeCode that was used to install the same application?</p> <p>I have given our application to many or our clients. </p> <p>They install our application using the MSI.</p> <p>Everytime I release a new version for bug fixes or minor upgrades. In the setup project properties I increment the version number and change the product code (I always leave the same upgrade code). And I set the 'RemovePreviousVersion' to true.</p> <p>However, a few weeks ago, I accidently changed the upgradeCode and released a new version to our customers. It was only now that a customer wanted to know why they have other instances of the same application in their 'add remove programs'. It installs ok, but they have to uninstall the previous version. </p> <p>I am wondering is it possible to get back the original upgrade that was used to install those versions. As I used the same setup project, I no longer have that upgrade code?</p> <p>I still have all my original setups.exe that were built with the original upgradecode, but I am not sure if they can help me.</p> <p>Many thanks for any suggestions,</p>
c#
[0]
4,893,147
4,893,148
Take values from a list of strings(python)
<p>If I have a list of several strings in python, and each of these strings contains a value. How can I take those values and print them to a list? Example: the string might be "abc def g T = 5 hij". All the strings will be the same except the number.</p>
python
[7]
2,720,453
2,720,454
Alert dialog closes without pressing the button and Activity goes to home page
<p>I'm building an android app with a Login activity. If email is not valid, I want to show an alertbox with a "Email not valid" message and want to stay at same activity. The problem is that the alertbox is shown only for a brief time and then I go back immediately to the parent activity, without pressing any button in the alertbox. my code is:</p> <pre><code>if (v.getId() == R.id.loginButton) { if(checkEmail(emailtheGame.toString())==true) { startActivity(new Intent(this, BackgroundImages.class)); } else { email=emailtheGame.toString(); showDialog(0); } finish(); boolean checkEmail(String inputMail) { Pattern pattern= Pattern.compile("^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\\.([a-zA-Z])+([a-zA-Z])+"); return pattern.matcher(inputMail).matches(); } @Override protected Dialog onCreateDialog(int id) { switch (id) { case 0: return new AlertDialog.Builder(this) .setTitle("Showing Response.........") .setMessage("sdfdsfdfsdf") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Toast.makeText(getBaseContext(), "OK clicked!", Toast.LENGTH_SHORT) .show(); } }) .create(); } return null; } </code></pre> <p>Any help is highly appreciated......!!!</p>
android
[4]
3,398,211
3,398,212
Error: could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit
<p>Pre-note: This is not a problem I am having with Minecraft. All answers I can find seem to be Minecraft issues.</p> <p>Error: could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.</p> <p>I get this error when I try to do something Java related. I cannot launch a .jar without this error coming up and when I try to install JDK, I get this error. This has been plauging me for a while and I was not able to research an answer so I thought I would ask it myself.</p> <p>EDIT: Windows 7 (x64) Dell Studio Laptop, 4GB RAM, external Radeon HD 6950 Graphics Card. I have tried uninstalling all JVMs and reinstalling but it didn't work, although I cannot remember how thorough I was so I may try again. Here is a list of all the Java related things I have installed (found in the uninstall or change programs window): </p> <ul> <li>Java 3D 1.5.1</li> <li>Java 3D 1.5.1 (x64)</li> <li>Java 3D 1.5.2</li> <li>Java 6 Update 30</li> <li>Java 6 Update 30 (64-bit)</li> <li>Java 7 Update 2</li> <li>Java 7 Update 3 (64-bit)</li> <li>JavaFX 2.0.3 (64-bit)</li> <li>JavaFX 2.0.3 SDK (64-bit)</li> </ul>
java
[1]
4,913,141
4,913,142
Is there any advantage to define function name in "var new_function = function name(){};" in javascript?
<p>I was running a program to change some parts of my javascript code when it bugged in the declaration of a var as a function like this:</p> <pre><code>var some_function = function name(args){ //do stuff }; </code></pre> <p>The code itself works, but I was just wondering if it's ok to remove the "name" for all functions that i find like this (for it doesn't break it in the other problem that analyzes my javascript) or if it could be any use for it that I can't see.</p> <p>removing the "name":</p> <pre><code>var new_function = function(){/*do stuff*/}; </code></pre> <p>Note: the original file where it first happen it was in <a href="http://code.jquery.com/jquery-1.6.4.js" rel="nofollow">jquery-1.6.4.js</a> in:</p> <pre><code>jQuerySub.fn.init = function init( selector, context ) { if ( context &amp;&amp; context instanceof jQuery &amp;&amp; !(context instanceof jQuerySub) ) { context = jQuerySub( context ); } return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); }; </code></pre> <p>ty for any help in advance :)</p>
javascript
[3]
5,035,473
5,035,474
jquery script only working on 1 page and not even by its self
<p>Finally got this script to work, now i have structured my php files so header and footer are there own php file and the desired page loads them to with the command ?php $PageTitle = "Domain"; include ('header.php'); ?</p> <p>now the menu is in header php can be viewed her www.apecharmony.co.uk/header.php when you click the apec logo on the left a menu should drop out. now if you load www.apecharmony.co.uk/indexb.php youll find when you click it the menu appears... Great! but again when you go to www.apecharmony.co.uk/more_info_domains.php no menu appears. So for some reason the only page that it works on is indexb.php??? i cant understand this when they are all usin the same header.php file.</p> <p>Secondly do i need to run another script to stop the menu highlighting the text on the first time you click the menu www.apecharmony.co.uk/indexb.php</p>
jquery
[5]
2,278,022
2,278,023
Use a different measurement of data rather than KB
<p>I'm currently tinkering around with some code which allows me to upload files to my site. I am going to set an option in a configuration file which allows users to set the maximum upload limit. At the moment this has to be entered in kilobytes and I was wondering whether or not it'd be possible to have it entered in MB?</p> <pre><code>if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "image/pjpeg")) **&amp;&amp; ($_FILES["file"]["size"] &lt; 2000000)** &lt;---- Entered in Kilobytes, not MB. &amp;&amp; in_array($extension, $allowedExts)) </code></pre>
php
[2]
18,491
18,492
What's the difference between <#eval and <#bind in asp.net
<p>In a gridview, we can use <code>&lt;%#Eval%&gt;</code> or <code>&lt;%#Bind%&gt;</code> to output values from a database. What is the difference between them?</p>
asp.net
[9]
4,413,868
4,413,869
Reading Line in a random way, then print numbers in random order
<p>Below is the text file, in which I want to read each line in some random way by printing each number in the line in some random order. I can read each line one by one and then print number corresponding to each line in a sequential order, But is there any way we can read line in some random way so that I can print all the numbers in some random order.</p> <pre><code> Line1 1 1116 2090 100234 145106 76523 Line2 1 10107 1008 10187 Line3 1 10107 10908 1109 </code></pre> <p>Any suggestions will be appreciated. Below is the code that I wrote it will read the line sequentially.</p> <pre><code>BufferedReader br = null; try { String sCurrentLine; br = new BufferedReader(new FileReader("C:\\testing\\Test.txt")); while ((sCurrentLine = br.readLine()) != null) { String[] s = sCurrentLine.split("\\s+"); for (String split : s) { if(split.matches("\\d*")) System.out.println(split); } } } catch (IOException e) { e.printStackTrace(); } finally { try { if (br != null)br.close(); } catch (IOException ex) { ex.printStackTrace(); } } </code></pre>
java
[1]
2,095,343
2,095,344
I can not connect to the phone for debugging any more
<p>After developing and testing for months my android application both on the emulator and on a phone, I suddenly can not connect any more to the phone in one of the two PCs I use for development. One PCs runs Windows XP 32bits. Here everything is ok. But my main development machine is a Windows 7 32bits: Both of them run Eclipse Galileo. I can not get connected to the Samsung Galaxy S GT-I9000T phone from there. Two Sundays ago I updated my application last version to the phone. Went on vacations. After returning I upgraded the Samsung Kies suite to the new version 2. It is supposed it installs USB drivers for Windows. I also upgraded to Android SDK 9 and ADT 9 but I'm not sure it was after the problem appeared. Then I realized can not connect to the phone. My first suspect was Samsung Kies. But I made all these intallations on the xp PC and the connection works OK. Then I returned to the Windows 7. There is another driver called "USB Driver for Windows" which I have installed from Android's SDK "SDK and AVD Manager"/"Available Components"/"Android Repository" I tried to reinstall it. I deleted the package despite the warning it can not be undone. Then I tried to find it on the "Available Packages" but it was no more there.</p> <p>I reinstaled Samsung Kies, Eclipse, Android SDK but the problem remains the same: Another fact: with USB debugging active, Samsung Kies can not connect to the phone. It detects something is connected but it stays forever trying to connect.But it occurs also on the XP machine. In summary:</p> <ul> <li>I can not get listed the "USB Driver for Windows" in the "SDK and AVD Manager"/"Available Components" for installation, even after reinstalling all the development environment</li> <li>I can not get the development environment to connect to the phone for debugging.</li> </ul> <p>How to fix this?</p> <p>Any hint is welcomed. Thanks in advance. Sammy</p>
android
[4]
1,788,581
1,788,582
A better way to write exception handling code
<p>in my work almost 60 to 70% of the code is for exception handling and logging those exceptions. Rest 30 to 40% is the business logic.</p> <p>Is there a way to extract out the exception handling part using EntLib or any other concept which can be applied here?</p> <p>Regards.</p>
c#
[0]
4,622,844
4,622,845
android: remote service vs sharedUserId?
<p>What is different in these two approaches : remote service (<a href="http://developer.android.com/reference/android/app/Service.html" rel="nofollow">http://developer.android.com/reference/android/app/Service.html</a>) vs sharedUserId (<a href="http://developer.android.com/guide/topics/manifest/manifest-element.html" rel="nofollow">http://developer.android.com/guide/topics/manifest/manifest-element.html</a>)? What is adv/Disadv each of them?</p>
android
[4]
4,833,835
4,833,836
How to get link url when using select box form method get?
<p>I have a sample code:</p> <pre><code>&lt;form action="index.php" method="get"&gt; &lt;select name="id"&gt; &lt;option value="1"&gt;One&lt;/option&gt; &lt;option value="2"&gt;Two&lt;/option&gt; &lt;/select&gt; &lt;input type="submit" value="submit" name="submit" /&gt; &lt;/form&gt; </code></pre> <p>When I submit form is url is "<code>index.php?id=1</code>" // or <code>index.php?id=2</code></p> <p>=> How to fix it is result "<code>index.php?id=1&amp;name=One</code>" // or <code>index.php?id=2&amp;name=Two</code></p>
php
[2]
3,510,028
3,510,029
New to Python, implementing a function using a string as an input
<p>I'm new to Python and one of the problems I have for homework has me stuck.</p> <p>Here's the question? Implement function cheer() that takes as input a team name (as a string) and prints a cheer as shown:</p> <pre><code>cheer(‘Huskies’) </code></pre> <p>How do you spell winner?<br> I know, I know!<br> H U S K I E S !<br> And that's how you spell winner!<br> Go Huskies!</p> <p>I've been able to get everything figured out except for the spaced out team name on the third line. I'll post what I have below. If anyone had any ideas how to fix it, I would greatly appreciate it?</p> <pre><code>def cheer(team): print("How do you spell winner?"+"\nI know, I know!""\n"+team.upper()+"!"+"\nAnd that's how you spell winner!"+"\nGo "+ team+"!"+"\n") </code></pre> <p>Using the team name "Devils" as the input, this is what the above code gets me:</p> <pre><code>cheer("Devils") How do you spell winner? I know, I know! DEVILS! And that's how you spell winner! Go Devils! </code></pre>
python
[7]
1,891,829
1,891,830
How to access UI Element of Activity in non-activity class? Android
<p>Activity Class contain TextView, TextView text = (TextView)findById(R.id.notify);</p> <p>Non-Activity Class contain, text.setText("Hello");</p>
android
[4]
3,512,198
3,512,199
Better $_GET security
<p>My PHP is very rusty. I have a md5 hash that's being passed via get to a script and then I'm grabbing it like this:</p> <pre><code>$id = $_GET['id']; </code></pre> <p>Obviously there's a security risk here...I was thinking of checking the string length to make sure it's 32 characters long but that doesn't seem very robust to me. What else could I do to make it more secure?</p> <p>thanks</p>
php
[2]
4,636,771
4,636,772
Can I go from managed thread ID to ProcessThreadID
<p>I've been brainstorming ways to measure UI thread utilization, and it looks like I can possibly back my into it by looping through the ProcessThreads for the current process and then trying to figure out which one the UI is on.</p> <p>Is there any structured way to go from a managed thread ID to a process thread ID? Generally this is a bad idea because if your managed thread is recycled it could end up on a different process thread, but AFAIK, that can't happen with the UI thread. While the UI is running, that UI managed thread is going to map to the same process thread ID.</p>
c#
[0]
3,692,054
3,692,055
combo box and Generic list
<p>I'm Having a list</p> <pre><code> List&lt;string&gt; strArraylist = new List&lt;string&gt;(); </code></pre> <p>i want to add to it the values of a <strong>combo box</strong> ..</p>
c#
[0]
1,061,235
1,061,236
null value in getIntent.getExtras.getString()
<p>This is my code in my first activity:</p> <pre><code>Intent i = new Intent(this, OtherScreen.class); i.putExtra("id1", "first"); i.putExtra("id2", "second"); startActivity(i); </code></pre> <p>where first,second are the values I want to be passed. and on my other class i have this:</p> <pre><code>Intent i = getIntent(); Bundle extras = i.getExtras(); String result = extras.getString("id1"); System.out.println("yeah"+result); </code></pre> <p>but after i run it, my result is null.Can you help me? If I write my getString in that ways, I am getting syntax errors.</p> <pre><code>String result = extras.getString(id1); //id1 cannot be resolved to a variable String result = extras.getString("id1","default value"); // remove argument </code></pre>
android
[4]
3,749,299
3,749,300
How does a ClickListener know which data to return?
<p>I have the following ClickListener:</p> <pre><code> itemList=(ListView)findViewById(android.R.id.list); itemList.setTextFilterEnabled(true); itemList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; a, View v, int position, long id) { Intent intent = new Intent(); Bundle b = new Bundle(); b.putString("TEXT", ((TextView) v).getText().toString()); intent.putExtras(b); setResult(SUCCESS_RETURN_CODE, intent); finish(); } }); </code></pre> <p>It worked fine when I used android.R.layout.simple_list_item_1 for the item layout. But when I made a custom layout consisting of the following, it stopped working.</p> <pre><code>&lt;RelativeLayout&gt; TextView TextView(this is what I want) TextView &lt;/RelativeLayout&gt; </code></pre> <p>Edit: It might have something to do with one of the TextViews being clickable?</p>
android
[4]
1,001,742
1,001,743
Toggle select options w/jQuery
<p>I have selector with multiple option grouped into option groups. I am trying to toggle select/deselect of all options when an optgroup label is clicked.</p> <p>It works fine on initial load, but I also have a functionality that allows me to copy options from one selector to another and back. Once options are copied my toggle stops working.</p> <pre><code>$("optgroup").toggle(function(){ $(this).children().attr("selected", "selected"); }, function() { $(this).children().attr("selected", false); }); </code></pre> <p>Here's the <a href="http://jsfiddle.net/SwrVK/6/" rel="nofollow">copy/remove script</a>.</p>
jquery
[5]
2,515,514
2,515,515
iterating over file object in Python does not work, but readlines() does but is inefficient
<p>In the following code, if I use: </p> <pre><code>for line in fin: </code></pre> <p>It only executes for 'a'</p> <p>But if I use:</p> <pre><code>wordlist = fin.readlines() for line in wordlist: </code></pre> <p>Then it executes for a thru z.</p> <p>But <code>readlines()</code> reads the whole file at once, which I don't want.</p> <p>How to avoid this?</p> <pre><code>def avoids(): alphabet = 'abcdefghijklmnopqrstuvwxyz' num_words = {} fin = open('words.txt') for char in alphabet: num_words[char] = 0 for line in fin: not_found = True word = line.strip() if word.lower().find(char.lower()) != -1: num_words[char] += 1 fin.close() return num_words </code></pre>
python
[7]
4,129,024
4,129,025
Handling "No cells were found." Error in Excel
<p>I am working on Excel VSTO application and finding error cells in the worksheets using the below code</p> <pre><code>Excel.Range rngTemp; Excel.Range rngErrorRange; Excel._Worksheet Sheet1 = (Excel._Worksheet)xlCTA.Sheets["Sheet1"]; rngTemp = wsCTAWK11.UsedRange; rngErrorRange = rngTemp.SpecialCells(Excel.XlCellType.xlCellTypeFormulas, Excel.XlSpecialCellsValue.xlErrors); </code></pre> <p>when there are really error cells found then i do not have any issues but when i dont have any error cells in these sheet i get the below exception</p> <pre><code>**threw an exception of type 'System.Runtime.InteropServices.COMException' base {System.Runtime.InteropServices.ExternalException}: {"No cells were found."}** </code></pre> <p>How to handle this... Pls help</p>
c#
[0]
5,908,658
5,908,659
Issue with JQuery Each function
<p>I have a jquery function to hide email ids on the webpage to avoid spambots. I am trying to replace all the span tags with class 'mailme' to valid email ids with the help of this function. The code was working for 1 span tag but since its changed to multiple spans with the help of each method, its not working.</p> <p>Html</p> <pre><code>&lt;span class="mailme"&gt;myemail at mydomain dot com&lt;/span&gt; </code></pre> <p>jQuery</p> <pre><code>$('span.mailme').each(function(){ var spt = "#" + $(this).attr("id"); var at = / at /; var dot = / dot /g; var addr = $(spt).text().replace(at,"@").replace(dot,"."); $(spt).after('&lt;a href="mailto:'+addr+'" title="Send an email"&gt;'+ addr +'&lt;/a&gt;') .hover(function(){window.status="Send a letter!";}, function(){window.status="";}); $(spt).remove(); }); </code></pre>
jquery
[5]
4,078,254
4,078,255
Append quotation
<p>I am trying to <code>append()</code> a button with an <code>onclick</code> attribute which calls a javascript function:</p> <pre><code>$('#button').append('&lt;button onclick=setUrlLink(\''+pageN+'\')&gt;Next&lt;/button&gt;); </code></pre> <p>When checking the source code, quotations are missing around <code>pageN</code>, how can I do that?</p>
jquery
[5]
5,929,486
5,929,487
Is there a variant of jQuery's live() function that does not bind to events?
<p>Is there a variant of jQuery's live() function that does not bind to events? </p> <p>For example, I would like to do something like this: </p> <pre><code>$('.jdate').live(function() { var datebox = $(this); datebox.datepicker(); //do a couple more things } </code></pre> <p>so all '.jdate' fields that are in the form and the ones that are added later through ajax are treated the same. </p>
jquery
[5]
864,768
864,769
how to build an ordered list for a menu using JQUERY need help
<p>I want to build this DIV with unordered list using jquery for a menu and the data would be coming from a sharepoint list. I have the main DIV on the area where i want the menu </p> <pre><code> &lt;div id="menumain"/&gt; </code></pre> <p>I have tried doing the below but not too good with JQUERY. I want to append or add the below DIV to the DIV mainmenu element above Any help will be appreciated</p> <pre><code>$("#menumain").find('div') .append($('&lt;ul&gt;') .append($("&lt;li&gt;&lt;a href=&gt;" + $(this).attr("ows_Group") + "&lt;/a&gt;&lt;/li&gt;") .append($('&lt;/ul&gt;') ) ) ); &lt;div id="header"&gt; &lt;ul id="navbar"&gt; &lt;li class="menu"&gt;&lt;a href="#"&gt;Home&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;Menu item 1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Menu item 2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Menu item 3&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Menu item 4&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Menu item 5&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre>
jquery
[5]
3,955,272
3,955,273
How to create options of a select element dynamically using jquery?
<p>I need to create options of a select element dynamically via an ajax call. The number of options and their content will vary. This is how it looks prior to the ajax call:</p> <pre><code> &lt;select name="groupid" style="width:100%;"&gt; &lt;option value="0" selected&gt;(Please select an option)&lt;/option&gt; &lt;/select&gt; </code></pre> <p>Here is one of my attempts to create an option element with a dummy value:</p> <pre><code>$("&lt;option&gt;&lt;/option&gt;", {value: "999"}).appendTo('.select-group'); </code></pre> <p>But it adds it outside of select. I also don't know how to set the text within .</p> <p>Any ideas? I've seen some questions about populating existing select forms with a static number of existing options but not one like this. </p> <p>Thanks.</p>
jquery
[5]
5,357,403
5,357,404
I'd like my private virtuals now, please
<p>What is the reasoning behind disallowing private virtual functions? </p> <p>Empty private virtuals would have enabled low friction pure customization points.</p> <p>Abstract functions have high friction and protected virtuals cause confusion and noise.</p> <p><strong>Some further explanation:</strong></p> <p>The Non Virtual Interface pattern separates the interface responsibility (public) from providing customisation points (virtual).</p> <p>When using NVI in class design I have to make my virtuals protected. Having the option to make them private makes the intent even stronger. It means that descendants can <em>only</em> provide customisation and there is no confusion over whether to call the base or not, in fact it is prohibited. There must have been a good reason to explicitly disallow it (Diagnostic: "Private method cannot be polymorphic"). </p>
c#
[0]
4,193,011
4,193,012
Selecting a row in uitableviewcell
<p>how to make a row in uitableview back to white after selecting.</p> <p>My problem is when I select a row in uitableview it shows me blue color and it remains on. It doesn't go off, I mean back to white color. </p> <p>How to do that. any help please..</p>
iphone
[8]
3,092,786
3,092,787
Highlighting variables and keywords in jQuery
<p>I am trying to highlight variables and keywords in a code snippet using jQuery. Suppose, I have a java snippet like this,</p> <pre><code>public class abc { public static void main(String args[]) { int count = 0; } } </code></pre> <p>I am using button called "Variable" for variables and "Keyword" for reserved keywords. Is there any method for it? Or should I be using Regex?</p>
jquery
[5]
1,453,558
1,453,559
Beginner PHP Question - Access Data from Function
<p>I have this function:</p> <pre><code>function selectValue($test) { $connection = dbConnect(HOST, USERNAME, PASSWORD, DATABASE); $query = "SELECT * FROM table where value = '$test'"; $results = @mysql_query($query, $connection); $value = mysql_fetch_assoc($results); } selectValue('abcde'); echo $value['something']; </code></pre> <p>This results in $value becoming an array. I would like to access this array from outside of the function. I tried to do this using the last line of code above (ie. echo...) but this doesn't work. How should I do this?</p>
php
[2]
3,444,333
3,444,334
Or-Operator in return statement
<p>I stumbled upon this piece of code, which I truly do not understand so far. I clearly know what the or-operator <code>||</code> does in codes like these:</p> <pre><code>bool a = true; bool b = false; if(a || b) { //does something, if one of a/b is true } </code></pre> <p>But this is a structure, I do not understand:</p> <pre><code>public bool c { get { return a || b; //? } set { c = value; } } </code></pre> <p>What will this getter return with that return-statement and why?</p>
c#
[0]
3,516,665
3,516,666
IME window overlap cursor in Edittext, how to prevent it?
<p>I'm using Edittext and it has images and texts. Then, I add image file on Edittext and I click Edittext, IME window shows, naturally. ( * At that time cursor is located at right-bottom corner of added image file.) The problem is IME window overlap cursor, so users complain that 'where is my cursor?'</p> <p>How to prevent that IME window overlap cursor?</p>
android
[4]
2,663,667
2,663,668
add a new item to vector and shift it remaining part to right
<p>I am trying to put a new item to vector, and shift remaining items. How can I do that ?</p> <p>Ex </p> <pre><code>vector ------------------------------------------------------- | 1 | 2 | 3 | 4 | 5 | 9 | 10 | 15 | 21 | 34 | 56 | 99 | ------------------------------------------------------- ^ new item = 14, it should be added to ^ After insertion, vector ------------------------------------------------------------ | 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 21 | 34 | 56 | 99 | ------------------------------------------------------------ ^ ^ ^-shifted to right by one-^ </code></pre>
c++
[6]
5,636,873
5,636,874
Is it possible to use an asp.net page to have the get results from the server sent back as an XML file?
<p>My application sending SMS request to Mblox XML interface through, I have get response from Mblox as XML file. </p> <pre><code>string RequestXML = GenerateRequestXML(); string uri = string.Empty; uri = "http://xml.us.mblox.com:8180/send"; HttpWebRequest request =(HttpWebRequest)WebRequest.Create(uri); request.KeepAlive = false; request.ProtocolVersion = HttpVersion.Version11; request.Method = "POST"; request.ContentType = "text/xml"; HttpWebResponse respon = (HttpWebResponse)request.GetResponse() </code></pre>
asp.net
[9]
4,279,627
4,279,628
Android: How to Handle Back Press Specifically?
<p>Let me explain more detail.</p> <p>First of all; I know that if user press back and returns the previous activity, the previous activity triggers <code>onResume</code> method properly. This is okay. </p> <p>There is a root activity in my application and it's directing 4 different activities through the buttons. I want to learn, on which activity did user press back button? Is it possible to use something like <code>Handler</code> or similar?</p> <p>Actually, I've found a solution verdantly. I've 4 different static Boolean vars an each one represents one Activity. Let me show in code:</p> <pre><code>public class MainActivity extends Activity { // This is root static Boolean activityA; static Boolean activityB; static Boolean activityC; static Boolean activityD; public void onClick(View v) { if(v == ActivitvyA) //of course psuedo activityA = true //...there are similar controls } protected void onResume() { if(activitiyA) // If true, this means the user pressed back on ActivityA } } </code></pre> <p>What do you think? Is there any diffent and effecient way?</p> <p>Any helps would be great.</p>
android
[4]
5,103,775
5,103,776
how to get the keys of sub array for an array tree
<p>I want to get the keys of this nested array and store them as a separate array </p> <pre><code>Array ( [151] =&gt; Array ( [152] =&gt; Array ( ) ) ) </code></pre>
php
[2]
1,363,395
1,363,396
$this->{$this->varname}() syntax
<p><a href="http://www.php.net/manual/en/functions.variable-functions.php#24931" rel="nofollow">http://www.php.net/manual/en/functions.variable-functions.php#24931</a></p> <p>That function does something like <code>$this-&gt;{$this-&gt;varname}()</code>. I tried it out and confirmed that that's valid syntax but it leaves me wondering... where does php.net discuss the use of curly brackets in variable names like that?</p>
php
[2]
94,064
94,065
passing checkbox & text field value in php
<p>I'm trying to pass a text value field over to the next page for every checkbox selected, but I'm only getting the last text fields value, example:</p> <pre><code>checkbox textfield selected ABCD selected ABCDE </code></pre> <p><strong>I am only getting back the ABCDE every time</strong></p> <p><strong>page1.php</strong></p> <pre><code>echo "&lt;td width='10px'&gt;&lt;input name='question[$rowid][]' type='checkbox' value='1' /&gt;&lt;/td&gt;"; echo "&lt;td width='230px'&gt;&lt;input name='newname' type='text' value='$certn'/&gt;&lt;/td&gt;"; </code></pre> <p><strong>page2.php</strong></p> <pre><code>foreach ($_POST['question'] as $key =&gt; $ans) { $nn = $_POST['newname']; echo $key . $nn; echo "&lt;/br&gt;"; } </code></pre> <p>Help will be greatly appreciated</p>
php
[2]
5,770,742
5,770,743
The http session loses the attribute after request.sendRedirect
<p>Inside filter I am trying to set one attribute to the current http session. Then I am redirecting to another resource using response.sendRedirect(). The resource sends the request back to the filter. Second time the session losses the session attribute.</p> <p>Please provide some pointer.</p> <p>First Request is as below:</p> <pre><code>HttpSession objSession = request.getSession(true); objSession.setAttribute("wasRequestURL", completeURL); </code></pre> <p>Second request is as below:</p> <pre><code>if (null != objSession.getAttribute("wasRequestURL") &amp;&amp; !"".equals(objSession.getAttribute("wasRequestURL").toString().trim())) { requestedURL = objSession.getAttribute("wasRequestURL").toString(); logger.info("The session value for wasRequestURL is :::"+requestedURL); } </code></pre>
java
[1]
2,253,015
2,253,016
Font size adjusting function in Android Webview
<p>I have been developing an Android RSS news reader.I want to add two buttons for adjusting the font size when a news is loaded in Webview.Can anyone tell me, how can I create a function for changing the font size of Webview?</p>
android
[4]
37,070
37,071
jQuery: Selecting by class and input type
<p>I would like to select a set of elements that are both of a certain input type (say, a checkbox) and have a certain class using jQuery. However, when I try the following:</p> <pre><code> $("input:checkbox .myClass") </code></pre> <p>I don't get any items returned. How can I accomplish this in jQuery?</p>
jquery
[5]
5,174,596
5,174,597
Is there any way to make PHP generate dynamic WAV images?
<p>if you go to this link: <a href="http://www.audionetwork.com/production-music/beyond-discovery_49869.aspx" rel="nofollow">http://www.audionetwork.com/production-music/beyond-discovery_49869.aspx</a></p> <p>click on any song title in the list, then click Play button. See the graphic in the top?</p> <p>Is there any way to make PHP generate dynamic WAV images and play them as this one?</p>
php
[2]
1,585,934
1,585,935
I can't detect text change in a search field on the actionbar
<p>I have the following code, and onOptionItemSelected() never runs. it never reaches <code>Log.i("", "switch");</code> Anyone know why?</p> <pre><code>@Override public boolean onCreateOptionsMenu(Menu menu) { getSupportMenuInflater().inflate(R.menu.category_menu, menu); Log.i("", "created menu"); return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { Log.i("", "switch"); switch (item.getItemId()) { case 0: Log.i("", "case 0"); search = (EditText) item.getActionView(); search.addTextChangedListener(filterTextWatcher); search.requestFocus(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); } return true; } private TextWatcher filterTextWatcher = new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { Log.d("", "my search logic"); } }; </code></pre>
android
[4]
4,635,995
4,635,996
Using maps within maps in C++
<p>I'm trying to use a map within a map using the following code;</p> <pre><code> map&lt;map &lt;int,int&gt;,int &gt; multimap; </code></pre> <p>Now I want to insert the data such that <code>multimap[1]</code>--->(2,3), <code>multimap[4]</code>--->(5,6). I have been trying to insert it the following way but i guess there is a syntax error which I can't seem to figure out! </p> <pre><code> multimap.insert(pair&lt;int,pair&lt;int,int&gt;(2,3)&gt;(1)); </code></pre> <p>Any help will be appreciated. And after adding, how would I display the values by using an iterator?</p>
c++
[6]
3,347,062
3,347,063
$.get / $ post jquery function to manipulate a function from another file(*.html)
<p>I have a scenario like the one I described below...</p> <p>how can I accomplish by using $.get / $ post jquery function ?</p> <p><strong>Send.html</strong></p> <pre><code> &lt;script type="text/javascript"&gt; $(function () { $("#btn").click(function() { Receive.ShowMsg("Heloword"); // }); &lt;/script&gt; &lt;body&gt; &lt;input type="button" id="btn" value="SendMessage"&gt; &lt;/body&gt; </code></pre> <p><strong>Receive.html</strong></p> <pre><code>&lt;script type="text/javascript"&gt; function ShowMsg (strtext) { $("#result").val(strtext); } &lt;/script&gt; &lt;body&gt; &lt;div class="input"&gt; &lt;input type="text" id="result"&gt;&lt;/input&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p>thank's in advance</p>
jquery
[5]
2,393,767
2,393,768
jQuery how to remove all <span> tags from a <div>?
<p>I've tried both of the following but none of them worked:</p> <pre><code>$('#divhtml').remove('span') $('#divhtml').find('span').remove() </code></pre> <p><strong>EIDT:</strong> $('#divhtml').find('span').remove() worked on 2nd try.</p>
jquery
[5]
4,757,451
4,757,452
PHP Getting data from mysql and then use it in different actions
<p>So I want to get some data from mysql and use it to create some conditions. Here is my code, but it only shows the last record from mysql.</p> <pre><code> $result = mysql_query("SELECT * FROM system") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { $name_system = $row['name']; $value_system = $row['value']; } if($name_system=='website_register' AND $value_system==1) $register_system = 1; else $register_system = 0; if($name_system=='website_offline' AND $value_system==1) $offline_system = 1; else $offline_system = 0; </code></pre> <p>Then if I'm trying to echo "$offline_system" or "$register_system" in another page, it dosen't show the true data.</p>
php
[2]
5,794,934
5,794,935
Android system / system context / replace classes
<p>Hi I'm engineer but more from a chip/assembler x86 level. I'm new to Android. Still figuring some general things out. I have written some apps, but have a general question. If I were to write an improved version of - let's say - TextView. Is it possible to make all app's on the system using this class, basically replace TextView? How are the java classes on the Android system, are they compiled, can I replace the library? Is this protected? Thanks for help</p>
android
[4]
4,960,741
4,960,742
approach for array of arrays
<p>I'm doing this graphics project in which I have a set of points(in 3 coordinates)and have to transform them via matrix arithmetic.Each point needs to be transformed(rotation,scaling etc) and stored back.The obvious approach I figured was to use a 2-D array of size n by 3 matrix where every row would contain 3 values (x,y,z).Is there any better approach using vectors or structs?</p>
c++
[6]
1,967,788
1,967,789
try catch around mixed content warning
<p>I was wondering if there is a way that I can try catch around a Mixed Content Warning using Javascript? I get this warning whenever I call a loading gif using IE 8 in compatibility mode. I know what the problem is, so I figure I can just try catch around the mixed content warning. Anybody know how?</p>
javascript
[3]
2,775,151
2,775,152
Single word Palindrome Checker (True or False)
<p>Right now, what I have is a code that I can test a single word whether it is a Palindrome or not. I have to input the word, and it will tell me whether it is a Palindrome (True) or if it is not (False)</p> <p>I need to create one that Asks for a single word, then provides a True of False based on the word that is typed. This is what i have so far. </p> <p>I really have no idea how to do this, any help would be greatly appreciated. </p> <pre><code>def isPalindrome(s): if len(s) &lt;= 1: return True else: if s[0] != s[len(s)-1]: return False else: return isPalindrome(s[1:len(s)-1]) print(isPalindrome("poop")) </code></pre>
python
[7]
3,044,892
3,044,893
Does turning a list into a set, then back again, cause problems in Python?
<p>I'm turning a list into a set in Python, like so:</p> <pre><code>request.session['vote_set'] = set(request.session['vote_set']) </code></pre> <p>So I can easily do a <code>if x in set</code> lookup and eliminate duplicates. Then, when I'm done, I reconvert it:</p> <pre><code>request.session['vote_set'] = list(request.session['vote_set']) </code></pre> <p>Is there a better way to do this? Am I potentially doing something dangerous (or stupid)?</p>
python
[7]
2,904,479
2,904,480
Convert specified format of time to a date asp.net
<p>Hii,</p> <p>I have time, for e.g <strong>33 hr 40 mins 50 secs</strong> . i would like to convert it to a date time format.</p> <p>for e.g I have used Convert.ToDateTime("33:40:50"), but in this case when you converting to date time, hour should be less than 24, otherwise it will fire an exception. Pls help me to solve the above problem. </p>
asp.net
[9]
3,724,821
3,724,822
How to catch onload event on css styles?
<p>I load css</p> <pre><code>var ss = document.createElement("link"); var url = 'http://site.ru/style.css'; ss.setAttribute("rel", "stylesheet"); ss.setAttribute("type", "text/css"); ss.setAttribute("href", url); document.getElementsByTagName("head")[0].appendChild(ss); </code></pre> <p>I want to call function after css loading, but tag link hasn't onload event, is there a way to do it? </p>
javascript
[3]
245,353
245,354
is javascript null separate type of object's value?
<p>According to "8.2 The Null Type" chapter of Ecma-262 "null" is type.</p> <p>But typeof(null) is object, so null is just a value of type object.</p> <p>How could it be?</p>
javascript
[3]
5,599,226
5,599,227
Using this() in code
<p>I am new to CSharp.I have seen "this()" in some code.My question is Suppose if i call</p> <p>Paremeterized constructor ,am i invoking the paremeterless constructor forcefully?.But According to constructor construction ,i believe parameterless constructor will be executed first.Can you please explain this with simple example so that i can get exactly when should i call "this()".Thanks in advance.</p> <pre><code> public OrderHeader() { } public OrderHeader(string Number, DateTime OrderDate, int ItemQty) : this() { // Initialization goes here .... } </code></pre>
c#
[0]
1,058,225
1,058,226
Python, trace undefined variables
<p>in my program I have undefined variable somewhere:</p> <pre><code>global name 'cmd' is not defined </code></pre> <p>How can I pull out the line number where the variable is being used?</p> <p>I know where the error is (cmd versus self.cmd). The question is how to get the line number (or why it isnt shown).</p> <p>Since I was catching error, I had to <code>traceback.print_exc()</code> to get line numbers</p>
python
[7]
3,888,360
3,888,361
User permissions binary/decimal confusion after unexpected behavior
<p>First of all I do not understand why some people are using binary number and powers of two for permissions. Is it because they stand for true/false with 1/0 from backwards relation?</p> <p>Ex: <code>1010 means false, true, false, true</code> ?</p> <p>My question is following. <code>15</code> in decimal is same as <code>1111</code> in binary, BUT:</p> <pre><code>DEFINE ('READ',1); DEFINE ('WRITE',2); DEFINE ('EDIT',4); DEFINE ('DELETE',8); $current = 15; if ($current &amp; READ) print("can read &lt;br /&gt;"); if ($current &amp; WRITE) print("can write &lt;br /&gt;"); if ($current &amp; EDIT) print("can edit &lt;br /&gt;"); if ($current &amp; DELETE) print("can delete &lt;br /&gt;"); </code></pre> <p>This outputs that all permissions are allowed, as I expect. However, if I change 15 with <code>1111</code> then it shows only 3 of them that are allowed not all four (<code>delete</code> permission comes as invalid):</p> <pre><code>DEFINE ('READ',1); DEFINE ('WRITE',2); DEFINE ('EDIT',4); DEFINE ('DELETE',8); $current = 1111; if ($current &amp; READ) print("can read &lt;br /&gt;"); if ($current &amp; WRITE) print("can write &lt;br /&gt;"); if ($current &amp; EDIT) print("can edit &lt;br /&gt;"); if ($current &amp; DELETE) print("can delete &lt;br /&gt;"); </code></pre> <p>Is not it strange? Do I understand it incorrectly? I need some help to understand this. Should I store permissions as decimals or binaries in db?</p>
php
[2]
4,394,164
4,394,165
PHP Mailing Code sending mail to spam/quarantine
<p>The title explains itself. It is a website for in-house employees to buy and sell from each other. Its based solely around Microsoft Outlook emailing addresses. All the emails are supposed to be sent from the seller's email as they post items. Except when I enter <code>&lt;php phpinfo(); ?&gt;</code> on the action php page it tells me that the sendmail_from attribute thing is sending from a bogus email on the server. It seems to be the automatic email for the php script to send from. This may be why the emails are getting sent to spam, because the email is not valid. Also, I read online about having full and valid headers but most headers seem optional and i cant find anywhere that explains optimal headers. My mailing code: </p> <pre><code>//send approval email to the approver $from = isset($_POST['from'])? $_POST['from']:1; $message = isset($_POST['message'])? $_POST['message']:1; $message = $message . '&lt;a href="http://dev-corkboard/newapproval.php?id=' .$result[0][0].'"&gt; Click here to approve website post.&lt;/a&gt;'; // In case any of our lines are larger than 70 characters, we should use // wordwrap() $message = wordwrap($message, 70); $to = '[email protected]'; $replyto = isset($_POST['replyto'])? $_POST['replyto']:1; $subject = isset($_POST['subject'])? $_POST['subject']:1; $headers = "MIME-Version: 1.0" . "\r\n" . 'From: "'.$from.'"' . "\r\n" . 'Reply-To: "'.$replyto.'"' . "\r\n" . 'Content-Type:text/html;charset=iso-8859-1' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); if (mail($to, $subject, $message, $headers)) { //test message for email } header ("location: newindex.php"); ` </code></pre> <p>Any ideas?</p>
php
[2]
5,341,074
5,341,075
Uninstall app icon from home screen when app is uninstall
<p>I have put <code>app_icon</code> on Home Screen when app is install<br/></p> <p>now want to remove it, when app is going to uninstall <br/></p> <p>i know how to remove <code>app_icon</code> but dont know on which event i need to do this</p> <p>Can any one provides me solution for this.</p> <p>Thanks in Advance</p>
android
[4]
3,612,092
3,612,093
how to use include tag for setting herder in all activity android?
<p>i want toe create common template for my android application.i don't know how? some body told use include tag.I need some example for this.</p>
android
[4]
226,444
226,445
JQuery Unbind event when removing a class
<p>So I have a couple of divs with a class "turn". Then in Jquery I have</p> <pre><code>$(".turn").click(function(){ ...some code... if (..) $(this).removeClass("turn"); }); </code></pre> <p>which I expect to remove the handler, so I can't click on it anymore. But I still want to be able on the other divs that has that class. This is not working (I believe is because JQuery doesn't remove the handlers when a class is removed) I've also tried with </p> <pre><code>$('.turn?).live(click,...) and $(this).die() </code></pre> <p>and </p> <pre><code>$('.turn?).bind()/$(this).unbind() </code></pre> <p>But neither of those seems to work. Can I get some hint about how to do this? Thanks</p>
jquery
[5]
5,406,160
5,406,161
How to make a call which begin with * in iPhone?
<p>In my application, I want to call the number *111, when I use this URL tel:*111 to call, but can't make call success, please give me some indicate, thank you very much.</p> <blockquote> <p>[[UIApplication sharedApplication] openURL:@"tel:*111"] </p> </blockquote> <p>was not work. but it will work when remove *</p> <blockquote> <p>[[UIApplication sharedApplication] openURL:@"tel:111"];</p> </blockquote>
iphone
[8]
4,607,767
4,607,768
object assignment
<p>I have a scenario like:</p> <pre><code>MyClass obj1 = new MyClass(); ............//some operations on obj1; MyClass obj2 = new MyClass(); obj2 = obj1; </code></pre> <p>I have the following problem: if I modify any parameter, it is affected in both objects (as both refer to same location) - but, when I modify obj2 parameter, it should not modify that parameter value in obj1 (i.e. means both should not point to same location). How can I do that? Please help me. I can't clone here as myclass is not implementing ICloneable and I can't modify myclass. if I clone by serializing and deserializing, will it be a Deep clone?</p>
c#
[0]
2,663,123
2,663,124
android Can we have Session Management and time out in app
<p><em>hello frnds,,,</em></p> <p>I am working on an application XYZ ,which maintains a session time out at Server end..</p> <p>Actually on login to service I receive a session token which is used to access further web services and that token expires after certain amount of time say 30 minutes...</p> <p>The token is then expired as a consequence the different web services used do not show desired response.</p> <p>Is there any Android specify way to maintain timeout for complete application for being able to automatically redirected at login after timeout(session token expired).</p> <p>If not,Please provide the either ways( to do with Apache HttpClient, the library that I am using for HTTP access.)</p> <p><strong>keen to know about any android specific way to do this..</strong></p> <p>With Regards,</p> <p>Arpit</p>
android
[4]
3,569,857
3,569,858
Fetch the drive contents dynamically
<p>Hi friends in my project i have a situation that when i select the drive letter it display the corresponding files with in the share drive will dispaly . for that i find the connected drives with my system using the following code<br /> <code>echo "&lt;select id = 'drives'&gt;&lt;option&gt;Drives&lt;/option&gt;"; for($ii=66;$ii&lt;92;$ii++) { $char = chr($ii); if(opendir($char.":/")) echo "&lt;option&gt;".$char."&lt;/option&gt;"; } echo "&lt;/select&gt;";</code></p> <p>But i select the drive letters the corresponding files are not displayed. Please help me to fetch the files. Thanks in advance</p>
php
[2]
1,267,433
1,267,434
What is the path of logging.java?
<p>When I try and search in Windows it just gives me "java" or "java/util" I can't find that in explorer. Thanks.</p>
java
[1]
3,837,637
3,837,638
Local variable in each class - python timed loop
<p>I have a python file in a continuous loop reading from an external file, I have a lot of different data points I'm reading and have a class (fb) that I'm calling to feed the locations of each point (m1.x, m2.x etc....) The file loops every 30 seconds. </p> <p>I need a variable in the loop which is not reset for each instance I'm using. If I define it within the loop it's reset and if I use a global variable I can't use it for multiple variables. </p> <p>So in the example below 'test' counts by one for all instance as its a global variable and self.X is reset after each loop. Neither of which do what I need. I was attempting to use threading but this causes even more problems with the modules I'm using. So if anyone has any ideas on how to create a local variable which is not reset within a class which is looping that would be great. Thanks. </p> <pre><code>test = 0 s = sched.scheduler(time.time, time.sleep) def loop1(sc): class fb: def link(self): global test test = test + 1 print test self.X = self.X + 1 print self.X m1 = fb() m1.X = 1 m1.link() m2 =fb() m2.X = 0 m2.link() # Update loop every 10 second sc.enter(10, 10, loop1, (sc,)) # end loop s.enter(1, 1, loop1, (s,)) s.run() </code></pre>
python
[7]
612,867
612,868
why isnt there a Math.floor(float)?
<p>Why is there only Math.floor(double)? </p> <p>I have a float and I want to round it "down".<br> do I have to cast it to double? </p>
java
[1]
4,584,327
4,584,328
C# returning Exception at runtime
<p>Don't think this is possible but thought I would ask and maybe someone could suggest an alternative technique or pattern.</p> <p>Say I have a Customer class that has as list of Books which are both pulled seperately from an external source. If the Customer class is successfull but the Books failed to load I don't want to throw an Exception unless the client tries to access the Books property so..</p> <pre><code>this.Books = new List&lt;Book&gt;() { throw new Exception("Books couldn't load because blah blah"); }; </code></pre> <p>Is something along these lines possible?</p>
c#
[0]
3,353,933
3,353,934
Is it more pythonic to close a function with return or through indentation?
<p>If I have a function that does not need to return a variable, is it considered better coding practice to close the function like this:</p> <pre><code>def foo(): """Code""" return # More code </code></pre> <p>or like this?</p> <pre><code>def bar(): """Code""" # More code </code></pre>
python
[7]
1,292,036
1,292,037
Registering an application on twitter
<p>I am trying to post on twitter having an register application. But every-time whenever i am editing my application to make it read&amp;write it always shows read only and whenever i am trying to edit it and save it, again it shows "<strong>This is an application to check twitter authorization. created by Piyush – read-only access by default</strong> ".For that reason i am not able to post my comments on twitter.</p> <p>My application gives an</p> <pre><code> //401:Authentication credentials were missing or incorrect. {"request":"\/1\/statuses\/update.json","error":"Read-only application cannot POST"} </code></pre> <p>any suggestions?</p>
android
[4]
1,264,953
1,264,954
jQuery Add Collapsible Panel
<p>Using jQuery I want to dynamically add new collapsible panels. An accordion is not enough, as I need to have more than one section open at a time.</p> <p>The sample <a href="http://dl.dropbox.com/u/24708866/labs/jquery-multi-open-accordion/index.html" rel="nofollow">here</a> is exactly what I need apart from I'm wanting a button click to dynamically add a new panel.</p> <p>Using .append() to add in a new tag doesn't work. I don't mind if the solution includes plugins or whatever (I don't want to use a framework such as 'KendoUI' though)</p>
jquery
[5]
3,598,661
3,598,662
jquery live hover not working
<p>I ran into some dropdown flickering issue on IE due to mouseover and mouseout , so i changed the code to hover and live as the data is dynamic from ajax.</p> <p>But the following code is not working , i got the latest jquery also.</p> <p>The following code is getting executed without error but not working</p> <pre><code>$('.cs-rec').live("hover", function() { $(this).find('.cs-title').css('text-decoration','underline'); }, function() { $(this).find('.cs-title').css('text-decoration','none'); } ); </code></pre>
jquery
[5]
2,378,135
2,378,136
I am using this code in php which show
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4524698/php-cannot-modify-header-information">PHP - Cannot modify header information&hellip;</a> </p> </blockquote> <blockquote> <p>error: Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\VertrigoServ\www\alok\cookies\Time\session.php:5) in C:\Program Files\VertrigoServ\www\alok\cookies\Time\session.php on line 8</p> </blockquote> <pre><code>&lt;?php session_start(); $inactive = 10; $session_life = time() - $_SESSION['timeout']; echo "$session_life"; if($session_life &gt; $inactive){ session_destroy(); header("Location: logout.php"); } $_SESSION['timeout']=time(); ?&gt; </code></pre>
php
[2]
2,725,699
2,725,700
move content from one hidden div to another displayed div
<p>how do i move content from one hidden div to another displayed div using jquery?</p> <p>say i have div1 with display style is none and another div "div2" with display style block.</p> <p>how do I move the content from div1 to div2 and clear div1?</p>
jquery
[5]
439,591
439,592
Android: Steps for reading a wav file
<p>Hey i have imported WavFile from <a href="http://www.labbookpages.co.uk/audio/javaWavFiles.html" rel="nofollow">http://www.labbookpages.co.uk/audio/javaWavFiles.html</a> aim is to plot a waveform from the data retrieved from the wave file that i have read. However i dont know which variable represents the data retrieved from the wav file. Can anyone please help... I found many posts but none of them have explained the concepts clearly...</p> <p>This is my code:</p> <pre><code>try { WavFile fp = WavFile.openWavFile(myFile); Log.d(TAG, "Wav file found"); fp.display(); // Get the number of audio channels in the wav file int numChannels = fp.getNumChannels(); // Create a buffer of 100 frames double[] buffer = new double[100 * numChannels]; int framesRead; do { // Read frames into buffer framesRead = fp.readFrames(buffer, 100); for (int s=0 ; s&lt;framesRead * numChannels ; s++) { Log.d(TAG, "DATA:"+buffer[s]); //does buffer[s] has data which i need to plot the waveform } } while (framesRead != 0); // Close the wavFile fp.close(); catch (IOException e) { Log.d(TAG, "IOException occoured"); e.printStackTrace(); } catch (WavFileException e) { Log.d(TAG, "WavFileException occoured"); e.printStackTrace(); } </code></pre> <p>}</p> <p>Does buffer[s] has data which i need to plot the waveform??</p>
android
[4]
4,367,219
4,367,220
How to include Header File (.h) in Java
<p>I want to use <a href="http://fallabs.com/tokyocabinet/spex-en.html#tcadbapi" rel="nofollow">this</a> which says to use a particular method I have to include tcutil.h in my java code. Can anybody help me, how to do that ? Another point: we can easily create an header file and include it in to C code but why reverse is so hard (means lots of work have to do) ? May be stupid, but little bit hints will be helpful.</p>
java
[1]
939,854
939,855
Find Format of Date in Java
<p>How can we get the format of a date in Java?? I have a column which is in the date format . I want to find its format for every rows. How can i do this ? Ex -- </p> <pre><code>COL1| COL2 |COL3 ------------------------- 1 | 12-2005-31 |zzz 2 | 24 March 2009 |aaa </code></pre>
java
[1]