Unnamed: 0 int64 65 6.03M | Id int64 66 6.03M | Title stringlengths 10 191 | input stringlengths 23 4.18k | output stringclasses 10 values | Tag_Number stringclasses 10 values |
|---|---|---|---|---|---|
5,789,396 | 5,789,397 | Sharing password between applications | <p>I have written a application in C# that requires the user to login.</p>
<p>The application contains three sub applications and if the user has identified himself in one applicationn they should not have to login to the others. </p>
<p>The user can start the sub applications from the main application or seperately. Currently im solving it by passing the username and password from the main applications a command line arguments, but i beleive there must be a better way to share the information between applications.</p>
<p>Each application is a seperate assembly. Anyone?</p>
| c# | [0] |
2,366,621 | 2,366,622 | Finding the line numbers of all occurences of a string in a text file | <p>I'm trying to write a function that does the following:</p>
<p>Given a text file, I want to find all occurences of a certain string in this file; then, for each occurence, the line on which it was found should be added to a list. We assume that each line only contains at most one occurence. The text file can get very large, which means a simple for-loop to iterate over each line the file will be too slow.</p>
<p>For example, say we have a file with the content:</p>
<ol>
<li>A B C D E F G</li>
<li>H J K L M N O</li>
<li>G F E D C B A</li>
<li>P Q R S T U V</li>
</ol>
<p>If I were to search for "A", the function would find it on lines 1 and 3 and thus add 1 and 3 to a list (and then return the list).</p>
<p>I was considering binary search, but it seems to require that a list to be sorted and the elements to be distinct - I'm looking for identical values.</p>
<p>So, is any other search algorithm i can base my function on, with roughly the same performance as binary search?</p>
<p>Thanks!</p>
| c# | [0] |
1,837,375 | 1,837,376 | c# Production code running DEBUG version | <p>I have the following code:</p>
<pre><code> #if (DEBUG)
imgPath = GetDirectoryName(Application.ExecutablePath);
#else
imgPath = GetDirectoryName(Application.ExecutablePath) + "\\images\\";
#endif
</code></pre>
<p>When the code went into Production (live site) , it still looked the the DEBUG version. How is this possible? Is there something during the promotion process that can indicate do RELEASE vs DEBUG</p>
| c# | [0] |
2,343,389 | 2,343,390 | UIModalPresentationFullScreen gives error in UniversalApplication | <p>i am created Universal application, in that i used UIModalPresentationFull, for displaying MFMailComposerSheet in iPad, which helps me to show the full screen of a MailComposer view in landscape view of ipad. When i run the application in ipad simulator i works well. If i set it to iPhone simulator 3.0 or 3.1.3 it shows the error like "<strong>error: 'UIModalPresentationFullScreen' undeclared (first use in this function)</strong>" when i comment it and run in iPhone simulator it works what would be the solution for this error or, else is that any method replaces "UIModalPresentationFull" works in both ipad and iphone?</p>
<p>Thanks and regards
Venkat</p>
| iphone | [8] |
4,003,140 | 4,003,141 | ActivityGroup with custom ListView | <p>In my app, it has 4 tabs on the bottom, and each tab is connect to a ActivityGroup:</p>
<pre><code>tabHost.addTab(tabHost
.newTabSpec("Group1")
.setIndicator("group1")
.setContent(new Intent(this, Group1.class)));
</code></pre>
<p>group1 just like a interface that control the behavior of sub Activity</p>
<pre><code>this.history = new ArrayList<View>();
group1 = this;
/** a frame for its child **/
View view = getLocalActivityManager().startActivity(
"Group1_Layer1",
new Intent(Group1.this, costumeList.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
.getDecorView();
replaceView(view);
</code></pre>
<p>and goup1 has a custom ListView:</p>
<pre><code> @Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.xml, null);
ImageView image = (ImageView) v.findViewById(R.id.cell);
.
.
}
return v;
}
}
</code></pre>
<p>but it crashed, and the logCat shows:</p>
<p><code>Unable to start activity, java.lang.NullPointerException</code></p>
<p>the crash just happened in custom ListViews,</p>
<p>other activities don't have this problem,</p>
<p>what's wrong with it? </p>
| android | [4] |
3,292,574 | 3,292,575 | T STRING Error causing me nighamres | <pre><code>// SAVE ACCOUNT SETTINGS
if($task == "dosave")
{
$user->user_info['user_div'] = $_POST['user_div'];
// UPDATE DATABASE
$database->database_query("UPDATE se_users SET user_div='{$user->user_info['user_div']};
</code></pre>
<p>Error received:
Parse error: syntax error, unexpected T_STRING in /home/bennyboy/public_html/user_profile_swap.php on line 26</p>
<p>Any help greatly appreciated.</p>
| php | [2] |
67,878 | 67,879 | How to open and read a file in the src/my/package folder? | <p>I would like to load the contents of a text file in a String.
The text file should stay in the same folder <code>src/my/package</code> as the <code>.java</code>.</p>
<p>However, I can't find the path to this file:
I have tried:</p>
<pre><code>File f = new File("src/my/package/file.js");
File f = new File("file.js");
</code></pre>
<p>and many others but nothing worked.</p>
<p>What is the correct path to my file?</p>
| android | [4] |
5,412,067 | 5,412,068 | passing a value to call-button in android | <p>i am creating a calling application . I am trying to use a default number in actionView and want to pass a mobile number in mobile call button. </p>
<p>this is my code:-</p>
<pre><code>public void onClick(View arg0) {
// this is real calling number
long mobile = "tel:9999999999";
// this is default number.and show in textfield of calling.
Uri uri = Uri.parse("tel:+919910699440");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
// here i want to pass real calling num in Button. so when i press the
//calling button . button will get mobile num but not show.
intent.setData(Uri.parse("tel:"+mobile));
startActivity(intent);
}
</code></pre>
<p>thank you for your time.</p>
| android | [4] |
4,273,027 | 4,273,028 | Where is the path will be set for Request.AppRelativeCurrentExecutionFilePath | <p>I need to know the path for Request.AppRelativeCurrentExecutionFilePath. It gives the wrong file path when i retrieve any requests.</p>
| asp.net | [9] |
1,657,826 | 1,657,827 | Is it possible to do object initialization in JavaScript similar to C#? | <p>More specifically, for a random class with two public properties, in C# you can do something like this : </p>
<pre><code>new Point() {
Y = 0,
X = 0
}
</code></pre>
<p>Is it possible to do something similar in JavaScript? I was thinking of something along the line of :</p>
<pre><code>{
prototype : Object.create(Point.prototype),
X : 0,
Y : 0
}
</code></pre>
<p>but I don't think it works as intended. Or a simple copy function : </p>
<pre><code>function Create(object, properties) {
for (p in properties)
object[p] = properties[p];
return object;
}
</code></pre>
<p>so the object initialization would become : </p>
<pre><code>Create(new Point(), {X : 0, Y : 0});
</code></pre>
<p>but there is an extra object creation. Is there a better way of achieving this?</p>
| javascript | [3] |
3,253,653 | 3,253,654 | Sending messages between threads in C# | <p>How can I sending and receiving message between threads?</p>
| c# | [0] |
1,597,472 | 1,597,473 | Can't understand SecurityManager.IsGranted() | <p>I intentionally reduced the permission for a method to see whether IsGranted method works, but it doesn't. Here's my code:</p>
<pre><code>[FileIOPermission(SecurityAction.Deny, Read = "d:\\faz.txt")]
void aMethod()
{
Console.WriteLine(SecurityManager.IsGranted(new
FileIOPermission(FileIOPermissionAccess.Read,"d:\\faz.txt")));
}
</code></pre>
<p>The method returns true even if the method never given that permission. Can some one please explain about this issue.</p>
| c# | [0] |
3,070,735 | 3,070,736 | Explode a string into a hashmap for searching? | <p>I have a string like this being returned from my backend:</p>
<pre><code>"1,2,3,4,5,6"
</code></pre>
<p>I have a large array locally and want to display only those items not in this list, so I was thinking of exploding this string into an array but how can I search efficiently? As far as I know there are no hashmaps in JS so how does one do this? I just need to check for key existence.</p>
| javascript | [3] |
1,428,378 | 1,428,379 | jQuery possible to Detect when a user is in a Textarea and when they leave? | <p>jQuery possible to Detect when a user is in a Textarea and when they leave? so I could make a textarea height = 15px when the user isn't focused on it...</p>
<p>But when the user does click and focus on the textarea it gets a height of 50px?</p>
| jquery | [5] |
4,878,736 | 4,878,737 | Function not loading on page | <p>Click event with jquery function is not working when it is before the a tag but it is working fine after the a tag. Also, if I use <code>document.ready</code> then it works. I would like to know why it is not working when it is before the a tag.</p>
<pre><code><head>
<script type="text/javascript">
function jchand(){
$('a').click(function(){
alert('a')
})
}
jchand();
</script>
</head>
<body>
<a href="#" >click me</a>
</body>
</code></pre>
| jquery | [5] |
769,072 | 769,073 | how do i remove the matched character from a string? | <p>here is my code</p>
<pre><code>$a = "Hey there, how do i remove all, the comma from this string,";
$a = str_replace($a,',','';)
echo $a;
</code></pre>
<p>i want to remove all the commas available in the string, how do i do it?</p>
| php | [2] |
3,314,386 | 3,314,387 | Pass mysqli object to class | <p>I want to pass a mysqli object to a class. I create the object in one file:</p>
<pre><code>$host = 'host';
$user = 'username';
$pw = 'pw';
$db = 'db';
$link = new mysqli($host,$user,$pw,$db);
</code></pre>
<p>which is included in one page:</p>
<pre><code>include 'php/mysql.php';
include 'php/classes/Class.Dataconnector.php';
$dc = new Dataconnector($link);
</code></pre>
<p>and the class looks like this:</p>
<pre><code>class Dataconnector {
protected $_link;
protected $_stub;
function __construct(mysqli $link) {
$_link = $link;
}
public function getPageContent($stub) {
$query = "select * from contents where pageId = (select id from pages where stub = '$stub')";
$result = mysqli_query($_link,$query);
return $result;
}
}
</code></pre>
<p>But I get this error:</p>
<pre><code>Warning: mysqli_query() expects parameter 1 to be mysqli, null given in \php\classes\Class.Dataconnector.php on line 18
</code></pre>
<p>What is wrong ?</p>
| php | [2] |
5,139,986 | 5,139,987 | Which university is offering video courses in programming languages? | <p>Frankly speaking. I'm looking for a specific video course webpage which I visited few months ago. It was posted as an answer to some question. I know this kind of questions are frowned upon and closed. But I'm helpless. I've been searching for it for more than a month and this is my last approach.</p>
<p>I'm writing a report on education methodologies. Professor taking that course was trying a new approach. I <em>need</em> to go through it once again to include that in my report. I'm really hoping that some one would give me link to that page. Here is the description of that course & webpage.</p>
<p><strong>Description of course & webpage:</strong></p>
<ol>
<li>They were offering video courses in more than one language. AFAIR, languages were Python, Java, (Haskell).</li>
<li>First lecture of course is about his new approach of teaching. Prof mentions something like "unlike a traditional university course, this course doesn't have two or three big exams or it doesn't have cutoff marks and hence no pass or fail. After each topic is taught they'll need to give a quiz. If they don't get around 70% then they'll have to keep on giving the test until he scores it.". He goes on to show some performance statistcs (he uses slides for this) of his previous students in previous programming courses and why he took this new approach. etc..etc.. I don't exactly remember it. But I was very much impressed with the concept. Now this is exactly what I'm after.</li>
<li>Also that prof's webpage has a time lapse of some building construction out side his room's window.</li>
</ol>
<p>I wish I could start bounty now itself.</p>
| python | [7] |
3,348,147 | 3,348,148 | Not able to change <label> text using jquery in IE | <p>I am using below code to change label value using JQuery.</p>
<pre><code>$("#labelId").text('Some Text here:');
</code></pre>
<p>although it is working in mozilla and chrome but it is not working in IE (any versions).</p>
<p>What should be the solution for this?</p>
| jquery | [5] |
5,201,948 | 5,201,949 | Disable specific version for example Honeycomb / 3.1 | <p>Is there a way to disable a specific version from Google Play.
For example hide/disable Honeycomb version 3.1 from Google Play?</p>
<p>Currently I have</p>
<pre><code><supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true"/>
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="10"/>
</code></pre>
<p>But I don't want user with version 3.1 to see my app.</p>
<p>Thanks!</p>
| android | [4] |
2,150,910 | 2,150,911 | shutil.copy script not working | <p>I wrote a script in python that was supposed to copy a bunch of files to system32 and then install them through cmd.</p>
<p>I can do it manually but I'm trying to make it automatic. This is what I wrote:</p>
<pre><code>import shutil
import os
L = ['file1.type', 'file2.type'.... ]
dst = "C:\\Windows\\system32"
for f in L:
shutil.copy(f, dst)
os.system("cmd command yada yada...")
</code></pre>
<p>And it doesn't work. I tried doing it step by step with idle and it worked fine. All the files are in the same directory as the script. What am I missing here?</p>
| python | [7] |
4,202,830 | 4,202,831 | jquery zoom and pan | <p>i am using jquery-1.2.6.js and jquery.panFullSize.js two js file to Zoom and Pan image.</p>
<p>here is my html,</p>
<pre><code><a href="#" id="zoom">Zoom< /a>
<img src="testimage.jpg" alt="finnish winter" width="600" border="0"
usemap="#mypicMap" id="mypic" style="border: medium solid black" />
</code></pre>
<p>Here is my javascript,</p>
<pre><code>$("img#mypic").panFullSize(700, 450).css("border", "medium solid black");
$("a#zoom").toggle(function(){
$("img#mypic").normalView();
},
function(){
$("img#mypic").panFullSize();
}
);
</code></pre>
<p>what i am trying, if i click on the image(mousedown <200 microsecond ) it will zoom in / out (toggle) as zoom hyperlink working. and if i drag(mousedown >200 microsecond ) the image then it will pan as pan working.</p>
| jquery | [5] |
4,671,148 | 4,671,149 | Prevent a multi-select input box from deselecting all the options if the user clicks a single record | <p>Is there a way to prevent a multi-select input box from deselecting all the options if the user clicks a single record with using the <kbd>Ctrl</kbd> button? Basically they would have to click the item from the list to turn it on or off and the other values would always stay either selected or unselected unless there was a click.</p>
| jquery | [5] |
1,619,176 | 1,619,177 | How to send email from code ? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3491651/how-to-send-an-email">How to send an email?</a> </p>
</blockquote>
<p>I have some simple winform application.
In some place in the flow the user have button that if he will press on it the application will send email to some know mail address. </p>
<p>How can i implement this ?
How can i send the mail ? </p>
<p>Thanks for any help. </p>
| c# | [0] |
4,200,677 | 4,200,678 | obj expected error when run javascript function in asp form (visual studio) | <p>i get obj expected error when click on asp button. where is the problem?</p>
<p>code:</p>
<pre><code><%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script type"text/javascript">
Hmove=-100;
function moveObjRight(obj) {
obj.style.left=Hmove;
Hmove+=2;
if(Hmove<100)
window.setTimeout("moveObjRight(" +obj.id+ ");", 0);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
#AS
{
top: 141px;
left: 118px;
position: absolute;
height: 25px;
width: 25px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<img alt="asd" src="pic 3-4.jpg" id="AS"/>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="moveObjRight(AS);"/>
</div>
</form>
</body>
</html>
</code></pre>
| javascript | [3] |
3,103,831 | 3,103,832 | ASP.NET MVC 3 Compare 2 Lists with Model Objects for duplicates | <p>I am building an ASP.NET MVC 3 application, where I have on list of custom objects according to this model:</p>
<pre><code>public class AbnAmroTransaction
{
public int TransactionId { get; set; }
public int AccountNumber { get; set; }
public string Currency { get; set; }
public int TransactionDate { get; set; }
public int InterestDate { get; set; }
public decimal StartBalance { get; set; }
public decimal EndBalance { get; set; }
public decimal Amount { get; set; }
public string Description { get; set; }
public int CategoryId { get; set; }
}
</code></pre>
<p>I also have second list with slightly similar objects of custom object type "Transaction" (which I get from my SQL Server 2008 database using a DBML):</p>
<pre><code>Transaction LinqToSql Object
int TransactionId
int ImportId
int CategoryId
DateTime DateTime
Nvarchar(MAX) Currency
Money Amount
Nvarchar(MAX) Description
</code></pre>
<p>I'm trying to create a 3rd list that contains all AbnAmroTransactions, where the AbnAmroTransaction.TransactionId is not in the Transactions list (TransactionId). How do I do this without having to loop through both lists, which seems like a very unefficient way to do it?</p>
<p>I have found this article:
<a href="http://msdn.microsoft.com/en-us/library/system.collections.iequalitycomparer.equals.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.collections.iequalitycomparer.equals.aspx</a>
But that only seems to apply to objects of the same type.</p>
| c# | [0] |
1,334,016 | 1,334,017 | infinitly execution while send broadcast | <p>I want to use<br>
<code>context.sendBroadcast(intent, receiverPermission);</code> </p>
<p>in my application
but I don't know to pass receiverPermission parameter in function and also how to set in manifest file
please any body help me</p>
<p>I want to show you my source code</p>
<pre><code>public class LocationReceiver extends BroadcastReceiver {
public static final String BROADCAST_ACTION = "LOCATION_CHANGE";
@Override
public void onReceive(Context context, Intent intent) {
intent.setAction(BROADCAST_ACTION);
Bundle b = intent.getExtras();
Location loc = (Location)b.get(android.location.LocationManager.KEY_LOCATION_CHANGED);
Logger.debug("Loc:"+loc);
if(loc != null){
doBroadCast(context,intent,loc);
}
}
public void doBroadCast(final Context context,final Intent i1,final Location loc){
Handler h = new Handler();
h.post(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
Logger.debug("LocationReceiver->sendLocation update broadcast");
i1.putExtra("Latitude", loc.getLatitude());
i1.putExtra("Longitude", loc.getLongitude());
context.sendBroadcast(i1,null);
}
});
}
}
</code></pre>
<p>and on activity I have write</p>
<pre><code> @Override
protected void onResume() {
registerReceiver(broadcastReceiver, new IntentFilter(LocationReceiver.BROADCAST_ACTION));
}
private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
UpdateUI(intent);
}
};
private void UpdateUI(Intent i){
Double Latitude = i.getDoubleExtra("Latitude",0);
Double Longitude = i.getDoubleExtra("Longitude",0);
showMap(Latitude, Longitude);
}
</code></pre>
<p>Now my problem is when it sendbroadcast it execute infinitly doBroadcast function(), please help me to come out.</p>
| android | [4] |
2,580,858 | 2,580,859 | Filtering ArrayList of Strings | <p>I have an array list of strings and I would like to remove strings which are below a certain length. I was thinking about this method:</p>
<pre><code> for (int i = 0; i < result.size(); i++) {
if (result.get(i).split("\\s").length != maxLength) {
System.out.println(result.get(i));
result.remove(i);
}
}
</code></pre>
<p>But it is only removing few entries because when it removes one then it shifts the next one in the place of removed one. What is the other way to do that</p>
| java | [1] |
580,667 | 580,668 | converting date and time string to unsigned __int64 in C++ | <p>I have a requirement in <a href="/questions/tagged/c%2b%2b" class="post-tag" title="show questions tagged 'c++'" rel="tag">c++</a>, which I have to read a file which consists date and time and convert it to <code>unsigned __int64</code>.</p>
<p>For example I have a file "mytime.txt" with following data.</p>
<pre><code>2012-06-25 05:32:06.963
</code></pre>
<p>How do I convert it to <code>unsigned __int64</code>, and how do I convert back from <code>unsigned __int64</code> to the above string to write to file and also to verify it is converted to <code>unsigned __int64</code> correctly.</p>
<p>I am working on windows in VS.NET C++ compiler.</p>
<p>I am not supposed to use <code>boost</code>.</p>
| c++ | [6] |
3,232,529 | 3,232,530 | Unable to start debug on web server Webserver is not configured properly | <p>I am getting the error as i specifed and when i check out the properties <code>Web Sites</code> in <code>IIS</code> it is showing as per below is it correct i think some are miising here can any one tell how to resolve this</p>
<p><img src="http://i.stack.imgur.com/L1oDW.png" alt="enter image description here"></p>
| asp.net | [9] |
138,638 | 138,639 | selecting phone from iphone contacts | <p>I am a new comer in iphone development.I am developing an application for iphone which needs to select phone number and name from iphone contacts .I used "ABPeoplePickerNavigationController" class to open the contacts view.I need to show some instructions which guides the user to select the phone number when the contacts view opens.Is there any way to do this ?Because the contacts view covers the entire parent view ..Looking for a solution</p>
<p>Thanks in advance</p>
| iphone | [8] |
2,856,307 | 2,856,308 | PHP:: three echo statements with the same result | <p>Perhaps this is a petty question, but consider the following PHP code:</p>
<pre><code>$a = "foo1"; $b = "foo2"; $c = "foo3";
echo $a, $b, $c;
echo $a . $b . $c;
echo "$a$b$c";
</code></pre>
<p>aren't these three statements equivalent. What's the difference.
What if one cannot decide whether to use one or the other?</p>
| php | [2] |
4,442,772 | 4,442,773 | compare string from a list of strings | <p>i'm reading a file with 10002 lines, in each line there is a name that I want to compare with a single string, and if this string is the same, i want to add the string file to a listbox, I'm using the FILE.READLINE and then add each line to a list then I use .CONTAINS method and doesnt works also with == but that doesn work either...Any suggestions?</p>
<pre><code>//This is my code:
foreach (string h in Directory.EnumerateFiles(NomDirec, "resume*"))
{
this.listBox1.Items.Add(h);
//Read Lines here and add them to a list and a listbox
var NombreLinea = File.ReadLines(h);
foreach (var item in NombreLinea)
{
NombreAbuscar.Add(item).Remove(item.IndexOf(":"));
this.listBox3.Items.Add(item);
}
//Here I want to add this file only if "NombreCompleto" is present in my resume file.
foreach (string t in Directory.EnumerateFiles(NomDirec, "ESSD1*"))
{
string[] Nombre = File.ReadLines(t).ElementAtOrDefault(6).Split(':');
string[] ApellidoPat = File.ReadLines(t).ElementAtOrDefault(7).Split(':');
string[] ApellidoMat = File.ReadLines(t).ElementAtOrDefault(8).Split(':');
string NombreCompleto = ApellidoPat[1] + ApellidoMat[1] + "," + " " + Nombre[1] + " " + ":";
foreach (var item in NombreAbuscar)
{
if (NombreCompleto == item)
{
this.listBox1.Items.Add(t);
break;
}
}
}
</code></pre>
<p>Could be a way to only read the a certain part of the line and add it to my listbox??</p>
| c# | [0] |
5,186,454 | 5,186,455 | Image processing Iphone | <p>I like to develop a hair styling application for which allows the user to take a picture and try different predefined hair styles.I need to correctly place the predefined hair in correct position of image.I really don't know from where i need to start.If any one have any ideas please share it. Thanks in advance .....</p>
| iphone | [8] |
4,793,242 | 4,793,243 | Convert FLV to MP4 or 3GP | <p>Can I convert videos with PHP or do I have to use some library?</p>
| php | [2] |
5,875,665 | 5,875,666 | Stop Mirror Effect in Android Thumbnails? | <p>If I call MediaStore.Images.Thumbnails.getThumbnail() with the parameter "kind" set to MINI_KIND, many of the returned thumbnail images have an annoying mirror effect applied to them, and the image is larger than it should be because an appended part of the image "reflects" the other half.</p>
<p>Does anyone know how to stop this? I have looked at the MediaStore.java source code and I cannot find where Android creates the mirror effect:</p>
<p><a href="http://www.devdaily.com/java/jwarehouse/android/core/java/android/provider/MediaStore.java.shtml" rel="nofollow">http://www.devdaily.com/java/jwarehouse/android/core/java/android/provider/MediaStore.java.shtml</a></p>
<p>The getThumbnail() call does use a BitmapFactory.Options parameter for decoding the MINI_KIND. But I cannot see where in BitmapFactory.Options there is a flag to create or decline a mirror effect.</p>
<p>Thank you.</p>
| android | [4] |
4,819,671 | 4,819,672 | Android: Gapless playback of a looped audio file in MediaPlayer | <p>I am playing a setLooped enabled audio file in my app, but every time the audio file loops, there is a noticeable, though very brief, gap in the audio playback... is there any way to get around this?</p>
| android | [4] |
2,033,810 | 2,033,811 | Viewing all photos in a folder in android on the web | <p>I am running a web server and storing all my photos at a folder called photos. Now I want the android application to list all the photos under that particular folder(It can be a slide show or a grid view). I know how to load an image from a url . But I am really unsure about how to view all the images stored on a folder. Could someone please point me in the right direction. </p>
| android | [4] |
3,425,132 | 3,425,133 | session not working | <p>I am using SQL express 2008 and visual studio 2010.</p>
<p>I made a simple login form using session. I want that if the session is null the user shouldn't be able to go to the desired page. I have written the following code:</p>
<pre><code>public void btnsubmit_CLICK(object sender, EventArgs e)
{
if (TextBox1.Text =="admin" && TXTID.Text =="admin")
{
Session["user"] = "admin";
Response.Redirect("generate_report.aspx");
}
else
{
lblmsg.Text = "user name Or password is not correct!";
}
</code></pre>
<p>NEXT PAGE:</p>
<pre><code>protected void Page_Load(object sender, EventArgs e)
{
if (Session["user"] != "admin")
{
Response.Redirect("Default.aspx");
}
</code></pre>
<p>It is working fine if I use it locally but when I load it on the client server it doesn't work at all. Why is so?</p>
| c# | [0] |
3,877,084 | 3,877,085 | inline function -- "unresolved external" error? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3540931/inline-functions-in-c">Inline functions in C++</a> </p>
</blockquote>
<p><code>#foo.cpp</code></p>
<pre><code>void func1(){
...
}
inline void func2(){
...
}
</code></pre>
<p><code>#boo.cpp</code></p>
<pre><code>void func3{
func1();
func2();
}
</code></pre>
<p>for <code>func1</code>, we say that after everything has been compiled, linker uses the address of func1 to make a call to it. For <code>func2</code>, as it is inline and defined in <code>foo.cpp</code>, compiler will not get the it's definition to replace <code>func2</code> call but inline functions also have addresses then why can't linker use this address of <code>func2</code> to link its call and gives the error of unresolved external?</p>
| c++ | [6] |
4,720,699 | 4,720,700 | Checking if a View == null before setting onClickListener | <p>I usually create the <code>initialize()</code> function and functions for setting on-click listeners, and then I call these functions from an Activity's <code>onCreate()</code>. When I call <code>someView.setOnClickListener(...)</code> in a function, should I check if the <code>someView == null</code> or not? I know, that it <code>!= null</code>, but I need an advice about coding style. Which is the best practice?<br />
Here is an example:</p>
<pre><code>...
public class SomeActivity extends Activity
{
private ImageButton someButton;
private Intent someIntent;
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
setContentView(R.layout.add_alarm);
initialize();
setSomeButtonHandler();
}
public void initialize()
{
someButton = (ImageButton) findViewById(R.id.someButton);
}
public void setSomeButtonHandler()
{
if(someButton != null) //Should I check this?
{
someIntent = new Intent(SomeActivity.this, SomeButtonActivity.class);
someButton.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
startActivity(someIntent);
}
});
}
}
}
</code></pre>
| android | [4] |
5,222,805 | 5,222,806 | Session object with WCF? | <p>Is it possible to use Session object with WCF to store session related data?
If yes the can you describe how?</p>
<p>Thanks</p>
| c# | [0] |
3,652,317 | 3,652,318 | How to make Java Swing Desktop app communicate with a server? | <p>ex) Authenticate users on their desktop app from a server.</p>
<p>Questions about server: Do I have to use Tomcat ? Are there any other solutions ? could I even use Apache ?</p>
| java | [1] |
5,947,109 | 5,947,110 | How to save the contents of Data URI to image | <p>In Google Chrome the <strong>'chrome.tabs.captureVisibleTab(integer windowId, function callback)</strong>' method will return a data URL of the JPEG encoding of the visible area of the captured tab.</p>
<p>We want to save that content as image to hard disk without opening/passing the contents into new html page.</p>
<p>Does anybody know how it can be done by javascript.
Please provide help.</p>
<p>Thanks.</p>
| javascript | [3] |
214,488 | 214,489 | PHP new array from old array | <p>Here is the code in question:</p>
<pre><code>$countries = array("New Zealand", "Australia", "United Kingdom", "New Zealand");
</code></pre>
<p>I am after some code that will let me declare a new array from this previous array with me specifying how many items in the array.</p>
<p>eg:</p>
<p>If I did something like this:</p>
<pre><code>$newArray = $countries[1], $newArray will hold "New Zealand" and "Australia"
$newArray = $countries[2], $newArray will hold "New Zealand", "Australia" and "United Kingdom"
</code></pre>
<p>Currently I am doing this by using a for loop. Is there an easier/more efficient way to do this?</p>
<p>thanks</p>
| php | [2] |
2,446,212 | 2,446,213 | python multiline string - $ for variables | <p>I'm looking for a clean way to use variables within a python multiline string. Say I wanted to do the following</p>
<pre><code>string1 = go
string2 = now
string3 = great
"""
I'm will $string1 there
I will go $string2
$string3
"""
</code></pre>
<p>In a way I'm looking to see if there is a perl like $ to indicate a variable in the python syntax.</p>
<p>If not - what is the cleanest way I can achieve this multiline string with variables.</p>
| python | [7] |
1,904,882 | 1,904,883 | How to distinguish whether a word is half-width or full-width? | <p>Recently I've been dealing with texts with mixed languages, including Chinese, English, and even some emoticons.</p>
<p>I've been searching for this issue quite a lot, but the only thing I can find is "to replace full-width characters with half-width characters" rather than telling you how to determine whether the character is a half- or full-width word.</p>
<p>So, my question is:</p>
<p><strong>Is it possible to tell whether a word is half-width or full-width?</strong></p>
| python | [7] |
5,864,603 | 5,864,604 | How to assign the value of AutoCompleteTextView from Dropdown selected value to another String | <p>Friend's
I need help on setting the data content showing from DropDownlist of auto complete text box to another string,when i click the particular content from dropdown list.
Help me.</p>
<p>thanks in advance.</p>
| android | [4] |
172,279 | 172,280 | Am I allowed to pass an integer pointer to a function that takes an integer array as an argument in c++? | <p>Probably a stupid question to ask, but seeing as how I'm new here, and this question has to do with a project I'm working one, I'm sure it wouldn't hurt to ask. Many thanks to whosoever answers.</p>
| c++ | [6] |
3,322,238 | 3,322,239 | I want to refresh treeview with new value | <p>I use the following code to display xml as a treeview.</p>
<p>Now I want to refresh when I edit xml by using some text box in same window. When I edit and save file using textbox I want to refresh treeview also with that new value. </p>
<p>How can I do it?</p>
<p>I use <code>treeview1.update();</code> and <code>treeview1.refresh();</code> but it's not working.</p>
<p>I used the following code part: </p>
<pre><code>private void button1_Click(object sender, EventArgs e)
{
XmlDataDocument xmldoc = new XmlDataDocument();
XmlNode xmlnode ;
FileStream fs = new FileStream("tree.xml", FileMode.Open, FileAccess.Read);
xmldoc.Load(fs);
xmlnode = xmldoc.ChildNodes[1];
treeView1.Nodes.Clear();
treeView1.Nodes.Add(new TreeNode(xmldoc.DocumentElement.Name));
TreeNode tNode ;
tNode = treeView1.Nodes[0];
AddNode(xmlnode, tNode);
}
private void AddNode(XmlNode inXmlNode, TreeNode inTreeNode)
{
XmlNode xNode ;
TreeNode tNode ;
XmlNodeList nodeList ;
int i = 0;
if (inXmlNode.HasChildNodes)
{
nodeList = inXmlNode.ChildNodes;
for (i = 0; i <= nodeList.Count - 1; i++)
{
xNode = inXmlNode.ChildNodes[i];
inTreeNode.Nodes.Add(new TreeNode(xNode.Name));
tNode = inTreeNode.Nodes[i];
AddNode(xNode, tNode);
}
}
else
{
inTreeNode.Text = inXmlNode.InnerText.ToString();
}
}
</code></pre>
| c# | [0] |
556,451 | 556,452 | asp.net 4.0: data access strategy for single stored procedure retuning multiple recordsets in web page | <p>what is the recommended data access strategy for the following environment: single stored procedure, many parameters, asp.net 4.0, sql server 2008, and the stored proc returns 11 different recordsets, all of which get displayed in various different elements too complex and specific to be handled by server controls. Thoughts?</p>
| asp.net | [9] |
4,313,874 | 4,313,875 | How can I delete calender events in android programmatically? | <p>If it possible to delete then give some hint.</p>
| android | [4] |
4,650,979 | 4,650,980 | Why UIAlertView need to be localized? | <p>I have declared UIAlertView *alert in the .h file. alloc alert in func1. and show & release in func2. This would cause memory BAD_EXEC_ACCESS issue.</p>
<pre><code>-(void) func1
{
alert= [[UIAlertView alloc] initWithTitle:nil message:@"To Confirm." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
}
-(void) func2
{
[alert show];
[alert release];
}
</code></pre>
<p>If I do following it's OK. If everything localized in a function then its OK. Why?</p>
<pre><code>-(void) func1
{
alert= [[UIAlertView alloc] initWithTitle:nil message:@"To Confirm." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
</code></pre>
| iphone | [8] |
910,289 | 910,290 | How to make unix timestamp to show time over 24 hours? | <p>I would like to show any give time in hours only.</p>
<p>Example:</p>
<p>Unix timestamp: 169200</p>
<p>Which is equal to 1 day and 23 hours...</p>
<p>But how can I convert this to hours so it shows 47:00:00 (47 hours)?</p>
<p>Thanks</p>
<p><strong>Edit</strong>: It must show minutes and seconds too ;)</p>
| php | [2] |
2,394,420 | 2,394,421 | Exiting Foreach loop in C# | <pre><code>foreach (var name in parent.names)
{
if name.lastname == null)
{
Violated = true;
this.message = "lastname reqd";
}
if (!Violated)
{
Violated = !(name.firstname == null) ? false : true;
if (ruleViolated)
this.message = "firstname reqd";
}
}
</code></pre>
<p>// whenever violated is true I want to get out of the foreach loop immediately. How do I do it? </p>
| c# | [0] |
4,617,750 | 4,617,751 | Finding total number of words in .txt document | <pre><code>find = open("words.txt")
def noE():
for line in find:
if line.find("e") == -1:
word = line.strip()
print word,
noE()
</code></pre>
<p>The above code searches the .txt file for all words that do not contain the letter "e" and then prints them. I would like to then be able to get a count of the total number of words under this <em>if</em> conditional. I looked into the python docs and found Count() but the import wasn't working for me (assuming I did something wrong). Any help would be much appreciated! </p>
| python | [7] |
3,816,812 | 3,816,813 | How to connect Android user with his web account on the site | <p>I have a website with a database of users. On the site, I ask for their name and email.</p>
<p>I am making an Android app for that website and want to keep track of the mobile users in the same way. Should I explicitly make them fill out a form on the mobile device if they are registering for the first-time?</p>
<p>If so, whats the best practice way of handling passwords in Android forms?</p>
| android | [4] |
694,681 | 694,682 | passing subdomain to a variable then creating new url | <p>HI,
I am nearly there I think but am struggling to put the final bits in place. </p>
<p>I am trying to look up the the subdomain of a number of different envoronments and pass the subdomain as a variable to prefix a url called via an onclick event. This is all delivered through an xsl transformation. </p>
<p>I am just getting the domain passed to the link at present. Any tips on how to make this work or write the code in a better way greatly appreciated.</p>
<pre><code> <xsl:text disable-output-escaping="yes">
<![CDATA[
<script type="text/javascript">
function enironment()
{
if (window.location.host.toLowerCase() === 'www.mydomain.com') {
SsoServer = "https://sso.mydomain.com";
}
else{
var sub_domain = window.location.split('.')[0].split('//')[1];
SsoServer = "https://" + sub_domain + "sso.mydomain.com";
}
top.location.replace(SsoServer);
}
</script>]]>
</xsl:text>
<a href="#" onClick="javascript:enironment()" title="Sign in">Sign
in</a>
</code></pre>
| javascript | [3] |
479,714 | 479,715 | Should I comment my log calls when creating my final package? | <p>I have an application that uses a lot of Log.d() or Log.e() calls for debugging. Now I want to create my final package for release. The Android Export feature from Eclipse mentions to remove the "Debuggable" flag in the manifest, which I have done. Should I also comment all the Log calls to improve the performance of my application or these calls will do nothing in the non debuggable final version package ?</p>
| android | [4] |
5,765,662 | 5,765,663 | Changing the background of a <td> by firing a click event is not working | <p>I have a requirement hope i can get answer here.<br>
I am using a theme in my web application. That will style the Table as By the default table rows will have colors alternatively as shown below. </p>
<p><img src="http://i.stack.imgur.com/Nz5Lr.png" alt="enter image description here"><br>
The color will be changed whenever i click on any of that Checkbox or radio buttons(Assumes we are clicking on checkbox means we are clicking on ).But if i change the property of checkbox programatically (with exclusive buttons), style is not effecting on that as below. </p>
<p><img src="http://i.stack.imgur.com/bna3X.png" alt="enter image description here"></p>
<p>for that i have written a code to manually fire Click event. But it is not working.. Please someone help me. Below is my code.I can't paste HTML, Sorry.</p>
<pre><code> $('TABLE TBODY TR TD INPUT').change(function() {
if($(this).prop('checked'))
{
S(this).parents('TD').click();
}
});
</code></pre>
| jquery | [5] |
2,418,768 | 2,418,769 | Sending text file line by line to server | <p>This code is supposed to send data from a text file line by line to a server. But its sending only the 1st line. how to move to next line of text file in android. And after sending I want to delete the line.</p>
<pre><code>File file = new File(Environment.getExternalStorageDirectory(),"/BPCLTracker1/gpsdata.txt");
File f1=new File(Environment.getExternalStorageDirectory(),"/BPCLTracker1/gpsdata.txt");
RandomAccessFile in = null;
RandomAccessFile in1 = null;
try
{
in = new RandomAccessFile(file, "rw");
in1= new RandomAccessFile(f1, "rw");}
catch (FileNotFoundException e)
{// TODO Auto-generated catch bloc e.printStackTrace();}
String line ="0";
while (true)
{
try
{
if (isInternetOn())
{
while ((line = in.readLine()) != null)
{
HttpEntity entity;
HttpClient client = new DefaultHttpClient();
String url = "some url is here";
HttpPost request = new HttpPost(url);
StringEntity se = new StringEntity(line);
se.setContentEncoding("UTF-8");
se.setContentEncoding(new BasicHeader(
HTTP.CONTENT_TYPE, "application/json"));
entity = se;
request.setEntity(entity);
HttpResponse response = client.execute(request);
entity = response.getEntity();
if (entity != null) {}
}
}
}
}
</code></pre>
<p>Thank You</p>
| android | [4] |
2,379,682 | 2,379,683 | how can i set time delay between two functions in iPhone? | <p>I build app which call to server. </p>
<p>it takes for 20 seconds - 30 seconds to get reply from server, because the system we use depending to outside service (connecting to our partners system).</p>
<p>before i can do the next, i must wait to get results. </p>
<p>is there any way to set the delay time for waiting reply???</p>
<p>thanks in advance</p>
| iphone | [8] |
83,205 | 83,206 | how to make array of words contained in string? | <p>i have a string </p>
<p><code>gpbusd buy update HIT 40 PIPS HIT 110 PIPS gpbusd buy BREAK EVEN update HIT 100+ gpbusd buy 1.5500/25 1.5455 new 40 100+ gpbusd buy update CLOSE 0 TO 10 PIPS N gpbusd buy 1.5335/50 1.5320 new 40 80+ gpbusd buy update 15-20 PIPS CLOSE KEEP OPEN gpbusd buy 1.5530/50 1.5505 update HIT 80 KEEP OPEN gpbusd buy 1.5530/50 1.5465 new 40 80 100+ gbpjpy sell 131.05/.130.75 132.15 new 60 100 keep open eurusd sell 1.2840/20 1.2870 STOP update</code></p>
<p>i want to make array of the words contained between spaces of string?how can i do it?</p>
| iphone | [8] |
851,824 | 851,825 | splitting of xml file using c# | <p>I am using c# and am creating xml from an external data source and saving the xml as a single xml file. How can I split the xml up and save it as multiple xml files? For example, say there are 263 records in my xdocument xml. I need to split that into multiple xml files containing exactly 25 records. (That's the specs - no way around it.) So, for this example, I'd end up with 11 xml files.</p>
<p>My data source is a XML file , and I have the option of splitting that into chunks of 25 records per XML file, if that is easier. How would I approach doing it that way?</p>
| c# | [0] |
5,148,758 | 5,148,759 | C++ I'm getting expected ‘;’ before '\xa' from g++ 4.4.3 from this code | <pre><code>#include <iostream>
using namespace std;
int main()
{
// char[20] name = "blah";
int ssn = 123456789;
int dob = 12742;
cout << ssn '\n';
cout << dob'\n';
return 0;
}
</code></pre>
| c++ | [6] |
5,869,988 | 5,869,989 | How can i know that the AsyncTask that ran on the background is done ? | <p>There is something that i don't understanding here ... </p>
<p>I define class </p>
<pre><code>public class SendStringToServer extends AsyncTask<String, Integer, Boolean>
{
.
.
.
}
</code></pre>
<p>Now, i implimented the 'onPostExecute' method and i calling this background action from the main activity by using</p>
<pre><code> new SendStringToServer().execute("stringToSend");
</code></pre>
<p>Now, How can i know from the main activity that this action was done ?
Hiw can i know from the main activity that this string was send already ? </p>
| android | [4] |
3,263,665 | 3,263,666 | how to get all folder only in a given path in python? | <p>i'm using this code to get all files in a given folder. Is there a way to get only the folders ?</p>
<pre><code>a = os.listdir('Tools')
</code></pre>
| python | [7] |
3,456,492 | 3,456,493 | Where to save classes of the web-application | <p>I have to create a small asp.net-application. The last such web-application I have built was a while ago. At this time, I have saved my classes in the <code>App_Code</code>-folder. </p>
<p>During setting up the web-solution in VS2010, I have seen that VS does no more propose to create the <code>app_code</code> directory (right click on the project, Add asp.net-folder). Is the <code>App_Code</code> folder no more the prefered location to save classes of the web-application and where is the new place to store them?</p>
<p><strong>Update</strong></p>
<p>Thanks to Oded I have received the answer to my question. </p>
<p>If one has the same question as I had, probably he is also not aware (as I was), that there are two different types of projects with their own menu-points in VS: <strong>Web-Application</strong> and <strong>Web-Site</strong>. The organisation of these two types is different. For a web-application, the <code>app_code</code>-folder is not proposed in the asp.net-folder-menu . Maybe this information helps someone.</p>
| asp.net | [9] |
3,322,926 | 3,322,927 | Splitting results from chardet output to collect encoding type | <p>I am testing chardet in one of my scripts. I wanted to identify the encoding type of a result variable and chardet seems to do fine here.</p>
<p>So this is what I am doing:</p>
<blockquote>
<p>myvar1 <-- gets its value from other functions</p>
<p>myvar2 = chardet.detect(myvar1) <-- to detect
the encoding type of myvar1</p>
</blockquote>
<p>Now when I do a <strong>print myvar2</strong>, I receive the output:</p>
<blockquote>
<p>{'confidence': 1.0, 'encoding':
'ascii'}</p>
</blockquote>
<p>Question 1: Can someone give pointer on how to collect only the encoding value part out of this, i.e. ascii.</p>
<p><strong>Edit:</strong>
The scenario is as follows:</p>
<p>I am using unicode(myvar1) to write all input as unicode. But as soon as myvar1 gets a value like 0xab, unicode(myvar1) fails with the error:</p>
<blockquote>
<p>UnicodeDecodeError: 'ascii' codec
can't decode byte 0xab in position xxx: ordinal not in range(128)</p>
</blockquote>
<p>Therefore, I am tring to:</p>
<blockquote>
<ol>
<li>first identify the encoding type of the input which comes in myvar1, </li>
<li>take the encoding type in myvar2,</li>
<li>decode the input (myvar1) with this encoding (myvar2) using decode() [?]</li>
<li>pass it on to unicode.</li>
</ol>
</blockquote>
<p>The input coming in is variable and not in my control.</p>
<p>I am sure there are other ways to do this, but I am new to this. And I am open to trying.</p>
<p>Any pointer please.</p>
<p>Many Thanks.</p>
| python | [7] |
4,294,907 | 4,294,908 | what view is this in android, I have seen this in iphone can any one help | <p>what view is this in android, I have seen this in iphone can any one help<img src="http://i.stack.imgur.com/Bx4kz.png" alt="alt text"></p>
<p>the one shown in bottom near footer</p>
<p><img src="http://i.stack.imgur.com/w7pP3.png" alt="alt text"></p>
| android | [4] |
2,512,768 | 2,512,769 | Is it possible to get all audios in audio library and store into a MPMediaItemCollection without using mediapicker | <p>I hope to sue codes to load all audios into a MPMediaItemCollection object without using mediapicker manual action.</p>
<p>Is it possible?</p>
| iphone | [8] |
1,131,040 | 1,131,041 | AppDomain.FirstChanceException and stack overflow exception | <p>I'm using the <a href="http://msdn.microsoft.com/en-us/library/system.appdomain.firstchanceexception.aspx">FirstChanceException</a> event to log details about any thrown exceptions.</p>
<pre><code>static void Main(string[] args)
{
AppDomain.CurrentDomain.FirstChanceException += (sender, eventArgs) =>
{
Console.WriteLine("Inside first chance exception.");
};
throw new Exception("Exception thrown in main.");
}
</code></pre>
<p>This works as expected. But if an exception is thrown inside the event handler, a stack overflow will occur since the event will be raised recursively.</p>
<pre><code>static void Main(string[] args)
{
AppDomain.CurrentDomain.FirstChanceException += (sender, eventArgs) =>
{
throw new Exception("Stackoverflow");
};
throw new Exception("Exception thrown in main.");
}
</code></pre>
<p>How do I handle exceptions that occur within the event handler?</p>
<p>Edit: </p>
<p>There's a few answers suggesting that I wrap the code inside the event handler in a try/catch block, but this doesn't work since the event is raised before the exception can be handled.</p>
<pre><code>static void Main(string[] args)
{
AppDomain.CurrentDomain.FirstChanceException += (sender, eventArgs) =>
{
try
{
throw new Exception("Stackoverflow");
}
catch
{
}
};
throw new Exception("Exception thrown in main.");
}
</code></pre>
| c# | [0] |
488,474 | 488,475 | is-a and has-a implementation error | <p>So, I got a code like this:</p>
<pre><code>class Fruit
{//some constructor method and instance in here}
class Banana: public Fruit
{//some constructor method and instance in here}
class plant
{
public:
plant(){
thisFruit->Banana();//everytime a new plant is created, its thisFruit will point to a new Banana Object
}
private:
Fruit *thisFruit;//this plant has a pointer to a fruit
}
</code></pre>
<p>however, I got an error in the "this-Fruit->banana();" that state "pointer to incomplete class type is not allowed. is there something wrong with my code? thx</p>
| c++ | [6] |
2,915,736 | 2,915,737 | How to create a tuple of tuples in python? | <p>I want to combine:</p>
<pre><code>A = (1,3,5)
B = (2,4,6)
</code></pre>
<p>into:</p>
<pre><code>C = ((1,2), (3,4), (5,6))
</code></pre>
<p>Is there a function that does this in python?</p>
| python | [7] |
4,757,949 | 4,757,950 | iPhone - removing files matching a pattern | <p>Is there a way to remove all files in a given directory (not recursively) using a pattern?</p>
<p>I mean, I have files like file1.jpg, file2.jpg, file3.jpg, etc., and I want something like the unix</p>
<pre><code>rm file*.jpg
</code></pre>
<p>is there a way to do that?</p>
<p>thanks</p>
| iphone | [8] |
2,683,558 | 2,683,559 | How do I access the 1st element of each list in a lists of lists | <p>Example:</p>
<pre><code>numbers = ['1','2','3']
letters = ['a','b','c']
</code></pre>
<p>I want to get [1,a] as a results. Yeah I can loop through it, but I'm wondering if there is a fast one line way of doing this.</p>
<p>EDIT EDIT !!!!</p>
<p>I made a horrible mistake in describing the problem.</p>
<p>I have access to the combined list (the list of lists of the question):</p>
<pre><code>list_of_lists = [ numbers, letters]
</code></pre>
<p>which is equal to:</p>
<pre><code>[ ['1','2','3'],['a','b','c']]
</code></pre>
<p>Sorry for the confusion. The end result is still the same, this would be ['1','a'].</p>
| python | [7] |
3,539,083 | 3,539,084 | php, get values from matrix (array) | <p>I have Matrix and how get value from there?
The data obtained from a file, so that the matrix can be of different sizes</p>
<p>Thanks</p>
| php | [2] |
4,004,492 | 4,004,493 | hashCode implementation for singleton class | <p>what will be the implementation for</p>
<pre><code>public int hashCode()
{
}
</code></pre>
<p>method in singleton class? Please do provide me the implementation</p>
| java | [1] |
5,490,252 | 5,490,253 | Is this illegal syntax? | <pre><code><script type="text/javascript" language="JavaScript">
<!--
alert('foo');
//-->
</script>
</code></pre>
<p>It's used all over in my company's grails app, but I know <code><</code> is an illegal javascript character...</p>
<p>Should the <code><!--</code> be like <code>//<!--</code> instead?</p>
| javascript | [3] |
2,849,574 | 2,849,575 | Is it possible to maintain "boundness" of a method when passing it as an object outside its class | <p>I'm trying to write a library that will register an arbitrary list of service calls from multiple service endpoints to a container. I intend to implement the service calls in classes written one per service. Is there a way to maintain the boundedness of the methods from the service classes when registering them to the container (so they will still have access to the instance data of their owning object instance), or must I register the whole object then write some sort of pass through in the container class with <code>__getattr__</code> or some such to access the methods within instance context?</p>
<p>container:</p>
<pre><code>class ServiceCalls(object):
def __init__(self):
self._service_calls = {}
def register_call(self, name, call):
if name not in self._service_calls:
self._service_calls[name] = call
def __getattr__(self, name):
if name in self._service_calls:
return self._service_calls[name]
</code></pre>
<p>services:</p>
<pre><code>class FooSvc(object):
def __init__(self, endpoint):
self.endpoint = endpoint
def fooize(self, *args, **kwargs):
#call fooize service call with args/kwargs utilizing self.endpoint
def fooify(self, *args, **kwargs):
#call fooify service call with args/kwargs utilizing self.endpoint
class BarSvc(object):
def __init__(self, endpoint):
self.endpoint = endpoint
def barize(self, *args, **kwargs):
#call barize service call with args/kwargs utilizing self.endpoint
def barify(self, *args, **kwargs):
#call barify service call with args/kwargs utilizing self.endpoint
</code></pre>
<p>implementation code:</p>
<pre><code>foosvc = FooSvc('fooendpoint')
barsvc = BarSvc('barendpoint')
calls = ServiceCalls()
calls.register('fooize', foosvc.fooize)
calls.register('fooify', foosvc.fooify)
calls.register('barize', barsvc.barize)
calls.register('barify', barsvc.barify)
calls.fooize(args)
</code></pre>
| python | [7] |
3,220,442 | 3,220,443 | Encrypt iOS app ipa file | <p>I hope to encrypt the ipa file of a freeware for jailbreak users so that others cannot view the project details.</p>
<p>Is there any tool to do this?</p>
<p>Welcome any comment</p>
| iphone | [8] |
4,255,433 | 4,255,434 | how to set EditText box height and width programmatically in android | <p>hey i want to manage height and width of EditText Box programmatically in android i tried <code>edittext.setWidth(32);</code> and <code>edittext.setEms(50);</code> both are not working please see my below coding coze i am using it to create dynamic EditText in android</p>
<pre><code>private EditText createEditText()
{
final LayoutParams lparams = new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
final EditText edittext = new EditText(this);
edittext.setLayoutParams(lparams);
edittext.setWidth(32);
edittext.setEms(50);
return edittext;
}
</code></pre>
| android | [4] |
5,136,378 | 5,136,379 | programmatically erase android browser cache, history, etc. with root | <p>I have an android tablet that is locked down (users will only be able to use standard issue android browser), so all the temporary internet stuff should be in the same place.</p>
<p>Assuming I am able to root the device sometime here soon, I would like to be able to wipe out (1) cookies, (2) temp internet files, (3) history, (4) form data, (5) location access info, (6) passwords, and (7) cache.</p>
<p>I think I can knock out most of these by erasing:</p>
<p>/data/data/com.android.browser/cache</p>
<p>The cookies appear to be in a database. I'm not sure if I can just delete it</p>
<p>/data/data/com.android.browser/databases/webview.db</p>
<p>And then I think I can just delete these files to erase location information:</p>
<p>/data/data/com.google.android.location/files/wifi
/data/data/com.google.android.location/files/cell</p>
<p>Will that take care of everything?</p>
<p>What am I leaving out?</p>
<p>Is it safe to just erase that database? Does anyone know?</p>
| android | [4] |
1,678,753 | 1,678,754 | sip do not talk | <p>I use <strong><code>sipdemo.register</code></strong> and invite sucess,but can not talk with <code>peer.trace startaudio</code>,<br>i can see <strong><code>audiogroup.setmode(MODE_NORMAL)</code></strong> .
all permissions is seted,epscial <strong><code>MODIFY_AUDIO_SETTINGS</code></strong> is seted. what are settings elso?
when invite peer,peer is handle on.<br>we can not listen echo other.</p>
<p>how process it?</p>
| android | [4] |
2,981,733 | 2,981,734 | i want to show four random numbers minimum one maximum ten but contains one number fix | <p>I want to show 4 options of numbers as like quiz options, out of four three should be wrong and one should be the right answer. All options are numeric numbers, and I want to change right answer's position every time when page opens. Please help me</p>
<p>and my result is in a String result, where i will add result.....</p>
<p>I'm trying this , but not getting the solution </p>
<pre><code>LinearLayout rowoptions = (LinearLayout) findViewById(R.id.linearlayout);
ArrayList<Integer> numbers = new ArrayList<Integer>();
String[] s = new String[4];
while (numbers.size() < 4) {
int random = r.nextInt(10)+1;
int chk = r.nextInt(4)+1;
if (!numbers.contains(random)) {
numbers.add(random);
s[chk] =String.valueOf(random);
}
}
for (int i = 0; i < 4; i++) {
Button optionbutton = new Button(this);
optionbutton.setText(s[i]);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(70, 70);
layoutParams.setMargins(5, 5, 0, 0); // left, top, right, bottom
optionbutton.setLayoutParams(layoutParams);
//ivBowl.setBackgroundDrawable(null);
rowoptions.addView(optionbutton);
}
</code></pre>
| android | [4] |
3,409,369 | 3,409,370 | Zend Server Job predecessor fails dependent | <p>I using Zend Server Jobs with setting max concurrent jobs = 4, this setting is needed - many high priority jobs what need to serve ASAP.</p>
<p>Also I have jobs with low priority with long execution time 5-7 min - heavy DB operation - and I want this jobs run one at the time - if run parallel compete for DB resources and timeouts. I have loop that creates them ( about 30 jobs ), I am checking if jobs with proper name existing in queue using getJobsList(), pickup biggest job id and set as predecessor to next job. However even job was already created (second iteration) is not picked up by getJobsList(), and following iterations do not picked up biggest / newest job id...</p>
<p><strong>Is it delay is involved during job creation ?</strong> createHttpJob() and following getJobsList() does not return recently created...</p>
<p>After predecessor is set and predecessor fails - like timeout - it automatically fails dependents. </p>
<p><strong>Is it a way to set predecessor only to complete regardless of status</strong> - just not being in queue or already running ?.</p>
| php | [2] |
3,721,236 | 3,721,237 | How to get preloaded .apk installed in the "stopped" state and *not* start on BOOT_COMPLETED | <p>We have an application that is being evaluated for preload on some devices. Our application has a service that will run automatically on BOOT_COMPLETED as long as the application is not in the "stopped" state. When an application is installed on a device the application is in the "stopped" state and will not run automatically until the user launches it. At that time it is no longer in the "stopped" state and will run automatically on BOOT_COMPLETED. If the user force stops the app it will go back into the "stopped" state. This is all good and expected behavior.</p>
<p>Now, when our app is preloaded on a device it is not in the "stopped" state, therefore it runs without any user interaction when the device is started for the first time. We do not want this to happen, we want the application to be preloaded in the "stopped" state.</p>
<p>So, my two questions are:</p>
<p>1) Can an application be preloaded in the "stopped" state, and if so how? Or at least what can I tell the preload team to do because they are telling me they can not do it.</p>
<p>2) If an app can not be preloaded in the "stopped" state is there anything I can do when I get the BOOT_COMPLETED to tell if the user launched the app or not. That way I can track that the user launched the app at least once and if not kill the app from running on BOOT_COMPLETED. This is a hack I would like to avoid, so any other options would be appreciated as well.</p>
<p>Thanks!</p>
| android | [4] |
3,179,698 | 3,179,699 | Numerical computation in Java | <p>Ok so I'm trying to use Apache Commons Math library to compute a double integral, but they are both from negative infinity (to around 1) and it's taking ages to compute. Are there any other ways of doing such operations in java? Or should it run "faster" (I mean I could actually see the result some day before I die) and I'm doing something wrong?</p>
<p>EDIT: Ok, thanks for the answers. As for what I've been trying to compute it's the Gaussian Copula:
<img src="http://upload.wikimedia.org/math/a/c/8/ac8e3a7b79c030c2bf8ff053b80823c3.png" alt="alt text"></p>
<p>So we have a standard bivariate normal cumulative distribution function which takes as arguments two inverse standard normal cumulative distribution functions and I need integers to compute that (I know there's a Apache Commons Math function for standard normal cumulative distribution but I failed to find the inverse and bivariate versions).</p>
<p>EDIT2: as my friend once said "ahhh yes the beauty of Java, no matter what you want to do, someone has already done it" I found everything I needed here <a href="http://www.iro.umontreal.ca/~simardr/ssj/" rel="nofollow">http://www.iro.umontreal.ca/~simardr/ssj/</a> very nice library for probability etc.</p>
| java | [1] |
432,528 | 432,529 | How to restrict a user to enter data when a session expired in ASP.NET? | <p>I have developed a ASP.NET application,I have used sessions for parameter passing.
I dont want to let the user to enter data when the session expired.Please suggest me how to do that.</p>
| asp.net | [9] |
2,350,419 | 2,350,420 | Why aren't video games written in Java? | <p>So I was just wondering, why aren't many video games (commercial 3D games, not random open source 2D ones) written in Java? In theory, it makes a lot of sense; you get a productivity boost and a cross-platform application for free (among other things, such as the vast amount of Java libraries, and built-in garbage collection -- although I admit I'm not sure if that's a good thing). So why is it never used? I can't think of a single semi-popular commercial game written for the Java platform.</p>
<p>Is it because of performance? Well, I've seen games written for the .NET platform, so why not Java? Also, most of the heavy lifting would be done by the GPU anyway, through OpenGL.</p>
<p>Any insight would be great, thanks.</p>
| java | [1] |
1,799,218 | 1,799,219 | Highlight the tabbaritem with image | <p>I have three TabBarItem in a TabBar . And each tabbar item has normal image. I want to highlight the TabBarItem image instead of the normal image.</p>
<p>Can i achieve it?</p>
<p>Thanks in advance</p>
| iphone | [8] |
792,602 | 792,603 | Avoid hang when writing to named pipe which disappears and comes back | <p>I have a program which dumps information into a named pipe like this:</p>
<pre><code>cmd=open(destination,'w')
cmd.write(data)
cmd.close()
</code></pre>
<p>This works pretty well until the pipe (destination) disappears while my program is writing to it. The problem is that it keeps hanging on the write part(?)
I was expecting some exception to happen, but that's not the case.
How can I avoid this situation?</p>
<p>Thanks,</p>
<p>Jay</p>
| python | [7] |
1,062,178 | 1,062,179 | Undefined in associative array lookup | <pre><code>var candidates = {
"1":"Barack Obama",
"2":"Mitt Romney",
"3":"Dennis Kucinich",
"4":"Quentin Tarantino",
"5":"Count Dracula"
};
function getRandomInt(min, max){
return Math.floor(Math.random() * (max - min + 1)) + min;
}
Object.size = function(obj) {
var size = 0, key;
for (key in obj) {
if (obj.hasOwnProperty(key)) size++;
}
return size;
};
function getRandomPresident(){
var num = getRandomInt(1, Object.size(candidates));
if (num!=5){
alert(num);
var key = num.toString();
var res = candidates[key];
return res;
} else {
getRandomPresident();
}
}
alert(getRandomPresident());
</code></pre>
<p>This code works, but sometimes after generating random value it outputs "undefined" instead of the name - <a href="http://jsbin.com/uriwal/edit#source" rel="nofollow">http://jsbin.com/uriwal/edit#source</a> Why?</p>
| javascript | [3] |
2,860,239 | 2,860,240 | Ternary operator in foreach | <p>I am currently struggling with about 5 nested if-statements and its becoming quite confusing to look over all of them.</p>
<p>So, I thought about adding ternary operators instead of ifs for simple checks, see</p>
<pre><code>foreach (String control in controls)
{
if (!control.Equals(String.Empty))
{
// Do some stuff
foreach (Int32 someStuff in moreStuff)
{
if (!someStuff.Equals(0))
{
// More stuff with more if equals
}
}
}
</code></pre>
<p>Thats how it looks like right now. Thats my idea on how to make it look a little bit more nice:</p>
<pre><code>foreach (String control in controls)
{
(control.Equals(String.Empty)) ? continue : null;
// Do some stuff
foreach (Int32 someStuff in moreStuff)
{
(someStuff.Equals(0)) ? continue : null;
// More stuff
}
}
</code></pre>
<p>So, the questions are: 1. is is bad programming to solve it like this and 2. will it work the way I want?</p>
| c# | [0] |
2,075,033 | 2,075,034 | execute function IF criteria is met - wordpress | <p>At the moment i have a function and a filter which shortens titles if they are longer than 25characters and appends the triple dot '...'</p>
<p>However, it appends the dots to all the titles. How can i get the following code to run only if the title is longer than 25 characters?</p>
<pre><code>function japanworm_shorten_title( $title ) {
$newTitle = substr( $title, 0, 25 ); // Only take the first 25 characters
return $newTitle . " &hellip;"; // Append the elipsis to the text (...)
}
add_filter( 'the_title', 'japanworm_shorten_title', 10, 1 );
</code></pre>
| php | [2] |
1,073,146 | 1,073,147 | Overwriting a field in a binary file | <p>I'm writing a program that writes structs to a binary file, and then gives the user the option to edit the file. The program should then rewrite that section in the file where the original struct was written. Code:</p>
<pre><code>struct Record
{
char name [16];
char phoneNum [16];
float balance;
};
int edit ( fstream& ref)
{
char searchVal[16];
cout << "Enter customer name: ";
cin.ignore();
cin.getline(searchVal, sizeof(searchVal));
int position = -1;
Record buffer;
bool found = false;
while(!ref.eof() && !found)
{
position = ref.tellg();
ref.read(reinterpret_cast<char*>(&buffer), RECORD_SIZE);
if((strcmp(buffer.name,searchVal) == 0))
{
found = true;
cout << buffer.name << " found! " << endl;
cout << "Enter new customer name: ";
cin.getline(buffer.name, sizeof(buffer.name));
cout << "Enter new customer phone number: ";
cin.getline(buffer.phoneNum, sizeof(buffer.phoneNum));
cout << "Enter new customer balance: ";
cin >> buffer.balance;
ref.seekg(-(RECORD_SIZE), ios::cur);
ref.write(reinterpret_cast<char*>(&buffer), RECORD_SIZE);
position = ref.tellp();
break;
}
}
if(!found)
{
cout << "Record not found" << endl;
}
ref.clear();
ref.seekg(0L, ios::beg);
return position;
}
</code></pre>
<p>BAsically, the record is found and the user can "edit" it, but it is written at the end of the file, and I'm not sure why. I appreciate your help on this.</p>
| c++ | [6] |
3,416,604 | 3,416,605 | How to download a large, compressed file to the iphone | <p>I want to download a 90MB sqlite file to my iphone app from the web. So I'll need to save the data to disk as it comes in to avoid having too much in memory. This is similar to this question -
<a href="http://stackoverflow.com/questions/648275/best-way-to-download-large-files-from-web-to-iphone-for-writing-to-disk">http://stackoverflow.com/questions/648275/best-way-to-download-large-files-from-web-to-iphone-for-writing-to-disk</a></p>
<p>But I'd like to zip the file if possible. How can I handle unzipping such a large file? It's about 20 MB zipped.</p>
| iphone | [8] |
5,615,317 | 5,615,318 | How to convert .caf file to .mp3 file using php? | <p>I have created one webservice using php which upload audio file from IOS device to server.audio file gets uploaded as .caf format which is not supported by server so is there any way to convert .caf file to .mp3 or .wav file?</p>
<p>I want to create PHP script which will convert .caf file to .mp3 file any idea about it?</p>
<p>Thanks</p>
| php | [2] |
5,885,673 | 5,885,674 | Why is this jquery code snippet failing | <pre><code>$(if($('#errorExplanation').length > 0)){
$('#venue_details').toggle($('#errorExplanation').length > 0); //if there is at least one errorExplanation element on the page,
$("#venue_details").load("/load_events/"+ escape($('#request_artist').val()), successCallback );
}
</code></pre>
<p>It seems like i am repeating myself with this code. I basically need to show #venue_details and run the load whenever #errorExplanation').length > 0...is there a better way or is my syntax off</p>
| jquery | [5] |
2,337,043 | 2,337,044 | FigCreateCGImageFromJPEG returned | <p>I am new to iphone app development, while taking picture from camera I am getting the <strong>FigCreateCGImageFromJPEG returned</strong> error. Can any one help me out to solve this issue.
Thanks in advance.</p>
| iphone | [8] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.