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 |
|---|---|---|---|---|---|
1,629,287 | 1,629,288 | Decryption function | <p>I have this function which decrypts encrypted message. First letter in the encrypted text is a signal character. </p>
<pre><code>function decryptWord(cipherText, indexCharacter, plainAlphabet, cipherAlphabet)
{
var signalCharacter = cipherText.charAt(0);
var decryptedString;
cipherAlphabet = rotateToPosition(signalCharacter, indexCharacter, plainAlphabet, cipherAlphabet);
for (var count = 1; count<cipherText.length; count++)
{
var singleLetter = cipherText.charAt(count);
var i = cipherAlphabet.indexOf(singleLetter);
decryptedString = decryptedString + plainAlphabet[i];
}
return decryptedString;
}
</code></pre>
<p>I'm looking for word JAVASCRIPT as a result but i get 'undefinedJAVASCRIPT' is that because when the first loop is being carried out there is no value assigned to decryptedString? is there a way to go around it? Thanks.</p>
| javascript | [3] |
2,510,455 | 2,510,456 | .ics attachment Issue in yahoo mail | <p>I am sending meeting events from my service . so i am generating .ics file in icalendar format and sending to defferent mail clients.</p>
<p>My Aim is to get the event dates enter code here be imported to the calendar automatically and should be able to send response to my service by clicking ( yes, no , maybe if gmail) Accept , decline, tentative.</p>
<p>in all other clients My goal has been achived except Yahoo, and Hotmail.<br>
In Yahoo Mail it is showing attachment as inline</p>
<p>can anybody please help why my ics file has not been understandable by yahoo and hotmail?</p>
<p>Thanks</p>
<p>Appu</p>
| python | [7] |
3,882,440 | 3,882,441 | Represent Graph as a 2d Matrix | <p>Lets say I have a graph of x nodes. I want to first represent it and then with help of a Algorithm Y, I would assign value to each of the node. Then I want to refresh the graph to display the value calculated.</p>
<p>Steps
1) Represent the graph as 2d Matrix. Perform processing over the 2d Matrix and then use the result to generate a new graph. [Better than doing processing by iterating the graph]</p>
<p><strong>Problems</strong>:</p>
<p>1) I need to create a 2d Array with indexes as node names i.e string. I am not sure what's the best way to do this?</p>
<p>2) What's the best graph api which can A) produce good looking results 2) user friendly 3) allows vertex names as strings </p>
<p>I hope I made myself clear. Any input would be of immense help.</p>
<p>Thanks
Sunil</p>
| java | [1] |
3,146,373 | 3,146,374 | Jquery each, how to apply to element and not object? | <p>So i need to use tiptip (a tip plugin) like this:</p>
<pre><code>$('#my-element').tipTip('show');
</code></pre>
<p>In my code I have:</p>
<pre><code>var cells = $('.' + all_cells); //cells refers to all div's with class cells
cells.each(function() {
$(this)
.removeClass('my_links') //fine
.append('<div class="temp"></div>') //fine
.tipTip({ edgeOffset: 10, delay: 0, fadeIn: 0 }); //fine
.tipTip('show') //syntax error
</code></pre>
<p>I guess this is because cells isn't an element but an object. </p>
<p>Similarly,</p>
<pre><code> $('.' + all_cells)
.attr('title', 'something'))
.tipTip({ edgeOffset: 10, delay: 0, fadeIn: 100, fadeOut: 100, maxWidth: "300px" });
.tipTip('show') //syntax error
</code></pre>
<p>How can I use tipTip('show'); in these loops please?</p>
| jquery | [5] |
874,959 | 874,960 | jQuery is not defined $ is not defined $(...).scrollable is not a function | <blockquote>
<p>Error: ReferenceError: jQuery is not defined /js/jquery.tools.min.js</p>
<p>Error: ReferenceError: $ is not defined /js/popup.js</p>
<p>Error: TypeError: $(...).scrollable is not a function /js/carousel.js</p>
</blockquote>
<pre><code><script type="text/javascript" src="js/jquery.tools.min.js"></script>
<script type="text/javascript" src="js/popup.js"></script>
<script src="ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"; type="text/javascript"></script>
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/…; type="text/javascript"></script>
<script src="js/jquery-ui-1.8.21.custom.min.js" type="text/javascript"></script>
<script src="js/jquery-timer.js" type="text/javascript"></script>
</code></pre>
<p>I am getting these errors. Please, can somebody give me some advice?</p>
| jquery | [5] |
100,336 | 100,337 | Android Application uses file that doesnt exist on the server anymore | <p>I have implemented an android application that downloads an image from a server and sets as wallpaper. After deleting the <code>first image(image1)</code> and uploading another one to the server <code>(image2)</code>; some devices are getting <code>image2</code> and setting it as wallpaper and on some devices get a weird behavior of getting <code>image1</code> and setting it as wallpaper. <code>image1</code> doesn't exist on the server. I have tried to clear the app cache and the app data but neither worked and the image1 is still being set. Any ideas? Thank you
NB:The two images have the same name on the server. </p>
| android | [4] |
4,779,560 | 4,779,561 | Swype Keyboard implementation | <p>My Activity contains three Buttons and I set the onTouchListener for them. If I touch on any button and move I should be able to get the text of the buttons on which I moved.Also I should draw a continuous line following the Touch Events.I am able to trace the path but failing to draw the path.
I am presenting the following code I implemented. Please let me know what I am missing to complete the task. If possible explain with code.</p>
<pre><code>public class MyActivity extends Activity {
private Button btn1,btn2,btn3;
private EditText editText;
private float x1,y1,x2,y2;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btn1=(Button)findViewById(R.id.button1);
btn2=(Button)findViewById(R.id.button2);
btn3=(Button)findViewById(R.id.button3);
editText=(EditText)findViewById(R.id.editText1);
btn1.setOnTouchListener(myTouchListener);
btn2.setOnTouchListener(myTouchListener);
btn3.setOnTouchListener(myTouchListener);
}
public boolean OnTouch(View view,MotionEvent event){
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
x1=view.getX();
y1=view.getY();
break;
case MotionEvent.ACTION_MOVE:
x2=view.getX();
y2=view.getY();
canvas.drawLine(x1,y1,x2,y2,paint);
x1=x2;
y1=y2;
break;
case MotionEvent.ACTION_UP:
x2=view.getX();
y2=view.getY();
canvas.drawLine(x1,y1,x2,y2);
break;
}
}// code ends
</code></pre>
<p>I know that I need to extend the View class and override the onDraw() method to draw line.
But I am unable to complete it. so please someone help me to finish it.
Please post the total code. Ur efforts towards the solution will be thanked!!</p>
| android | [4] |
905,433 | 905,434 | Datastructure to map Class objects to values while considering superclasses? | <p>Is there a map like data structure that uses Java Class objects as keys but uses fallback to superclasses if no mapping is found? Let me give a short example:</p>
<pre><code>ClassMap<Integer> map = new ClassMap<Integer>();
map.put(Object.class, 1);
map.put(Number.class, 2);
assertEquals(1, map.get(String.class));
assertEquals(2, map.get(Number.class));
assertEquals(2, map.get(Double.class));
</code></pre>
<p>I know that I could do the fallback manually, e.g.</p>
<pre><code>WeakHashMap<Class<?>, Integer> map = // snip
Class<?> cls = Double.class;
Integer i;
do {
i = map.get(cls);
cls = cls.getSuperclass();
} while (i == null && cls != null);
</code></pre>
<p>Still I'm interested in existing or alternative solutions.</p>
| java | [1] |
4,209,982 | 4,209,983 | Android Graphics issue for seekbar background | <p><img src="http://i.stack.imgur.com/68CJl.png" alt="enter image description here"></p>
<p>So I have this image set as the background of a seekbar. On different screens, the image gets skewed so much that it is quite horrible. I tried doing a 9 patch, but obviously there are several regions I would like to scale so 9 patch wasnt the best option. What I would like to acheive is, have the background stretched and leave the numbers proportional. The numbers tend to eith stretch too much or shrink too much. </p>
<p>Any help is appreciated. </p>
<p>Thanks</p>
| android | [4] |
5,293,336 | 5,293,337 | Why isn't parseInt a method? | <p>Why is parseInt a function instead of a method?</p>
<p>Function:</p>
<pre><code>var i = parseInt(X);
</code></pre>
<p>Method:</p>
<pre><code>var i = X.parseInt();
</code></pre>
| javascript | [3] |
4,254,496 | 4,254,497 | How inheriting static fields affects the performance? | <p>Since static fields objects are created at class level(and common to all objects), Is it static import on particular fields and inheriting(using implements) all the fields will create same amount of memory? </p>
<p>For Example In this below propgram how many MyOwn objects are created? </p>
<pre><code>class MyOwn{}
public interface ConstantIfc {
public final static MyOwn REF = new MyOwn();
}
class A implements ConstantIfc {}
class B implements ConstantIfc {}
public class c {
public static void main(String... arg) {
A refA = new A();
B refB = new B();
}
}
</code></pre>
<p>If it is same how final constant class for static import is better than constant interface?</p>
<p>Update: <BR>
I understood that It is better to avoid Inherittance for constants. Improperly leveraging implementation inheritance often leads to inflexible design. So we can better go for static import of class/interface. but still Interfaces are an abstraction, and to remain abstract, they should not contain implementation details (including constant variables.) Interfaces also are often used to describe a public API, in which implementation details do not belong. For this reason it makes sense to put constant data into a class, rather than an interface. Thanks robjb.</p>
| java | [1] |
707,845 | 707,846 | How do I declare multiple vars in JavaScript's "for" statement? | <pre><code>for(var i = 0, var p = ''; i < 5; i++)
{
p += i;
}
</code></pre>
<p>Based on a JavaScript book i'm reading, this is valid code. When I test it doesn't work, and in FireBug I get this error:</p>
<pre><code>SyntaxError: missing variable name
</code></pre>
| javascript | [3] |
4,804,557 | 4,804,558 | Is it possible to send an MMS from an iPhone app | <p>I have searched around and cant find a solution or even a mention of it. I wondered if it is possible. </p>
<p>Can an MMS be sent from within an app?</p>
| iphone | [8] |
5,730,020 | 5,730,021 | Safe Background size | <p>So I want to use a png as the background for my android application. </p>
<p><img src="http://i.stack.imgur.com/mZl5e.png" alt="Sample Background"></p>
<p>The condition is that the biggest snowflake:</p>
<p><img src="http://i.stack.imgur.com/JQuZC.png" alt="Big Snowflake"></p>
<p>is always at the top right corner. I can scale the image proportionately only, because otherwise, the snowflake will end up looking like a bunch of I don't know whats:</p>
<p><img src="http://i.stack.imgur.com/d3gad.png" alt="Thorns"></p>
<p>Given the plethora of device resolution and dpi's available, what is a reasonable way to achieve what I want? </p>
<p><strong>Update:</strong>
I am aware of 9-patch. But my background cannot be expressed in terms of a 9-patch. At best, what I can do is include the source in the largest dimensions (proportionately) possible. In my case, the source is 1920X2400 in size. To rephrase my question, what would be the safest size (with uniform scaling) to include in my app?</p>
<p>Here's an example:</p>
<p><img src="http://i.stack.imgur.com/803In.png" alt="Non-9Patch drawable"></p>
<blockquote>
<p>Image copyright of original authors. Used here, only for illustration.</p>
</blockquote>
| android | [4] |
4,830,785 | 4,830,786 | Creating an empty Drawable in Android | <p>Creating a Drawable that is completely empty seems like a common need, as a place holder, initial state, etc., but there doesn't seem to be a good way to do this... at least in XML. Several places refer to the system resource <code>@android:drawable/empty</code> but as far as I can tell (i.e., it's not in the reference docs, and aapt chokes saying that it can't find the resource) this doesn't exist.</p>
<p>Is there a general way of referencing an empty Drawable, or do you end up creating a fake empty PNG for each project?</p>
| android | [4] |
111,378 | 111,379 | ERROR/ActivityManager(98): Reason: keyDispatchingTimedOut | <p>i playing live video from api in my app. when i click play video then Progress dialog will come in between progress when i press back button 2 or 3 times of device then after some times it will give this error </p>
<pre><code>ERROR/ActivityManager(98): Reason: keyDispatchingTimedOut
</code></pre>
<p>so how i can handle this error plz give me solution.
Thnax in advace.</p>
| android | [4] |
5,414,767 | 5,414,768 | Having trouble with a toString() method | <p>I am making a program that keeps up with hot dog stands and sells hotdogs. This program is composed of two files, the first one I got to work fine that has the hot dog stand class in it. Now I am moving on and stuck on a <code>toString()</code> method where it keeps telling me that it is the illegal start of the expression. I am still pretty new to the toString method and am confused why it would say that. Here is the code</p>
<pre><code>public class TheHotDogStands
{
public static void main(String[]args)
{
HotDogStand one = new HotDogStand ("Bob's hotdog stand" , "0081" , "5");
HotDogStand two = new HotDogStand ("Chris's hotdog stand" , "4591" , "3");
HotDogStand three = new HotDogStand ("Matt's hotdog stand" , "1171" , "10");
public String toString()
{
System.out.println("Total sold =" + (one.getNumSold() + two.getNumSold() + three.getNumSold()) + "\n");
}
one.SetJustSold();
two.SetJustSold();
three.SetJustSold();
System.out.println(one.getName + one.getID + one.getNumSold);
System.out.println(two.getName + two.getID + two.getNumSold);
System.out.println(three.getName + three.getID + three.getNumSold);
System.out.println("Total sold for all stands = " + (one.getNumSold() + two.getNumSold() + three.getNumSold()));
public one(one aOne)
{
nameHotDogStand = aNameHotDogStand;
IDnumber = aIDnumber;
hotDogsSold = aHotDogsSold;
}
}
</code></pre>
<p>Do I need to turn the <code>System.out.println</code> to "return" instead? Any info on what I did wrong would be appreciated.</p>
| java | [1] |
1,542,806 | 1,542,807 | how to check image is visible or not? | <p>The code below can checks if the image is visible or not.</p>
<pre><code>$('#div1 img:visible')
</code></pre>
<p>Which selects all image descendants and:</p>
<pre><code>$('#div1 > img:visible')
</code></pre>
<p>I just need to know that when I iterate over every image in a container like dgImages <code>$("#dgImages] img").each(function () {}</code> how I can determine that the image is visible or not ? Can I write something like <code>if($(this:visible)){//Do something}</code>?. Thanks.</p>
| jquery | [5] |
1,705,028 | 1,705,029 | Class method chaining | <p>I have the following code but it does not seem to want to work chained.</p>
<pre><code> $this->view->setData($class_vars);
$this->view->render('addview');
</code></pre>
<p>The above works and runs fine but when i try to do the following:</p>
<pre><code> $this->view->setData($class_vars)->render('addview');
</code></pre>
<p>I get the following error:</p>
<blockquote>
<p>Fatal error: Call to a member function render() on a non-object in....</p>
</blockquote>
<p>But the strange thing is when i call it the other way:</p>
<pre><code> $this->view->render('addview')->setData($class_vars);
</code></pre>
<p>It runs, but I need the setData to run first as this sets up the var for the actual view, so even though i get the view its got errors where the vars should be? Both methods are public?</p>
<p>Thanks You</p>
| php | [2] |
1,963,432 | 1,963,433 | Should class.getPackage() return manifest.mf information for an unpacked manifest? | <p>An experiment seems to show that having META-INF/MANIFEST.MF in a directory in classpath is not sufficient to cause Class.getPackage().getImplementationVersion() to return a value, at least, a top-level value. </p>
<p>That is, of my manifest.mf contains:</p>
<pre><code>Implementation-Version: 4.3.100
</code></pre>
<p>(nothing per-package), I'm assuming that Class.getPackage().... will return the string for all classes in the JAR file, and this does not seem to work when the files are 'loose'.</p>
<p>Have I misunderstood the contract or do I need to look or something stupid?</p>
| java | [1] |
1,658,371 | 1,658,372 | python: unhashable type error | <pre><code>Traceback (most recent call last):
File "<pyshell#80>", line 1, in <module>
do_work()
File "C:\pythonwork\readthefile080410.py", line 14, in do_work
populate_frequency5(e,data)
File "C:\pythonwork\readthefile080410.py", line 157, in populate_frequency5
data=medications_minimum3(data,[drug.upper()],1)
File "C:\pythonwork\readthefile080410.py", line 120, in medications_minimum3
counter[row[11]]+=1
TypeError: unhashable type: 'list'
</code></pre>
<p>i am getting this error on this line:</p>
<pre><code>data=medications_minimum3(data,[drug.upper()],1)
</code></pre>
<p>(i have also tried drug.upper() without brackets</p>
<p>here is a preview of this function:</p>
<pre><code>def medications_minimum3(c,drug_input,sample_cutoff): #return sample cut off for # medications/physician
d=[]
counter=collections.defaultdict(int)
for row in c:
counter[row[11]]+=1
for row in c:
if counter[row[11]]>=sample_cutoff:
d.append(row)
write_file(d,'/pythonwork/medications_minimum3.csv')
return d
</code></pre>
<p>does anyone know what am i doing wrong here?</p>
<p>i know that what must be wrong is the way i am calling this function, because i call this function from a different location and it works fine:</p>
<pre><code>d=medications_minimum3(c,drug_input,50)
</code></pre>
<p>thank you very much for your help!</p>
| python | [7] |
2,821,146 | 2,821,147 | PHP and access to a global object from everywhere | <p>I have a global object, a "registry", it is a container with other important objects:</p>
<ul>
<li>Input object. </li>
<li>Output object. </li>
<li>DB object with connection. </li>
<li>Logging object. </li>
<li>Session object.</li>
</ul>
<p>I need to have this global object in every place (object), where I process my request. </p>
<p>Like in my JBoss environment, where I have one Stateful Session Bean as a front controller, which directs the processing to a special Stateless Session Bean, I have one entry point, "facade.php". </p>
<p>In this facade.php, I create the global object and place the other objects (input object, ...) into it.</p>
<p>Then there is a large switch statement, where I redirect the request to special processing objects.</p>
<p>Is there a method, mechanism, to have access to this general object from the processing objects without handing it over as a parameter?</p>
| php | [2] |
1,614,718 | 1,614,719 | I need to find the distance between the element and the bottom of the browser window | <p>I need to find the distance between the element and the bottom of the browser window.</p>
<p>So when I select the element, and the distance between the element and the bottom of the browser window is smaller than 50px, i want to make the window scroll automatically.</p>
<p>Any Ideas?</p>
<p>Wish Jquery...</p>
| jquery | [5] |
1,479,356 | 1,479,357 | Do I need to set initial values in my class constructor? | <p>I have the following class:</p>
<pre><code>public class Detail
{
public Detail()
{
this.File = String.Empty;
this.State = false;
this.Tag1 = 0
}
public string File { get; set; }
public bool State { get; set; }
public int Tag1 { get; set; }
}
}
</code></pre>
<p>Do I need to set the initial values like this in the constructor or will these just default when I create the class. How about programming practice. Does it look better to set them here even if not needed?</p>
| c# | [0] |
3,723,993 | 3,723,994 | Unassigning a variables value from $_GET | <p>I use;</p>
<pre><code>$referrer = $_GET['_url'];
</code></pre>
<p>If I <code>echo $referrer;</code> it will display correctly.</p>
<p>If I use $referrer within a $_POST, it is empty. I think due to $referrer being assigned to $_GET.<br>
How can I extract the <em>value of $referrer</em> into another variable so it is no longer assigned to the $_GET? </p>
<p>I hope that makes sense..</p>
| php | [2] |
1,949,922 | 1,949,923 | How can i split the string only once using C# | <p>Example : a - b - c must be split as
a and b - c, instead of 3 substrings</p>
| c# | [0] |
1,288,146 | 1,288,147 | How to merge CursorLoader | <p>How can I merge cursor loader in the following case to get one Cursor loader. I am calling content provider more than one to create my database adapter to use with simple cursor adapter. Please look my code below.</p>
<pre><code>@Override
public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {
productIdCursor.moveToFirst();
CursorLoader cursorLoader;
// CursorLoader cursorLoader;
int i = 0;
while (productIdCursor.isLast()) {
String[] Projection = { "p.id as _id", "p.name", "p.subTitle",
"p.textColour", "pi.thumb" };
String userSelectionCritera = "p.id = pp.prod_id and pp.imag_id = pi.id and p.id= ? and p.id = pc. prod_id and pc.coun_id = ?";
String[] selecttionArgs = new String[] {
productIdCursor.getString(productIdCursor
.getColumnIndex("prod_id")),
String.valueOf(countryId) };
cursorLoader = new CursorLoader(getActivity(),
DatabaseContentProvider.CONTENT_URI_PRODUCTCATEGORY,
Projection, userSelectionCritera, selecttionArgs, null);
productIdCursor.moveToNext();
}
return cursorLoader;
</code></pre>
| android | [4] |
2,369,837 | 2,369,838 | JavaScript Object/Array access question | <p>Set an object, with some data.</p>
<pre><code>var blah = {};
blah._a = {};
blah._a._something = '123';
</code></pre>
<p>Then wish to try and access, how would I go about doing this correctly?</p>
<pre><code>var anItem = 'a';
console.log(blah._[anItem]);
console.log(blah._[anItem]._something);
</code></pre>
| javascript | [3] |
3,179,351 | 3,179,352 | How can i play different video files in android application? | <p>i am developing an android application. In my application i need to play different format video files which are coming from server. My application getting the video links from server. Those are different formats like avi,flv,mkv,mp4. I tried to played .3gp file link successfully but the remaining formats are not supported. May be android supports only .3gp.
I tried a way to play the video links in web view and got failed. Please suggest me is there any way to play the avi,flv,mkv,mp4 file formats.</p>
<p>Thanks in advance.</p>
| android | [4] |
394,101 | 394,102 | Assigning base struct to derived struct | <p>I use a struct to represent data that is written to a file. If I need to add members to this struct (i.e. save out extra data) I create a new struct (this represents a new version of the dataset) that derives from the original one. So for example:</p>
<pre><code>struct data1
{
int stuff1;
int stuff2;
};
struct data : data1
{
int stuff3;
};
</code></pre>
<p>Backward compatibility is maintained by checking if we're loading <code>data1</code>, and if so, convert it to <code>data</code> (and value-initialize only those new members in <code>data</code>). What would be the best way to do this? Here is what I've started:</p>
<pre><code>if( loaded_data.size() == sizeof(data1) ) {
// Old data format detected, upgrade to new structure
data d = data(); // value-initialize everything
// TODO: Assign 'data1' to 'data'
}
</code></pre>
<p>I've thought of putting a constructor in <code>data</code> to copy from a <code>data1</code>, but then that breaks the free value-initialization I get (I'd have to implement my own default constructor at that point). Should I use memcpy(), or is there a better more built-in way (perhaps some trick with copy semantics)?</p>
| c++ | [6] |
5,811,743 | 5,811,744 | why without var? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1470488/difference-between-using-var-and-not-using-var-in-javascript">Difference between using var and not using var in JavaScript</a> </p>
</blockquote>
<p>seems stupid question but just curious.</p>
<pre><code>num = "hello";
alert(num);
</code></pre>
<p>why is this possible I didnt initialize the num variable here.</p>
<pre><code>num = "hello";
</code></pre>
<p>instead of</p>
<pre><code>var num = "hello";
</code></pre>
| javascript | [3] |
5,122,099 | 5,122,100 | (android) How to do something on app "launch"? | <p>I know Android's Activity model is a bit different from what I usually consider to be an "app".</p>
<p>I want to do something (in this case, check some notifications on a server and show them if available) when my app is "launched". What is a good way to accomplish this?</p>
<p>I likely don't want to do it in an activity's OnCreate, since each activity can be created any number of times - the code would get called more often than necessary.</p>
<p>The app also has multiple entry points - would I have to duplicate the check in each activity?</p>
<p>What I'm thinking of doing is setting up this code inside the Application object, along with a flag that tracks whether it's already been called - and just call it from each Activity's onCreate().</p>
<p>Is there a better or more "proper" way to do this?</p>
| android | [4] |
1,459,215 | 1,459,216 | assign onclick event to function | <p>I want to call a function onclick and pass the event object to the function:</p>
<pre><code> progressBarOuter.onclick = function(e) {
var x; if (!e) {
x=window.event.clientX;
}
else {
x = e.clientX
}
yt.clickedOffset = x; yt.progressBarClicked
}
</code></pre>
<p>So i'm assigning clickedOffset to by enclosing object (yt) and then calling progressBarClicked which then uses the clickedOffset var. But what I actually would rather be doing is something like this:</p>
<pre><code>progressBarOuter.onclick = yt.progressBarClicked(e);
</code></pre>
<p>Because it's much more compact. Problem is that even if the user has clicked or not this bit of code is executed... yt.progressBarClicked(e). </p>
<p>Is there any way around this?</p>
| javascript | [3] |
3,554,462 | 3,554,463 | Killing process in onPause() | <p>I want to kill my Activity process when I pause it by answering a call or something like that
but when i try to start my app it closes instantly. Any solutions? Sample code below</p>
<pre><code>@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Things to do
}
//@Override
public void onPause() {
super.onPause();
android.os.Process.killProcess(android.os.Process.myPid());
}
</code></pre>
| android | [4] |
1,632,218 | 1,632,219 | jQuery API Browser using raw XML from jquery site and XSLT. How to generate and embed runnable code? | <p>I have developed a jQuery API browser from the raw XML available from <a href="http://api.jquery.com/api/" rel="nofollow">http://api.jquery.com/api/</a> they also have a Dynamic API browser which is built from this XML i guess <a href="http://api.jquery.com/browser/" rel="nofollow">http://api.jquery.com/browser/</a> but it is slightly difficult to navigate because you do not get to see all the API of one type together, you can only see the details when you click on one of the links. So to overcome this difficulty i have built my own API browser with this raw XML. This is what I have <a href="http://samarjit.net78.net/jquerybrowser/jquery.apitest2.xml" rel="nofollow">http://samarjit.net78.net/jquerybrowser/jquery.apitest2.xml</a>. build with XSLT mostly and 4 javascript functions. I did the navigation simplistic and with minimum code and minimum javascript parsing as this XML is big. Left side is menu right side is snapshot of similar APIs and middle is details description. The pages gets loaded only once and hence its fast.</p>
<p>This is what I wanted to share.
There is a possibility to create dynamically, demo sections.
I couldn't figure out how to create sample executable code dynamically from snippets of <code><css>, <code> and <html></code> dynamically. The codes look so different some methods needs to be called on <code>$(document).ready()</code> but some are normal functions which should be outside closures.</p>
<p>I would also like to learn some scalable implementation methods, given that generated HTML is quite big.
I do not want to create many <code><iframes/></code> which will download lot of files while initial loading. </p>
| jquery | [5] |
557,942 | 557,943 | Build android open source project | <p>I try to build FBReader project(http://code.google.com/p/fbreaderplus/source/checkout). How to add libraries which described in README.build? When I make project with cygwin got such messages:</p>
<pre><code>make[2]: Entering directory `/cygdrive/c/Users/Argentum/Desktop/fbreader/zlibrar
y/text/src/model'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/cygdrive/c/Users/Argentum/Desktop/fbreader/zlibrary
/text/src/model'
make[2]: Entering directory `/cygdrive/c/Users/Argentum/Desktop/fbreader/zlibrar
y/text/src/area'
Compiling ZLTextParagraphBuilder.o ...In file included from ZLTextParagraphBuild
er.cpp:30:0:
ZLTextParagraphBuilder.h:26:29: fatal error: fribidi/fribidi.h: No such file or
directory
compilation terminated.
/cygdrive/c/Users/Argentum/Desktop/fbreader/zlibrary/text/../../makefiles/subdir
.mk:14: recipe for target `ZLTextParagraphBuilder.o' failed
make[2]: *** [ZLTextParagraphBuilder.o] Error 1
make[2]: Leaving directory `/cygdrive/c/Users/Argentum/Desktop/fbreader/zlibrary
/text/src/area'
Makefile:25: recipe for target `.objects' failed
make[1]: *** [.objects] Error 1
make[1]: Leaving directory `/cygdrive/c/Users/Argentum/Desktop/fbreader/zlibrary
/text'
Makefile:9: recipe for target `all' failed
make: *** [all] Error 1
</code></pre>
| android | [4] |
1,039,921 | 1,039,922 | How to display a phone number in an iphone webapp? | <p>I have a webapplication that runs on an iphone and I would like to display a phone number on it. How can I make this so that when the phone number is clicked then the phone number will be dialled?</p>
| iphone | [8] |
5,758,371 | 5,758,372 | (MDM) - Android Remote Device management | <p>I have an task to implement remote device management, The use case is Admin have take control over the enterprise based mobile devices, admin can able to delete all device data over remote(wipe out/lock the device) when the device stolen. I gone through that Android device management API, but I need of someone to elaborate the implementation procedure involved over this.</p>
| android | [4] |
3,460,629 | 3,460,630 | Class.forName is giving ClassNotFound Exception | <p>I am using the following code ::</p>
<pre><code>String className = "SmsHelper"
Class c = Class.forName(className);
</code></pre>
<p>And I am getting the following </p>
<p>stackTrace ::</p>
<pre><code> inside main java.lang.ClassNotFoundException: SmsURLHelper
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.tcs.sms.actions.SmsUtil.invoke(SmsUtil.java:131)
</code></pre>
<p>Note : The SmsHelper class is present.</p>
<p>Please suggest if I have missed any thing.</p>
| java | [1] |
1,988,177 | 1,988,178 | How to show only Month and Year in datapicker using datapicker dialog box | <p>Please tell me how to show only Month and Year in Datapicker using Datapicker dialog box</p>
<pre><code>private DatePickerDialog.OnDateSetListener mDateSetListener2 = new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
try {
Log.e("","myear"+mYear_1+","+"myear"+mMonth_1+","+mDay_1);
Field f[] = mDateSetListener2.getClass().getDeclaredFields();
for (Field field : f) {
if (field.getName().equals("mDatePicker")) {
field.setAccessible(true);
Object dayPicker = new Object();
dayPicker = field.get(mDateSetListener2);
((View) dayPicker).setVisibility(View.GONE);
}
}
} catch (SecurityException e) {
Log.e("ERROR", e.getMessage());
}
catch (IllegalArgumentException e) {
Log.e("ERROR", e.getMessage());
} catch (IllegalAccessException e) {
Log.e("ERROR", e.getMessage());
}
}
};
</code></pre>
| android | [4] |
304,697 | 304,698 | error with onunload event | <p>I've got a problem with the <code>onunload</code> event testing script
it must fire only on the window <code>onunload</code>
but it fires with load as well.. Why?
There is something wrong, and I don't know what it is..
Please help</p>
<p>Here is the html code</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function hello(){alert("welcome to my page");}
</script>
<script type="application/javascript" src="script.js"></script>
</head>
<body onload="hello()" >
</body>
</html>
</code></pre>
<p>and here's the script code</p>
<pre><code>window.onunload = goodbye();
function goodbye(){
alert("Thank you for visiting.come back soon!");
}
//window.addEventListener('unload',goodbye(),false);
</code></pre>
<p>I've tried the inline calling with body tag, the <code>window.onunload</code> calling and the listener calling.
Nothing works correctly, and I get the "Thank you for visiting. come back soon!" message when the page first loads.</p>
| javascript | [3] |
5,814,928 | 5,814,929 | php string function to get substring before the last occurrence of a character | <pre><code>$string = "Hello World Again".
echo strrchr($string , ' '); // Gets ' Again'
</code></pre>
<p>Now I want to get "Hello World" from the <code>$string</code> [The substring before the last occurrence of a space ' ' ]. How do I get it??</p>
| php | [2] |
3,186,428 | 3,186,429 | Java non static method playCompletely cannot be referenced from a static context | <p>I've been trying to create a method (in a separate class) that takes a String as a parameter and uses a premade SoundEngine (a different class) object to play that file inputted as a string. This is the code I have so far. The problem comes up with<br>
SoundEngine.playCompletely(file);</p>
<pre><code>import java.util.ArrayList;
public class AudioFileList
{
// Field for a quantity of notes.
private ArrayList<String> files;
// Constructor that initializes the array field.
public AudioFileList()
{
files = new ArrayList<String>();
}
// Method to add file names to the collection.
public void addFile(String file)
{
files.add(file);
}
// Method to return number of files in the collection.
public int getNumberOfFiles()
{
return files.size();
}
// Method to print the strings in the collection.
public void listFiles()
{
int index = 0;
while(index < files.size())
{
System.out.println( index + ":" + files.get(index));
index++;
}
}
// Method that removes an item from the collection.
public void removeFile(int fileNumber)
{
if(fileNumber < 0)
{
System.out.println ("This is not a valid file number");
}
else if(fileNumber < getNumberOfFiles())
{
files.remove(fileNumber);
}
else
{
System.out.println ("This is not a valid file number");
}
}
// Method that causes the files in the collection to be played.
public void playFile(String file)
{
SoundEngine.playCompletely(file);
}
}
</code></pre>
<p>Any help is very much appreciated.</p>
| java | [1] |
3,067,668 | 3,067,669 | PHP 5.3 and interface \ArrayAccess | <p>I'm now working on a project and I have one class that implements the ArrayAccess interface.</p>
<p>Howewer, I'm getting an error that says that my implementation:</p>
<p><em>must be compatible with that of ArrayAccess::offsetSet().</em></p>
<p>My implementation looks like this:</p>
<pre><code>public function offsetSet($offset, $value) {
if (!is_string($offset)) {
throw new \LogicException("...");
}
$this->params[$offset] = $value;
}
</code></pre>
<p>So, to me it looks like my implementation is correct. Any idea what is wrong? Thanks very much!</p>
<p>The class look like this:</p>
<pre><code>class HttpRequest implements \ArrayAccess {
// tons of private variables, methods for working
// with current http request etc. Really nothing that
// could interfere with that interface.
// ArrayAccess implementation
public function offsetExists($offset) {
return isset ($this->params[$offset]);
}
public function offsetGet($offset) {
return isset ($this->params[$offset]) ? $this->params[$offset] : NULL;
}
public function offsetSet($offset, $value) {
if (!is_string($offset)) {
throw new \LogicException("You can only assing to params using specified key.");
}
$this->params[$offset] = $value;
}
public function offsetUnset($offset) {
unset ($this->params[$offset]);
}
}
</code></pre>
| php | [2] |
1,682,587 | 1,682,588 | How to play mp3 file in raw folder as notification sound alert in android | <p>I am having my own audio file placed in raw folder inside resource folder.I want to set it as notification sound alert. how should i proceed</p>
| android | [4] |
359,600 | 359,601 | PersistenceException when calling javax.persistence.query.getResultList() | <p>I am getting PersistenceException when calling the getResultList() of javax.persistence.query class. It happens when I pass on a particular piece of data . Any clue why/what it may cause this to happen?</p>
| java | [1] |
1,496,143 | 1,496,144 | Compare two files | <p>So, I'm trying to write function, which compares content of two files, but I doesn't work.</p>
<p>I want it to return 1 if files are the same, and 0 if different.</p>
<p>ch1 and ch2 works as a buffer, and I used fgets to get content of my files.</p>
<p>I think there is something wrong with the eof pointer, but I'm not sure. FILE variables are given within command line.</p>
<p>P.S. It works with small files with size under 64KB, but gets anyoned with larger files (700MB movies for example, or 5MB mp3).</p>
<p>Any ideas, how to work it out?</p>
<pre><code>int compareFile(FILE* file_compared, FILE* file_checked)
{
bool diff = 0;
int N = 65536;
char* b1 = (char*) calloc (1, N+1);
char* b2 = (char*) calloc (1, N+1);
size_t s1, s2;
do {
s1 = fread(b1, 1, N, file_compared);
s2 = fread(b2, 1, N, file_checked);
if (s1 != s2 || memcmp(b1, b2, s1)) {
diff = 1;
break;
}
} while (!feof(file_compared) || !feof(file_checked));
free(b1);
free(b2);
if (diff) return 0;
else return 1;
}
</code></pre>
<p>EDIT: I've improved this function with inclusion of Your anwers. But it's only comparing first buffer only -> but with exception -> I figured out that it stops reading file until it reaches 1A character (attached file). How can We make it work?</p>
<p>EDIT2: Task solved (working code attached). Thanks to everyone for help!</p>
| c++ | [6] |
531,184 | 531,185 | Checkboxes inside dropdown menu php | <p>I want to create dropdown menu with multiple checkboxes using framework of cakephp.</p>
<p>For example:</p>
<p>I have a dropdown having four options respectively--</p>
<p>a</p>
<p>b</p>
<p>c</p>
<p>d</p>
<p>Now I want checkboxes before each option.</p>
<p>Please help me to solve this problem. </p>
| php | [2] |
5,527,558 | 5,527,559 | Call JSONArray items in ListView in android | <p>Hi need to call JSONArray
<code>{"questions":{"poll_id":"1","user_id":"110","questions":"Captial of USA?"},"answers":[{"poll_id":"1","answer_id":"1","answer":"New York"},{"poll_id":"1","answer_id":"2","answer":"New Jersy"}]}</code> in to the listview, im new to the android plz.... help me in this.</p>
<p>I got questions part, but i need to show answers part in the listview. </p>
| android | [4] |
2,846,719 | 2,846,720 | jquery selecting specific element and manipulating it | <p>ok, bit of a noob question - and more to satisfy my need to understand WHY i cant do this, or how to do it better....</p>
<pre><code>$("#hi div").hide();
var temp = $("#hi div")[0];
$(temp).show();
</code></pre>
<p>This works, fantastic.</p>
<pre><code>$("#hi div")[0].show();
</code></pre>
<p>Why doesnt that work!
Is there a short hand way to do what I need to do, without having to define a variable?</p>
| jquery | [5] |
22,111 | 22,112 | How to find that how much time phone took to download a file from internet | <p>I want to write code that will give me the time it took to download a file(speciallly an app)
from internet.
More specifically I want to know the downloading speed of last downloaded app.</p>
<p>So I thouhgt to find the time for downloading and then divide the file size by time ,I will get the speed.</p>
<p>can anyone help me in finding the time it took to download a file from internet.</p>
| android | [4] |
1,295,659 | 1,295,660 | Would you prefer using del or reassigning to None (garbage collecting) | <p>Consider following code:</p>
<pre><code>if value and self.fps_display is None:
self.fps_display = clock.ClockDisplay()
elif not value and self.fps_display is not None:
self.fps_display.unschedule()
# Do this
del self.fps_display
# or this
self.fps_display = None
# or leave both in ?
</code></pre>
<p>Which is better python cleanup ?</p>
| python | [7] |
3,769,184 | 3,769,185 | Javascript for loop, index variable in function | <p>I'm trying to figure out how to generate functions inside for loop.
I have:</p>
<pre><code>for (var i = fir_0_f.length - 1; i >= 0; i--){
var next = i+1;
var N = i;
// Attemps
//goal0_[i](next,N);
//eval('goal0_'+i+'('+next+', '+N+')');
};
</code></pre>
<p>Have done also some searching. [] expects a string, eval() is a B.A.D practice. Is there any other way?
How to set the timeout for each function later? So they would run sequentally?</p>
<p>Thanks a lot!</p>
| javascript | [3] |
1,913,027 | 1,913,028 | How to setup language for jQuery datapicker? | <p>I just just use the standard package of <a href="http://jqueryui.com/demos/datepicker/" rel="nofollow">http://jqueryui.com/demos/datepicker/</a>.</p>
<p>And docs there doesn't say how <strong>to setup some other language than English.</strong></p>
<p>So I have this code and how I can implement it?</p>
<pre><code><script type="text/javascript">
$(function () {
// Datepicker
$('.datepicker').datepicker({
inline: true
});
});
</script>
</code></pre>
<p>This <a href="http://forum.jquery.com/topic/automatic-localization-of-datepicker" rel="nofollow">link</a> says that I have to do like</p>
<pre><code><script type="text/javascript" src="js/jquery.ui.datepicker-<% insert language code here%>.js"></script>
</code></pre>
<p>But I have totally different links to files... </p>
<p>Links:</p>
<pre><code> <link href="@Url.Content("~/Scripts/jquery-ui-1.8.18/css/flick/jquery-ui-1.8.18.custom.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.18/js/jquery-1.7.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.18/js/jquery-ui-1.8.18.custom.min.js")" type="text/javascript"></script>
</code></pre>
| jquery | [5] |
2,630,157 | 2,630,158 | install 2 apk files while installing one | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3062685/download-and-install-apk-from-a-link">Download And Install apk from a link.</a> </p>
</blockquote>
<p>hi..
Wen my application is being installed i also want to install Adobe reader apk.</p>
<p>Is it possible to add the Adobe Reader apk somewhere in my application so that it gets installed with my application?</p>
| android | [4] |
3,249,377 | 3,249,378 | declarations within python class equivalent to _init_? | <p>I was wondering if the declarations put at the top of the python class are equivalent to statements in <code>__init__</code>? For example</p>
<pre><code>import sys
class bla():
print 'not init'
def __init__(self):
print 'init'
def whatever(self):
print 'whatever'
def main():
b=bla()
b.whatever()
return 0
if __name__ == '__main__':
sys.exit( main() )
</code></pre>
<p>The output is:</p>
<pre><code>not init
init
whatever
</code></pre>
<p>As a sidenote, right now I also get:</p>
<pre><code>Fatal Python error: PyImport_GetModuleDict: no module dictionary!
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
</code></pre>
<p>Any ideas on why this is? Thank you in advance!</p>
| python | [7] |
3,961,447 | 3,961,448 | How to access member pointers in template functions | <pre><code>class A
{
pointer* p;
template<class T> f(T a)
{
p->property()->doSomething(a); // doSomething is a template function
}
};
</code></pre>
<p>Above won't compile, but I want to access the member pointer in the template function even though it's unsafe. The reason I want to do this is because 'p->property()->doSomething(a)' is actually really really long, and I'm tried of rewriting it (and I don't want to use #define). So, how do I do something like that?</p>
<p>Edit: doSomething is a 3rd party function... but I think it is something like this:</p>
<pre><code>template<class T>
void doSomething(T a)
{
// something
}
</code></pre>
<p>Edit: here's the actual code:</p>
<pre><code>#include <QMainWindow>
#include <QtNetwork>
#include <QtWebKit>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void replyFinished(QNetworkReply*);
private:
Ui::MainWindow *ui;
QNetworkAccessManager *nam;
QUrl _url;
void outputHeader(QNetworkReply*);
template<class T> void writeToOuput(T arg)
{
ui->textEdit->append(QString("%1").arg(arg));
}
};
</code></pre>
<p>Edit: Here's the error I'm getting: 'invalid use of incomplete type ui::MainWindow'
When I click it, it goes to this line 'ui->textEdit->append(QString("%1").arg(arg));' in the code</p>
<p>Edit: Here's the other error: 'Forward declaration of Ui::MainWindow'
When I click it, it goes no where.</p>
| c++ | [6] |
4,733,120 | 4,733,121 | PHP: What is the complexity [i.e O(1),O(n)] of the function 'count'? | <p>What is the Big-O time complexity of the <a href="http://php.net/manual/en/function.count.php" rel="nofollow"><code>count()</code></a> function for arrays?</p>
<p>Example</p>
<pre><code>$x = array(1,2,3);
echo count($x); // how many operation does it takes to count the elements
// of the array? is it 3, or is it 1
</code></pre>
| php | [2] |
1,698,939 | 1,698,940 | Problem with elements that overlaped each other and hover | <p>I have <a href="http://jsfiddle.net/Ed5yw/13/" rel="nofollow">this script</a>. Element with class "help" and id "help" overlap each other. I want with hover on ".help" the "#help" show. But when click on ".onHelp" the "#help" couldnt close.
What is solution for such elements?</p>
<p>Thanks in advance</p>
<p>(I have edited jsfiddle)</p>
| jquery | [5] |
4,563,736 | 4,563,737 | How can I connect jQuery Frontier Calendar to my mysql database? | <p>Can I view an information from database in a certain date box of the calendar? What I want is something like scheduler.</p>
<p>HTML Fields:</p>
<p><strong><em>Record 1</em></strong>
<strong>Name of Patient</strong>: Mr. Name
<strong>Company</strong>: Company A
<strong>Test Date</strong>: 03-27-2013</p>
<p><strong><em>Record 2</em></strong>
<strong>Name of Patient</strong>: Ms. Name
<strong>Company</strong>: Compnay B
<strong>Test Date</strong>: 03-27-2013</p>
<p>When I save these information into my database, automatically the jquery frontier calendar will display a note on datebox(I mean the day box) that there is a patient schedule on this date, and when you click on that date, it will display all patients with their information schedule on that date in a modal dialog. Is it possible to make this? Thanks..</p>
| jquery | [5] |
5,807,099 | 5,807,100 | C# List<string> proper usage | <p>What I have basically going on is a mySQL query that pulls in a list of ids, I want to store those id's in a list and basically check that list later on. Is List what I need? If so how do I say if(List<>.Contains"IDX") Console.writeline("true");</p>
<pre><code> public static void FillListingIDS()
{
string mysqlQuery = "select listingid from live where crawlerid = '"+StaticStringClass.crawlerID+"'";
DataTable listIDTable = new DataTable();
MySQLProcessor.DTTable(mysqlQuery, out listIDTable);
List<string> listingId = new List<string>();
foreach (DataRow listingidRow in listIDTable.Rows)
{
listingId.Add(listingidRow.ItemArray.ToString());
}
ListingIDS = listingId;
}
public static List<string> ListingIDS { get; set; }
</code></pre>
| c# | [0] |
356,214 | 356,215 | I am Trying to make it so that if a form field is left blank it will default to something I have set | <p>OK so I have a php form where I am dynamically adding to a recordset. One of the fields is an image field. What I would like to do is when it is left blank I would like it to insert a default image. I would use and if else statement that said something like</p>
<pre><code> if(image==null){
get(logo.jpg)}
else post image
</code></pre>
<p>but I'm not exactly sure how to do this in PHP any ideas?</p>
<pre><code>$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO Adventures (Image, Activity, Location, `Date`) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['Image'], "text"),
GetSQLValueString($_POST['Activity'], "text"),
GetSQLValueString($_POST['Location'], "text"),
GetSQLValueString($_POST['Date'],`enter code here` "text"));
mysql_select_db($database_Mat, $Mat);
$Result1 = mysql_query($insertSQL, $Mat) or die(mysql_error());
</code></pre>
<p>this is the code for the form.</p>
| php | [2] |
3,829,730 | 3,829,731 | Jquery menu with less code | <p>I'm using Jquery for menu created like:</p>
<pre><code><div class="prof_info1">home</div><div class="prof_info2">info2</div><div class="prof_info3">info3</div>
</code></pre>
<p>And Jquery code like:</p>
<pre><code>$(document).ready(function(){
$(".prof_info1").unbind("click").click(function(event) {
$("#main").html('<img src="img/spin.gif" class="spin">');
location.replace("?&id=<?=$id?>")
return false;
});
$(".prof_info2").unbind("click").click(function(event) {
$("#main").html('<img src="img/spin.gif" class="spin">');
$("#main").load('?a=2&id=<?=$id?>');
return false;
});
$(".prof_info3").unbind("click").click(function(event) {
$("#glavni").html('<img src="img/spin.gif" class="spin">');
$("#glavni").load('?a=3&id=<?=$id?>');
return false;
});
});
</code></pre>
<p>Is there any easier way to do write this Jquery code and make it with less code?
Something like </p>
<pre><code>if click somethind{
...
}elseif{
....}
</code></pre>
| jquery | [5] |
2,911,164 | 2,911,165 | Javascript error: Slide(function) undefined | <p>What I'm trying to do is get the Slide function to work - its passing the CurrenPage data, but the PanelScroller is not updating. Could I possibly have a conflict with some of the other JS libraries / scripts I'm using?</p>
<p>please see <a href="http://www.deepwater.nu/simonev" rel="nofollow">http://www.deepwater.nu/simonev</a></p>
| javascript | [3] |
1,216,556 | 1,216,557 | jQuery code difference | <p>Let me start by saying that I'm not a JavaScript programer or a jQuery guru by any means, I'm actually just starting with jQuery.</p>
<p>I have the two following jQuery codes:</p>
<pre><code>$('.tipTrigger').hover(function(){
$(this).toggleClass('active').prev('.tipText').stop(true, true).fadeToggle('fast');
});
</code></pre>
<p>and</p>
<pre><code>if ($(".tooltip-container").length > 0){
$('.tipTrigger').hover(function(){
$(this).toggleClass('active').prev('.tipText').stop(true, true).fadeToggle('fast');
});
}
</code></pre>
<p>Several questions I have about this:</p>
<ol>
<li>What is basically the difference between the two codes above?</li>
<li>What is the meaning of <code>if ($(".tooltip-container").length > 0){</code>?</li>
<li>Is there a benefit to using the above <code>if</code>?</li>
<li>What's more 'efficient' from a developer's stand point? (that is IF something so small would have a considerable performance impact in any way)</li>
</ol>
<p>Any other comments/help with this simple comparison would be greatly appreciated.</p>
<p>Thanks in advance.</p>
| jquery | [5] |
3,679,364 | 3,679,365 | UIImageOrientationRight(left) won't work | <p>I want to pick a photo from UIImagePickerController and check the photo if it is landscape. if selected photo is landscape, I want to rotate to portrait.
so, here is my code</p>
<pre><code>- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo {
if(image.imageOrientation == UIImageOrientationRight || image.imageOrientation == UIImageOrientationLeft){
UIImage *retatedImg = [image imageRotatedByDegrees:90];
}else {
UIImage *retatedImg = image;
}
}
</code></pre>
<p>I'm sure [imageRotatedByDegrees:] method is working fine. Just stuck why it does not recognize landscape photo. help me!</p>
| iphone | [8] |
2,129,814 | 2,129,815 | ASp.NET Dropdown and Dictionary | <p>I am using a dropdown list in ASP.NET with C#. </p>
<p>I am trying to bind a dictionary to the dropdownlist. </p>
<p>How can we specify the "Text" (key of dictionary as Text of drop down) and "value" (value as Value) for the dropdown?</p>
<p>Could you please help?</p>
<p>Note: There is a constraint that a class should not be introduced for this purpose. That is why I am trying to use a dictionary.</p>
<p>Thanks</p>
<p>Lijo</p>
| asp.net | [9] |
2,432,527 | 2,432,528 | maximum no of android virtual devices on a pc | <p>How many android virtual devices can run simultaneously on a PC.
Does it differ with configuration of the pc?</p>
| android | [4] |
5,568,850 | 5,568,851 | Download Progress in Android | <p>i have developed an app which shows progress of downloads in a progress bar. </p>
<pre><code>while ((chunkBytes = httpInputStream.read(outputByte, 0, 1024)) != -1) {
bytesRead = bytesRead + chunkBytes;
// write contents to the file
fileOutputStream.write(outputByte, 0, (int) chunkBytes);
// publish the progress of downloading..
publishProgress((int)((bytesRead)*100/fileSize));
}
</code></pre>
<p>But, what i am trying to do is - instead of that 58/100 .. (secondary progress ?) would like to display 3.5 mb/5.5 mb .... (MBs downloaded / Total MB) below that progress.. i have tried to change the secondary progress but of no help.. Is there any other way?</p>
| android | [4] |
1,219,649 | 1,219,650 | How do I generate random numbers and match it to a button click? | <p>I have a UI with 9 image buttons with images of numbers from 1 to 9..I have a button listen which on click should play mp3 files (of number between 1 to 9) randomly on each click.I should have 5 such random mp3 files playing when i click the listen button 5 times.Problem is "i have to match the randomly generated mp3 files with the image button containing the image of correct number how do i do this...because only randomly generated are the mp3 files while the image buttons are not randomly shuffled...there remain static in their position....please help me...</p>
| android | [4] |
4,218,578 | 4,218,579 | fix the orientation of the image + iphone | <p>I am using camera functionality in my application and saving the images in documents directory after clicking the photo. Whenever I use images, the orientation of these images get change. So for it I search on stackoverflow and get the solution in this link:</p>
<p><a href="http://stackoverflow.com/questions/5427656/ios-uiimagepickercontroller-result-image-orientation-after-upload/5427890#5427890">iOS UIImagePickerController result image orientation after upload</a></p>
<p>But I am unable to know that how to use the fix orientation method to get the original orientation of the image. If anyone has some idea about it, please help me.</p>
<p>Thanks to all.</p>
| iphone | [8] |
5,340,029 | 5,340,030 | What does :-1 mean in python? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/509211/the-python-slice-notation">The Python Slice Notation</a> </p>
</blockquote>
<p>I'm trying to port some python code to C, so far so good. However I came across this line and I can't figure out what it means:</p>
<p><code>if message.startswith('<stream:stream'):
message = message[:-1] + ' />'</code></p>
<p>I understand that if 'message' starts with '
<p>Would somebody be so kind on explaining what hapends?</p>
| python | [7] |
5,548,810 | 5,548,811 | Convert date/time in GMT to EST in Javascript | <p>In Javascript, how can I convert date/time in GMT to EST irrespective of user settings?</p>
| javascript | [3] |
4,829,832 | 4,829,833 | Android How to capture two consecutive frames from camera | <p>I'm trying to program Optical flow on android device.
My problem is to get two consecutive frames from camera.</p>
<p>That's the code to get ONE frame.</p>
<pre><code>mCamera.setPreviewCallback(new PreviewCallback() {
public void onPreviewFrame(byte[] data, Camera camera) {
synchronized (SampleViewBase.this) {
mFrame2 = data;
SampleViewBase.this.notify();
}
}
});
</code></pre>
| android | [4] |
2,054,925 | 2,054,926 | Java: Resolve namespace conflict | <p>We have a jar that we lost the source code to. I decompiled the jar and created new source from it. I want to then verify that the source code and the old jar have the same behavior. I am writing unit tests to do the verification the problem is that they both have same namespace / class name so I do not know how to disambiguate the old jar and the new source code. What can I do or is it impossible?</p>
| java | [1] |
1,504,741 | 1,504,742 | Why does JQuery .live work with deleting dynamically added items but JQuery .on or .bind does not? | <p>I've heard that JQuery .live has been deprecated and should not be used any more. I've got some sample code below that I've written where I have a button, with an id of adddiv, which appends a div with an id of seconddiv to an existing div with an id of firstdiv. </p>
<p>Within the seconddiv, I have another button, with an id of delete, that, when clicked, I want to delete the seconddiv. The code works fine as is, but if I change the JQuery where I'm catching the click event for the delete button to use either .on or .bind, it fails to work. </p>
<p>Can anyone tell me how to change this to use either .on or .bind to get this to work?</p>
<p>HTML:</p>
<pre><code><div id="firstdiv">
Pre Existing Div
<input type="button" id="adddiv" value="Add Div" />
</div>
</code></pre>
<p>Javascript:</p>
<pre><code><script type="text/javascript">
$().ready(function () {
$('#adddiv').click(function () {
$('#firstdiv').append('<div id="seconddiv"> Click here to delete the second div: <input type="button" id="delete" value="Delete Div"></div>')
});
$('#delete').live('click', function (e) {
$(this).parent('#seconddiv').remove();
});
});
</script>
</code></pre>
| jquery | [5] |
3,372,650 | 3,372,651 | Why are two 'this' not same? | <pre><code>var arrayfunc = [function(){return this;}];
var func = arrayfunc[0];
arrayfunc[0](); //[function (){return this;}]
func(); //Window
</code></pre>
<p>i don't know why <code>this</code> is not same? Do you help me ?</p>
| javascript | [3] |
133,580 | 133,581 | Inneractive ad integration error in xml file | <p>Im trying to integrate inner-active to my app .. i downloaded sample project but getting error in xml file...</p>
<pre><code> Multiple annotations found at this line:
- error: No resource identifier found for attribute 'adType' in package 'com.inneractive.api.ads.sample'
- error: No resource identifier found for attribute 'refreshInterval' in package
'com.inneractive.api.ads.sample'
- error: No resource identifier found for attribute 'keywords' in package
'com.inneractive.api.ads.sample'
- error: No resource identifier found for attribute 'appID' in package 'com.inneractive.api.ads.sample'
</code></pre>
<p>XML</p>
<pre><code> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.inneractive.api.ads.InneractiveAd
android:id="@+id/ad"
xmlns:inneractive="http://schemas.android.com/apk/res/com.inneractive.api.ads.sample"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
inneractive:appID="Android_IA_Test"
inneractive:adType="Banner"
inneractive:keywords="android,test"
inneractive:refreshInterval="120"
android:layout_alignParentBottom="true"
/>
</code></pre>
<p></p>
<p>BTW is that a right choice to go with inner-active for native android apps? TIA</p>
| android | [4] |
2,818,755 | 2,818,756 | How to create screen locker in android | <p>i am new here.
I can't find, maybe you know. I need to learn something about how to make screen locker on android.
Maybe any tips for me?</p>
| android | [4] |
2,475,584 | 2,475,585 | Best practice for filing of abstract class and subclasses? | <p>I was wondering what is the best (and real-word) practice for doing an abstract class and subclasses in PHP when it comes to filing.</p>
<p>I have <code>abstract class games</code>, and I was wondering if I should put the subclasses into separate files and <code>require_once('games.class.php');</code> for separate files or just have each subclass in the <code>abstract class games</code> file?</p>
<p>Thanks!</p>
| php | [2] |
1,609,163 | 1,609,164 | Javascript href link counter | <p>I need to make a button that increments and decrements a variable. When you click a link it increments a variable in the link href.When you click another link it decrements a variable in the link href.The variable can only go up to the last number in a specified array.PHP will be embedded around it. Any ideas?</p>
<pre><code><script type="text/javascript">
var counter = 0;
document.write('<button onclick="counter++">Increment</button>');
document.write(counter);
</script>
</code></pre>
<p>This is an abomination I know, and it uses a button.</p>
| javascript | [3] |
2,692,832 | 2,692,833 | Location of /Downloads folder for devices with and without SD card | <p>Please let me know what are default locations for <code>Downloads</code> folder on devices with and without SD card. </p>
<p>And how can I check if particular phone doesn't have SD card.</p>
| android | [4] |
1,753,995 | 1,753,996 | javascript global variables visibility | <p>I'm using a global variable in javascript, declared in a script tag outside any function:</p>
<pre><code><script type="text/javascript">
var prov_status_dict={};
....
</script>
</code></pre>
<p>Later on in a javascript method I'm using the variable normally.</p>
<pre><code>temp=prov_status_dict[current_as_id];
</code></pre>
<p>I'm having issues with it on opera and ie, while on firefox it works. This is what opera's error console reports:</p>
<pre><code>JavaScript - http://localhost:8000/input/
Event thread: click
Error:
name: ReferenceError
message: Statement on line 62: Undefined variable: prov_status_dict
stacktrace: n/a; see opera:config#UserPrefs|Exceptions Have Stacktrace
</code></pre>
<p>I've noticed that the problem is with global variables in general. I tryed moving some into hidden fields, but the same error pops up on the next use of a global var.</p>
<p>Help?</p>
| javascript | [3] |
2,487,527 | 2,487,528 | Creating a regex for parsing screens resolutions | <p>I have a string of text that somewhere will contain the resolution to my vid in the format <code>###x###</code> or <code>####x####</code> (ex. 320x240 or ex. 1024x1280 ex. 320x1024 etc.) or any combo in between. I am not great at regexes yet and I was wondering if anyone could point out where I am going wrong.</p>
<pre><code>$res='some long string';
$search='/([0-9]{3-4})x([0-9]{3-4})/';
preg_match($search, $res, $matches);
$res1=$matches[1];
$res2=$matches[2];
</code></pre>
| php | [2] |
5,177,411 | 5,177,412 | Jquery- Hide div | <p>I have a div inside form something like</p>
<pre><code><form>
<div>
showing some information here
</div>
<div id="idshow" style="display:none">
information here
</div>
</form>
</code></pre>
<p>i am population information inside div(idshow) on some button click event. what i want whenever i ill click outside div(idshow), it should be hide. just like i click on menu then menu is display and when i click outside menu it goes hide.
I need everything using jquery</p>
| jquery | [5] |
5,594,004 | 5,594,005 | how to implement tab layout using only one activity? | <p>official android dev website says that:「You can implement your tab content in one of two ways: use the tabs to swap Views within the same Activity,.....」</p>
<p><a href="http://developer.android.com/resources/tutorials/views/hello-tabwidget.html" rel="nofollow">http://developer.android.com/resources/tutorials/views/hello-tabwidget.html</a></p>
<p>i just wanna use tabs to swap views, no more than one activity.</p>
<p>could someone teach me how to do that?? is there any sample code?? thx ~</p>
| android | [4] |
562,184 | 562,185 | android.view.ScaleGestureDetector cannot be resolved | <p>I am using GraphView in my android APP and including the package into my project works pretty fine. But, there is something missing because the eclipse isn't resolving android.view.ScaleGestureDetector. </p>
<p>There goes a printscreen <a href="http://www.mediafire.com/i/?sc8j7r341u126ak" rel="nofollow">http://www.mediafire.com/i/?sc8j7r341u126ak</a></p>
| android | [4] |
143,664 | 143,665 | refresh page for a given time range | <p>I have a website that I want to be reloaded at a given range of time in the day for every five minute. time, like 9:00am to 12:00am every five minute. How do I do that?</p>
<pre><code> function refreshAt(hours, minutes, seconds) {
var now = new Date();
var then = new Date();
if(now.getHours() > hours ||
(now.getHours() == hours && now.getMinutes() > minutes) ||
now.getHours() == hours && now.getMinutes() == minutes && now.getSeconds() >= seconds) {
then.setDate(now.getDate() + 1);
}
then.setHours(hours);
then.setMinutes(minutes);
then.setSeconds(seconds);
var timeout = (then.getTime() - now.getTime());
setTimeout(function() { window.location.reload(true); }, timeout);
}refreshAt(15,35,0); //Will refresh the page at 3:35pm
</code></pre>
<p>the following is just for a given time</p>
| javascript | [3] |
1,943,700 | 1,943,701 | QUOTES ON ASP.NET - SQLDataSource - FilterExpression | <p>hI Experts,</p>
<p>I'm getting the error below when I pass serach filed with quote e.g. abb's</p>
<pre><code>The expression contains an invalid string constant: '.
</code></pre>
<p>is there anyway I can resolve this? Also if you could send me a link on all the functions avaialbe for filterexpression such as Replace, Cast etc will be great.</p>
<p>Thanks</p>
| asp.net | [9] |
4,256,128 | 4,256,129 | Monitoring of Activities visibility | <p>Is it possible to determine the moment of switching of certain Activity from foreground to background and vice versa?
This activity should run in the separate process.</p>
<p>I need to write the application that collects some statistics from using of big set of applications (app names read from configuration file). My application works as Service and should remember moments of switching of activities between foreground and background.
Set of applications is sufficiently big and most part of these applications will never work on certain phone.</p>
| android | [4] |
2,429,056 | 2,429,057 | Recursive call on the java memory leaks | <pre><code>public class TailRecursionTest2 {
public static void main(String[] args) {
TailRecursionTest2 t = new TailRecursionTest2();
t.a(0);
}
public void a(int j) {
System.out.println(j);
j++;
if (j == 10000)
return;
List list = new Array List<Integer>(100000);
}
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.ArrayList. <init> (Unknown Source)
at TailRecursionTest2.a (TailRecursionTest2.java: 17)
at TailRecursionTest2.a (TailRecursionTest2.java: 20)
at TailRecursionTest2.a (TailRecursionTest2.java: 20)
at TailRecursionTest2.a (TailRecursionTest2.java: 20)
at TailRecursionTest2.a (TailRecursionTest2.java: 20)
</code></pre>
| java | [1] |
3,472,891 | 3,472,892 | How do I successfully use functions declared inside the jQuery "ready" function? | <p>I'm having a bit of a jQuery problem. Basically I have some functions that I need to place inside the ready function so that they have scope access to some of the objects initialized on document ready. However, for whatever reason, no methods created seem to respond to any of the DOM objects' <code>onClick</code>. I am forced to pull them outside the <code>$()</code>. I'm sure there is some elementary point I'm missing here, but I can't seem to see it. Any ideas?</p>
<p>FYI (to anyone interested) for this particular problem, I am working with datatables (http://www.datatables.net/) and need to provide a few functions access to the initialized table(s).</p>
<p>Best.</p>
| jquery | [5] |
1,559,758 | 1,559,759 | NSUserDefaults:setObject crash | <p>I trying to save app state on processing event applicationWillTerminate. But NSUserDefaults:setObject crashes in 30% cases if UIAlertView with UITextField present on screen. Call stack looks like</p>
<pre><code>[NSUserDefaults setObject]
[NSNotificationCenter postNotificationName]
_CFXNotificationPostNotification
__CFXNotificationPost
_nsnote_callback
[UIKeyboardImpl defaultsDidChange]
[UIKeyboardImpl takeTextInputTraitsFrom]
[NSObjectCopy]
[UITextInputTraits copyWithZone]
[UITextInputTraits takeTraitsFrom]
[UITextInputTraits setInsertionPointColor]
objc_setProperty
objc_msgSend
</code></pre>
<p>Then CBR: Program received signal "EXC_BAD_ACCESS". How I can fix it? Thanks.</p>
| iphone | [8] |
1,414,405 | 1,414,406 | how to open link of one web application (server 1) from another web applicaton (server2). Sigle sign on Problem | <p>Guys,
I have made two web application, both application deployed on differnent server with database. one have SQL and other Oracle.</p>
<p>server 1: Web application 1/SQL Database.
Server 2: Web Application 2/Oracle Database.</p>
<p>I have given link of Web application 2 on web Application 1. its means single sign on logic. I have login in web application 1 and click link of web application 2, when I click on link I want to authenticate to user in oracle databse (on server 2) if user is valid or not.</p>
<p>Please help how could do this.</p>
<p>its urgent.</p>
| asp.net | [9] |
1,672,593 | 1,672,594 | BigDecimal("0.00") causes NumberFormatException | <p>Am I missing something?
From reading the JavaDoc and sites 'new BigDecimal("0.00")' should work, but it raises an exception.
Why is this?
How can I code around this?
I'm trying to display prices in an OData feed so OData automatically converts my string to a BigDecimal for Edm.Decimal types.</p>
| java | [1] |
1,650,960 | 1,650,961 | JS loop only works when matching to the last element in an array | <p>I cannot get the loop to work in my simple js login script. When i try to login with any login other than the last one in the array (user3 and pass3) it returns false.</p>
<p>What am I doing wrong?</p>
<p>I have tried both <code>==</code> and <code>===</code>.</p>
<pre><code>var userLogins = [{user:"user1", password:"pass1"},{user:"user2", password:"pass2"},{user:"user3", password:"pass3"}]
var success = null;
function logon(user, pass) {
userok = false;
for (i = 0; i < userLogins.length; i++)
{
if(pass == userLogins[i].password && user == userLogins[i].user )
{
success = true;
}
else
{
success = false;
}
}
secret(success);
}
function getData() {
var user = document.getElementById("userid").value;
var password = document.getElementById("password").value;
logon(user, password);
}
function secret(auth){
if(auth)
{
show('success');
hide('login');
}
else
{
show('error');
hide('login');
}
}
function show(show) {
document.getElementById(show).className = "show";
}
function hide(hide) {
document.getElementById(hide).className = "hide";
}
</code></pre>
<p></p>
| javascript | [3] |
1,799,728 | 1,799,729 | Why is f(x).swap(v) okay but v.swap(f(x)) is not? | <p>We have:</p>
<pre><code>vector<int> f(int);
vector<int> v;
</code></pre>
<p>This works:</p>
<pre><code>f(x).swap(v);
</code></pre>
<p>This doesn't:</p>
<pre><code>v.swap(f(x));
</code></pre>
<p>And why?</p>
| c++ | [6] |
636,237 | 636,238 | Using AVAudioPlayer and MPMoviePlayerController simultaneously | <p>I need to use <strong>AVAudioPlayer</strong> and <strong>MPMoviePlayerController</strong> simultaneously i.e play a movie while the background loop is playing is it possible.<br>
My bg music loop stops working when a movie starts playing , so I tried to stop the bg music loop and start the movie and when movie stops, start playing the bg loop again but this is also is not working.</p>
| iphone | [8] |
4,189,052 | 4,189,053 | Is there another way to create objects in java rather than using the "new" keyword? | <p>One of my lecturer said that there are some other ways to create/instantiate objects in Java rather than using the "new" keyword. If it is possible, please guide me how to do so?</p>
| java | [1] |
4,938,807 | 4,938,808 | How to fetch numeric values from paragraph tag? | <p>I am having N number of paragraph tag. Each paragraph tag will have some numbers. I want to fetch these numbers and store it in a variables. For Example:</p>
<pre><code><p id="id_1">1</p>
<p id="id_2">2</p>
<p id="id_3">3</p>
<p id="id_2">4</p>
and so on...
</code></pre>
<p>These numbers are fetch from the input text field and stored inside paragraph tag.
I want to store these numbers in a variable called numbers.</p>
<pre><code><input type="text" id="numerics" /> //using #numeric.val(); I stored the numbers in paragraph
</code></pre>
<p>And the js is:</p>
<pre><code>var numbers = parseInt($("#id_'+$('#numeric').val()+'").text().trim(), 10);
</code></pre>
<p>But it doesn't works. Thanks..</p>
| jquery | [5] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.