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 |
|---|---|---|---|---|---|
5,300,022 | 5,300,023 | How to convert an Integer[] to an int[]? | <pre><code>// how to convert this
Integer[] array = {1, 2};
// to this
int[] array = {1, 2};
</code></pre>
<p>I'm working on code that has the second form, and I need to modify how the array is read. Not knowing enough of Java, I would rather just convert than risk bugs.</p>
| java | [1] |
2,117,674 | 2,117,675 | What is out-of-band callback? | <p>What is an out-of-band callback?
Is this similar to AJAX? Please explain..</p>
<p>Thanks.</p>
| asp.net | [9] |
3,298,782 | 3,298,783 | change window location | <p>My code opens a new window with the name <code>radio</code> I am curious to know how I can change the url for this window automatically every hour from <code>radio.php</code> to <code>/server2/radio.php</code></p>
<pre><code><a href="#" onclick="RadioLink('radio.php','radio','width=300,height=150')">Play Radio</a>
<script type="text/javascript">
<!--
function RadioLink(theURL,winName,features) {
window.open(theURL,winName,features);
}
//-->
</script>
</code></pre>
| javascript | [3] |
1,932,942 | 1,932,943 | Why onKey event double processing in Android? | <p>I wonder why onKey event is double processing when I logging it. Here is my coding. </p>
<pre><code>ed1.setOnKeyListener(new View.OnKeyListener()
{
Integer count = 0;
String typeWord = "";
public boolean onKey(View v, int keyCode, KeyEvent event)
{
count++;
char c = (char)event.getUnicodeChar();
typeWord = typeWord + c;
Log.v ("keypress", "Keycode " + typeWord + " - skeyCode " + count);
return false;
}
});
</code></pre>
<p>And here is logging of when I type "a".</p>
<pre><code>10-16 02:38:27.025: VERBOSE/keypress(362): Keycode a - skeyCode 5
10-16 02:38:27.315: VERBOSE/keypress(362): Keycode aa - skeyCode 6
</code></pre>
| android | [4] |
4,664,661 | 4,664,662 | Issue in switching from one activity to other | <p>I have Activity1 Activity2 Activity3 activities in my application.</p>
<p>now I want to switch from Activity3 to Activity1.</p>
<p>How do I proceed?</p>
<p>And also, how to finish an activity from another activity?</p>
| android | [4] |
111,562 | 111,563 | triggering jquery on dynamic elements | <p>I'm trying to trigger a <code>.show</code> on a div, when a link has a dynamically added class and it's parent has the class <code>pdSelectedSwatch</code> which is added on selection(click).</p>
<p>example code:</p>
<pre><code><li class="pdSelectedSwatch">
<a href="javascript:void(0)" class="outOfStock">
<img class="outOfStock" src="/outofstock.gif" >
</a>
</li>
if ($("a.outOfStock").parent().hasClass("pdSelectedSwatch")) {
$(".stockMessage").show();
}
</code></pre>
<p>But I can't get it to work properly, and I'm betting my syntax is off.</p>
<p>I should note that the <code>outOfStock</code> class is determined by values in an xml file, and there are several functions that determine the link's class based on that file.</p>
<p>I should also note that the site is using jQuery 1.4.2, which won't be updated at thsi time.</p>
<p>thanks.</p>
| jquery | [5] |
1,375,691 | 1,375,692 | height of an element javascript | <p>I would like to adjust the size of an element in the opposite direction, so the code below does adjust it, but it enlarges it from current position to bottom, I want current position to top. What would be an efficient way of doing this? thanks</p>
<pre><code>var ele=document.getElementById('mydiv');
ele.style.height = 500+'px';
</code></pre>
| javascript | [3] |
2,076,716 | 2,076,717 | jquery array stored check box not responding | <p><img src="http://i.stack.imgur.com/RSElA.jpg" alt="enter image description here">I have 4 group of checkboxes, in which i am grouping all this 4 in to an array, after i stored the group checkboxes, i can't add the event to those boxes, i think i am doing something wrong.. any one correct my code?</p>
<p>what i want is when a user click on a checkbox, then can check further withing group(max 4 allowed), if they switch to other group, then rest of the groups need to uncheck, and they have the rights to check 4 from which group they selected.</p>
<p>i am grouping like this, and next i need to disable and unable to group to allowing 4 selection, any good idea to get this done?</p>
<pre><code>var geoGroup = [];
$('input:checkbox','#geography').each(function(i){
if(typeof geoGroup[$(this).attr('name')] == 'undefined')
geoGroup[$(this).attr('name')] = [];
geoGroup[$(this).attr('name')].push($(this));
$('input:checkbox',geoGroup[$(this).attr('name')]).live('click', function(){
alert('hi')
})
})
</code></pre>
| jquery | [5] |
391,330 | 391,331 | Decorators in Python | <p>I am just learning python, and I am currently playing with Tornado framework. I see this class:</p>
<pre><code>class AuthHandler(BaseHandler, tornado.auth.GoogleMixin):
@tornado.web.asynchronous
def get(self):
if self.get_argument("openid.mode", None):
self.get_authenticated_user(self.async_callback(self._on_auth))
return
self.authenticate_redirect()
</code></pre>
<p>I am having trouble grasping what the decorator does there (@tornado.web.asynchronous). Does it overwrite that function?</p>
<p>You can see the full source at <a href="https://github.com/facebook/tornado/blob/master/demos/chat/chatdemo.py" rel="nofollow">https://github.com/facebook/tornado/blob/master/demos/chat/chatdemo.py</a></p>
| python | [7] |
5,657,563 | 5,657,564 | PHP Zip code matching | <p>How can I have it if a zip is entered that I have a page for go to the page for the zip and if not then go to another page? I'm new to PHP and don't know how to start. </p>
| php | [2] |
523,762 | 523,763 | List loop cannot be accessed | <p>I have a new list which have at least 5 objects. I am trying to copy the elements of the new list to the old one. The problem here is that loop never accessed.</p>
<pre><code>foreach (JobPosition Position in JobPositionsListNew)
{
JobPositionsList.Add(
new JobPosition(
Position.SetGetPositionName,
Position.SetGetMinimumDegree,
Position.SetGetSalary));
}
</code></pre>
| c# | [0] |
1,034,451 | 1,034,452 | Classical Inheritance implement in javascript | <p>What I am trying to do is inherit the <code>id</code> and <code>name</code> from the <code>TField</code> and override the <code>render</code> function of the <code>TField</code>. I want to know if this is the stardard way to implement inheritance in JavaScript.</p>
<pre><code>var TField=function(jData)
{
this.id=jData.id;
this.name=jData.name;
this.attributes=jData.attributes;
this.render=function(){
alert('TField render.');
};
};
var TChildField=function(jData)
{
var t= new TField(jData);
t.render=function(){
alert('TChildField render.');
}
return t;
}
var tobj={id:"1",name:"test",attribute:{}};
var c= new TChildField(tobj);
alert(c.id);
alert(c.name);
</code></pre>
| javascript | [3] |
548,224 | 548,225 | Regex result not show up in C#? | <p>I tried to parsing query from google that comming to mysite but its not showing up, but according <a href="http://derekslager.com/blog/posts/2007/09/a-better-dotnet-regular-expression-tester.ashx" rel="nofollow">http://derekslager.com/blog/posts/2007/09/a-better-dotnet-regular-expression-tester.ashx</a>, and with regex buddy, my regex was right. But when I tried its with live development its not showing up....</p>
<p>Its the string that I want to parse:</p>
<pre><code>imgurl=http://www.blabla.com/products/W7i5W4Pw4fH22Mih/P_500.jpg&q=ASUS+Rampage+II+Extreme+LGA1366+Intel+X58+DDR3-1600+ATX+Motherboard&imgrefurl=http://www.blabla.com/Mboards/Intel/Rampage_II_Extreme/&usg=__4HSriQuFeVXg5AWsOGlZlsAmMmg=&h=500&w=500&sz=37&hl=en&start=1&zoom=1&tbnid=9ImqgVuzVz5ThM:&tbnh=130&tbnw=130&ei=MKrYUNm9MI6zrAfWi4GQBw&um=1&itbs=1&ptbm=isch
</code></pre>
<p>And here my code.</p>
<pre><code>string Website = url; //url
string regularExpressionPattern = @"&q=(.*?)&imgrefurl";
MatchCollection matches = Regex.Matches(Website, regularExpressionPattern);
foreach (Match m in matches)
{
MessageBox.Show(m.Groups[1].Value);
}
System.Diagnostics.Debugger.Break();
</code></pre>
<p>Even with debugger its not result?
NB: I using Microsoft Visual C# 2008, windows xp 2</p>
| c# | [0] |
5,686,159 | 5,686,160 | Animation of different images in list | <p>I have different images, say 100 images or so. Now, I want to apply animation on them. I want my ImageView to get each image after specified interval but when the change of image occurs, each image should FadeIn or FadeOut. I place my images in @drawable/[list_of_images].xml file as:</p>
<pre><code><animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/a1" android:duration="1000"/>
<item android:drawable="@drawable/a2" android:duration="2000"/>
<item android:drawable="@drawable/a3" android:duration="3000"/>
<item android:drawable="@drawable/a4" android:duration="500"/>
</code></pre>
<p></p>
<p>and then I can successfully change these images depending on their time interval in ImageView by using:</p>
<pre><code>public class AnimTest extends Activity
{
AnimationDrawable myAnim;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.anim);
ImageView myIV = (ImageView) findViewById(R.id.image_view);
myIV.setBackgroundResource(R.drawable.list_of_images.xml);
myAnim = (AnimationDrawable) myIV.getBackground();
}
public boolean onTouchEvent(MotionEvent event)
{
if (event.getAction() == MotionEvent.ACTION_DOWN)
{
myAnim.start();
return true;
}
return super.onTouchEvent(event);
}
</code></pre>
<p>}</p>
<p>The problem is that I can't figure out on how to apply fade effect on every single image, while they are getting changed by the above animation. I can apply fade animation on whole list of images but cannot do this on every image. Am i going to the right direction to achieve this functionality? If not, please guide me to the right path.</p>
<p>Regards,
Khawar</p>
| android | [4] |
3,597,997 | 3,597,998 | How to pass an arraylist as a request parameter so that i can fetch the values through request parameter | <p>I have a method in a java class that returns an ArrayList of a particular class type. How can it be passed as a request parameter?</p>
| java | [1] |
5,812,749 | 5,812,750 | How do I access System.Web.Http.Current.Response from a within a thread? | <p>I have a ASP.NET page with a WebMethod that creates an object and runs one of the object's methods in a new thread.</p>
<p>I need to access the <code>System.Web.HttpContext.Current.Response.ContentType</code> property from within this thread. </p>
<p>Each time I (try to) access it, I receive a <code>NullReferenceException</code>.</p>
<p>Is this posible?</p>
| asp.net | [9] |
5,455,405 | 5,455,406 | how do i receive messages sent to gtalk? | <p>im making an application that needs to get received messages that were sent to google chat. is there an api for working with google chat?</p>
<p>can someone please give me an example in C# how do i receive gtalk messages? im sorry the xmpp documentation is too complex and i do not understand where to start</p>
| c# | [0] |
2,624,209 | 2,624,210 | pass value from gridview to stored procedure | <p>I had stored procedure which get data where Id=@id and the @id which pass to stored from gridview I tried to do that but I couldnot please any one help me</p>
<p></p>
<p>protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{</p>
<pre><code> using (SqlConnection con = Connection.GetConnection())
{
string Sql = "Select Logo From Model where Id=@Id";
SqlCommand com = new SqlCommand(Sql, con);
com.Parameters.Add(Parameter.NewInt("@Id", GridView1.SelectedDataKey));
com.CommandType = CommandType.Text;
SqlDataReader dr = com.ExecuteReader();
if (dr.Read())
{
string Img2 = dr["Logo"].ToString();
if (Img2 == System.DBNull.Value.ToString())
{
Img.Visible = false;
}
}
}
}
</code></pre>
| c# | [0] |
5,551,081 | 5,551,082 | Which file Mode enumerator should john use in the constructor of the file stream class? | <p>John need td write a program in C# for file handling. He wants to write a code to open an existing file. If the file does not exist, an error message should be shown. Which file Mode enumerator should john use in the constructor of the file stream class?</p>
<ol>
<li>Open</li>
<li>OpenOrCreate</li>
<li>CreateNew</li>
<li>Create </li>
</ol>
| c# | [0] |
2,034,993 | 2,034,994 | Python: Object identity assertions thrown by differences in import statement notations | <p>When checking an object's identity, I am getting assertion errors because the object creation code imports the object-defining module under one notation (<code>base.other_stuff.BarCode</code>) and the identity-checking code imports that same module under a different notation (<code>other_stuff.BarCode</code>). (Please see below for gory details.)</p>
<p>It seems that the isinstance() call is sticky about the references to the object definition module, and wants it imported under the exact same notation. (I'm using version 2.5.)</p>
<p>I suppose could fix this by changing the import notation in the code checking the identity, but I'm worried that I'll just propagate the same problem to other code that depends on it. And I'm sure there is some more elegant solution that I probably should be using in the first place.</p>
<p>So how do I fix this?</p>
<p>DETAILS</p>
<p>PythonPath: '/', '/base/'</p>
<p>Files: </p>
<pre><code>/__init__.py
base/__init__.py
base/other_stuff/__init__.py
base/other_stuff/BarCode.py
base/stuff/__init__.py
camp/__init__.py
</code></pre>
<p>Text of base/stuff/FooCode.py:</p>
<pre><code>import other_stuff.BarCode as bc
class Foo:
def __init__(self, barThing):
assert isinstance(barThing, bc.Bar)
</code></pre>
<p>Text of camp/new_code.py:</p>
<pre><code>import base.stuff.FooCode as fc
import base.other_stuff.BarCode as bc
thisBar = bc.Bar()
assert isinstance(thisBar, bc.Bar)
thisFoo = fc.Foo(barThing=thisBar)
</code></pre>
<p>This fails. It survives its assertion test, but blows up on the assertion in the initial code.</p>
<p>However, it works when I modify new_code to import BarCode.py with:</p>
<pre><code>import other_stuff.BarCode as bc
</code></pre>
<p>. . . because both base/ and base/other_stuff are on the PythonPath.</p>
| python | [7] |
2,776,790 | 2,776,791 | Join two lists of dictionaries around a single non-unique key | <p>I have 2 lists of dictionaries, say:</p>
<pre><code>l1 = [{"customer":"amy", "order":2}, {"customer":"amy", "order":3}, {"customer":"basil", "order":4}]
l2 = [{"customer":"amy", "died":"who fell down the stairs"}, {"customer":'basil', "died":"assaulted by bears"}]
</code></pre>
<p>I am looking for an elegant way of taking the keys from l2 and putting them into l1. This is for joining lists of dictionaries that use different values as their index</p>
<p>The function should look something like join(l1,l2,'customer'), and produce</p>
<pre><code>l3 = [{"customer":"amy", "order":2,"died":"who fell down the stairs"}, {"customer":"amy", "order":3,"died":"who fell down the stairs"}, {"customer":"basil", "order":4,"died":"assaulted by bears"}}]
</code></pre>
<p>l3 should have a dictionary for every dictionary in l1.</p>
<p>if l1 and l2 have the same non-joining key with different values, l2 takes, precedence.</p>
<p>l2 will have unique values for the joining key.</p>
<p>right now I have tried this ugly piece of code:</p>
<pre><code>l3 = []
rdict = {}
for i in range(len(l2)):
rdict[l2[i][field]]=i
for d in l1:
l3.append(dict(d.items()+l2[rdict[d[field]]].items()))
return l3
</code></pre>
<p>as well as <a href="http://stackoverflow.com/questions/5501810/join-two-lists-of-dictionaries-on-a-single-key">the solution from</a> but that assumes only one index in all lists.</p>
<p>Thank you</p>
| python | [7] |
164,301 | 164,302 | showing and hiding something on slide toggle in jquery | <p>i have a panel having slide toggle effect on click of a button along with this slide toggle i am also hiding one div on the click event what i want when the panel slide down that div should hide and when panel slide up the div reappear how to do this</p>
| jquery | [5] |
1,777,585 | 1,777,586 | Restore Python class to original state | <p>I have a class where I add some attributes dynamically and at some point I want to restore the class to it's pristine condition without the added attributes.</p>
<p>The sistuation:</p>
<pre><code>class Foo(object):
pass
Foo.x = 1
# <insert python magic here>
o = Foo() # o should not have any of the previously added attributes
print o.x # Should raise exception
</code></pre>
<p>My initial thought was to create a copy of the original class:</p>
<pre><code>class _Foo(object):
pass
Foo = _Foo
Foo.x = 1
Foo = _Foo # Clear added attributes
o = Foo()
print o.x # Should raise exception
</code></pre>
<p>But since Foo is just a reference to _Foo any attributes get added to the original _Foo as well. I also tried</p>
<pre><code>Foo = copy.deepcopy(_Foo)
</code></pre>
<p>in case that would help but apparently it does not.</p>
<p><strong>clarification</strong>:</p>
<p>The user should not need to care about how the class is implemented. It should, therefore, have the same features of a "normally defined" class, i.e. introspection, built-in help, subclassing, etc. This pretty much rules out anything based on <code>__getattr__</code></p>
| python | [7] |
515,529 | 515,530 | Troubleshooting "call_user_func_array() expects parameter 2 to be array, string given" error | <pre><code>if( array_key_exists( $fn, $this->_request ) ){
if( $array ){
$result = call_user_func( $func, $args );
}else{
$result = call_user_func_array( $func, $args );
}
if( !empty( $GLOBALS['xhrErrorHandlerText'] ) ){
$error = 'PHP Error Message: ' . addslashes( $GLOBALS['xhrErrorHandlerText'] );
}
}else{
if( $fn ){
$error = 'Cannot call function '. addslashes( $fn ) .'. Function not registered!';
}else{
$error = 'No function call specified!';
}
}
</code></pre>
<p>I'm getting this error:</p>
<blockquote>
<p>PHP Error Message: WARNINGcall_user_func_array() expects parameter 2
to be array, string givenError in line 649 of file</p>
</blockquote>
| php | [2] |
5,553,730 | 5,553,731 | How to use large audio file size of more than 15 MB in android | <p>I wanted to use very audio files of each abt 15 MB in android. Is there a way where I can optimize my audio files before using them or shd i directly stream from internet for every file. Pls suggest if thr is any way that i can make the user to use audio files without any time lag.</p>
| android | [4] |
2,012,686 | 2,012,687 | Move files to server | <p>How is it possible to move files from a folder to web server through FTP, using ASP.Net with C# ?</p>
| asp.net | [9] |
3,700,081 | 3,700,082 | how to make UIView animation? | <p>I have implemenetd one animation application.In which there is one main view and another is subview in that view.There is also one button.When user touch on that button i want to disply subview with animation.That view must be display from bottom to top.How it possible.I dont know how it possible.</p>
| iphone | [8] |
3,887,222 | 3,887,223 | How to create a layer menu? | <p>How to create a layer menu? I want to create a custom menu,but I do not know how to create a layer,For example, a Imagebutton is pressed to display a list of menu.like this:</p>
<p><a href="http://ss12.sinaimg.cn/orignal/5d8cb30ag8f47eca43a5b&690" rel="nofollow">http://ss12.sinaimg.cn/orignal/5d8cb30ag8f47eca43a5b&690</a></p>
| android | [4] |
3,419,428 | 3,419,429 | Java: Easiest way to convert Calendar to String and back | <p>My application uses an API that accepts only a <code>Map<String, String></code>. Therefore, all objects must be converted to this form before they can be passed to the API.</p>
<p>This is quite trivial for simple classes like <code>Boolean, BigDecimal</code> etc. But it is proving somewhat problematic for converting a <code>Calendar</code> object.</p>
<p>I am not overly familiar with all the nuances of Calendars/Dates etc in Java so would appreciate some advice on converting my Calendar to a String and then back again.</p>
<p>When my application receives a request, it already has the Calendar constructed. It must then convert this to a String (1), pass it through the API (2), and then convert it back to a Calendar (3) on the other side.</p>
<p>So I am in control of 1 and 3, but not 2.</p>
<p>Based on this, what is the easiest way to convert to and then from a String?</p>
<p>Thanks</p>
| java | [1] |
3,030,347 | 3,030,348 | How to make a copy of a text file that located in another server | <p>How to make a copy of a text file that located in another server , in php</p>
| php | [2] |
5,364,535 | 5,364,536 | What does while (true){ mean in PHP? | <p>I've seen this code, and I've no idea what it means.</p>
<pre><code>while(true){
echo "Hello world";
}
</code></pre>
<p>I know what a while loop is, but what does while(true) mean? How many times will it executed. Is this not an infinite loop?</p>
| php | [2] |
1,099,224 | 1,099,225 | How can I access the button placed in datalist I want to access button text that's bind with the database table field | <pre><code><asp:DataList ID="DataList2" runat="server" DataSourceID="SqlDataSource2" onitemcommand="DataList2_ItemCommand">
<ItemTemplate>
<div class="style49">
<table style="width:100%;">
<tr>
<td class="style50">
<asp:Image ID="Image3" runat="server" Height="61px"
ImageUrl='<%# Eval("F_Image") %>' Width="48px" />
</td>
<td>
<asp:LinkButton ID="LinkButton3" runat="server" Height="25px"
TabIndex="1" Text='<%# Eval("Name") %>'
Width="92px" CommandName="view_frnd">
</asp:LinkButton>
</td>
</tr>
</table>
</div>
</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [Friends] WHERE ([Email] = @Email)">
<SelectParameters>
<asp:SessionParameter Name="Email" SessionField="uid" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
protected void DataList2_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "view_frnd")
{
Response.Write(e.CommandName.ToString());
}
}
</code></pre>
<p>Is succsessfully execute but I want to text of linkbutton that's bind with database table field. How can I access linkbutton3 text?</p>
| c# | [0] |
3,638,821 | 3,638,822 | Finding an image in a folder with subfolders which contains a post value | <p>I am using Jquery to post a value to a page which should then search a folder and its sub-folders to see where the file exists.</p>
<p>The start of the filename will always have something like "HAV_" and then the product code...</p>
<pre><code>HAV_345GG.jpg
</code></pre>
<p>I need to take the posted value which is the product code and search all folders to find a match then return the location as a link ie:</p>
<pre><code>http://www.mydomain.co.uk/folder/subfolder/HAV_345GG.jpg
</code></pre>
<p>Any help would be great.</p>
| php | [2] |
5,939,256 | 5,939,257 | How to sort NSMutableArray in ascending order, iPhone? | <p>I have SQLite Database(DB) and made this to model class and taken the data of DB in NSMutableArray. My DB is similar to this DB.
<strong>StudentName | RegisterNumber | DatesOfJoin(DoJ)</strong>
I am displaying the DoJ in tableView successfully, but I wanna sort the DatesOfJoin in Ascending order and Descending order in tableView.
Any help would be appreciated and Thanks you in advance.</p>
| iphone | [8] |
5,489,603 | 5,489,604 | calculator in c++ adding function | <p>So my program makes a random <code>(x,y)</code> arrays, what i want to do is to make <code>x</code> a real number and <code>y</code> imaginary number and add them:
my main program</p>
<pre><code> #include "complx.h"
int main(){
const int n = 2;
Complex a[n];
getData(a,n);
printArray(a,n);
isort(a,n);
printArray(a,n);
complex_sum(a,n);
return 0;
}
</code></pre>
<p>it also prints and arranges the arrays, but what I am interested in is how to add the arrays, when for example I would use 4 arrays <code>(x,y)(x,y)(x,y)(x,y)</code>.</p>
<p>this is how i get a random numbers</p>
<pre><code> void getData(Complex a[],int n){
int i;
srand(time(0)); //If comment this out, get same sequence with each run.
for(i=0; i<n; i++){
a[i].x = rand()%3; //3 and 10 are just for testing isort
a[i].y = rand()%10;
}
return;
}
</code></pre>
<p>and here is how i'm trying to add it:</p>
<pre><code>void complex_sum(Complex a[], int n){
for (int i=0; i<n; i++)
cout<<"("<<a[i].x+a[i].x<<")";
cout<<endl;
return;
</code></pre>
<p>I am stuck on how to add <code>(x,y)(x,y)= x+yi</code></p>
<p>thanks</p>
| c++ | [6] |
3,535,633 | 3,535,634 | City Name Fetching Via GetLocality | <p>I am developing an android application in which i have to fetch the current city name from server. I have achieved this in my following code. the problem is when i try to fetch the current city name and if internet connection slow at that time application is being force closed. can anyone help me how to Prevent my application being force closed.i just want to toast a simple message like "Slow internet connection". help me to get it.</p>
<pre><code>public String getCity() {
String city = "";
try
{
Geocoder geo=new Geocoder(mContext, Locale.getDefault());
Log.i("TAG","latitude"+ latitude+"\n logitude"+longitude);
List<Address> addresses=geo.getFromLocation(latitude, longitude, maxResults);
if (addresses.size() > 0)
{
Log.i("TAG",""+addresses.size()+"-"+addresses.get(0).getLocality());
city=addresses.get(0).getLocality();
}
}// end of try
catch(IOException e)
{
city="error";
}
return city;
}
</code></pre>
| android | [4] |
859,917 | 859,918 | Python Packager | <p>What is the easiest way to package Python programs into stand-alone executables?</p>
| python | [7] |
2,670,962 | 2,670,963 | What is the difference between #import and #include in C++? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/172262/c-include-and-import-difference">C++ include and import difference</a> </p>
</blockquote>
<p>Can someone explain the difference and where may I use one versus the other?</p>
| c++ | [6] |
4,592,439 | 4,592,440 | Enable "postage stamp" compatibility mode | <p>Is there a way to enable the postage stamp compatibility mode for my app? I want to port it on all tablets. Using the "Zoom to fill screen" mode is available only from the 3.2 version, so the 3.0 and 3.1 tablets won't be handled. I've tried to set the targetSdkVersion and minSdkVersion attributes to 3, but it has no effect, not even on a large screen device with the 2.3.3 API level. </p>
<p>Thanks a lot,
Grati</p>
| android | [4] |
1,973,312 | 1,973,313 | What does this block of obfuscated JavaScript do? | <p>I've seen a block of JavaScript code, that return an alert message with 1 on page load. Here is the code</p>
<pre><code>($=[$=[]][(__=!$+$)[_=-~-~-~$]+({}+$)[_/_]+
($$=($_=!''+$)[_/_]+$_[+$])])()[__[_/_]+__
[_+~$]+$_[_]+$$](_/_)
</code></pre>
<p>Can someone please explain what's going on here?</p>
| javascript | [3] |
4,631,917 | 4,631,918 | Editing a C# resource file of a compiled assembly | <p>I have a resource file where I am storing connection string etc for a class library (I cant use an App.config, don't ask why!?!).
It was my assumption (might be a stupid one) that I would be able to modify the .rex file out side of the complied assembly at runtime to be able to change connection string through environments without recompiling the assembly each time, can someone verify my assumption and if possible tell me how to do it?</p>
<p>Cheers</p>
| c# | [0] |
771,566 | 771,567 | Are there any new/updated Java web development frameworks to watch for? | <p>I know recently Spring 3.0 was released which brought about a nice new set of features and ease of web development with their MVC package. However are there any new frameworks on the horizon and/or new versions of other frameworks that a web developer should have their eyes on?</p>
<p>I heard about the Stripes framework, but it seems as though development has stopped. It also seems grails has a new release coming out as well which that looks like it is just an update to support the new features in the latest groovy release. </p>
| java | [1] |
4,789,893 | 4,789,894 | disable keypad after entering text in textfield | <p>I am new to iphone;</p>
<p>what i did is creating a 10 labels with corresponding text fields.</p>
<p>when i click on text field keypad is open.</p>
<p>But it covers the bottom 4 textfields.</p>
<p>I can't able to enter text to those fields.</p>
<p>i need when i click textfield in front of keypad screen moves up.</p>
<p>now i can able to enter in those textfields.</p>
<p>How can i done this.</p>
<p>Thank u in advance.</p>
| iphone | [8] |
3,479,709 | 3,479,710 | for loop control | <p>hey all
i want to know if there anyway that i control the for loop so if i push the button more than one time the program dose not freez and do the for loop again</p>
| c# | [0] |
3,848,960 | 3,848,961 | How to read table values in text? | <p>I am tryig to read from the textboxes in a table. How can I do it? I have the following code, but it`s not working.</p>
<pre><code><table id="dataTable">
<thead>
<tr>
<th>Name</th>
<th>Value</th>
</tr>
</thead>
<tr>
<td>
<input id="Name" type="text" value = "test1" />
</td>
<td>
<input type="text" value = "test11" />
</td>
<td>
<input type="button" value = "button11" />
</td>
</tr>
</table>
</code></pre>
<p>My actual script is as follows:</p>
<pre><code>$(document).ready(function() {
$("#Click").click(function() {
var i = 0;
var inputs = new Array();
$("#dataTable tr").find("input").each(function() {
alert($(this.value));
alert($(this.id));
inputs[i] = [this.id, this.value];
i++;
});
var columnsCount = $("#dataTable").find("th").length;
alert($(columnsCount));
});
});
<input type="button" id= "Click" value="Click" />
</code></pre>
| jquery | [5] |
5,892,715 | 5,892,716 | Questions on Javascript hoisting | <p>While I was reading about Javascript hoisting, I tried the following. I am not sure why the first one and second one output differently. Thanks in advance. (I am not even sure that this is related to hoisting. )</p>
<pre><code>var me = 1;
function findme(){
if(me){
console.log( me );//output 1
}
console.log( me ); //output 1
}
findme();
</code></pre>
<p>However the followings output undefined. </p>
<pre><code>var me = 1;
function findme(){
if(me){
var me = 100;
console.log(me);
}
console.log(me);
}
findme();
// undefined
</code></pre>
| javascript | [3] |
1,757,473 | 1,757,474 | Javascript srcElement property on IE9 | <p>I have some images in a <code>div</code> object, when mousedown event fired I use <code>n.srcElement</code> to catch the image object.</p>
<p>In Firefox it would be <code>n.target</code></p>
<p>However <code>IE9</code> doesn't work on both <code>n.target</code> and <code>n.srcElement</code> because IE9 will return div object rather than image object when use <code>n.target</code> and <code>n.srcElement</code>.</p>
<p>Question is what property can be use on IE9 in order to get image object when click a image in div object.</p>
| javascript | [3] |
4,289,947 | 4,289,948 | Dictionary for the language of javascript | <p>Is there a dictionary for the language of javascript?</p>
<p>Eg if I want to lookup what "catch" is/means/does in javascript.</p>
<p>And also to get a good overview of ALL the "words" of the language to see what "words" you have missed.</p>
| javascript | [3] |
4,867,317 | 4,867,318 | Why this copy-constructor is invoked in the program? | <pre><code>#include <iostream>
#include <string.h>
using namespace std;
class withCC
{
public:
withCC() {}
withCC(const withCC&) {
cout<<"withCC(withCC&)"<<endl;
}
};
class woCC
{
enum {bsz = 100};
char buf[bsz];
public:
woCC(const char* msg = 0) {
memset(buf, 0, bsz);
if(msg) strncpy(buf, msg, bsz);
}
void print(const char* msg = 0)const {
if(msg) cout<<msg<<":";
cout<<buf<<endl;
}
};
class composite
{
withCC WITHCC;
woCC WOCC;
public:
composite() : WOCC("composite()") {}
void print(const char* msg = 0) {
cout<<"in composite:"<<endl;
WOCC.print(msg);
}
};
int main()
{
composite c;
c.print("contents of c");
cout<<"calling composite copy-constructor"<<endl;
composite c2 = c;
c2.print("contents of c2");
}
</code></pre>
<p>The running result is below:</p>
<pre><code>$ ./a.out
in composite:
contents of c:composite()
calling composite copy-constructor
withCC(withCC&)
in composite:
contents of c2:composite()
</code></pre>
<p>And I don't understand why <code>withCC(withCC&)</code> is given as part of output. I guess <code>composite c2 = c;</code> causes copy-constructor to be executed. But as below shown, <code>WITHCC</code> is part of <code>class composite</code>, why it will be invoked to handle this copy-constructor? Thanks!</p>
| c++ | [6] |
4,017,164 | 4,017,165 | how to use com.android.mms.transaction package in my app | <p>I am working on MMS app, I need to use "com.android.mms.transaction" this package in my app..</p>
<p>please suggest me which JAR file I need to include my app to access this package..</p>
| android | [4] |
3,952,298 | 3,952,299 | Take text by class name Jquery | <p>I need to get 2 as number for future using (2)</p>
<pre><code><div class="pageCont">
<span class="link">
<span class="page">
<span class="page active">2</span>
</div>
</code></pre>
<p>I have tried <code>alert(jQuery(".page active").text());</code> do not work because I use 2 parameters. I do not know how to tell jquery to show </p>
<p>pageCont->active</p>
| jquery | [5] |
2,442,939 | 2,442,940 | Changing the next button of softkeybord to Search | <p>I want to change the next button of virtual keyboard to search button , is there any way to change the text of that next button to Search button.</p>
| android | [4] |
398,358 | 398,359 | python naming convention for plugins, i.e. non-top-level packages | <p>I'm wondering if there is naming convention for non-top-level python packages, i.e. so called plugins or extensions. According to PyPI the plugins, mostly, named with dash(-) or dot(.)</p>
<p>e.g.:
most django plugins named with dash while plone/zope and many others prefer the dot, WTF? :)</p>
<p>Thanks!</p>
| python | [7] |
5,098,097 | 5,098,098 | Limit Javascript script Internet access | <p>I have a webpage with a master script that connects, via AJAX, to a remote server and downloads unsecure JS scripts (let's call them slave scripts), to be executed lately on the client. I would like to limit the Internet access slave scripts have; e.g. they can communicate just with the remote server.</p>
<p>Do you have any idea of how can I achieve this?</p>
<p>Thanks,
Laurențiu Dascălu</p>
| javascript | [3] |
2,135,487 | 2,135,488 | Extract value between HTML-tags using JavaScript | <p>How can I extract the value between the tags (49% in message) using Javascript?
I will first parse the JSON with JSON.parse.</p>
<pre><code>{
"id": "189180337778229046",
"from": {
"name": "My FB page",
"category": "Automobiles and parts",
"id": "189180337778229046"
},
"subject": "A good deal",
"message": "<p><strong>49%</strong></p><p>This is a good deal for you.</p>",
"icon": "http://static.ak.fbcdn.net/rsrc.php/v1/yY/r/d1gBp2bDGEuh.gif",
"created_time": "2011-11-02T10:49:56+0000",
"updated_time": "2011-11-02T10:49:56+0000"
}
</code></pre>
| javascript | [3] |
4,382,003 | 4,382,004 | "this" in c# constructor? | <p>When referenced in the constructor, does the keyword this refer to the instance of the class being created?</p>
<p>For instance, I have a list of all instances of a certain class. If I put
MyList.Add(this);
at the end of the constructor, will that add the newly created class?</p>
| c# | [0] |
531,951 | 531,952 | jQuery Repeat Element with A Following Number | <p>How do I use less code here? Don't want to keep calling the div's, I want to have one name and increment the number after it.</p>
<pre><code>$('.slider1').stop().hover(function () {
$('#slider_1').fadeIn('fast');
});
$('.slider1').stop().mouseleave(function () {
$('#slider_1').hide('fast');
});
$('.slider2').stop().hover(function () {
$('#slider_2').fadeIn('fast');
});
$('.slider2').stop().mouseleave(function () {
$('#slider_2').hide('fast');
});
$('.slider3').stop().hover(function () {
$('#slider_3').fadeIn('fast');
});
$('.slider3').stop().mouseleave(function () {
$('#slider_3').hide('fast');
});
</code></pre>
| jquery | [5] |
4,022,177 | 4,022,178 | why lazy copy when we have deep copy and shallow copy? | <p>We have <strong>shallow copy</strong> and <strong>deep copy</strong> who can do the job for us when we want to copy objects in C++. So,<br>
What is <strong>Lazy copy</strong>?<br>
Is this a thing that is taken care by a programmer or compiler does this on its own?<br>
What are the programming scenarios where a lazy copy is advantageous?</p>
| c++ | [6] |
4,664,293 | 4,664,294 | PHP Format string like a chemical formula | <p>What is the best way to convert a string such as <code>CO2</code> and make it output <code>CO<sub>2</sub></code> via PHP?</p>
| php | [2] |
4,719,988 | 4,719,989 | Use the same piece of code without using macros for two different data types | <p>I want to use a single piece of code for two different data types without using macros. I tried something like this, but I did not come up with a complete solution.</p>
<pre><code>void func(bool istype1, void *ptr)
{
void *t1;
if(isType1)
t1=static_cast<type1>(ptr);
else // isType1 == false means data type 2.
t1=static_cast<type2>(ptr);
...
...
...
}
</code></pre>
| c++ | [6] |
3,550,614 | 3,550,615 | C# how to check if file is in folder according to object of filenames | <p>I have the following method:</p>
<pre><code>public static Boolean CheckContents(string ExportDirectory, string FileName, string DspFleName, String RteFleName, string FulRteName, string EqpFleName, int CompanyId, string CompanyName)
{
if (DspFleName != "None")
{
IList<string> DspFle= DspFleName.Split(',');
IList<string> ActualFiles = Directory.GetFiles(ExportDirectory);
for (int i = 0; i < DspFle.Count; i++)
{
if (DspFle[i] != ActualFiles[i])
{
return false;
}
}
}
return true;
}
}
</code></pre>
<p>Basically what this code is meant to do is get all file names from the DspFle field which is seperated by a ,. So this would look like so:</p>
<pre><code>test.txt,test2.csv
</code></pre>
<p>Then it is getting the acutal files in the directory that is specified from 'ExportDirectory' and returns those into an IList</p>
<p>I am having 2 problems here:
1.The Directory.GetFiles returns the whole file path so that will always return false. I also tried Path.GetFileNames and this only returns the file name but it does not return the extension.</p>
<p>2.I need to compare my entire DspFle to my ActualFile IList as the file names could be in different parts of the list.</p>
<p>Any ideas?</p>
| c# | [0] |
5,947,484 | 5,947,485 | anchor title attribute | <p>The title is showing only the first word when you mouse over the link. How can I get the whole order description to show? Thanks</p>
<pre><code><a title=$row[order_description] href=order.php?order_id=$row[qid]><font class=fontblueData_sub> $row[prod_title]</font></a>
</code></pre>
| php | [2] |
1,725,995 | 1,725,996 | logic for Custom Start Day and End Day for a week. (c#) | <p>We have a unique requirment where we have our own start day of a week and end day of a week(C#),</p>
<p>Contrary to the existing Date Time class whose start day is Sunday and end day is Saturday, we have Wednesday as our start day and Tuesday our EndDay (and this will vary per client).</p>
<p>and we need to implement the following logic</p>
<p>a) for a given date get the start Date of a week and end Date of a week</p>
<p>Ex: based on the above if the current day is 23/Sep/2010 (Thur) we need to get 22/Sep/2010 (Wed) as our Start Day and 28/Sep/2010 (Tue) as our end day</p>
<p>i apologize there is a correction the end day should be Tuesday (7 days a week)</p>
<p>Can anyone help here?</p>
<p>Thanks</p>
| c# | [0] |
5,550,002 | 5,550,003 | what does below java line indicates with final modifier assigned to list? | <p>Please consider my question. final values cannot be changed in java.</p>
<pre><code>private final List<Integer> list = new ArrayList<Integer>();
</code></pre>
<p>above list instantiation is of final. now i can add any elements.
after that can i assign list=null?</p>
<p>Please help me.</p>
<p>Thanks!</p>
| java | [1] |
5,790,347 | 5,790,348 | View my android app rating in my app | <p>I want to load rating of my app uploaded in android market in some app.
how to do this?
thanks</p>
| android | [4] |
971,889 | 971,890 | cant start browser from service in android | <p>Hello I am trying to start the android browser from a service using this code: </p>
<pre><code>protected void showBrowser(){
String url = "http://www.google.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
this.startActivity(i);
}
</code></pre>
<p>but this doesn't seem to work! the browser is never started and using log the execution stops when the startActivity is called.
thanks in advanced maxsap.</p>
| android | [4] |
1,392,648 | 1,392,649 | Bind click and live click | <p>Why this code works <a href="http://jsfiddle.net/Lzezc/5/" rel="nofollow">(see code at jsfiddle)</a></p>
<pre><code>$(document).ready(function() {
var html = '<div><a href="javascript:">click me</a></div>';
var $div = $(html);
$div.find('a').bind('click', function() { //attention on bind
alert('Hi');
});
$('#test').append($div);
});
</code></pre>
<p>but the same code with <code>.bind('click'</code> replaced with <code>.live('click'</code> is not working? Why?</p>
<p>Thank you.</p>
| jquery | [5] |
2,252,777 | 2,252,778 | ASP.NET runtime error: Could not load file or assembly 'Interop.CertEnroll' | <p>I have a ASP.Net 4.0 site that I am editiing in VS2010. Every @ Master and @ Page tag has the blue squiggle lines giving the following error:</p>
<p>ASP.NET runtime error: Could not load file or assembly 'Interop.CertEnroll' or one of its dependencies. An attempt was made to load a program with an incorrect format.</p>
<p>I know it is related to trying to load a 32bit dll into a 64bit application but I am not sure how to control it since I am not sure how this Iterop.CertEnroll client is evening being referenced.</p>
<p>I am targetting Any CPU for my builds.</p>
<p>My application still functions but it bothers me to see all of these warnings and I have seen hints that this may be causing issue with my AjaxToolkit server tags not being recognized.</p>
<p>Thank you!
Karl</p>
| asp.net | [9] |
3,393,566 | 3,393,567 | Saving playlist file from application | <p>I'm a newbie in android application. I would like to save an m3u file from my application to a shared folder on the phone, in order to make it available to other applications (music player) and make it survive even if user removes my application.</p>
<p>This is what I tried to do:</p>
<pre><code>String directory = MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI.getPath();
File file = new File(directory, filename + ".m3u");
</code></pre>
<p>But it does not work, i get</p>
<pre><code>java.io.IOException: No such file or directory
</code></pre>
<p>What am I doing wrong here?</p>
| android | [4] |
5,067,255 | 5,067,256 | PHPexcel CONCATENATE makes blank column | <p>i have this commands, other columns has its data, but I2 is empty, no function, nothing
i think im donig something wrong, but dont know what.
thanks</p>
<p>in I2 is this data "2012/10"</p>
<pre><code>$foo->mergeCells("B$rowCounter:E$rowCounter");
$foo->setCellValue("B$rowCounter", "Lukáš Doubek")
->setCellValue("F$rowCounter", "IČ: 77889977")
->setCellValue("H$rowCounter", "Variabilní symbol")
->setCellValue("I$rowCounter", '=CONCATENATE("LEFT(I2;4)","RIGHT(I2;2)")');
$rowCounter++;
</code></pre>
| php | [2] |
6,005,878 | 6,005,879 | Android - process life cycle? | <p>I know everything about activity life cycles, but what about the process itself? There's many projects which use the singleton pattern, where the Application class is extended to hold static objects.</p>
<p>Do these objects ever get destroyed? If so, when? Is there any documentation on this?</p>
| android | [4] |
2,761,554 | 2,761,555 | How does the load() function allow the user to provide a callback? | <p>In javascript it's very popular for libraries/frameworks to let us define a callback function for post-processing of data.</p>
<p>eg.</p>
<pre><code>load("5", function(element) {
alert(element.name);
});
</code></pre>
<p>I wonder how the load() function looks like to be able to let the user provide a callback?</p>
<p>Are there good tutorials for this?</p>
| javascript | [3] |
4,269,956 | 4,269,957 | Good Android tutorial? | <p>I am iOS developer .
I have decided to begin developing applications for android .
I have seen a lot of books and tutorials about android .
But unfortunately I did not find a book or tutorial that explain everything in details about everything in android .
For example When I want to use button clickListener I found that eclipse do everything for me .All I have to do is to put the code that will be executed when I click this button .That is great but I do not understand what is the code that represented by eclipse do so I do understand the following code </p>
<pre><code>Button btn = (Button) findViewById(R.id.btn_dialog);
btn.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
}
});
</code></pre>
<p>This is just example .
Could anyone help me to find great book or tutorial that will help me to understand everything in deep and in detail ?
Thank you</p>
| android | [4] |
830,621 | 830,622 | Window.open and modifying DOM of new window | <p>Suppose I open a new window using:</p>
<pre><code>newWindow = window.open(newUrl)
var ul = newWindow.document.getElementsByTagName("ul")[0];
ul.innerHTML = "new content";
</code></pre>
<p>However, this doesn't modify the DOM of the new window at all.. </p>
<p>Is there a way to do what I want to do? which is modify the DOM of a new window opened thru window.open?</p>
<p>Note that the last 2 lines work if I put it in the js for the opened page, so there's nothing wrong with my DOM manipulation code.</p>
| javascript | [3] |
2,136,072 | 2,136,073 | How to keep the WakeLock for as long as an application is open/running? | <p>I need to keep a SCREEN_DIM_WAKE_LOCK for as long as my application is running. Before somebody lectures me on good or bad practice and how this messes with the device's own power management, this will be on a dedicated device and are the client's express wishes.</p>
<p>Most of the places where I see this only talk about using the WakeLock for a limited amount of time while you do something for example. I've tried to get the lock at the start of the application, but it is not working.</p>
<p>My questions are:<br>
- Where should I put it so that I can keep the lock for the duration of my application?<br>
- If the lock goes out of scope in a method does it stop working? <br>
- Should I be refreshing it or something ?<br></p>
<p>How would you go about achieving something like this ?</p>
| android | [4] |
275,666 | 275,667 | How to encapsulate this variable into the string? | <p>I want to encapsulate this variable into the string, but I always get an error:</p>
<pre><code>for($i = 0; $i < $_POST['rows']; $i++) {
echo "<tr>"
for($j = 0; $j < $_POST['columns'] $j++) {
echo "<td>$_POST['row{$i}column{$j}']</td>"; // << I get an error. Please help me encapsulate this.. I'm so confused.
}
}
</code></pre>
<p>The error is:</p>
<pre><code>Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
</code></pre>
| php | [2] |
1,036,614 | 1,036,615 | Generating Random numbers: Counting the times x number has been randomly generated | <p>I am currently working with generating a random number(1-20) and counting the number of times each number has been randomly generated. In <code>textBox1</code> I choose the amount of numbers I want to generate. I display the final results in a multiline <code>textBox2</code>. The problem I am experiecing is that every time I click the button again it resets the count of times a number has been randomly generated. </p>
<p>Is there away i can click the button an x amount of times and count the times a number has been randomly generated without resetting the count? I am trying to this specifically with the help of an array. </p>
<p><strong>Code</strong></p>
<pre><code> public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Random r = new Random();
private void button1_Click(object sender, EventArgs e)
{
var n = int.Parse(this.textBox1.Text);
var y =
Enumerable
.Range(0, n)
.Select(x => r.Next(20) + 1)
.ToArray();
var sum = y.Sum();
var avg = (double)sum / (double)n;
var frequency = y.ToLookup(x => x);
textBox2.Text = String.Join(Environment.NewLine, new[]
{
"Number of times an integer was randomly generated",
String.Format("{0} {1}", sum, avg),
}.Concat(Enumerable
.Range(1, 20)
.Select(x => String.Format("{0} ({1})", x, frequency[x].Count()))));
}
}
</code></pre>
| c# | [0] |
2,371,745 | 2,371,746 | Get specific element in Json string in php problem | <p>This is my data struuture:</p>
<pre><code>array(6) {
["id"]=> string(15) "264729823543848"
["application"]=> array(2) {
["name"]=> string(7) "Prizzer"
["id"]=> string(15) "100398126714422"
}
["to"]=> array(2) {
["name"]=> string(18) "Danielle McPherson"
["id"]=> string(15) "100000204975672"
}
["from"]=> array(2) {
["name"]=> string(13) "Billy Zearott"
["id"]=> string(10) "1292797153"
}
["message"]=> string(45) "Become my Prizzer Buddie and win Real Prizes!"
["created_time"]=> string(24) "2011-08-02T06:06:39+0000"
}
</code></pre>
<p>I get this by dumping the var:</p>
<pre><code>$obj = json_decode($returned_content, true);
var_dump($obj);
</code></pre>
<p>Now I need to extract only the value <code>"100000204975672"</code> which is the third id right after <code>"Danielle McPherson"</code>. How do I do that?</p>
| php | [2] |
439,790 | 439,791 | Resolving DNS in bulk | <p>I need to resolve a large number (hundreds of thousands) of domains to IP addresses in Java. While using <code>InetAddress.getByName()</code> is feasible for small numbers it is far to slow for use in large quantities (probably because it is only sending one request at a time to the DNS server and waiting for the response before moving on to the next one).</p>
<p>Is there a more efficient way (such as sending them to the DNS server in bulk) that would cut down the time required to resolve a large number of domains?</p>
<p>At fmucar's request I'm adding the code used to try a more multi-threaded approach:</p>
<pre><code>Set<String> ips = Collections.synchronizedSet(new HashSet<String>());
int i = 0;
List<Set<String>> sets = new ArrayList<Set<String>>();
for (String host : domains) {
if (i++ % 5 == 0) {
sets.add(new HashSet<String>());
}
Set<String> ipset = sets.get(sets.size()-1);
ipset.add(host);
}
for (Set<String> ipset : sets) {
Thread t = new Thread(new DomainResolver(ips, ipset));
t.start();
}
</code></pre>
<p>At 250 per thread we peaked around 700 results per minute. Which, while better than before (<300) was still not that great when needing to resolve hundreds of thousands. Lowering it to only 5 per thread greatly speeds this up to several thousand per minute. This obviously creates an insane amount of threads though, so presently investigating doing the resolving in C to make use of <a href="http://www.chiark.greenend.org.uk/~ian/adns/" rel="nofollow">http://www.chiark.greenend.org.uk/~ian/adns/</a> </p>
| java | [1] |
2,077,326 | 2,077,327 | Need advice, how to delete uploaded photo in PHP | <p>I have a system where people upload their photo and can add glasses images on top of it. Uploaded photo are stored in folder uploads, but I dont want to store these photo. Can you advice me what is the best way to remove these photos from the server. Maybe to check the time when it was uploaded and delete all photos older than 24h or smth. Thanks for advice.</p>
| php | [2] |
5,171,307 | 5,171,308 | Read contacts all contacts (also imported from facebook, etc) | <p>According to this sample: <a href="http://developer.android.com/resources/samples/ContactManager/index.html" rel="nofollow">http://developer.android.com/resources/samples/ContactManager/index.html</a>
I wrote a simple function for getting all contacts:</p>
<pre><code> Uri uri = ContactsContract.Contacts.CONTENT_URI;
String[] projection = new String[] {
ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME
};
String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '" +
(mShowInvisible ? "0" : "1") + "'";
String[] selectionArgs = null;
String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC";
</code></pre>
<p>It works well but it dosn't return contacts imported with Facebook application (but they are visible in the Contacts application). Any idea on how to read all the contacts like in the Contacts application?</p>
<p>Thanks</p>
| android | [4] |
4,135,872 | 4,135,873 | array Storing and and asking user to search for it | <p>The Question Is Write a program that asks the user to enter 10 integers, stores these numbers in an array. The program should ask if
the user would like to search an element in the array, in which case the program should then prompt the user to enter the
number to look for. Use a recursive function find( int index, int array[] ) that does sequential search for a target in this
array.Display an appropriate message to the user after searching the element. The program should again ask if the user
would like to search another element in the same array and repeat this process if necessary.</p>
<p>i am a beginners programmer ...done this so far. I need some help..I have tried my best to solve it</p>
<blockquote>
<pre><code>#include<stdio.h>
#include<conio.h>
int main (int,int)
{
int i,n;
int size[10];
printf("\nPls Enter 10 numbers for Arrays \n");
scanf("%d",&n);
for(i=0; i<10 ;i++)
{
return 0;
}
getch();
}
</code></pre>
</blockquote>
| c++ | [6] |
2,504,957 | 2,504,958 | char array to LPCTSTR | <p>May I know how I can perform the following conversion?</p>
<pre><code>// el.strCap is char[50]
// InsertItem is expecting TCHAR pointer (LPCTSTR)
// How I can perform conversion?
// I do not have access in both "list" and "el" source code
// Hence, there is no way for me to modify their signature.
list.InsertItem(i, el.strCap);
</code></pre>
<p>And No. I do not want to use</p>
<pre><code>WideCharToMultiByte
</code></pre>
<p>They are too cumbersome to be used.</p>
| c++ | [6] |
5,637,854 | 5,637,855 | How to back out of Application from any point. | <p>I have an application that accesses a server. I have many activities that access the server for data. At various points in the application, I do a simple check to verify two things, 1) There is internet connectivity and 2) The server is not in maintenance mode or down.. If it is, I display an Activity detailing why and when the server will be back up. </p>
<p>When a user clicks back in this "Server is down" Activity, I need to exit the application. I have tried the following code/intent to call the "Server Down" activity but it doesn't work.</p>
<pre><code>Intent i = new Intent(this, ServerMaintenanceActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
</code></pre>
<p>I have looked all over and this is a very common problem faced with people typically on login/logout screens. None of the solutions I find works for me. I know it's possible because I have apps that do just this for example Spotify. </p>
<p>Any ideas? Thanks. </p>
| android | [4] |
2,753,567 | 2,753,568 | How do I add optional arguments to my function? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/34868/how-do-you-create-optional-arguments-in-php">How do you create optional arguments in php?</a> </p>
</blockquote>
<p>I built a function with 1 argument. That function is called numerous places on many, many pages on my site. I just decided that I need another parameter for this function.</p>
<p>In order to avoid "Warning: Missing argument" errors, is there any way to add a second argument with a bit of logic that tests the presence of a second argument in the calling command?</p>
<p>I do not want to go back through my entire website and try to catch and update every function call merely to throw a null value on it in order to void the error messages.</p>
<p>Thanks.</p>
| php | [2] |
88,568 | 88,569 | Removing columns in python | <p>Having a comma separated file with around 50 columns and several rows, there is a need to remove columns which are always 0 (i.e all values in that column are zero).</p>
<p>The file is read with the following piece of code:</p>
<pre><code>with open('data.txt', 'rb') as f:
reader.csv.reader(f, delimiter=',')
for row in reader:
print row
0 0.1 0.3 0.4 0
0 0.2 0.5 0.3 0
0 0.7 0.9 0.2 0
</code></pre>
<p>How one can exactly remove columns (that are 0) from this memory structure. It would be more better, if there is no re-writing and re-reading to another temporary csv file to achieve this.</p>
| python | [7] |
2,943,219 | 2,943,220 | Try Catch errors when setting attributes | <p>Is there a rule of thumb to follow for error catching while setting attributes of an object? Let's say for example that you have a Shape class as follows:</p>
<pre><code>class Shape():
def __init__(self, size):
self.size = size
</code></pre>
<p>I can do the following:</p>
<blockquote>
<p>>>> s = Shape(3)</p>
<p>>>> s.size</p>
<p>3</p>
<p>>>> s.size = "hello"</p>
<p>>>> s.size</p>
<p>'hello'</p>
</blockquote>
<p>But what if the attribute must be numeric? How do I catch TypeErrors in this situation? Do I put a try/except inside the <strong>init</strong> definition? This is my guess:</p>
<pre><code>class Shape():
def __init__(self, size):
try:
float(size)
self.size = size
except:
raise TypeError, "Value must be numeric"
</code></pre>
<p>This will catch the error on initialization but not when setting the attribute. How do I catch a TypeError when the user tries s.size = "hello" ?</p>
<p>Thank you!</p>
<p>I tried implementing the answer below and it didn't work:</p>
<pre><code>class Shape():
def __init(self, size):
self.size = size
@property
def size(self):
return self._size
@size.setter
def size(self, value):
self._size = float(value)
</code></pre>
<p>I get the following error message:</p>
<blockquote>
<p>Traceback (most recent call last): File "python_playground.py", line 18, in </p>
<pre><code>print s.size File "python_playground.py", line 9, in size
return self._size AttributeError: Shape instance has no attribute '_size'
</code></pre>
</blockquote>
| python | [7] |
1,202,578 | 1,202,579 | click through span | <p>I have a span tag that's over an input field. What I'm trying to do is when you click on the input field the span with text in it gets hidden. then on Blur it's shown. This all works using jquery. The problem is because the span is on top of the input field the input focus doesn't get triggered when you click on the span text. Is there a way to get around this and not have the span stop the input filed focus from working.</p>
| jquery | [5] |
2,930,336 | 2,930,337 | How to change link url from format html? | <p>Here is my code:</p>
<pre><code>$str = '<html><p><img src="http://test.com/images.jpg" /><img src="test.com/image2.jpg"><p><html>';
$str_rep = str_replace('/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i','http://mywebsite.com/', $str);
</code></pre>
<p>I want to replace the image URL using a regular expression. How can I do this?</p>
| php | [2] |
5,171,403 | 5,171,404 | Is it okay to write own magic methods? | <p>In my web application I often need to serialize objects as JSON.
Not all objects are JSON-serializable by default so I am using my own <code>encode_complex</code> method which is passed to the <code>simplejson.dumps</code> as follows: <code>simplejson.dumps(context, default=self.encode_complex)</code></p>
<p>Is it okay to define my own magic method called <code>__json__(self)</code> and then use code similar to the following in <code>encode_complex</code> method?</p>
<pre><code>def encode_complex(self, obj):
# additional code
# encode using __json__ method
try:
return obj.__json__()
except AttributeError:
pass
# additional code
</code></pre>
| python | [7] |
2,720,443 | 2,720,444 | Do people still dislike PHP? | <p>I've ran across a number of topics on this particular exchange site, and I've seen many many comments "stop using php" and making fun of it. I'm a php user and I find it quite good and useful, I've never had some real problems with php itself, and I never thought that php encourages bad code.</p>
<p>I have seen some terrible code. But why blame the language? I mean it's not like PHP is some kind of ol-procedural style pile of mess people describe it to be. By looking at PHP frameworks, I don't really see any mess or bad code there.</p>
<p>So do these people hate PHP because of the past (procedural mess) or do they discredit OOP and popular MVC frameworks too (not fully OOP, not like Java and stuff) ?</p>
<p>I'm not very experienced in programming and I'm not saying PHP is awesome or anything, but I've seen some Python/Java/C# and I don't see how PHP is so messy vs them.</p>
<p>What is your take on this?</p>
| php | [2] |
2,002,046 | 2,002,047 | Getting the docstring from a function | <p>I have the following function:</p>
<pre><code>def my_func():
"""My docstring is both funny and informative"""
pass
</code></pre>
<p>How do I get access to the docstring?</p>
| python | [7] |
279,893 | 279,894 | Problem using Conditional Operation with Nullable Int | <p>A small problem. Any idea guys why this does not work?</p>
<pre><code>int? nullableIntVal = (this.Policy == null) ? null : 1;
</code></pre>
<p>I am trying to return 'null' if the left hand expression is True, else 1. Seems simple but gives compilation error - </p>
<p>Type of conditional expression cannot be determined because there is no implicit conversion between 'null' and 'int'</p>
<p>If I replace the " ? <strong>null</strong> : 1 " with any valid int, then there is no problem.</p>
| c# | [0] |
6,004,030 | 6,004,031 | Name a variable on the fly | <p>I am accepting a variable into a function.</p>
<p>For example, the variable is called <code>$field</code> and I then want to name a variable by what is inside the <code>$field</code> variable.</p>
<p>Say <code>$field = 'randomName'</code>, I want my variable to be <code>$randomName</code>.</p>
<p>Is this possible?</p>
<p>Thanks.</p>
| php | [2] |
5,079,957 | 5,079,958 | Make an Android app out of website | <p>I have a small wordpress website and I wanted to try to make an Android app out of it. But, I have no idea from where to begin. I found out about App Inventor which makes it real easy to create apps. But, what I still haven't figured out is how to extract data from my website and put it into the app through the App Inventor.
Thanks~</p>
| android | [4] |
5,665,852 | 5,665,853 | Use CodeOnTime asp.net | <p>I am planning use code generator <a href="http://codeontime.com/" rel="nofollow">CodeOnTime</a> in my asp.net application. Before starting this i just want to confirm that is this reliable for big project? Is code customization is possible in CodeOnTime?</p>
<p>If some one has used CodeOnTime then please suggest me whether i should use this or not.</p>
| asp.net | [9] |
3,543,368 | 3,543,369 | remove last word in label split by \ | <p>Ok i have a string where i want to remove the last word split by \</p>
<p>for example:</p>
<pre><code>string name ="kak\kdk\dd\ddew\cxz\"
</code></pre>
<p>now i want to remove the last word so that i get a new value for name as</p>
<p>name= "kak\kdk\dd\ddew\"</p>
<p>is there an easy way to do this</p>
<p>thanks</p>
| c# | [0] |
5,164,064 | 5,164,065 | What is the difference between new Object and new Object() in JavaScript | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3034941/new-myobject-vs-new-myobject">new MyObject(); vs new MyObject;</a> </p>
</blockquote>
<p>In some articles I seen following statement to create new object in JavaScript:</p>
<pre><code>var myObject = new Object;
</code></pre>
<p>and at some sites:</p>
<pre><code>var myObject = new Object();
</code></pre>
<p>In there is any difference between two statements or one is just shorthand?</p>
| javascript | [3] |
4,064,441 | 4,064,442 | What C# type stands for C++ float*? | <p>i have a function which is called from a library in C++ that has been imported to a C# project</p>
<p>I think it is asking for a pointer to an array. But I'm not sure how to make it work.</p>
<p>here is what it is asking for <code>function(float*, float*);</code></p>
<p>but if i do something like </p>
<pre><code>float[] f = {};
float[] f1 = {};
function(f,f1);
</code></pre>
<p>it says there are invalid arguments.</p>
| c# | [0] |
3,459,854 | 3,459,855 | Need help with an android layout question | <p>I need to have a linear Layout whose height is wrap_content,
but how can I specify a child of this linear layout to stretch to its parent?</p>
<p>I tried
... some other children ...
</p>
<p>But this does not work. The image does not scretch.</p>
| android | [4] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.