Unnamed: 0 int64 65 6.03M | Id int64 66 6.03M | Title stringlengths 10 191 | input stringlengths 23 4.18k | output stringclasses 10 values | Tag_Number stringclasses 10 values |
|---|---|---|---|---|---|
1,663,096 | 1,663,097 | onProviderDisabled - differentiating the provider | <pre><code>public void getCurrentLocation(){
final LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
//
}
public void onStatusChanged(String provider, int status, Bundle extras) {
}
public void onProviderEnabled(String provider) {}
public void onProviderDisabled(String provider) {
if(provider=="gps"){
Toast.makeText(getApplicationContext(), "GPS is off", Toast.LENGTH_LONG).show();
startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
}
Log.i("lm_disabled",provider);
}
};
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0, locationListener);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,0,0, locationListener);
}
</code></pre>
<p>This seems like a legit code. However, the if expression never runs. I have debugged my application, the provider is "gps", it is string type - but the if returns false, I guess...</p>
<p>What am I missing here?</p>
| android | [4] |
4,417,796 | 4,417,797 | How to randomly choose one div out of a group and assign an event to it | <p>I'm trying to randomly choose one div out of a group and assign a click event to just the selected one. Below is the code I wrote thus far.</p>
<pre><code><div id="div1"> </div>
<div id="div2"> </div>
<div id="div3"> </div>
<div id="div4"> </div>
<script>
var div1 = document.getElementById("div1");
var div2 = document.getElementById("div2");
var div3 = document.getElementById("div3");
var div4 = document.getElementById("div4");
var randomnumber = Math.floor(Math.random() * (4 - 1 + 1)) + 1;
var bomb = "div" + randomnumber;
alert(bomb);
bomb.onclick = function() { alert("You clicked me...BOOM!")}; // does not work
</script>
</code></pre>
| javascript | [3] |
5,512,611 | 5,512,612 | how to switch item with urlid(path) on item select | <pre><code>Hits hits = indexSearcher.search( parser.parse("("+ "text:" +mEdit.getText().toString() + ")"));
String txt2[] =new String[100];
String txt="";
for (int i = 0; i < hits.length(); i++)
{
Document hitDoc = hits.doc(i);
Log.i("TestAndroidLuceneActivity", "Lucene: " +hitDoc.get("title")+ hitDoc.get("path"));
txt=hitDoc.get("title");
txt2[i]=txt;
final String path= hitDoc.get("path");
lv.setAdapter(new ArrayAdapter<String>(Lucenconcept.this,android.R.layout.simple_list_item_1 ,txt2));
}
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> myAdapter, View myView, int myItemInt, long mylng) {
Intent intent = new Intent(Lucenconcept.this,ShowDetails.class);
Bundle bundle = new Bundle();
bundle.putString("keyLink", path );
intent.putExtras(bundle);
startActivity(intent);
}
});
</code></pre>
<p>I wrote this code for switching another activity but not differing URL-id or path id in bundle. Every url string stored but when I go to next activity.</p>
<pre><code>String link = bundle.getString("keyLink");
Toast.makeText(this,link,Toast.LENGTH_SHORT).show();
</code></pre>
<p>Code for retrieving URL-id or path in next activity, but not differ it gives constant url.
Please help me, I am not able to set the position.</p>
| android | [4] |
3,019,742 | 3,019,743 | Jquery - using a POST request, which is not allowed Error | <p>I am trying to get jquery to communicate with a web service!!</p>
<pre><code> function Test(item) {
$.ajax({
type: 'POST',
url: 'WebService.asmx/Test',
data: '{ "Item" : "' + item + '" }',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (msg) {
alert("oi");
},
error: function (msg) {
alert('Get Details Failure: ' + msg);
}
});
};
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
using System.Web.Script.Services;
using System.Web.Script.Serialization;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[ScriptService]
public class WebService : System.Web.Services.WebService {
public WebService () {}
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod(UseHttpGet = true, ResponseFormat = System.Web.Script.Services.ResponseFormat.Json)]
public string Test(string Item)
{
JavaScriptSerializer js = new JavaScriptSerializer();
string strJSON = js.Serialize(Item);
return strJSON;
}
</code></pre>
<p>I get the following message:</p>
<pre><code>{"Message":"An attempt was made to call the method \u0027Test\u0027 using a POST request, which is not allowed.","StackTrace":" at System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData, HttpContext context)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"}
</code></pre>
| jquery | [5] |
986,648 | 986,649 | Problem with Runtime.getRuntime().exec() | <p>I have rooted my device, then in my application</p>
<pre><code>Process p = Runtime.getRuntime().exec("su");
</code></pre>
<p>and it work fine, my application will be root mode. Then I try add wlan address space, but it doesn't work, when I check out in terminal, following error message is shown</p>
<pre><code> busybox ifconfig there is not a new wlan address space.
</code></pre>
<p>I try with following way:</p>
<pre><code>Process p = Runtime.getRuntime().exec("su");
p = Runtime.getRuntime().exec("busybox ifconfig wlan0 add xxxxxxxxxxxx");
p.waitfor();
</code></pre>
<p>When I run my application, the toast shows that the app is root mode but there is not added wlan0.</p>
| android | [4] |
2,961,402 | 2,961,403 | Full Browser Image that Maintains Ratio | <p>Basically what I'm looking for is a way for an image to always be as big as the browser window but maintaining it's aspect ratio. The image should always resize with the smallest browser edge so that it hangs off the edge of the frame but never shows the white underneath. I've gotten this far:</p>
<pre><code>window.onload = checkSize;
window.onresize = resize;
function checkSize(){
var x = self.innerWidth;
document.getElementById("picture").style.width = (x)+"px";
}
function resize(){
var x = self.innerWidth;
var y = self.innerHeight;
var picy = document.getElementById("picture").style.height;
document.getElementById("picture").style.width = (x)+"px";
if (picy >= y){
document.getElementById("picture").style.height = (y)+"px";
document.getElementById("picture").style.removeProperty("width");
}
}
</code></pre>
<p>Which in my head worked as follows:</p>
<ul>
<li>resize with width</li>
<li>if the image height is less that the window height, start resizing the height and remove the width property (to keep the aspect ratio)</li>
</ul>
<p>Am I close?</p>
| javascript | [3] |
3,508,664 | 3,508,665 | How to avoid call-time pass-by-reference deprecated error in PHP? | <p>I'm trying to <strong>reduce the warnings</strong> that are sent to my apache server log.</p>
<p>One warning is:</p>
<blockquote>
<p>Call-time pass-by-reference has been deprecated.</p>
</blockquote>
<p>It is <strong>hard for me to imagine</strong> why this was deprecated since it is such a useful programming feature, basically I do this:</p>
<pre><code>public function takeScriptsWithMarker(&$lines, $marker) {
...
}
</code></pre>
<p>and I call this function repeatedly getting results back from it and processing them but also letting the array $lines build up by being sent into this method repeatedly. </p>
<ol>
<li>To reprogram this would be extensive.</li>
<li>I don't want to just "turn off warnings" since I want to see other warnings.</li>
</ol>
<p>So, as call-by-reference is deprecated, <strong>what is the "accepted way" to attain the functionality</strong> of this pattern: namely of sending an array of strings into a method, have them be changed by the method, then continuing to use that array?</p>
| php | [2] |
3,231,049 | 3,231,050 | jQuery noob: Auto select checkbox if another is selected | <p>Basically all I'm trying to do is if one check box is selected by the user, then automatically check the previous box. Each check box has an iterating number id. So for example if checkbox id=3 is selected then auto select check box id=2. Here's my code below:</p>
<pre><code><script>
var $j = jQuery.noConflict();
$j('input:checkbox').click(function()
{
if (this.checked)
{
var original = $j(this).attr("id");
var temp = original - 1;
var follower = $j(temp);
follower.attr("checked",true);
}
});
</script>
</code></pre>
<p>This doesn't do anything at all. Can someone help tell me what's wrong or if there's a better way to do this that would be awesome! Thanks!</p>
| jquery | [5] |
229,021 | 229,022 | Android - Download all files from a folder on server | <p>Hope I am able to explain this correctly...
I am able to connect to my web server and download a single file.What I am now attempting to do is connect to my server and download all the flies from a particular folder.In this case i want to download images.
This is the code i use to download a single file...</p>
<pre><code>URL url = new URL("http://127.0.0.1/Folder/file.csv");
URLConnection conexion = url.openConnection();
conexion.connect();
int lenghtOfFile = conexion.getContentLength();
InputStream is = url.openStream();
File testDirectory =
new File(Environment.getExternalStorageDirectory()+"/Folder");
if(!testDirectory.exists()){
testDirectory.mkdir();
}
FileOutputStream fos = new FileOutputStream(testDirectory+"/file.csv");
byte data[] = new byte[1024];
int count = 0;
long total = 0;
int progress = 0;
while ((count=is.read(data)) != -1){
total += count;
int progress_temp = (int)total*100/lenghtOfFile;
if(progress_temp%10 == 0 && progress != progress_temp){
progress = progress_temp;
}
fos.write(data, 0, count);
}
is.close();
fos.close();
</code></pre>
<p>How can I add to this code to make it download all the files from that folder?</p>
| android | [4] |
611,098 | 611,099 | android launch modes | <p>In my android application i am using standard launch mode for all activities.In my application i have a footer bar with home icon to navigate to homescreen from any application activity.the home screen is getting created that many times.If i place the launch mode as single instance the same activity is popped up but even if the data i am expecting is different it is popping up the same data with initial data. </p>
<p>Please let me know as how can i get new activity created only if there is change of data. </p>
<p>Please forward me your valuable suggestions </p>
| android | [4] |
601,266 | 601,267 | question about compress header | <p>from this site there is header "compress.h"</p>
<pre><code>http://www.fredosaurus.com/notes-cpp/examples/compress/compress.html
</code></pre>
<p>i am using visual c++ 2010 and also boost library and am interested if there is similary header of compress.h?
thanks</p>
| c++ | [6] |
2,888,265 | 2,888,266 | Is there an opposite of the date() function (for formatting?) | <p>I know that there's <code>strtotime()</code>, but that's not quite what I'm looking for.</p>
<p>Say I have this: <code>date('l, F jS', $datetime)</code></p>
<p>Would there be a function where I can tell it the format (<code>'l, F jS'</code>) and a string (for example: <code>Saturday, August 21st</code> And it will output a timestamp?</p>
| php | [2] |
3,059,881 | 3,059,882 | How to disable back button In camera in Android | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/13191946/disable-back-button-in-androidnot-working">Disable back button in Android(Not working)</a> </p>
</blockquote>
<p>I am using the default camera in my app(The inbuilt-camera feature of Android). I have tried using</p>
<pre><code> public void onBackPressed() {
}
</code></pre>
<p>but instead of blocking the back button, the app hangs forcing the user to terminate the app/restart it.</p>
| android | [4] |
2,178,066 | 2,178,067 | Why does the setTimeout function execute forever? | <p>I read about the timing event. I am confused about <code>setTimeout</code>: I have an example on W3Schools where it is running every 500 milliseconds. I read about <code>setTimeout</code> that it works only once. <a href="http://www.w3schools.com/js/tryit.asp?filename=tryjs_timing_clock" rel="nofollow">link</a></p>
<pre><code><head>
<script>
function startTime() {
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
document.getElementById('txt').innerHTML=h+":"+m+":"+s;
setTimeout(function(){startTime()},500);
}
</script>
</head>
<body onload="startTime()">
<div id="txt"></div>
</body>
</code></pre>
| javascript | [3] |
1,704,978 | 1,704,979 | C# adding string to another string | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/21078/whats-the-best-string-concatenation-method-using-c">What's the best string concatenation method using C#?</a> </p>
</blockquote>
<p>I have a variable :</p>
<pre><code>string variable1;
</code></pre>
<p>And I'm trying to make something like this :</p>
<pre><code>for (int i = 0; i < 299; i += 2)
{
variable1 = variable1 && IntToHex(buffer[i]);
}
</code></pre>
<p>IntToHex is a string function, so the result of the "IntToHex(buffer[i])" will be string. But it comes up to an error saying I cannot use &&. Is there any solution to add a string to another string? Thanks!</p>
| c# | [0] |
3,668,635 | 3,668,636 | jquery how to make current ul visible/display block? | <p>Im building a menu dynamically and then a sub menu inside this dynamically also. </p>
<p>The submenu is hidden and then when the user hovers over te main menu link the submenu appears.</p>
<p>what i need to do is if the sub menu li has a class 'on' then i need that submenu ul to be given the attr visible or display block?</p>
<p>so i need some sort of jquery when the page loads if the submenu contain li with class on then that submenu gets the attr visible?</p>
<p>This is my menu:</p>
<pre><code> <div class="sideMenu2">
<ul>
<li><a href>retail</a>
<ul class="subsideMenu2">
<li class= "on"><a href="/portfolio/5/0">cabot circus</a></li>
<li><a href="/portfolio/6/0">st. stephen&#39;s</a></li>
<li><a href="/portfolio/7/0">silverburn</a></li>
<li><a href="/portfolio/8/0">the elements</a></li>
</ul>
</li>
<li><a href>sports &amp; leisure</a>
<ul class="subsideMenu2">
<li><a href="/portfolio/19/0">test</a></li>
</ul>
</li>
</ul>
</div>
</code></pre>
| jquery | [5] |
2,567,686 | 2,567,687 | If app is downloaded first time then registration comes from second time login comes | <p>I am working on an app. The requirement is as: If the app is downloaded and opened first time 1) The Registration screen appears. 2) If user already has Registered, then he can skip this step3) and go to Login Screen. From second time onwards only login screen appears. 4) If app is downloaded and opened first time, Registration/Login screen appears. If user has already registered, he can simply login. From Second time onwards, direct to home page, no need to login. I am not getting any idea about this. Can some one please help me in this regard.Thanks</p>
| android | [4] |
5,790,998 | 5,790,999 | What is the order of the Constructors in this Java Code? | <p>Here is the code, I defined two class named Father and Son, and create them in the main function:</p>
<pre><code>public class Test {
public static void main(String[] args) {
Father father = new Son();
}
}
class Father {
private String name = "father";
public Father() {
who();
tell(name);
}
public void who() {
System.out.println("this is father");
}
public void tell(String name) {
System.out.println("this is " + name);
}
}
class Son extends Father {
private String name = "son";
public Son() {
who();
tell(name);
}
public void who() {
System.out.println("this is son");
}
public void tell(String name) {
System.out.println("this is " + name);
}
}
</code></pre>
<p>and I got the output like this:</p>
<pre><code>this is son
this is father
this is son
this is son
</code></pre>
<p>But I can not understand how this happened? Anyone can tell me why?</p>
| java | [1] |
3,668,439 | 3,668,440 | My textarea is not working? it stores the data but the count is not working | <p>Please can you help with the query below, I am trying to setup a textarea count and it doesn seem to work, I have tried it in Another page and it works fine</p>
<p>code below</p>
<pre><code><td width="138" height="95" align="left" class="style31" >Case Notes</td>
<td width="214" align="left">
<textarea name="notes" id="limitedtextarea" onKeyDown="limitText(this.form.limitedtextarea,this.form.countdown,255);"
onKeyUp="limitText(this.form.limitedtextarea,this.form.countdown,255);"><?php if(isset($rec2['notes']) && $rec2['notes']!='') echo stripslashes($rec2['notes']); ?>
</textarea><br>
<font size="1">(Maximum characters: 255)<br>
You have <input readonly type="text" name="countdown" size="3" value="255"> characters left.</font></td>
</script>
<script language="javascript" type="text/javascript">
function limitText(limitField, limitCount, limitNum) {
if (limitField.value.length > limitNum) {
limitField.value = limitField.value.substring(0, limitNum);
} else {
limitCount.value = limitNum - limitField.value.length;
}
}
</script>
</code></pre>
| php | [2] |
5,582,284 | 5,582,285 | Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in | <p>hi i am new to php and now i having problem with login</p>
<ol>
<li>Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in...</li>
<li>Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in....</li>
</ol>
<blockquote>
<p>coding php:</p>
<pre><code> <?php
include ("config/koneksi.php");
include ("config/library.php");
$pass = md5($_POST['password']);
$login = mysql_query("SELECT * FROM user WHERE id_user='$_POST[username]' AND sesi='$pass'");
$found = mysql_num_rows($login); //error
$r = mysql_fetch_array($login); //error
if ($r){
session_start();
session_register("username");
session_register("sesi");
session_register("role");
$_SESSION[username] = $r[id_user];
$_SESSION[sesi] = $r[sesi];
$_SESSION[role]= $r[role];
header ('location:home.php');
}
</code></pre>
</blockquote>
| php | [2] |
2,708,031 | 2,708,032 | I want to check and run the below code but it is giving me error identifier expected | <p>Can anyone tell me why the program is failing to execute in the third part i.e. when i m passing copy constructor?
It says that the identifier expected near Stud(studs) </p>
<pre><code>class Stud
{
String name;
int rollno;
double per;
Stud()
{
name="";
rollno=0;
per=0.0;
}
Stud(String n,int rn,double p)
{
name=n;
rollno=rn;
per=p;
}
Stud(Studs)
{
name=s.name;
rollno=s.rollno;
per=s.per;
}
void display()
{
System.out.println(name+ "\t" +rollno+ "\t" +per);
}
}
class StudApp14
{
public static void main(String a[])
{
Stud s1=new Stud();
Stud s2=new Stud("Amit",501,65.0);
Stud s3=new Stud(s2);
s1.display();
s2.display();
s3.display();
}
}
</code></pre>
| java | [1] |
2,761,492 | 2,761,493 | redirect to another page after logging in | <p>I am working on how to redirect to another page by suing header() function, but it's not working, and give me an error message saying hat:Cannot modify header information - headers already sent by...... Anyone could help, thanks a lot.
here is my php code</p>
<pre><code> if(isset($_POST['email'])){
$email = $_POST['email'];
$pass = $_POST['pass'];
$query = "select email, password from member where email = '$email' and password='$pass'";
if(mysql_num_rows(queryMysql($query)) == 0)
{
echo "Email/Password invalid<br/>";
}
else
{
$query1 ="select uniid from member where email = '$email' and password ='$pass'";
$result1 = queryMysql($query1);
$row1 = mysql_fetch_object($result1);
$uniid = $row1->uniid;
$_SESSION['uniid'] = $uniid;
header("Location:View.php?view=$uniid");
}
}
</code></pre>
| php | [2] |
3,331,077 | 3,331,078 | Run jar file in command prompt | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1238145/how-to-run-a-jar-file">How to run a JAR file</a> </p>
</blockquote>
<p>Hi</p>
<p>How we can run jar file in command prompt?</p>
<p>Thank You.</p>
| java | [1] |
4,578,880 | 4,578,881 | open new windows in javascript | <p>hi how to use javascriptscript to open a new window and then closing the current window..</p>
<p>currently, i can only open a new window, however my current window is still left open.</p>
<p>Code:</p>
<pre><code>function newfunction()
{
window.open("index.html", "myWindow", "status = 1, height = 300, width = 300, resizable = 0");
}
</code></pre>
| javascript | [3] |
1,915,717 | 1,915,718 | How to put icon in the SlideTab of android | <p>I have a requirement to create android's Incoming call like screen in my application.</p>
<p>I need to develop SlideTab for this:</p>
<p>Below is the layout XML I have used for this:</p>
<pre><code> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<com.android.internal.widget.SlidingTab
android:id="@+id/incomingCallWidget"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_alignParentBottom="true"
android:layout_marginBottom="80dip"
android:keepScreenOn="true" android:soundEffectsEnabled="true"/>
</RelativeLayout>
</code></pre>
<p>Below is the onCreate() of my activity I have used to display this SlideTab:</p>
<pre><code> public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.phscreen);
mIncomingCallWidget = (SlidingTab) findViewById(R.id.incomingCallWidget);
mIncomingCallWidget.setLeftHintText(R.string.slide_to_answer_hint);
mIncomingCallWidget.setRightHintText(R.string.slide_to_decline_hint);
mIncomingCallWidget.setOnTriggerListener(this);
</code></pre>
<p>The above code working fine but I need to add answer and decline icons to left and right side of Tab.</p>
<p>Please help me in which way I can add these icons.</p>
<p>Please help me is there's any API's do this.</p>
<p>I have already tried "mIncomingCallWidget.setRightTabResources()" and mIncomingCallWidget.setLeftTabResources()" but its not useful for me , I just want add only icons.</p>
| android | [4] |
3,042,024 | 3,042,025 | Use string to call function method? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1893277/how-to-convert-a-string-value-to-a-variable-in-javascript">How to convert a string value to a variable in javascript?</a> </p>
</blockquote>
<p>In Javascript, I have an object that looks like this:</p>
<pre><code>clock = function(){
this.load = function(){
alert("once");
}
this.once = function(){
alert("load");
}
}
var clock = new clock();
</code></pre>
<p>On the page load, I call the <code>load()</code> function within the clock object like so</p>
<pre><code>clock.load();
</code></pre>
<p>When the user clicks a link, however, I need to be able to run <code>clock.once()</code>. Calling it like this is fine, but does not fit the dynamic needs of what I'm doing.</p>
<p>Let's say I need to call <code>clock.once()</code> when the user clicks an <code><a></code> tag:</p>
<pre><code>$("a").click(function(){
var id = $(this).attr("href").match(/[a-zA-Z]+/g);
[id].once();
}
</code></pre>
<p>I figured that would work, where the object that the <code>once()</code> function is being called from is grabbed from the string <code>id</code>. </p>
<p>When running this, however, I get the following error:</p>
<blockquote>
<p>Uncaught TypeError: Object clock has no method 'once'</p>
</blockquote>
<p>Manually calling <code>once()</code> by using <code>clock.once()</code> works fine.</p>
| javascript | [3] |
2,221,935 | 2,221,936 | question on this java code segment | <p>The following code is claimed to use a do loop with a flag to repeat input until a valid int is obtained.</p>
<pre><code> do
{
try
{
// attempt to convert the String to an int
n = Integer.parseInt( s );
goodInput = true;
}
catch ( NumberFormatException nfe )
{
s = JOptionPane.showInputDialog( null,
s + " is not an integer. Enter an integer" );
}
} while ( !goodInput );
</code></pre>
<p>I am a little confusing about the logic here. If the Integer.parseInt just works fine, or there is no exception occuring, then the "goodInput" is assigned to "true" at line of </p>
<pre><code> goodInput = true;
</code></pre>
<p>Then the !goodInput will be evaluated as False, so the while loop will continue again. This seems to me contradicts to the designed logic, i.e., the while loop should stop after performing a correct parse operation. What is wrong with my analysis above. </p>
| java | [1] |
2,733,576 | 2,733,577 | How to restrict number of concurrent processes? | <p>My situation is as follow:</p>
<ol>
<li>I have an application that can be started only a fixed number of times (less than 50).</li>
<li>A separate central process to manage other processes is not allowed due to business requirement. (ie. if a nice solution that involves ONLY the application processes is still acceptable)</li>
<li>I am using C# for developing the application and therefore managed solution is preferred.</li>
<li>I have to deal with "unexpected" cases such as the processes can be terminated by using TaskManager.</li>
</ol>
<p>I am thinking of solution that make use of system-wide mutex. However, it doesn't survive the "Unexpected" cases very well in the way that it leaves "abandoned" mutex. If this is a good way, may I ask what is the catch of "ignoring" the mutex abandoned?</p>
| c# | [0] |
2,984,423 | 2,984,424 | Is there anything Like as WMI for Windows same for Linux | <p>We would like to develop an test tool to work on Linux os systems Is there anything like WMI for linux to establish remotely connectons and execute commands ,get system infos.</p>
<p>Regards,
M.Channabasappa</p>
| c# | [0] |
5,049,899 | 5,049,900 | Looking for a better method of checking a variable repeatedly | <p>I recently created a site that simply has a variable and checks it against various possible values and gives an appropriate response. The program goes through using a lot of <code>else if</code> statements.</p>
<p>I'm sure there is a better method of doing this, but not sure what to use. I'm still learning PHP really.</p>
<p>Here's the source code to give you a better idea:</p>
<p><a href="http://github.com/r3morse/isitup/blob/a7a972bcf125d1f058a44406a467438d46aa4b16/functions.php" rel="nofollow">http://github.com/r3morse/isitup/blob/a7a972bcf125d1f058a44406a467438d46aa4b16/functions.php</a></p>
| php | [2] |
4,892,379 | 4,892,380 | jQuery resize not working at FireFox, Chrome and Safari | <pre><code>$("#dvMyDIV").bind("resize", function(){
alert("Resized");
});
</code></pre>
<p>or</p>
<pre><code>$("#dvMyDIV").resize(function(){
alert("Resized");
});
</code></pre>
<p>The questions</p>
<ol>
<li>Why is this not working at FireFox, Chrome and Safari?</li>
<li>Can this be considered a jQuery bug since the resize is not handled for other browsers?</li>
<li>Could the only workaround be calling a SetTimeout function checking the clientHeight and clientWidth?</li>
<li>Any workarounds using jQuery?</li>
</ol>
| jquery | [5] |
2,039,980 | 2,039,981 | View Docx Files On server without downloading | <p>How to view the files(doc,docx,pdf) uploaded on the server and view on grid or any other field. I only want to view the files without downloading.
Please help me..... </p>
| asp.net | [9] |
5,732,636 | 5,732,637 | what does the following mean "checked JMSException converted to unchecked" | <p>Can some checked exceptions be converted to unchecked exceptions. </p>
<p>When I read the docs from
jms, I found some method convert checked exceptions into unchecked. I do not need to use "throws" anymore. Is this a feature of Java?</p>
| java | [1] |
936,025 | 936,026 | Comparing arrays of objects with arrays of fields of objects | <p>Is there a good way to compare arr[i].A to A[i] and arr[i].B to B? </p>
<pre><code>int A[10], B[10];
class Foo {
int A, B;
};
Foo arr[10];
</code></pre>
<p>I could do the following:</p>
<pre><code>for (i=0;i<10;i++) {
if (A[i] == arr[i].A) {}
if (B[i] == arr[i].B) {}
}
</code></pre>
<p>But, this is painful especially if there are a lot of fields, and the if() conditional does the same thing over and over, there will be a lot of code duplication. What I really want to do is parametrize this somehow and call a function like (test(A,arr)). I guess I can solve this by using #define macros, but that seems ugly. </p>
<p>Any suggestions?</p>
<p>Also I want to avoid creating a new array of Foo objects because I don't want to create new objects that may have many fields I don't care about, also I may want to compare different subsets of fields.</p>
| c++ | [6] |
4,116,376 | 4,116,377 | Want to create three dropdown list in php from mysql different table with join querying | <p>Want to create three dropdown list in php from mysql different table.</p>
<p>I want to create three dropdown list like Unit, Location, Department it will depend with one another like unit -HO,Delhi,Mumbai.. location-Mumbai,Pune,Nashik... Dept. IT,Admin, Account each location have differnet account want to populat dept only which is only for that location. In my database we have create diffenet table line unit field--unit id , unit name locaiton table location id,location name unit id, dept table dept id dept name location id
my query run properly but how can i create dropdown menu which is dependatble to one another please help me sort this issue.</p>
<p>Thanks...</p>
| php | [2] |
1,616,812 | 1,616,813 | question regarding GUI in java | <p>HOW TO pass the string input in GUI using JTextfield to other class in java. </p>
| java | [1] |
722,890 | 722,891 | python negative look behind | <p>Is there a way to scan an entire text document and say find everything that says "lol" and replace it with the id value of the first previous chapter tag? maybe something like this.</p>
<p>python</p>
<pre><code>x=open('source.txt')
lines = x.readlines()
for line in lines:
if line.startswith('<text'):
line.replace('lol', first previous chapter id value)
x.write(lines)
x.close()
</code></pre>
<p>source text</p>
<pre><code><chapter id="1">
<text class="lol">
<text class="lol">
<chapter id="2">
<text class="lol">
<text class="lol">
<chapter id="3">
<text class="lol">
<text class="lol">
<chapter id="4">
<text class="lol">
<text class="lol">
</code></pre>
<p>result text</p>
<pre><code><chapter id="1">
<text class="1">
<text class="1">
<chapter id="2">
<text class="2">
<text class="2">
<chapter id="3">
<text class="3">
<text class="3">
<chapter id="4">
<text class="4">
<text class="4">
</code></pre>
| python | [7] |
2,827,410 | 2,827,411 | Set Action for home button in android | <p>How I can change working of home button in android? I want to when I click on home button I do some actions and after that application should go to background. How I can do that.</p>
| android | [4] |
3,106,219 | 3,106,220 | How to refresh the WebView in android using a Timer? | <p>Whether a timer can be set to refresh the webview every 1 min only if the application is currently active?</p>
<p>Whether it's possible?</p>
| android | [4] |
5,669,938 | 5,669,939 | BarCode Reader iphone Application | <p>I want to create a bar code reader application in iphone. What to do to implement this functionality in my application. Please,Give the detail process.</p>
| iphone | [8] |
1,279,015 | 1,279,016 | jQuery 1.2.6 -> 1.6 : Possibilities? | <p>This seems like such a ridiculous question, but our intranet portal which hosts hundreds of individual modules written by a wide range of developers is still running jQuery 1.2.6. I would like to upgrade, but I can already tell this is going to be a nightmare, and I can't find any definitive source of the compatibility issues between each version from 1.2.6 to 1.6. </p>
<p>Does anyone have any times, or do I just switch it out and start fixing errors and alerting developers when their modules break?</p>
<p>Edit: What about including two versions of jQuery to try and transition from the older version to the new one? Perhaps using $ and $$ or something to that affect? Reading this comments, makes me want to forget the whole thing because there is so much code that I don't support, I just support the portal itself and tell the developers what version of jQuery we are running.</p>
| jquery | [5] |
1,957,487 | 1,957,488 | Pausing MediaPlayer in a service from an activity | <p>This is probably a newbie question, but how can I pause and resume my media player in a service from my activity. Here is what I have set up so far, but it is not working.</p>
<pre><code>pause.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
MyService.pauseSong();
}
});
</code></pre>
<p>In my service is this:</p>
<pre><code>public void pauseSong(){
if (mediaPlayer.isPlaying() == true){
mediaPlayer.pause();
notificationManagerPlay.cancel(5);
pauseplay = 0;
}
}
</code></pre>
<p>Your help is appreciated so much!</p>
| android | [4] |
2,636,821 | 2,636,822 | python json dumps | <p>i have the following string, need to turn it into a list without u'':</p>
<pre><code>my_str = "[{u'name': u'squats', u'wrs': [[u'99', 8]], u'id': 2}]"
</code></pre>
<p>i can get rid of " by using </p>
<pre><code>import ast
str_w_quotes = ast.literal_eval(my_str)
</code></pre>
<p>then i do:</p>
<pre><code>import json
json.dumps(str_w_quotes)
</code></pre>
<p>and get</p>
<pre><code>[{\"id\": 2, \"name\": \"squats\", \"wrs\": [[\"55\", 9]]}]
</code></pre>
<p>Is there a way to get rid of backslashes? the goal is:</p>
<pre><code>[{"id": 2, "name": "squats", "wrs": [["55", 9]]}]
</code></pre>
| python | [7] |
1,181,948 | 1,181,949 | Loop through poco-class properties | <pre><code>public partial class Foo
{
public struct ContainerOne
{
public const long Sub1 = 1;
public const long Sub2 = 2;
}
public struct ContainerTwo
{
public const long Sub3 = 3;
public const long Sub4 = 4;
}
}
</code></pre>
<p>Is there any way to make a nested foreach that gets each container name, with an inne loop that gets each property name + value?</p>
<p>Hope you get the idea, otherwise ill elaborate, thanks!</p>
| c# | [0] |
5,997,166 | 5,997,167 | If file exist then include on all files | <p>I am fairly new to PHP and I was wondering if it is possible to put an "if file exists then include" all files listed. I am using different HTML templates and some of them don't include code that is being interpreted by an PHP file.</p>
<p>EDIT: Please up-vote and down-vote the comments because I have no idea which answer to use.</p>
| php | [2] |
1,135,993 | 1,135,994 | PHP stdClass Object arrays [_]=> syntax | <p>I am trying to access the 1st part of the following Object.</p>
<p>I'm unable to figure out what is the <code>[_] =></code> syntax?</p>
<p>If I try to print the 1st past of the Object using <code>Body->[_]</code> it errors out.</p>
<pre><code>[Body] => stdClass Object
(
[_] => http://xyz.com
http://MPQ.com
[BodyType] => Text
)
</code></pre>
| php | [2] |
3,172,947 | 3,172,948 | GET in a For Loop does just one execution | <p>Am trying to make a get request from javascript, with a function called geturl.
So if i prepare my querys and add it in to an array, and looping throw that executes just one request.
how can do that without a for loop? perhaps doing something with the array? </p>
<pre><code>for (var i=0; i<urls.length; i++)
{
url[i] = urls[i].value;
}
geturl(url);
</code></pre>
| javascript | [3] |
5,523,313 | 5,523,314 | Is there any difference when calling a javascript function onclick="fn1()" and onclick="javascript:fn1()" | <p>What is the difference between calling a function directly onclick="fn1()" and onclick="javascript:fnq()"?</p>
<p>What would be the best approach?</p>
<p>Thanks</p>
| javascript | [3] |
2,876,813 | 2,876,814 | convert POST array to json format | <p>How can I convert php's POST variable to json format?</p>
| php | [2] |
5,125,333 | 5,125,334 | Changing the 'Run As:' field for a scheduled task via C# | <p>I need to write a C# program to change the 'Run As' field of scheduled tasks on remote systems.</p>
<p>What are some of the libraries I should be looking at to achieve this?</p>
| c# | [0] |
3,063,401 | 3,063,402 | convert a structured string into array | <p>this question might have been asked already. But i really have no idea what to search for.</p>
<p>If I have a string like </p>
<pre><code>{{aa:bb,aaa:bbb,cc:ee{{aa:cd,cdc:dd,{{ss:ee}},kk:ee}},se:ff}}
</code></pre>
<p>I need to get output in probably in array</p>
<p>ar[0] = aa:bb, ar[1]=aaa:bbb, ar[3] = {{...}}</p>
<p>I tried using <code>variable.split("}}")</code></p>
<p>which is breaking the string and not getting the actual data. </p>
<p>Is there any recursive function to do this?
I am not able to search because I have no clear idea of what objects,strings. </p>
| javascript | [3] |
1,605,995 | 1,605,996 | Selecting text in a WebView? | <p>The browser does this by calling <code>public void emulateShiftHeld()</code> method on the WebView which is hidden in the SDK.<br>
Any other options?</p>
| android | [4] |
5,741,728 | 5,741,729 | jQuery: what is being extended here? | <pre><code>$.ajax($.extend(true, {...
</code></pre>
<p>Can anybody explain what this code is doing?</p>
| jquery | [5] |
3,545,468 | 3,545,469 | Java and using method addAll for List<Character> | <p>I have something simple, but can't solve. I just want to add one list of chars to another . It's working with <code>String</code> types. Why does it not work with <code>char</code>? </p>
<pre><code>Character [] myChar={'a', 's', 'd','f', 't', 'i'};
List<Character> listChar= Arrays.asList(myChar);
Character[] newChar= new Character[listChar.size()];
List<Character> newlistChar= Arrays.asList(newChar);
Collections.fill(newlistChar, 'd');
output(newlistChar,"filled d");
Collections.addAll(listChar,newlistChar); // does not work
</code></pre>
<p>I tried to do something like casting the list, but still got an exception. </p>
<pre><code> ...((String)(listChar),(String)(newlistChar))
</code></pre>
<p>Even if I use something like this it still throws and exception. So how do I use addAll with <code>char</code>?</p>
<pre><code>Collections.addAll(listChar,newlistChar.toArray(new Character[newlistChar.size()]));
</code></pre>
| java | [1] |
1,751,977 | 1,751,978 | Applying indexers on a class inheriting from a collection C# | <p>I have a class which inherits from a list of list implementing an indexer </p>
<pre><code>public class TwoDList<T>: List<List<T>>
{
public T this[int row, int column]
{
get;
set ;
}
}
</code></pre>
<p>on newing it and using it like this :</p>
<pre><code> TwoDCollection<int> target = new TwoDCollection<int>();
var linearSequecValue = target[0, 2];
</code></pre>
<p>but i get a compile time error " No overload for method 'this' takes 2 argument "</p>
| c# | [0] |
1,262,172 | 1,262,173 | including the php page when two variable are set | <p>hello everyone please help me about this problem
i am sending two variable to the main page and now i want to put the check that if these twi variable are true then called the specific page . here is the sample code </p>
<pre><code>http://localhost/admin/admin.php?page=add_user?view=3
</code></pre>
<p>now i want when page and view are set then call a specific page like this</p>
<pre><code>if(isset($_GET['page'])=='add_user' && $_GET['page']=='add_user' ) include("user/add_user.php");
</code></pre>
<p>in short i want to call this add_user.php when two variable are set up so please suggest for the above line </p>
| php | [2] |
650,771 | 650,772 | 3.0 android os to 2.2 android os issues | <p>I've built my project targeting android 3.0, now I have switched to 2.2 to see how it runs. No surprise, I get errors. Just wondering if someone could point me in teh right direction, on my imageViews, setX and setAlpha error. Any ideas?</p>
<p>Also, what is the lowest system you would deploy for 2.2?</p>
| android | [4] |
4,602,670 | 4,602,671 | Twitter json + php | <p>I am pulling the twitter json feed and parsing it with php.
One of the values in the array is <code>[created_at] => Wed Jun 22 06:19:31 +0000 2011</code> .
However I only want the "<code>Wed Jun 22</code>".</p>
<p>I am currently using <code>$data->created_at = substr($data->created_at, 0, 10);</code> </p>
<p>but for example if a month/day has 4 characters it will mess it up so I need a better way to do this.</p>
| php | [2] |
1,385,926 | 1,385,927 | omitting else keyword | <p>Is there any real difference between these two methods?</p>
<p>Method 1:</p>
<pre><code>bool IsNumOverFive(int num)
{
if(num > 5)
{
return true;
}
else
{
return false;
}
}
</code></pre>
<p>Method 2:</p>
<pre><code>bool IsNumOverFive(int num)
{
if(num > 5)
{
return true;
}
return false;
}
</code></pre>
| c++ | [6] |
2,856,867 | 2,856,868 | how to update a button text on my Main Form when a method is called on my user control? | <p>on my main form:</p>
<pre><code>public string updateButtonText
{
get { return btnInbox.Text; }
set { btnInbox.Text = value; }
}
</code></pre>
<p>on my usercontrol:</p>
<pre><code>public void refreshInbox()
{
try
{
mailboxLogic.constructInbox(lstViewInbox, StudentsData.studentUsername);
frmMailbox.updateButtonText = "Inbox" + "(" + MailboxLogic.emailcounter + ")";
}
catch (Exception ex)
{
MessageBox.Show("1"+ex.Message);
}
}
</code></pre>
<p>i am trying to call the updateButtonText method everytime i update my listview.can someone help please?</p>
| c# | [0] |
2,646,650 | 2,646,651 | Convert arbitary string to number between 0 and 1 in Javascript | <p>I'm working with Youtube videos which have ids like 8DnKOc6FISU, rNsrl86inpo, 5qcmCUsw4EQ (i.e. 11 characters in the set A-Za-z0-9_-)</p>
<p>The goal is to convert each id to a colour (represented by the range 0-1), so they can be reliably charted.</p>
<p>According to <a href="http://stackoverflow.com/questions/6180138/whats-the-youtube-video-id-maximum-length">this question</a> these are 64 bit numbers. Given that:</p>
<ul>
<li>I want to make full use of the colour space for any given set of videos</li>
<li>Colour perception isn't that accurate anyway</li>
</ul>
<p>...it seems sensible to base this off the last 2-3 characters of the id.</p>
<p>My lead approach is a function I borrowed from <a href="http://blog.sarathonline.com/2009/02/javascript-convert-strings-to-binary.html" rel="nofollow">here</a>, which converts each character into a binary number like so:</p>
<pre><code> function toBin(str){
var st,i,j,d;
var arr = [];
var len = str.length;
for (i = 1; i<=len; i++){
d = str.charCodeAt(len-i);
for (j = 0; j < 8; j++) {
st = d%2 == '0' ? "class='zero'" : ""
arr.push(d%2);
d = Math.floor(d/2);
}
}
}
</code></pre>
<p>But this leaves the question of how to convert this back to a float.</p>
<p>Any ideas for an elegant solution?</p>
<p>Many thanks for your help!</p>
| javascript | [3] |
784,520 | 784,521 | I am not able to store 0123 in PHP Variable | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1412712/interview-question-in-php-is-123-0123">Interview question: In php, is 123==0123?</a> </p>
</blockquote>
<p>I am newbie in PHP. I am trying to store 0123 in a PHP variable while learning PHP but it displays 83 instead of 0123 when I echo the variable. Can anyone give me exact technical reason of that.</p>
<p>Thanks in Advance,
Dhaval</p>
| php | [2] |
4,078,578 | 4,078,579 | Multi-key dictionary/list | <p>We have a multi-tenant application with running site instances stored in a <code>ConcurrentDictionary<string, SiteInstance></code>, where <code>string</code> is the hostname of the site.</p>
<p>We now have the requirement to support multiple hostnames per site instance. As a temporary solution I'm searching first by key and if no match is found, then performing a LINQ query against the dictionary to find an instance with a matching hostname. </p>
<p>Is there a better/faster performing solution here? </p>
<p>Note: The list of hostnames mapped to each site instance is variable.</p>
| c# | [0] |
5,968,196 | 5,968,197 | Calling subclass's static method from parent class | <p>This is a strange question but I was wondering if there was a way to "override" a parent class's static method in a subclass and call that subclass's static method from the parent class. </p>
<p>It would look something like this</p>
<pre><code>public class parentFoo {
public static void <T extends parentFoo> printFoo () {
T.printFoo();
}
}
public class childFoo extends parentFoo {
public static void printFoo() {
System.out.println("Foo");
}
}
</code></pre>
<p>so you could do something like this in your code</p>
<pre><code> //print out "Foo"
parentFoo.<childFoo>printFoo();
</code></pre>
<p>This isn't working for me but I was wondering if there is some way to make this possible. Right now I get a stack overflow because it only calls the parent class's printFoo method.</p>
| java | [1] |
4,050,578 | 4,050,579 | Can an activity receive an unordered broadcast(incoming call) intent before system's default receiver? | <p>Here is the scenario :</p>
<p>An activity is displayed(active). If a phone call comes, the activity should receive the intent (send the "incoming call screen" to the background/hide it from the display) and itself remain visible to the user. I dont necessarily want to suppress the incoming phone call as I have read in a lot of questions that it is not possible with public APIs.</p>
<p>All I want is to somehow make that android's default incoming call screen hidden by my activity on the top. </p>
<p>This behavior is only required when my activity is visible which is NOT EQUAL TO having a PHONE_STATE broadcast receiver to start my activity. The latter question has been answered a number of times on SO.</p>
<p>Please help me. I have been looking for directions for almost a day now.</p>
<p>Thanks for your time.</p>
| android | [4] |
4,077,753 | 4,077,754 | removing a css style with javascript | <p>I have normal HTML input fields, that have default borders depending on Window/Browser settings.</p>
<p>During form validation I set the border of elements to red. for Example</p>
<pre><code>elem.style.border = "1px solid #ff0000";
</code></pre>
<p>If the user corrects the input, I want to remove the red border, so that the input field contains again the
default border.</p>
| javascript | [3] |
5,555,759 | 5,555,760 | Validaiton on Phone no for multiple countries | <p>I have an application that has records of multiple countries' users.And I am recording the phone no. of each user.And i want to apply validation on phone no country wise format.</p>
<p>Thanks!</p>
| javascript | [3] |
4,349,478 | 4,349,479 | Python: Why dosent this work? | <p>So i have this small piece of code which just wont work:</p>
<pre><code> while c<b:
str2 += str1[c]
c+=1
print str2
</code></pre>
<p>b is the length of str1 that i want to copy to str2, and c is the point which i want to begin transfer from str1, then the while loop is just supposed to transfer all the characters from str1 to str2.</p>
<p>For some reason i can't seem to print str2 and get this error message:</p>
<p>"NameError: name 'str2' is not defined"</p>
<p>My guess is that I'm just doing something simple wrong, I just began experimenting with Python and have only really done C# before.</p>
| python | [7] |
4,203,484 | 4,203,485 | Disable Python return statement from printing object it returns | <p>I want to disable "return" from printing any object it is returning to python shell.</p>
<p>e.g A sample python script test.py looks like:</p>
<pre><code>def func1():
list = [1,2,3,4,5]
print list
return list
</code></pre>
<p>Now, If i do following: </p>
<pre><code>python -i test.py
>>>func1()
</code></pre>
<p>This always give me two prints on python shell.
I just want to print and get returned object.</p>
| python | [7] |
643,904 | 643,905 | associative array versus object in javascript | <p>In my script there is a need to create a hash table, i searched in google for this. Most of the folks are recommending JavaScript object for this purpose. Problem is, some of the keys in the hash table have "." in them. I am able to create these keys easily with the associative arrays.</p>
<p>I don't understand why associative arrays are bad. First thing that is mentioned in the sites that i looked at is the length property. I am coming from the Perl background, where i used hashes. Most common uses were to get the value from a key, check if a key exists, delete a key-value pair, add a key-value pair. If these are my common uses, can i safely use associative array? </p>
| javascript | [3] |
255,301 | 255,302 | javascript execution time varies | <p>Am trying to figure out the best way to capture time executed by a statement. For example what is the time taken by js stmt such as if(txt =='abc'). If i use console.time('test')/console.endTime('test') pair to calculate or simple js code (given below) to calculate time the console output varies every time code is executed. </p>
<p>Also difference seen on console sometimes 1 digit, 2 digit to 3 digit in milliseconds ie sometime 1 ms, 60ms & sometimes 800ms that too order is inconsistent. I even tried to run only once & close the browser & again run it so that other GC & variables does not come in picture to hamper the times but the result is same. few ms is undestandle but such huge difference is lot to get clear time taken. So what exactly is best & consistent way to get time executed by interpreter. How can we find best yardstick to prove which stmt performs better when written in certain way or best to use</p>
<pre><code>var start = (new Date).getMilliseconds();
if(txt =='abc'){};
var diff = (new Date).getMilliseconds() - start;
console.log(diff);
</code></pre>
<p>*<em>All test are conducted in FF. Also different approach such getMilliseconds, getTime & console.endTime as taken one after other *</em></p>
| javascript | [3] |
4,753,341 | 4,753,342 | Update Query Error using php | <p>hi to all m using the following query: </p>
<pre><code>$rows = mysql_query("UPDATE admin SET create ='".$close."' WHERE id=".$id) or die(mysql_error());
</code></pre>
<p>but i got the following error:
<strong>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'create ='0' WHERE id=6' at line 1</strong></p>
<p>help me plz in this regard thnx in advance</p>
| php | [2] |
965,974 | 965,975 | How to Override superclass property value using a bespoke implementation? | <p>I have a superclass "Entity" in a logic-tier project within existing 3-tier "core" application code, from which 2 concrete classes "RiskEntity" and "PolicyEntity" inherit (in that same core project). The superclass possesses a public property "Loss" which is not overridden by the 2 subclasses. This property is used by other code within this core project. The implementation of that property refers to other classes/properties within that core project.</p>
<p>For a particular use case, I require the propery's getter to be implemented differently. If possible, I'd like that bespoke implementation to exist outside of the "core" C# project mentioned above, and I'd like the application to be configurable so as to instruct it to use that bespoke implementation whenever that property is referenced from within my core project.</p>
<p>Can anyone point me to an elegant pattern/technique to achieve this? I've wondered about using a helper interface within the getter, and using reflection to instantiate the correct implementation of that interface, based on (say) a project setting. But even if this is along the right lines, I'm not sure how the bespoke implementation could live outside of the core project code.</p>
<p>Alternative suggestions also welcome. Thanks.</p>
| c# | [0] |
1,473,907 | 1,473,908 | Drawing an image is completely out | <p>Hi I'm using this code below to let a user "draw" their signature on a UIView component on my app:</p>
<pre><code> UIGraphicsBeginImageContext(signature.frame.size);
[drawImage.image drawInRect:CGRectMake(0, 0, signature.frame.size.width, signature.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0);
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
CGContextFlush(UIGraphicsGetCurrentContext());
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext()
</code></pre>
<p>The issue I am having is that the drawing is not only is the drawing not in line with the pointer when in use in the simulator, the image is going outside of the designated UIView compontent and is getting smaller/out of focus the more I draw, as you can see in this image:
<img src="http://dl.dropbox.com/u/1545603/iphone-signature-issues.png" alt="alt text"></p>
<p>And after a few lines, showing the boundaries of the exact are of where I can draw:
<img src="http://dl.dropbox.com/u/1545603/iphone-signature-issues2.png" alt="alt text"></p>
<p>Any ideas on what's happening here?</p>
<p><code>lastPoint.y</code> is defined as: <code>lastPoint.y -= 20;</code></p>
<p>Any ideas on what on earth is happening here?</p>
| iphone | [8] |
2,495,848 | 2,495,849 | Python, Evaluate a Variable value as a Variable | <p>I'd like to do something like below: particularly the 'f.eval(field)' part, such that it evaluates the value of the variable as the field name. How does one accomplish this in Python?</p>
<pre><code>def punctuated_object_list(objects, field):
field_list = [f.eval(field) for f in objects]
if len(field_list) > 0:
if len(field_list) == 1:
return field_list[0]
else:
return ', '.join(field_list[:-1]) + ' & ' + field_list[-1]
else:
return u''
</code></pre>
| python | [7] |
4,027,124 | 4,027,125 | dynamically construct array | <p>Hy, </p>
<p>I have a very big question .
I have an array like this one <code>$array[0] = 12, $array[1] = 20, $array[2] = 18</code> and based on this array i want to give a value to this array <code>$array_go[12][20][18] = $value</code> because i'm building a recursive function to create a multidimensional array with lots of subarrays. </p>
<p>Thank you very much .</p>
<p><code>P.S. : Is it more simple if I have a $variable = '[12][15][20]'; and somehow to create $array{$variable} = value ; because i can't seem how to do it ?</code></p>
| php | [2] |
881,524 | 881,525 | Create a dropdown List in android not spinner | <p>In my application I want to create a dropDown that shows data, but the dropDown looks like a dropDown as shown in web not like a spinner.</p>
| android | [4] |
3,968,386 | 3,968,387 | When is it appropriate to use "this" in Java | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2411270/when-should-i-use-this-in-a-class">When should I use “this” in a class?</a> </p>
</blockquote>
<p>How does one know whether to use "this" when referring to a field of an instance?</p>
<p>for example:</p>
<pre><code>return this.name
</code></pre>
<p>i was taught one case where it is useful. i.e. when an input parameter is the same as the field's name:</p>
<pre><code>public void setName(String name) {
this.name = name;
}
</code></pre>
<p>Other than that, "this" seems unneeded.. What are some other cases?</p>
| java | [1] |
4,338,705 | 4,338,706 | python: convert UUID to a string which is a C unsigned char[16] initializer | <p>(in case you're curious about motivation: this will be used in a <a href="http://www.scons.org/" rel="nofollow">scons</a> build to generate a C file containing a GUID)</p>
<p>I found the question about <a href="http://stackoverflow.com/questions/534839/how-to-create-a-guid-in-python">generating a GUID in python</a>. But I don't really know much about programming python. Could someone help me convert this to a string of the form</p>
<pre><code>"{0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**}"
</code></pre>
<p>where the **'s are filled in with the GUID bytes in 2-digit hex form?</p>
<pre><code>def getInitializer(someUUID):
hexByteList = [??? for b in someUUID.bytes]
return '{'+(', '.join(hexByteList))+'}'
</code></pre>
<p>I'm not sure what to use for the "???" above.</p>
| python | [7] |
2,661,878 | 2,661,879 | Simple question: Why does the string library function std::string::find always return std::string::npos? | <p>Please see the code fragment below, specifically the first 'else if' statement. I want the user to have the ability to do this:</p>
<p>load filename</p>
<p>so I want to check that "load " is in the string and attempt to open whatever is after "load ". However, string::npos seems to always be returned (string::npos just means there is no position).</p>
<p>I'm probably doing something stupid - this is basic stuff! </p>
<pre><code>void Main::user_choice() {
string choice;
while(choice != "exit") {
cout << "> ";
cin >> choice;
if(choice == "view") {
Main::view_frameworks();
}
else if(choice.find("load ") != string::npos) {
}
else if(choice == "exit") {
return;
}
else {
cout << "Invalid command" << endl;
}
}
}
</code></pre>
| c++ | [6] |
1,340,126 | 1,340,127 | Java Classes Document Naming | <p>I just began learning Java. My friend who knows much more than me has sent me a few different files which I try to run but it gives me an error. I appologize as I don't have any of the classes on this computer and can't generate the errors right now but it appears as though the errors are due to the naming of my project as something different than a class in the file. As soon as I try renaming things it seems to fall apart and cause more problems. I know this is a total noob question but could someone explain the naming convention of the main class, project name, etc so I can run a project with multiple classes?
Thank you.</p>
| java | [1] |
422,508 | 422,509 | SIMPLE HTML DOM Fatal Error Call to a member function find() on a non-object | <p>Im using Simple HTML DOM Library and im getting error </p>
<p>Fatal error: Call to a member function find() on a non-object in /home/rodingo/public_html/crawler/music.php on line 14</p>
<p>However it is working fine on localhost but causing problem on my Dedicated Server. cURL, fopen everything is enabled but still.</p>
<pre><code> include('includes/simple_html_dom.php');
$html = file_get_html('http://mp3skull.com/mp3/'.$mp3name.'.html');
$list = array();
echo $html;
foreach ( $html->find('div#song_html ') as $e ) { // <-- LINE 14
$song = array();
$song['bit'] = preg_replace('!\s+!', ' ',$e->find('div', 0)->plaintext);
$song['title'] = preg_replace('!\s+!', ' ',$e->find('div', 1)->plaintext);
$song['url'] = preg_replace('!\s+!', ' ',$e->find('a', 0)->href);
$list[] = $song;
}
</code></pre>
| php | [2] |
559,630 | 559,631 | strange catch clause... C++ | <p>What is this catch clause??</p>
<pre><code>STD_CATCH_ALL_with_kMETHODID(...)
</code></pre>
<p>Its used in a python interpreter extension...</p>
| c++ | [6] |
2,376,227 | 2,376,228 | Remove CSS Attribute with jQuery | <p>Im building a draggable map that when the map is dragged the element is given a 'left' and 'top' attribute with values for each as so...</p>
<pre><code><div class="map" style="top:200px; left:100px;">Map</div>
</code></pre>
<p>I have a button that I want to remove the top and left attribute from the inline style on the div when clicked, Is this possible with jquery? </p>
| jquery | [5] |
123,277 | 123,278 | font color change for every click using jquery | <p>I am using jquery in my application.I need to change the font-color of the text enclosed in <code><p></p></code> tags every time a click is made on the text.
Thanks</p>
| jquery | [5] |
3,874,075 | 3,874,076 | Retrieve Button value with jQuery | <p>A simple one, I'm trying to retrieve the value attribute of a button when its been pressed using jQuery, here's what I have:</p>
<pre><code><script type="text/javascript">
$(document).ready(function() {
$('.my_button').click(function() {
alert($(this).val());
});
});
</script>
<button class="my_button" name="buttonName" value="buttonValue">
Button Label</button>
</code></pre>
<p>In Firefox my alert displays 'buttonValue' which is great but in IE7 it displays 'Button Label'.</p>
<p>What jQuery should I use to always get the button's value? Or should I be using a different approach?</p>
<p>Many thanks.</p>
<p>ANSWER:
I'm now using</p>
<pre><code><input class="my_button" type="image" src="whatever.png" value="buttonValue" />
</code></pre>
| jquery | [5] |
4,845,542 | 4,845,543 | add drop down to drop down | <p>i have an object that holds inside of him objects, and i want a dropdown menu from the ToolStripMenuItem a list of those objects names, and for each object, i want to show 2 values ("start","stop") (for each system). </p>
<p>this is how to objects looks like:</p>
<pre><code>new ServiceReference1.CloudSystemEntry{SystemId = 1,SystemName = "ERP 1"},
new ServiceReference1.CloudSystemEntry{SystemId = 2,SystemName = "ERP 2"},
</code></pre>
<p>i did the first part: </p>
<pre><code> var systems;
foreach (var item in systems)
{
this.btnsSystemsToolStripMenuItem.DropDownItems.Add(item.SystemName);
}
</code></pre>
<p>now i want to add each system name a drop down with 2 options(strings "strart","stop")<br>
how? thanks :)</p>
| c# | [0] |
1,881,041 | 1,881,042 | Why I can't declare and initialize an object like this in C++? | <p>Suppose I have the following code.</p>
<pre><code>#include <iostream>
using namespace std;
class A{};
class B{};
class C{
public:
C(const A &, const B &){cout << "Constructing C" << endl;}
};
int main()
{
C cobj(A(),B());
}
</code></pre>
<p>I WILL NOT have <strong><em>Constructing C</em></strong> displayd on my screen.</p>
<p>But if I write:</p>
<pre><code>int main()
{
A a;
B b;
C cobj(a, b);
}
</code></pre>
<p>I will have <strong><em>Constructing C</em></strong> dispalced on my screen.</p>
<p>Even more, if I write this:</p>
<pre><code>void fun(const A &, const B &)
{
cout << "You are in fun!";
}
int main ()
{
fun(A(), B());
}
</code></pre>
<p>I will have <strong><em>You are in fun!</em></strong> displayed on my screen.</p>
<p>These seems quite inconsistent to me, can anyone explain it?</p>
| c++ | [6] |
4,469,847 | 4,469,848 | Sqlitedatabase cursor getString related | <p>I have a sqlitedatabase which has table lets say "ABC" and this table has a column lets say "X". While creating the table i mentioned the data type of column X to "text". And i store current milliseconds time in this column. But the problem is mentioned below.</p>
<ol>
<li>I get the cursor by running the query on this table "ABC"</li>
<li>I check the cursor that it has got rows.</li>
<li>When i try to get the value of column "X" by using cursor.getString method then it throws the numberFormatException.</li>
</ol>
<p>please suggest any reason for this...</p>
<p>Thanks
Dalvinder Singh</p>
| android | [4] |
3,657,452 | 3,657,453 | move the upper image layout with animation to get down image click | <p>I have two images overlapping each other, i am animating(sliding) the above image to the right of the screen up to some part of it remaining on the screen so that i can animate it back to its original position, Now i want to get click of the below image to start my new activity but i am getting the click of above image only, and i know that animating the upper image will not move its layout.
But i have tried to move the layouts of upper image but after moving the layouts the above image disappears.</p>
<p>Any help?</p>
| android | [4] |
513,076 | 513,077 | How to Page Results of "php -info" in PHP CLI on Windows | <p>I am trying to find where php is loading its ini file when I use it from the command line on Windows Vista. But when I run</p>
<pre><code>php -info
</code></pre>
<p>Although it gives my the phpinfo() output, there is so much output that even scrolling up I can only see the last third or so.</p>
<p>Is there a way of paging the output?</p>
| php | [2] |
3,761,287 | 3,761,288 | i need an Arabic keyboard on iPhone without installing anything? | <p>there are already inbuilt fonts for Arabic</p>
<p>i need to use Arabic keyboard - without installing any software.</p>
<p>i don't want internal - keyboard.</p>
<p>that is => if i change my setting to iphone =>keyboard arab & english on.</p>
<p>in textField i will have option to switch on both language.</p>
<p>But what i require is => my own keyboard for my application.</p>
<p>that is. if i tap on textField(for english input) internal english keyboard should be pop up.</p>
<p>and if i tap on other textField(for arebic input) my keyboard(or any other option suggested by you) should be pop up.</p>
<p>For you kind help,</p>
<p>Thanks in advance.</p>
| iphone | [8] |
1,799,314 | 1,799,315 | highlight div for few seconds | <p>I have many div's, when ever I any of the div, it's content gets copied to the top most div, but I want to highlight the top most div, how can I do it using jQuery.</p>
<p>Code:</p>
<pre><code><div id="code"> </div>
<div id="1">Click Me</div>
<div id="2">Click Me, please</div>
</code></pre>
<p>When I click div either with id 1 or 2, it contents get copied to div with "code" id, but I need to highlight for few seconds, so that I can notify user that something is changed.</p>
<p>Please help, thanks</p>
| jquery | [5] |
4,650,340 | 4,650,341 | Removing character in list of strings | <p>If I have a list of strings such as:</p>
<pre><code>[("aaaa8"),("bb8"),("ccc8"),("dddddd8")...]
</code></pre>
<p>What should I do in order to get rid of all the <code>8</code>s in each string? I tried using <code>strip</code> or <code>replace</code> in a for loop but it doesn't work like it would in a normal string (that not in a list). Does anyone have a suggestion?</p>
| python | [7] |
32,546 | 32,547 | syntax error on line: `if x.isupper() and not in y` | <p>I'm getting "invalid syntax" errors pointing to the "in" statement. What's my mistake?</p>
<pre><code>while(notes > 1):
note = choice(scale)
if note[0].isupper() and not in patternNotes:
patternNotes.append(note)
notes -= 1
elif note is not rootNote and note not in patternNotes:
patternNotes.append(note)
notes -= 1
</code></pre>
| python | [7] |
3,444,884 | 3,444,885 | How to display image which is stored in local drive? | <p>I have a asp page in which i have to display the image which is stored in my local disk C:
i.e..
C:\Program Files\Adrenalin\Adrenalin\UploadedFiles\TemplateFile\abc.jpg</p>
<p>how can i do that...i am not able to do so.
the image is not displayed instead it shows a empty image holder with the name of the image as specified and URL as not available.</p>
<p>Please help....</p>
| asp.net | [9] |
1,593,024 | 1,593,025 | Confirm box when browser/Tag close button clicks | <p>I have created my website for this I like to create confirm box when user clicks browser close button.....</p>
<p>So i created my coding as </p>
<pre><code>window.onbeforeunload = bunload;
function bunload() {
dontleave = "Are you sure you want to leave?";
return dontleave;
}
</code></pre>
<p>By this coding I got confirm box for each and every time when browser get loading.....I need confirm box when user only clicks browser close button......</p>
<p>Can anyone give me a idea </p>
| javascript | [3] |
2,406,755 | 2,406,756 | Defining class variables with a space | <p>I'm trying to make a class which has object names with a space in between. Just so I can access them like this:</p>
<pre><code>$object->{'Var name with spaces'};
</code></pre>
<p>I've read <a href="http://stackoverflow.com/questions/6649410/mysql-php-return-object-value-with-space-in-key">this topic over here</a> and now know how to access those variables, but I'm not sure how to create a class with these variables. I've tried something like this, but I can't get it to work:
</p>
<pre><code>class Hotel
{
public ${'Var name with spaces'} = 'Some value'; // Fails
}
</code></pre>
<p>How would I go and create variables in a class definition containing spaces?</p>
| php | [2] |
1,257,622 | 1,257,623 | C++ Auto Format | <p>I am trying to create a program that auto formats my f:\ (USB Drive), and I have this code so far:</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <iostream>
int main ()
{
system ("format f:");
system("pause");
return 0;
}
</code></pre>
<p>Now, when I run that, it comes up, with me needing to press <kbd>Y</kbd>, then <kbd>Enter</kbd>. How can I simulate that?</p>
| c++ | [6] |
4,536,549 | 4,536,550 | Find the occurence of a character in a string | <p>Could someone please tell me how to find the occurence of a character in a string? I have to check the number of lines getting displayed (using the br tag) in a dynamically created div. Thanks in advance,
Ashriya</p>
| javascript | [3] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.