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
4,966,591
4,966,592
Will strtok(null) cause any bugs?
<p>PHP script to read in user action requests and parse them to their components. Example, user types in <code>SET Colour = Blue</code> or <code>describe Chocolate Cake = The best cake ever!</code> I'm using like this:</p> <pre><code>$actionKeyword = strtok( $actionRequest, " " ); // keyword followed by space $name = strtok( "=" ); // Then name followed by equals $description = strtok(null); // get the rest of the string </code></pre> <p>I could not find anything on getting the rest of the string. PHP.net's example was using spaces to tokenize each word but there was no character I could think of that might not be part of the description. This solution works in my tests.</p> <p>Is there a side effect or special case this would fail on? Or is this a perfectly safe and acceptable way of getting the rest of the line?</p>
php
[2]
5,740,424
5,740,425
@selector key word in iPhone programming
<pre><code>-(void)displayNameBy:(NSString*)name{ mylable.text = name; } </code></pre> <p>i want call this method using @selector keywords.</p> <p>eg:</p> <pre><code>[MyButton addTarget:self action:***@selector(displayNameBy:name)*** forControlEvents:UIControlEventTouchUpInside]; </code></pre> <p>Here bold italics is my doubt.. could i pass name parameter from here. when i try to pass name value i getting error. </p> <p>any way to get name value in the displayNameBy:name method . using @selector key words.</p> <p>here MyButton i created by programatically . not in interface builder. </p> <p><strong>thanks and regards</strong></p>
iphone
[8]
4,701,390
4,701,391
Passing a variable through to another PHP page
<p>I'm making a server manager. I want to add a "kill" command, which would call a php script that would essentially run a shell_exec('kill $arrtext'); and kill the process, thus closing the server down. Here is the part of my script that returns the results and checks to see which servers are running:</p> <pre><code>&lt;?php $COMMAND = shell_exec('ps -o command ax | grep skulltag | grep -v grep'); $old = array("skulltag-server", "-port", "-iwad", "-wad", "+exec"); $new = array("SKULLTAG", "Running on Port", "Using IWAD", "+ PWAD", "with Config"); $COMMAND = str_replace($old, $new, $COMMAND); $arr = explode("./",$COMMAND); $text = shell_exec('pgrep -u doom'); $arrtext = preg_split('/\s+/', $text); for( $i = 1; $i &lt; count($arr); $i++ ) { echo '&lt;div class = "serverborder"&gt;'; echo '&lt;div class = "servertextalign"&gt;'; echo $i,'. PROCESS ID &lt;span style="color: #f00;"&gt;',$arrtext[$i],'&lt;/span&gt; with server parameters: &lt;span style="color: #777;"&gt;',$arr[$i],'&lt;/span&gt;'; echo '&lt;/div&gt;'; echo '&lt;/div&gt;'; echo '&lt;br&gt;'; } ?&gt; </code></pre> <p>However, I have no idea how I would add a link or something that would set the proper $arrtext[] variable (depending on which one they picked) and pass it to the PHP script that would kill the server.</p> <p>The live demo can be found at <a href="http://server.oblivionro.net/servers/" rel="nofollow">http://server.oblivionro.net/servers/</a></p> <p>Thanks!</p>
php
[2]
4,458,299
4,458,300
Why does Firebug say toFixed() is not a function?
<p>I am using jQuery 1.7.2 and jQuery UI 1.9.1. I am using the code below within a slider. (http://jqueryui.com/slider/)</p> <p>I have a function that should test two values and depending on the difference between the two values reformat them (to the appropriate decimal place). If the difference is greater than 10, I will parse out the integer. If the difference is greater than 5, it should keep one decimal. Everything else, I will keep two decimals. </p> <p>When I enter two values that have a difference that is ten or less, I use the toFixed() function. And, in Firebug, I see an error:</p> <pre><code>TypeError: Low.toFixed is not a function Low = Low.toFixed(2); </code></pre> <p>Is there something simple that I am doing wrong? </p> <p>Here is my code:</p> <pre><code>var Low = $SliderValFrom.val(), High = $SliderValTo.val(); // THE NUMBER IS VALID if (isNaN(Low) == false &amp;&amp; isNaN(High) == false) { Diff = High - Low; if (Diff &gt; 10) { Low = parseInt(Low); High = parseInt(High); } else if (Diff &gt; 5) { Low = Low.toFixed(1); High = High.toFixed(1); } else { Low = Low.toFixed(2); High = High.toFixed(2); } } </code></pre>
javascript
[3]
4,694,145
4,694,146
How can I use setOnClickListener in my adapter Android?
<p>In my aplication I have ListView and adapter to my ListView. My item ListView have two elements Text and Image. Now I want to separate the text and click on the picture. </p> <pre><code>public class MyAdapter extends ArrayAdapter&lt;String&gt; { private Activity context; private ArrayList&lt;String&gt; categories; public static boolean remove = true; public MyAdapter(Activity context, ArrayList&lt;String&gt; categories) { super(context, R.layout.my_list_element, categories); this.context = context; this.categories = categories; } static class ViewHolder { public TextView tvLanguage; public ImageView remove; } public View getView(int position, View convertView, ViewGroup parent) { View rowView = convertView; if (rowView == null) { LayoutInflater inflater = context.getLayoutInflater(); rowView = inflater.inflate(R.layout.my_list_element, null); ViewHolder viewHolder = new ViewHolder(); viewHolder.tvLanguage = (TextView) rowView.findViewById(R.id.tvLanguage); viewHolder.remove = (ImageView) rowView.findViewById(R.id.remove); rowView.setTag(viewHolder); } ViewHolder holder = (ViewHolder) rowView.getTag(); holder.tvLanguage.setText(categories.get(position)); if(remove) holder.remove.setVisibility(View.GONE); else holder.remove.setVisibility(View.VISIBLE); return rowView; } </code></pre> <p>How i should separate text and image and success use setOnClickListener on two elements ? </p>
android
[4]
4,616,699
4,616,700
Dynamic Increase / Decrease the number with C#
<p>I have two buttons to reduce or increase the number. Also, I have a label which is has value zero. How can I increase or decrease without giving zero value to the Label in C#?</p> <p>Code:</p> <pre><code>int sayi = int.Parse(lbltext1.Text); sayi = sayi - 1; lbltext1.Text = sayi.ToString(); </code></pre>
c#
[0]
5,232,958
5,232,959
Does asp.net use reflection to parse and build objects based on server control tags?
<p>If so, are the results cached after the first access?</p>
asp.net
[9]
1,344,435
1,344,436
Subtract time from date using format string
<p>If I have a date and time in a DateTime object, can I remove say 10 minutes, or 24 hours etc from the date and time using a format string?</p> <p>So if I have 1/1/1990 12:30:00pm and I wanted to remove 1 hour from it, can I use a format string?</p> <p><strong>edit</strong></p> <p>i need to store diary entries and the user can select a reminder type. so 1 hour before hand. so then i'd like to store the format string in a db that i can get and apply to a datetime to get the reminder date time</p>
c#
[0]
2,773,059
2,773,060
How to Add Smiley/Emojis in Edittext?
<p>How to Add Smiley/Emojis in Edittext?</p> <p>Any Source code is Available on Internet, if yes Please Give me Link.</p> <p>Thanks in Advance.</p>
android
[4]
3,350,803
3,350,804
TextView.onDraw causing endless loop
<p>I want a TextView which adjusts the font size so that the text in the view will automatically expand (or shrink) to fill the full width of the view. I thought I might be able to do this by creating a customised TextView which overrides onDraw() as follows:</p> <pre><code>public class MaximisedTextView extends TextView { // (calls to super constructors here...) @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); TextPaint textPaint = this.getPaint(); Rect bounds = new Rect(); String text = (String)this.getText(); // current text in view float textSize = this.getTextSize(); // current font size int viewWidth = this.getWidth() - this.getPaddingLeft() - this.getPaddingRight(); textPaint.getTextBounds(text, 0, text.length(), bounds); int textWidth = bounds.width(); // reset font size to make text fill full width of this view this.setTextSize(textSize * viewWidth/textWidth); } } </code></pre> <p>However, this sends the app into an endless loop (with the text size growing and shrinking slightly each time!), so I'm clearly going about it the wrong way. Does the call to setTextSize() trigger an invalidate so that onDraw is called again, endlessly?</p> <p>Is there a way I can prevent the recursive call (if that's what is happening)? Or should I be going about it a completely different way?</p>
android
[4]
2,847,962
2,847,963
Alarmmanager with pending Intent
<p>The code snippet below.... </p> <pre><code> public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ///////////Do something//////////////////////// showtext.startScan(); //SEt Alarm Intent intent = new Intent(this, TextReceiver.class); PendingIntent pi=PendingIntent.getBroadcast(this, 0, intent, 0); AlarmManager am=(AlarmManager) getSystemService(Context.ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+9000, pi);} </code></pre> <p>And my Receiver </p> <pre><code>TextReceiver extends BroadcastReceiver{ public void onReceive(Context context, Intent intent) { ///Show text///// } } </code></pre> <p>The thing is that when I run the program after 9sn, I am getting an error that "The app stopped unexpextdly." . My goal is to show the text every 9sn Why I get this error ? What is the correct usage of alarmmanager in the main activity ? OR Should I set alarm in the BroadcastReceiver ? Which one does make sense am.setRepeating or am.set in terms of my goal ? </p> <p>*<em>Edit: How can I change my alarm code to run in the Broadcast Receiver ? *</em></p>
android
[4]
968,920
968,921
How to add ajax control in the project
<p>I am using asp.net using C#.I want to add Ajax Control to my Web Pages.I am using visual studio 2005.That had ajax basic control not extended control and bin folder contain ajax controltoolkit.dll.But when I am adding control to my page,it shows the unknown elements.I add references and select that file(dll).Still the assembly details is not coming in my aspx page.And still saying unknown element.I have another project also.In that I done same ,and it works also.</p>
asp.net
[9]
3,744,217
3,744,218
Jquery xml parser not working in Chrome?
<p>I have this jquery code:</p> <pre><code> $.ajax({ type: "GET", url: "http://api.ipinfodb.com/v2/ip_query.php?key=3b80b5588c22d2a03c0e6979d1e85e397e043646c4a65ffe47ff01d47bce51e", dataType: "xml", success: function(xml) { alert('Success?'); $(xml).find('Response').each(function(){ var status = $(this).find('Status').text() alert(status); }); } }); </code></pre> <p>It work in IE but not in Chrome, any clue?</p> <p>Thanks in advance!</p>
jquery
[5]
4,643,414
4,643,415
Is there a way to tell if the soft-keyboard is shown?
<p>is there a way to tell if the softkeyboard is shown in an activity or not?</p> <p>I tried </p> <pre><code>InputMethodManager manager = (InputMethodManager) getSystemService(getApplicationContext().INPUT_METHOD_SERVICE); manager.isActive(v) </code></pre> <p>but <strong>isActive</strong> returns false only before the first time the keyboard is shown, but if the kb appears and then dismissed, <strong>isActive</strong> returns true also.</p> <p>so is there any other method to check for this issue.</p> <p>thanks</p>
android
[4]
2,747,602
2,747,603
How to get current Region Name using Coordinates?
<p>Hi all I just need current location details,</p> <p>I have done the part of getting Current location Coordinates.</p> <p>Now i want to get the region name, etc (No Maps) details using these coordinates.</p> <p>How to do that? Any sample code available? </p> <p>Thanks in advance.</p>
iphone
[8]
69,804
69,805
How can I close this thread used to run a method?
<p>I have multiple methods set up that need to be run simultaneously. I decided to create individual threads for said methods. There is also a method I made with the sole purpose of creating another thread. Here is an example of what I have done. My question is, how can I safely close these threads?</p> <pre><code>from threading import Thread .... def startOtherThread(): Thread(target = myMethod).start() Thread(target = anotherMethod).start() .... </code></pre>
python
[7]
4,852,502
4,852,503
Can we share session between ASP.NET 2.0 and ASP.NET 4.0 applications?
<p>Can we share session data between ASP.NET 2.0 and ASP.NET 4.0 applications? Is it possible if the types of the objects in the session are compatible?</p> <p>I need to load an ASP.NET 4 application in Iframe on ASP.NET 2 application. The session data will be in a ASPNET Session Server or SQL server, or in AppFabric if it could be used in ASP.NET 2.0.</p>
asp.net
[9]
2,809,795
2,809,796
Small through-request data storage
<p>Is there any solutions or practices of how to organize small local data storage to keep some data between requests (no cookies or another sending data to server)?</p>
javascript
[3]
2,227,820
2,227,821
Can we use PDFKit framework for iPad?
<p>i'm trying to launch a webView by clicking a URL link in a Pdf file.... but i'm unable to do it.... one of the forum member asked me to use PDFKit but it works only in MAc OS 10.0 and above. Where as i'm trying to create my APP in SDK 3.2.. please send the sample code if possible....</p>
iphone
[8]
376,218
376,219
get heap memory used by a method in a java class
<p>i m writing a java code and i want run some performance tests . I want to get the heap memory used by only one of the methods in my class.</p> <pre><code> public AccessControl { public boolean Allowed () { code } public void print () { code } } </code></pre> <p>i want to get the heap memory used in java everytime the method Allowed is called at runtime. i read i can do it through HPROf but i noticed that HPROf doesnt provide memory calculations for methods but only for classes is there a code i can write inside the method to get the available memory and then the used memory? thanks</p>
java
[1]
3,401,938
3,401,939
Is jQuery 1.4 syntax the same as 1.3 and earlier?
<p>We've written a lot of code in jQuery recently and id like to know if replacing the library with 1.4 will invalidate any of our current code or is the syntax identical?</p> <p>Thanks in advance!</p>
jquery
[5]
5,404,075
5,404,076
Calling native Android kernel function from user code
<p>As my <a href="http://en.wikipedia.org/wiki/Motorola_i1" rel="nofollow">Motorola i1</a> refuses to light its LED in the usual programmatic way (using NotificationManager with LED on specified), I've dived into Android Cupcake's source code and found out that the native applications such as Calendar &amp; Messaging do this using NotificationManagerService, which uses</p> <pre><code>IHardwareService.setLedState() </code></pre> <p>which, in turn, calls the </p> <pre><code>setLightFlashing_UNCHECKED() </code></pre> <p>function of the kernel (or is it a component other than the kernel?). How do I either instantiate the HardwareService implementing IHardwareService, or call the setLightFlashing_UNCHECKED myself?</p>
android
[4]
4,531,620
4,531,621
Putting a pointer as a value in a method call [python]
<p>I'm trying to have a function where I can put in a list and a pointer, and have it apply that pointer to the objects in the list to give me the object with the lowest value of that pointer.</p> <pre><code>def GetLowest(ListObject,Value): ObjectX=ListObject[0] for i in ListObject: if i.Value&lt;=ObjectX.Value: ObjectX=i return ObjectX </code></pre> <p>Then I could do things like (assuming I have lists of these objects) <code>GetLowest(Rectangles,Area)</code> and have it check the area of each rectangle. Or maybe something more complex like <code>GetLowest(Backpacks,Wearer.ShoeSize)</code>.</p> <p>I'm going to want to use this in a few places around my program. Thanks in advance, guys!</p>
python
[7]
4,899,572
4,899,573
What is the best way to track internal referrals with php?
<p><code>$_SERVER['HTTP_REFERER']</code> seems to be full of holes.</p> <p>Tracking through the url will not be possible for this particular application.</p> <p>I have a 301 Redirect to take into account also. </p> <p>I will check <code>$_SERVER['HTTP_REFERER']</code>, but what is a good second method to check what page on my site the user came from?</p> <p>Is it as simple as setting up a session variable? I am looking for specific examples that will help augment <code>$_SERVER['HTTP_REFERER']</code>.</p>
php
[2]
4,482,878
4,482,879
Declaring value types by using operator "new"
<p>It is said that value types are stored in stack. But what happens when we declare a value type with <code>new</code>? For example</p> <blockquote> <p>int a;</p> </blockquote> <p>is stored in stack, but</p> <blockquote> <p>int b=new int();</p> </blockquote> <p>Where does b is stored? Heap or stack? It's confuses me. It's like a reference, but it's a value type.</p>
c#
[0]
188,063
188,064
query a set of elements, but in a particular order
<p>I have a bunch of <code>&lt;div&gt;</code> elements, each of which has a <code>name</code>. I would like to query the <code>&lt;div&gt;</code> elements using jQuery, but I want them to come by alphabetical order with respect to <code>name</code>. The usual code</p> <pre><code>$("div").doStuff() </code></pre> <p>doesn't return the elements in any special order.</p>
jquery
[5]
4,469,127
4,469,128
Minor php issue
<p>In below code, the value of <code>date("m") is 10 i.e. October</code></p> <p>the <code>$mame1[$i] in &lt;td&gt;&lt;/td&gt;</code> is printing October three times.</p> <pre><code>&lt;?php $months = array("January","February", "March","April", "May", "June", "July", "August", "September", "October", "November", "December"); $mname1 = $months[date("m")-1]; for($i=0; $i&lt;date("m")-1; $i++){ $mname1[$i];} ?&gt; &lt;tr&gt; &lt;td colspan='4' style='border: 2px solid black;'&gt; &lt;div align="center"&gt;&lt;b&gt;&lt;u&gt;&lt;?=$mname1[$i]?&gt; &lt;?=$profile_stats['year']?&gt;&lt;/u&gt;&lt;/b&gt; &lt;?=$newstats_alert?&gt;&lt;/div&gt;&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>What I want to achieve is print Series untill October ie. 10 as Jan | Feb | March |... |Sept |</p> <p>Can anybody help me?</p>
php
[2]
2,098,586
2,098,587
What is a reasonable size of JavaScript?
<p>What is the maximum size of JavaScript that would be reasonable for a web page? I have a JavaScript program with a data segment of size about 130,000 bytes. There is virtually no whitespace, comments, or variables in this file which could be minified. The file looks something like this:</p> <pre><code>"a":[0], "b":[0,5], "c":[3,4,24], "d":[0,1,3], </code></pre> <p>going on for several thousand lines.</p> <p>Google Analytics gives the following info on the connection speed of the current users:</p> <pre> Rank Type Visitors 1. DSL 428 2. Unknown 398 3. Cable 374 4. T1 225 5. Dialup 29 6. ISDN 1 </pre> <p>Is the file size too much?</p> <p>The alternative is using a server-side program with Ajax.</p>
javascript
[3]
2,091,147
2,091,148
Android web view with notification
<p>I want to implement payments into my application. Now i came to conclusion that i will call one URL in the web view. This url will be on my server and user will interact with the webpage. Now when user click submit after providing the details then my server will interact with the payment gateway and makes the payment.</p> <p>Now here i m stucked. How can i get the information that user payment is successfully done.? and i can show an alert message to user.</p> <p>is there any web view inbuilt method?</p>
android
[4]
3,392,017
3,392,018
Android: extending PhoneBase?
<p>I know it is possible to use TelephonyManager to get information like: service state, device ID, Sim Operator, etc... Is it possible to edit some of this information?</p> <p>Couldn't find .set() functions on Android.com documentation but I've found the <a href="http://www.netmite.com/android/mydroid/frameworks/base/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java" rel="nofollow">GSMPhone.java</a> source code which includes functions like .setNumber1Number() (used to set/edit the number?).</p> <p>I basically want to know if it's possible to edit the phone number located on Sim card (Settings->About->Status->My Phone Number).</p> <p>Appreciate any answer, even a simple "NO", if it's indeed impossible.</p> <p>Thank you!</p>
android
[4]
5,605,600
5,605,601
httprequest to a webserver returns null json in javasqript
<p>I am trying to make a call to webservice using httpWebRequest but i get the resonse as always null JSON.</p> <pre><code>var con = $.net.http.getConnection("http://api.geonames.org/citiesJSON?north=44.1&amp;south=-9.9&amp;east=-22.4&amp;west=55.2&amp;lang=de&amp;username=demo"); con.setProxy("proxy", 8080); var resp = con.request("GET", "/Service1.html"); //resp here is always null </code></pre> <p>The output I get is this:</p> <pre><code> {} </code></pre> <p>Don't really know where I am going wrong.</p> <p>Help me if you know regarding this.</p>
javascript
[3]
1,508,265
1,508,266
Which book is about JDK1.5+ Thread?
<p>I wanna learn about Java Thread.and I wanna learn new feature of JDK 1.5+. So which book is about new feature of JDK1.5+ Thread? Thanks.</p>
java
[1]
2,299,546
2,299,547
why is javascript onmouseover funtions is getting called on page load?
<p>I have a html page with a link and onMouseOver of that link im calling <code>return escape(showToolTip())</code></p> <pre><code> function showToolTip(){ alert(document.getElementById('toggleFlag')); var text; alert(document.getElementById('toggleFlag').value); if(document.getElementById('toggleFlag').value == false){ text = 'hide'; alert('hide'); }else{ text = 'show'; alert('show'); } </code></pre> <p>This function is getting called on page load and when I mouse over I get show. When I mouse out and mouseover again it shows up as 'show' but never calls the function.</p> <p>Where am I doing wrong?</p>
javascript
[3]
2,594,040
2,594,041
3rd party api/tool for Spell suggestion in android
<p>Is there any API available for spell suggestion in android . I'm tring <a href="https://www.google.com/tbproxy/spell" rel="nofollow">https://www.google.com/tbproxy/spell</a> but nothing is working. I have also tried worknik but this is not providing proper suggestions</p>
android
[4]
435,166
435,167
Search functionality in asp.net
<p>I'm learning to create a webapp using asp.net and C#. And I already create a basic user database webapp. Wherein I display all the user information in a tabled manner. So basically I just used the table element from HTML and not the gridview control.</p> <p>But I have a problem right now, I want to add a user search functionality wherein I will just input the user's firstname in the search box, so then when I click the search button it will display the user information in a table format. So I don't know how to implement it because I used the table element not the gridview. Where to I write the data that I searched?</p> <p>Please advise.</p> <p>Many thanks</p>
asp.net
[9]
2,581,564
2,581,565
C++ Trickery : output actual enum, not its value
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3342726/c-print-out-enum-value-as-text">C++: Print out enum value as text</a> </p> </blockquote> <p>Say I have an enumeration:</p> <pre><code>typedef enum MyEnum_ { MY_ENUM_BLUE, MY_ENUM_RED, MY_ENUM_GREEN } MyEnum; </code></pre> <p>And that I have a method that gets an "MyEnum" as parameter. I'd like write to log file the value of that MyEnum, but I don't want 0, 1 or 2 to appear there--- I'd like to output the actual enumeration string "MY_ENUM_xxxx", of course <strong>without a switch/case block</strong>..... and dealing with each value individually.</p> <p>Is there some trickery or pattern, in c++ or using macros that would help me achieve that?</p>
c++
[6]
6,000,639
6,000,640
Android HotSpot Listening Socket
<p>My app opens an http socket to accept some files from user's browser, so it needs WiFi ON for that. What I think would be cool if the app could continue doing that in WiFi HotSpot mode (tethering?) however I can't obtain the Android's IP address to start listening on. Is it possible at all?</p>
android
[4]
4,797,866
4,797,867
How to create facebook kind of comment for my blog
<p>I am using C# asp.net. I want to implement a commenting system which is similar to facebook commenting system look &amp; feel. Please give your inputs.</p>
asp.net
[9]
5,736,138
5,736,139
toggle function happening on second click
<pre><code>function toggleDiv() { $('#myDiv').toggle(function() { $('.pnlMyarea').slideDown(); $('#separator').hide(); $('#manualInsert').css('margin-top', '15px'); }, function() { $('.pnlMyarea').slideUp(); $('#separator').show(); $('#manualInsert').css('margin-top', '42px'); }); } </code></pre> <p>i am using this function to toggle my panel but this is happening on the second click not on the first what is the error.</p>
jquery
[5]
412,500
412,501
Remove words starting with uppercase
<p>I have a string, for example FastFood, how do I remove Food and leave only first word? Also it could be VeryFastFood, then Very should be left, etc.</p> <p>Some strings may containt 3 uppercase starting letters. I need then only this 3 letters to be left. for example YOUProblem - must be YOU.</p>
php
[2]
1,227,659
1,227,660
php timezone displaying correct hours but not seconds and minutes
<p>I want to display the time in different timezones, so i m using this</p> <pre><code>$date=new DateTime(null, new DateTimeZone('America/Los_Angeles')); echo $date-&gt;format('Y-m-d H:i:sP') . "\n"; $date=new DateTime(null, new DateTimeZone('Europe/Paris')); echo $date-&gt;format('Y-m-d H:i:sP') . "\n"; </code></pre> <p>So the above code display the correct hours but it's displaying the minutes and seconds same for all the timezone.</p> <p>Please help</p> <p>Thanks in advance Dave</p>
php
[2]
655,595
655,596
Valid use of reinterpret_cast?
<p>Empirically the following works (gcc and VC++), but is it valid and portable code?</p> <pre><code>typedef struct { int w[2]; } A; struct B { int blah[2]; }; void my_func(B b) { using namespace std; cout &lt;&lt; b.blah[0] &lt;&lt; b.blah[1] &lt;&lt; endl; } int main(int argc, char* argv[]) { using namespace std; A a; a.w[0] = 1; a.w[1] = 2; cout &lt;&lt; a.w[0] &lt;&lt; a.w[1] &lt;&lt; endl; // my_func(a); // compiler error, as expected my_func(reinterpret_cast&lt;B&amp;&gt;(a)); // reinterpret, magic? my_func( *(B*)(&amp;a) ); // is this equivalent? return 0; } // Output: // 12 // 12 // 12 </code></pre> <ul> <li>Is the reinterpret_cast valid? </li> <li>Is the C-style cast equivalent? </li> <li>Where the intention is to have the bits located at <code>&amp;a</code> interpreted as a type B, is this a valid / the best approach?</li> </ul> <p>(Off topic: For those that want to know <em>why</em> I'm trying to do this, I'm dealing with two C libraries that want 128 bits of memory, and use structs with different internal names - much like the structs in my example. I don't want memcopy, and I don't want to hack around in the 3rd party code.)</p>
c++
[6]
4,157,151
4,157,152
How to do "strtolower", "str_replace" and "preg_replace" in javascript?
<p>How can I do this in javascript?</p> <pre><code>$name = $xml-&gt;name; $file_name = strtolower($name); $file_name = str_replace(array('-',' ',' ','å','ä','ö'), array('',' ','-','a','a','o'), $file_name); $file_name = preg_replace("/[^a-z0-9-]+/i", "", $file_name); </code></pre>
javascript
[3]
2,543,961
2,543,962
Moving a Control By Mouse
<p>I am going to Moving a Button with Mouse , Everything is ok , but when I move mouse on button window , left and top of the button ( top-left corner) will locate at cursor pos .</p> <p>I don't want this to occur . where is the bug in my code ?</p> <pre><code>private void button1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { clicked = true; } } private void button1_MouseMove(object sender, MouseEventArgs e) { if (clicked) { Point p = new Point();//in form coordinates p.X = e.X + button1.Left; p.Y = e.Y + button1.Top; button1.Left = p.X; button1.Top = p.Y ; } } private void button1_MouseUp(object sender, MouseEventArgs e) { clicked = false; } </code></pre>
c#
[0]
3,798,989
3,798,990
Basic Js function to scale two DIV's heights
<p>I want <code>#result</code> to being scaled to <code>#sidebar</code> height if set. If not, leaving <code>#result</code> at its original height. </p> <p>My code:</p> <pre><code>window.onload = setDiv; function setDiv() { var e = document.getElementById('sidebar'); // Get the sidebar infos var eh = e.offsetHeight // div height if ( typeof(eh) == "undefined" || typeof(eh) == null) { // if sidebar isnt in the page alert(eh); return true; } else { var eh = e.offsetHeight // div height var d = document.getElementById('result') // Get the result div height var dh = d.offsetHeight // div height d.style.height = eh + 65 + 'px'; // Set result div height to sidebar height alert(d); document.write(dh); return false; } } </code></pre> <p>I don't think HTML/CSS is needed.</p> <p>Thank you.</p>
javascript
[3]
5,503,000
5,503,001
Target just the selected class with jquery
<p>I have the following code;</p> <pre><code>$('.time-span').hover(function () { $('.leftRadius,.rightRadius').addClass('hovered'); }, function () { $('.leftRadius,.rightRadius').removeClass('hovered'); }); </code></pre> <p>My markup looks like this:</p> <pre><code>&lt;DIV class=leftRadius&gt;&lt;/DIV&gt; &lt;A class=time-span &gt;&lt;/A&gt; &lt;DIV class=rightRadius&gt;&lt;/DIV&gt; &lt;DIV class=leftRadius&gt;&lt;/DIV&gt; &lt;A class=time-span &gt;&lt;/A&gt; &lt;DIV class=rightRadius&gt;&lt;/DIV&gt; &lt;DIV class=leftRadius&gt;&lt;/DIV&gt; &lt;A class=time-span &gt;&lt;/A&gt; &lt;DIV class=rightRadius&gt;&lt;/DIV&gt; </code></pre> <p>How can I edit this to just target one '.time-span' class (there are multiple in my document and I can't use id's)?</p> <p>Thanks</p>
jquery
[5]
4,751,681
4,751,682
How do I get the value of a textbox using jQuery?
<p>I can get the element like this <code>$("#txtEmail")</code> but I'm not sure how to get the actual value.</p>
jquery
[5]
3,912,345
3,912,346
Activate method in Python
<p>I'm trying to set my Python programs in classes. But when I have this:</p> <pre><code>class program: def test(value): print value + 1 def functionTest(): a = test(2) if __name__ == "__main__": functionTest() </code></pre> <p>I get the error : <strong>NameError: global name 'test' is not defined</strong></p> <p>What do I have to do to 'activate' the test-method? Thanks a lot!</p>
python
[7]
5,305,864
5,305,865
How do you combine a form element with a variable?
<p>First, how do you append data to the end of a variable in Javascript? I know for PHP you use:</p> <pre><code>$foo = "bar"; $foo.= "bar2"; </code></pre> <p>Next, I can get the following to work for one form field:</p> <pre><code>var test = document.form1.option1.value; </code></pre> <p>However, how would I go about doing this with a for loop whilst appending each iteration onto the end of the variable? For example (where XXX is the loop variable i):</p> <pre><code>for(i=0; i&lt;10; i++){ test.= document.form1.optionXXX.value; } </code></pre> <p>Basically, I need all the data from a random set of form fields that can range anywhere from option1 to option20. Thanks.</p>
javascript
[3]
3,180,020
3,180,021
invert filename order script
<p>I have a set of files which the names follow this pattern: xxx - 001, xxx - 002 ..... xxx - 700</p> <p>What I would like to do it`s a python script which I can invert the order of the name of the files, doing the xxx - 700 to be the xxx - 0001!</p>
python
[7]
65,312
65,313
Receiving mails using Javamail API and extracting attachments from the mail
<p>I wanted to receive emails using Javamail API. And i also want to extract attachments from the received mails and store those extracted attachments in a folder using Javamail API. I want complete working code. Thanks, Jessica</p>
java
[1]
4,289,741
4,289,742
Where can I find an educational game for learning jQuery? (something like regenemies)
<p>I'm attempting to refine my jQuery skills by means of playing an educational game (for learning jQuery). However, I can't seem to find one because every time I google something with "jQuery" and "game" I get results for jQuery game development. I really want to learn jQuery by playing a game similar to regenemies (<a href="http://darevay.com/regenemies/" rel="nofollow">http://darevay.com/regenemies/</a>) which I used to learn regular expressions.</p> <p>Does anyone know of any applications/games out there that quiz you on jQuery selectors and the like? I can see a bunch of jQuery quizzes, but that's not really what I'm looking for...</p> <p>I wish I could find a site that aggregated tons of programming educational games.</p>
jquery
[5]
2,338,684
2,338,685
how do I figure out what is_image means in file.is_image in javascript?q
<p>I'm using a plugin in wich file.is_image is used. Somewhere, I reckon is_image ought to be defined. How do I find out what it is defined to?</p> <p>I'd reckon it should be something like "$is_image =" or something like that, I'm not great with javascript syntax etc.</p>
javascript
[3]
893,438
893,439
How can you update an 'onclick' event in jquery?
<p>I have a <a href="http://jsfiddle.net/rayd360/yjAeS/1/" rel="nofollow">JSFiddle</a> that seems like it should work but it doesn't.</p> <pre><code>function copyform(curnum){ if(curnum == 3) $('p').html('Thank You!') var num = $('form').length; var newNum = new Number(num + 1); // create the new element via clone(), and manipulate its ID using newNum value var newElem = $('#form'+curnum).clone().attr('id', 'form' + newNum); // //this is where I need to update the onclick to copyform('+newNum+') $('#form'+newNum+' input').attr('onclick', 'copyform('+newNum+')'); // insert the new element after the last "duplicatable" input field $('form').after(newElem); } </code></pre> <p>I just need help implementing the <code>onclick</code> function. This is part of a larger more complex program that would be a hard example to show. Any and all help is much appreciated!</p>
jquery
[5]
364,863
364,864
sysout work only in class with main method
<p>I am new in Java. Under fresh Lubuntu (12.10 x64 with all updates) I download Eclipse (3.8) from Lubuntu Software Center. My problem is that <strong>System.out.print()</strong> work only in class with main method.</p>
java
[1]
4,090,233
4,090,234
Changing CSS of a class is not effected when a dialog page is opened
<p>I have the following codes to read a list of color codes from the server and define a list of classes "cl-Colour" by setting the CSS background color. This codes work OK in that the classes are created with the correct CSS background color values.</p> <pre><code>$.post("php/getSettings.php", function(data){ $.each(data, function(index,value){ for (i=1;i&lt;=value.NumColours;i++) { colours[i] = value.Colours[i].Code; $(".cl-Colour"+i).css("background-color",colours[i]); } }); // First alert alert($('.cl-Colour1').css('background-color')); } ,"json"); </code></pre> <p>Then, I have the following codes when I open a dialog:</p> <pre><code> $( '#id-SettingsDialog' ).live( 'pageshow',function(event){ .................... $element.addClass('cl-Colour1'); // Second alert alert($('.cl-Colour1').css('background-color')); }); </code></pre> <p>The above code was intended to make use of the classes created in the earlier block of codes.</p> <p>However, I found that in the first alert, I see value = "138.43.226" which is correct (ie, it corresponds to the color code I have set). But in the second alert, I get a value of "0,0,0".</p> <p>It appears that the classes in the first block of codes is not visible in the dialog page.</p> <p>The next thing I did, I added the following into the CSS file:</p> <pre><code>.cl-Colour1 { background-color: #FE2EC8; } </code></pre> <p>With this, the second alert will show "254,46,200" which seems to be the color defined in the CSS file.</p> <p>So, how do I solve this problem? In a nutshell, basically I want to define a set of classes of colors when the app loads and then make them available when I open a dialog.</p> <p>Thanks.</p>
jquery
[5]
5,556,975
5,556,976
Device information
<p>How can I fetch complete device hardware and software information.</p>
android
[4]
4,977,895
4,977,896
Unable to retrive entire content present in the .ipa file created for an application
<p>I have created an e-book reader application. I have manually added around 10 books to my application &amp; run the application on my iPad. Everything works fine upto this point i'm able to see all the 10 books in my bookshelf.</p> <p>I created an .ipa file out of this build, the .ipa file comprises all the 10 books but when i transfer the application(.ipa file) through iTunes to my iPad i hardly get around 4-5 books. So, is there a restriction on the size of the .ipa file that can be transferred through iTunes? I'm unable to figure out the exact reason for this problem.</p> <p>Any help in this regard will be appreciated.</p>
iphone
[8]
3,907,781
3,907,782
Connecting to multiple sortable items
<p>I'm connecting to a sortable item : </p> <pre><code>$(function() { $('.page').sortable({ connectWith: ".connect", items: ".myItems" }) </code></pre> <p>How do I connect to multiple items? something like : </p> <pre><code>$(function() { $('.page').sortable({ connectWith: ".connect", items: [".myItems"] , [".myItems1"] }) </code></pre>
jquery
[5]
531,426
531,427
Win32 still best for Windows game development?
<p>I'm looking to start a new project to work on in my free time that covers a lot of areas of Computer Science and I've decided on a game (most likely flight simulator or simple 2D side-scroller). Anyway, I do a lot of C#/Java development at work writing business applications so I'm looking to do a game in C++ (I have used C#/XNA for games previously).</p> <p>However, I'm trying to find a good framework for C++ game development. I have used Qt before but don't believe this is suitable for what I am trying to achieve. Is Win32 and OpenGL still the best for C++ game development?</p> <p>Also, I want to keep this pretty OO, any recommendations for wrapping the Win32 for game development? Or does OpenGL provide abstractions to help?</p>
c++
[6]
2,962,339
2,962,340
Referring to the address of a collection element via iterators
<p>How can I refer to the address of an element in a vector using iterators. </p> <pre><code>vector&lt;Record&gt;::const_iterator iter = collectionVector.begin(); while(iter != collectionVector.end()) { //How can I refer to the address of a Record here function(...); //accepts &amp;Record type } </code></pre>
c++
[6]
1,597,643
1,597,644
Trying to "save" a variable for a jQuery .load() callback
<p>Is there a way to "save" a variable in jQuery?</p> <p>I have an .each() loop that changes the value of sz[1] and fires a .load() for each value. However, when I place sz[1] in the callback function, it only uses the last recorded value of sz[1], and not the value it had when I initially called .load().</p> <pre><code>$("#Big").find("a").each(function() { url = $(this).attr("href"); pattern = new RegExp("sizes/([" + sizes + "])/$"); otherPattern = new RegExp("sizes/([" + otherSizes + "])/$"); sz = pattern.exec(url); if(sz) { normLink(sz[1], srcBase); } else { sz = otherPattern.exec(url); if(sz) { NotOkToDeLoad++; $("a#" + sz[1]).load(URL + sz[1] + " div#psp", function() { fixLink(sz[1]); }); } } }); </code></pre> <p>sz[1] can be "k", "h" or "o". However, fixLink() is always called with that last possible value of "o" three times.</p> <p>My current workaround is to write three separate .load()'s for each possible value of sz[1], but there ought to be an easier way. Am I overlooking something?</p>
jquery
[5]
5,559,097
5,559,098
- (IBAction)doSomething:(id)sender model used generically
<p>So I was curious about something and not sure if there is a "standard" or "good" coding practice for something. If you have a home page for example with 3 buttons (like the facebook iphone app dashboard), that go to various parts of the app by pushing a view controller, then on one button, I would have the IBAction tied to it as:</p> <pre><code>- (IBAction)showSummary:(id)sender { SummaryViewController *detailViewController = [[[SummaryViewController alloc] initWithNibName:@"SummaryViewController" bundle:nil] autorelease]; detailViewController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; detailViewController.view.autoresizesSubviews = YES; [self.navigationController pushViewController:detailViewController animated:YES]; } </code></pre> <p>So my first question is, let's say on the first time I launch the app, I want to show this page first. So in viewDidLoad, could I just call this method</p> <pre><code>[self showSummary:nil]; </code></pre> <p>Or is it better to just have the same code in my viewDidLoad.</p> <p>The second question regarding this is refactoring. If all 3 of my buttons do the same thing in creating a viewController and pushing it onto the stack, the only difference being which viewController to initializer </p> <p>e.g.</p> <pre><code>SummaryViewController *detailViewController = [[[SummaryViewController alloc] </code></pre> <p>Should I refactor these methods? If so, what would be a good way to do it? Thanks!</p>
iphone
[8]
1,571,691
1,571,692
to see if item in dropdownList has been selected
<p>I would like to know what the best way would be to loop through a dropdown list in html to see if and item has been selected or not.</p> <p>I know in C# it would be something along the lines of</p> <pre><code>int selected = cmbFamily.SelectedIndex; for (int loop = 0; loop &lt; cmbFamily.Items.Count; loop++) { if (selected == -1) { MessageBox.Show("please select an item", "Please", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } } </code></pre> <p>how would I go about in doing this with javascript?</p> <pre><code>&lt;tr style="font-size:12pt; font-weight:bold; color:#FFFFFF; font-family:High Tower Text;"&gt; &lt;td&gt;Family to join:&lt;/td&gt; &lt;td&gt;&lt;select name="drpFamily"&gt; &lt;option/&gt;-select- &lt;option/&gt;Gambino &lt;option/&gt;Genovese &lt;option/&gt;Lucchese &lt;option/&gt;Colombo &lt;option/&gt;Bonanno &lt;/select&gt;&lt;font color="red"&gt;*&lt;/font&gt;&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>Kind regards Arian</p>
javascript
[3]
4,990,021
4,990,022
how to allow only certain selected users to download data from site
<p>I have a page in which i upload a circular &amp; also select users who can view this page using multiple select dropdown box. Now how to display the uploaded file to selected users when they login and not to other users. Can anybody help. Thanks in advance.</p>
php
[2]
4,092,417
4,092,418
How can I use Google API to obtain the Geolocation inside buildings?
<p>I'm looking for a program for locating places inside buildings. Has anyone done that before? </p>
android
[4]
2,540,493
2,540,494
Help using ImageSwitcher in android
<p>So In my program I used to use Imageviews in my layout to display images and had it so when a user pressed the Imageview it changes images. But i recently upgraded my project to version 8 and updated by SDK and i see now that there is a ImageSwitcher view under Transitions. I would like to replace my ImageViews with ImageSwitchers. Ive googled and searched all over but i cant seem to figure out how it works. I was wondering if anyone would be able to explain or show me an example of code on how to use it. What i want is very basic. I just want it to display an image from a bitmap and then when the user swipes left or right it changes the bitmap. I already have the bitmaps. I just cant figure out the code.</p> <p>I tried using this code to start out but i couldnt get it to work with the bitmap</p> <pre><code>ImageSwitcher is = (ImageSwitcher) findViewById(R.id.imageSwitcher1); is.setImageResource(bmap); </code></pre> <p>I tried using this new code to turn my bitmap into a drawable but it always crashes when run. Is there something i can fix?</p> <pre><code>Drawable d = new BitmapDrawable(bmap); ImageSwitcher is = (ImageSwitcher) findViewById(R.id.imageSwitcher1); is.setImageDrawable(d); </code></pre>
android
[4]
5,721,775
5,721,776
compatibility of ASP.net Pages with other OS es
<p>I was Planing to make my website and thought that either use ASP.net or Php as i have not used php but know c# so can do ASP.net.but problem that i came to mind as i make desktop apps are only for windows. what if i make a website in dot net (cross platform compatibility dose not hold for desktop apps) would users be able to open pages at their systems independent of os.</p>
asp.net
[9]
1,514,967
1,514,968
Get errors with javamail
<p>i'm trying an example of javamail and i get the following error:</p> <pre><code> Exception in thread "main" javax.mail.AuthenticationFailedException: [AUTH] Application-specific password required: http://www.google.com/support/accounts/bin/answer.py?answer=185833 at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:208) at javax.mail.Service.connect(Service.java:317) at javax.mail.Service.connect(Service.java:176) at javax.mail.Service.connect(Service.java:125) at javax.mail.Session.getFolder(Session.java:612) at MainClass.main(MainClass.java:19) Java Result: 1 </code></pre> <p>The code used is from Java2s.com Get Attachment File Name. And i use mail.jar from 1.4.4 version.</p> <p>I don't understand the end of the code here:</p> <pre><code>class MailAuthenticator extends Authenticator { public MailAuthenticator() { } public PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("username", "password"); } } </code></pre> <p>Thank you</p>
java
[1]
1,672,749
1,672,750
How to set headers to send mail in php when message contains attachments and HTML body
<p>I need to send one mail using php code. The mail contails HTML Part, Text , and two attachments (xls) file. How do i set headers and message body . For me Only one is working at a time either mail body or attachment. Please help</p>
php
[2]
136,781
136,782
c# im getting an error
<pre><code>double dval = 1; for (int i = 0; i &lt; Cols; i++) { k = 0; dval = 1; for (int j = Cols - 1; j &gt;= 0; j--) { colIndex = (i + j) % 3; val *= dval[colIndex, k]; k++; } det -= dval; } </code></pre> <p>im getting an error </p> <blockquote> <p>Cannot apply indexing with [] to an expression of type 'double' for dval </p> </blockquote> <p>help its urgent</p>
c#
[0]
1,606,169
1,606,170
R sum in a while loop
<p>I have loop and display this row</p> <pre><code>&lt;? if ($objResult["cashier_trans_Type"]=="out" || $objResult["cashier_trans_Type"]=="debit to customer" || $objResult["cashier_trans_Type"]=="debit") { echo "0.00"; } else { echo $Dofaa=number_format($objResult["cashier_trans_Value"],2); } ?&gt; </code></pre> <p>Now I would like to use a while loop in order to do the sum for the all columns: <code>$Dofaa</code></p> <p>How can I do this by php?</p> <p>thanks</p>
php
[2]
4,572,819
4,572,820
Tab '\t' in alert box not working with Chrome
<p>I want to display the three lines of text in "Javascript alert box" with center alignment of text. Im using the following code for that,</p> <p><code>alert( '\t\t\t\t'+"Congratulations!" + '\n\t' + "You are now subscribed with test.com!" + '\n' + "Keep on eye out on your inbox for future updates from us!" );</code></p> <p>Its working fine with Firefox. But in chrome, the tab '\t' functionality is not working. Texts are left aligned in all lines. Please help. </p>
javascript
[3]
4,959,805
4,959,806
How can I check if a string contains another string in C#
<p>I have strings like this:</p> <pre><code>var a = "abcdef * dddddd*jjjjjjjjjjjjj"; var b = "aaaaaaaaaaaaaaaaaaaaaaaa * aaaaaa"; var c = "hhhhhhhhhhhhhhhhhhhhhhhhhhh"; </code></pre> <p>Is there a smile way for me to check if the string contains a " * " within the first 20 characters?</p>
c#
[0]
1,735,815
1,735,816
Free ad exchange framework for Android?
<p>I know that Android has some ad networks to monetize the apps. But I'm looking for an ads systems that allows me to advertise for free on other apps/games, and at the same time I advertise them on mine.</p> <p>In windows phone we have this: <a href="http://www.adduplex.com/" rel="nofollow">http://www.adduplex.com/</a></p> <p>Is there something similar for Android?</p>
android
[4]
1,512,180
1,512,181
Where does the Encryption of ViewState (ViewStateEncryptionMode) happen?
<p>It could be a basic question on this topic. I am reading that the View State can be encrypted, by setting the ViewStateEncryptionMode.</p> <p>Even when the ViewStateEncryptionMode is not specified, the __VIEWSTATE hidden filed seem to be having encrypted values.</p> <p>Assuming this is based on the default value ViewStateEncryptionMode.Auto, I set the page's ViewStateEncryptionMode to Never. Still I see the same value (in encrypted form) in the hidden field.</p> <p>Is ViewStateEncryptionMode is dealing with something else than, the __viewstate hidden field? Please explain.</p>
asp.net
[9]
4,310,532
4,310,533
Genetic Algorithm optimization - using the -O3 flag
<p>Working on a problem that requires a GA. I have all of that working and spent quite a bit of time trimming the fat and optimizing the code before resorting to compiler optimization. Because the GA runs as a result of user input it has to find a solution within a reasonable period of time, otherwise the UI stalls and it just won't play well at all. I got this binary GA solving a 27 variable problem in about 0.1s on an iPhone 3GS.</p> <p>In order to achieve this level of performance the entire GA was coded in C, not Objective-C.</p> <p>In a search for a further reduction of run time I was considering the idea of using the "-O3" optimization switch only for the solver module. I tried it and it cut run time nearly in half.</p> <p>Should I be concerned about any gotcha's by setting optimization to "-O3"? Keep in mind that I am doing this at the file level and not for the entire project.</p>
iphone
[8]
5,151,318
5,151,319
Factorial loop results are incorrect after the 5th iteration
<p>I am currently taking pre-calculus and thought that I would make a quick program that would give me the results of factorial 10. While testing it I noticed that I was getting incorrect results after the 5th iteration. However, the first 4 iterations are correct.</p> <pre><code>public class Factorial { public static void main(String[] args) { int x = 1; int factorial; for(int n = 10; n!=1; n--) { factorial = n*(n-1); x = x * factorial; System.out.printf("%d ", x); } }//end of class main }//end of class factorial </code></pre> <p><img src="http://i.stack.imgur.com/NTJgu.jpg" alt="Why am I getting negative values"></p>
java
[1]
1,355,352
1,355,353
Android Development: How do graphics work in Android?
<p>I am an android development beginner with some experience in other object oriented languages like java, python, c#. So I have created various games before in Java, using buffers and graphics to draw lines and stuff. How do I do that stuff in android? I looked at some online guides, and they all seem to create a class to extend a View object, and the class will overrule the onDraw method, where they can cause the Canvas or something to draw a line.</p> <p>But what if you want to draw a line based on user input? That method wouldn't work then would it?</p> <p>For example, what is the simplest code for which I could draw a circle where the user touches the screen?</p> <p>Also, i was wondering what books people would reccomend for beginners, especially one that includes stuff on graphics? I user the developer site for android, but I feel a book would also help a lot to understand android? Any suggestoins?</p> <p>Thank you for your time, I greatly appreciate it!</p>
android
[4]
460,378
460,379
How to access ASP.NET App Over a Network Using IP Address
<p>My asp.net web app is hosted on this URL on my local machine: </p> <pre><code>http://localhost:45433/ </code></pre> <p>I want to access the same application from a different computer on the network. I tried replacing the localhost with my IP but it did not work. </p> <p>any ideas!</p> <p><strong>UPDATE 1:</strong> </p> <p>Now, I am getting this error: </p> <p>Login failed for user ''. The user is not associated with a trusted SQL Server connection.</p>
asp.net
[9]
1,603,605
1,603,606
Can JQuery check for the correct combination of class names eg .correct & .selected via a button?
<p>I'm trying to create a basic game using jQuery where a user clicks and selects a certain combination of images and then a notification appears.</p> <p>Can anyone at the very least can point me in the right direction on how to go about this as all attempts up until now have failed miserably.</p> <p>Thanks.</p>
jquery
[5]
3,356,124
3,356,125
sending sms with php via email or direct no
<p>how can i send sms message to a phone number so that it forwards the sms to the number sent by me........via php</p>
php
[2]
2,828,338
2,828,339
python 2.7 windows 7 installing mysqllib mingw32
<p>setup.py install build --compiler=mingw32</p> <blockquote> <blockquote> <p>gcc: error /Z1: No such file or directory</p> <p>error: command 'gcc' failed with exit status 1</p> </blockquote> </blockquote> <h1>Any suggestions? Thanks!</h1>
python
[7]
2,807,402
2,807,403
Compare dates - overlooking the hour part
<p>I frequently use the NSDate compare method - but I want to consider two dates similar if they are equal in year, month, day. I have made a procesure called "cleanDate" to remove the hour part before I compare.</p> <pre><code>-(NSDate*)cleanDate:(NSDate*)date { NSCalendarUnit unitflags; NSDateComponents *component; NSCalendar *calendar; calendar=[[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]autorelease]; unitflags=NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit; component=[calendar components:unitflags fromDate:date]; return [calendar dateFromComponents:component]; //Dato uten klokke } </code></pre> <p>But my dates come out as:</p> <p>2011-10-28 22:00:00 and some dates as: 2011-10-28 23:00:00</p> <p>I want the hour part to be similar, e.g. 00:00.</p> <p>Whats wrong? Does it have something to do with daylight saving time? Other? Thanks.</p>
iphone
[8]
3,489,143
3,489,144
audit checker for comments
<p>I have a java program that runs automatically every morning and contains several methods that are all independent of each other. Sometimes I have to do testing, so I will comment out all of the methods I am not using. This is a problem bc sometimes I forget to uncomment the code and the program may run for a few days without anyone catching on that its not completely running. </p> <p>Is there any way to set up an automated check for this?</p> <p>Solution: I have decided to add a counter to count the number methods that run and return an error when the number is wrong.</p>
java
[1]
3,750,149
3,750,150
In JavaScript doing a simple shipping and handling calculation
<p>I am having trouble with a simple JavaScript calculation. My document is supposed to add $1.50 to an order if it is $25 or less, or add 10% of the order if it is more then $25. The exact problem is: </p> <p>Many companies normally charge a shipping and handling charge for purchases. Create a Web page that allows a user to enter a purchase price into a text box and includes a JavaScript function that calculates shipping and handling. Add functionality to the script that adds a minimum shipping and handling charge of $1.50 for any purchase that is less than or equal to $25.00. For any orders over $25.00, add 10% to the total purchase price for shipping and handling, but do not include the $1.50 minimum shipping and handling charge. The formula for calculating a percentage is price * percent / 100. For example, the formula for calculating 10% of a $50.00 purchase price is 50 * 10 / 100, which results in a shipping and handling charge of $5.00. After you determine the total cost of the order (purchase plus shipping and handling), display it in an alert dialog box.</p> <p>This is my code:</p> <pre><code> var price = window.prompt("What is the purchase price?", 0); var shipping = calculateShipping(price); var total = price + shipping; function calculateShipping(price){ if (price &lt;= 25){ return 1.5; } else{ return price * 10 / 100 } } window.alert("Your total is $" + total + "."); </code></pre> <p>When testing I enter a number in the prompt box, and instead of calculating as if I entered a number it calculates as if I entered a string. i.e. i enter 19 and it gives me 191.5 or I enter 26 and it gives me 262.6</p>
javascript
[3]
1,520,653
1,520,654
Add Colors in Combo box in .NET Windows application
<p>How to add 'Colors' (not color name, color itself ) as an item in combo box in C#?</p>
c#
[0]
4,278,948
4,278,949
How to get Purchased state of a managed productid in android in appbilling?
<p>I am using market billing Dungeons example for inapp billing.Its working fine.But my problem is i purchased a product with reserved productid "android.test.purchased" and it displays in my product list,but if i uninstall my app and re-install iam not getting the product.How to get purchased items even if i uninstall and reinstall the app.?</p>
android
[4]
485,112
485,113
How to send request in samlphp
<p>I am simplesamlphp download and install simplesamlphp. How to send saml requets(AuthNRequest) in samlphp. </p> <pre><code> how can i send issuesinstant,id,entityid. how can i need this form.. &lt;samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="_d7607d551380ac97853a6ff4907c4ef01219be97dd" Version="2.0" IssueInstant="2008-05-27T07:46:06Z" ForceAuthn="true" IsPassive="false" Destination="https://openidp.feide.no/simplesaml/saml2/idp/SSOService.php" ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" AssertionConsumerServiceURL= "http://dev.andreas.feide.no/simplesamlaml2``sp /AssertionConsumerService.php" &lt;saml:Issuer&gt;http://dev.andreas.feide.no/simplesaml/saml2/sp/metadata.php&lt;/saml:Issuer&gt; &lt;samlp:NameIDPolicy Format="urn:oasis:names:tc:SAML:2.0:nameid-format:transient" AllowCreate="true"/&gt; &lt;/samlp:AuthnRequest&gt; </code></pre> <p>Pls any one help..</p>
php
[2]
2,732,864
2,732,865
TypeError: unsupported type for timedelta days component: datetime.datetime
<p>I am trying to perform some date arithmetic in a function.</p> <pre><code>from datetime import datetime, timedelta def foo(date1, summing_period): current_period_start_date = date1 - timedelta(days=summing_period) # Line above causes the error: # TypeError: unsupported type for timedelta days component: datetime.datetime </code></pre> <p>First arg is a datetime obj and 2nd arg is an integer</p> <p>What is causing this error, and how do I fix it?</p>
python
[7]
2,598,602
2,598,603
Timeago Jquery plugin not working
<p>Jquery:</p> <pre><code>&lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="js/timeago.js" &gt;&lt;/script&gt; $(document).ready(function(){ jQuery("abbr.timeago").timeago(); }); </code></pre> <p>html:</p> <pre><code>&lt;abbr class="timeago" title="2008-07-17T09:24:17Z"&gt;July 17, 2008&lt;/abbr&gt; function Refresh() { setTimeout(function(){ &lt;?php echo 'var id = '.json_encode($_GET['id']).';'; ?&gt; $('#cmdz').load('cmdajax.php?id='+id); },1000); } </code></pre> <p>the #cmdz div contains the abbr tag. time ago working properly in onload but when the div is refreshed it won't works. </p> <p>for some reason jQuery("abbr.timeago").timeago(); function not working. Here you can find full code:http://stackoverflow.com/questions/11083768/after-ajax-call-jquery-function-not-working-properly</p>
jquery
[5]
64,222
64,223
How to change the iframe width and height in PHP
<p>Can any body tell how to change the width &amp; height of iframe in php. in database i am saving below format.while i am displaying i want to fixed size.</p> <p>this is the iframe content</p> <pre><code>&lt;iframe width="400" height="225" src="http://www.youtube.com/embed/c7ct6pNOvEE?feature=oembed" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt; </code></pre> <p><code>Here width &amp; height changes dynamically</code> based on site.then how to convert the width to 500 &amp; height to 350 in php</p> <p>Thanks in advance</p>
php
[2]
5,769,249
5,769,250
C#, rotating 2D arrays
<p>I've looked at other post on rotating 2D arrays, but it's not quite what I want. I want something like this</p> <pre><code> int[,] original= new int[4,2] { {1,2}, {5,6}, {9,10}, {13,14} }; </code></pre> <p>I want to turn it like this, rotatedArray = { {1,5,9,13}, {2,6,10,14}}; I want to do some analysis by column, as opposed to by rows.</p> <p>This works, but is there an easier way??</p> <pre><code> private static int[,] RotateArray(int[,] myArray) { int org_rows = myArray.GetLength(0); int org_cols = myArray.GetLength(1); int[,] myRotate = new int[org_cols, org_rows]; for (int i = 0; i &lt; org_rows; i++) { for(int j = 0; j &lt; org_cols; j++) { myRotate[j, i] = myArray[i, j]; } } return myRotate; } </code></pre> <p>Is there an easy way to iterate through columns in c#?<br> B</p>
c#
[0]
4,190,072
4,190,073
Why does a global application context not work with "getassets"
<p>Just ironed out a bug in my Android app. I was trying to use getAssets() to pull a file from my assets directory. I subclassed Application and returned a "getApplicationContext" object so that all my classes can use a context whenever they need to.</p> <p>But after much headache and NullPointerExceptions, it turns out that I needed to pass a local context variable and use THAT instead. If I use a global application context, getAssets doesn't work!</p> <p>So why is this? What's so special about a local context variable that makes it work. I thought any old "Context" variable was enough to access the necessary methods and make them work properly!</p>
android
[4]
3,540,278
3,540,279
Understanding Global & Local Scope in Javascript
<p>I've been learning Javascript using <a href="http://www.packtpub.com/object-oriented-javascript/book" rel="nofollow">Object-Oriented JavaScript by Stoyan Stefanov</a></p> <p>He offers an example comparing global and local scope:</p> <pre><code>var a = 123; function f() { alert(a); var a = 1; alert(a); } f(); </code></pre> <p>Looking at this example, I expected the first alert to be '123' and the second alert to be '1'. Lo and behold, Stoyan says:</p> <blockquote> <p>You might expect that the first alert() will display 123 (the value of the global variable a) and the second will display 1 (the local a). This is not the case. The first alert will show “undefined”. This is because inside the function the local scope is more important than the global scope. So a local variable overwrites any global variable with the same name. At the time of the first alert() a was not yet defined (hence the value undefined) but it still existed in the local space.</p> </blockquote> <p>The explanation was not clear to me, how can the local variable overwrite the global variable in the first alert? Any other/different explanations would be appreciated.</p>
javascript
[3]
67,173
67,174
complex if statement in python
<p>I need to realize a <em>complex</em> if-elif-else statement in Python but I don't get it working.</p> <p>The elif line I need has to check a variable for this conditions:</p> <p><strong>80, 443 or 1024-65535 inclusive</strong></p> <p>I tried </p> <pre><code>if ... # several checks ... elif (var1 &gt; 65535) or ((var1 &lt; 1024) and (var1 != 80) and (var1 != 443)): # fail else ... </code></pre>
python
[7]
2,923,291
2,923,292
android development phone
<p>Is there any android development phone available? and at what cost? and what is the specialty of this phone comparing with normal android phone? </p>
android
[4]
1,006,805
1,006,806
JavaScript class - trouble accessing public var in private method
<p>Seems like a simple problem, but can't get this to work.</p> <p>In the example below, unselect is called but the public variable 'this.backSelected' is undefined. If I move the code of the unselect method directly into the public off method it works.</p> <p>how would I check a public variable in a private method? I don't understand why this is nor working.</p> <p>Thanks.</p> <pre><code>function MyClass() { // public vars this.isActive = false; this.backSelected = false; // public methods this.on = function() { this.isActive = true; this.backSelected = true; // set back button on image } this.off = function() { this.isActive = false; unselect(); } // private methods function unselect() { if(this.backSelected) { // set back button off image } }; } </code></pre> <p>var obj = new MyClass(); obj.on(); obj.off();</p>
javascript
[3]
3,505,341
3,505,342
Whether can set the theme of ProjectA to ProjectB?
<p>Whether can set the theme of ProjectA to ProjectB? how to modify framework to support it? The code like that:</p> <pre><code>friendContext = this.createPackageContext("com.android.projecta", Context.CONTEXT_IGNORE_SECURITY); Theme theme=friendContext.getTheme(); setTheme(theme); </code></pre> <p>There is not api like: setTheme with Theme object.</p> <p>This idea is not so unreasonable or can not be realized?</p>
android
[4]
3,729,236
3,729,237
split from full stop in java
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/7935858/the-split-method-in-java-does-not-work-on-a-dot">The split() method in Java does not work on a dot (.)</a> </p> </blockquote> <p>I'm new to java. I want to split a String from "." (dot) and get those names one by one. But this program gives error: <code>"Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0"</code> please help me</p> <pre><code> String input1 = "van.bus.car"; System.out.println(input.split(".")[0]+""); System.out.println(input.split(".")[1]+""); System.out.println(input.split(".")[2]+""); </code></pre>
java
[1]