PostId
int64 13
11.8M
| PostCreationDate
stringlengths 19
19
| OwnerUserId
int64 3
1.57M
| OwnerCreationDate
stringlengths 10
19
| ReputationAtPostCreation
int64 -33
210k
| OwnerUndeletedAnswerCountAtPostTime
int64 0
5.77k
| Title
stringlengths 10
250
| BodyMarkdown
stringlengths 12
30k
| Tag1
stringlengths 1
25
⌀ | Tag2
stringlengths 1
25
⌀ | Tag3
stringlengths 1
25
⌀ | Tag4
stringlengths 1
25
⌀ | Tag5
stringlengths 1
25
⌀ | PostClosedDate
stringlengths 19
19
⌀ | OpenStatus
stringclasses 5
values | unified_texts
stringlengths 47
30.1k
| OpenStatus_id
int64 0
4
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8,860,576 | 01/14/2012 06:23:29 | 887,310 | 08/10/2011 06:42:11 | 68 | 1 | How to remove parsing and NSPlaceholderMutableString frame Leaks in iPhone | ![enter image description here][1]
[1]: http://i.stack.imgur.com/Zwyhf.png
While parsing the I am getting above leaks. And NSPlaceholderMutableString responsible frame for other leaks. What is the best solution or tutorial or link to follow to get out of this leaks????
Code:
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)
namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
currentElementValue = [elementName copy];
if([elementName isEqualToString:@"markers"]) {
//Initialize the array.
appDelegate.markers = [[NSMutableArray alloc] init];
}
else if([elementName isEqualToString:@"marker"]) {
//Initialize the book.
aMarker = [[marker alloc] init];
tempaMarkerDict = nil;
tempaMarkerDict = [[NSMutableDictionary alloc] init];
aMarker.name = [[NSMutableString alloc] initWithString:[attributeDict valueForKey:@"name"]];
aMarker.distance = [[NSMutableString alloc] initWithString:[attributeDict valueForKey:@"distance"]];
aMarker.lat = [[NSMutableString alloc] initWithString:[attributeDict valueForKey:@"lat"]];
aMarker.lng = [[NSMutableString alloc] initWithString:[attributeDict valueForKey:@"lng"]];
aMarker.phone= [[NSMutableString alloc] initWithString:[attributeDict valueForKey:@"phone"]];
}
NSLog(@"Processing Element: %@", elementName);
}
- (void) dealloc
{
[aMarker release];
[currentElementValue release];
[super dealloc];
}
| iphone | objective-c | memory-leaks | null | null | 02/18/2012 02:31:16 | too localized | How to remove parsing and NSPlaceholderMutableString frame Leaks in iPhone
===
![enter image description here][1]
[1]: http://i.stack.imgur.com/Zwyhf.png
While parsing the I am getting above leaks. And NSPlaceholderMutableString responsible frame for other leaks. What is the best solution or tutorial or link to follow to get out of this leaks????
Code:
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)
namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
currentElementValue = [elementName copy];
if([elementName isEqualToString:@"markers"]) {
//Initialize the array.
appDelegate.markers = [[NSMutableArray alloc] init];
}
else if([elementName isEqualToString:@"marker"]) {
//Initialize the book.
aMarker = [[marker alloc] init];
tempaMarkerDict = nil;
tempaMarkerDict = [[NSMutableDictionary alloc] init];
aMarker.name = [[NSMutableString alloc] initWithString:[attributeDict valueForKey:@"name"]];
aMarker.distance = [[NSMutableString alloc] initWithString:[attributeDict valueForKey:@"distance"]];
aMarker.lat = [[NSMutableString alloc] initWithString:[attributeDict valueForKey:@"lat"]];
aMarker.lng = [[NSMutableString alloc] initWithString:[attributeDict valueForKey:@"lng"]];
aMarker.phone= [[NSMutableString alloc] initWithString:[attributeDict valueForKey:@"phone"]];
}
NSLog(@"Processing Element: %@", elementName);
}
- (void) dealloc
{
[aMarker release];
[currentElementValue release];
[super dealloc];
}
| 3 |
11,165,195 | 06/22/2012 22:58:16 | 679,339 | 03/27/2011 20:58:11 | 26 | 0 | Best email marketing software (alternative to PHPlist) | Are there good alternatives to PHPlist out there? Particularly in ruby on rails?
We are looking to build a product like www.campaignmonitor.com
thanks! | email | newsletter | mailman | phplist | null | 07/09/2012 01:47:32 | off topic | Best email marketing software (alternative to PHPlist)
===
Are there good alternatives to PHPlist out there? Particularly in ruby on rails?
We are looking to build a product like www.campaignmonitor.com
thanks! | 2 |
10,750,162 | 05/25/2012 07:21:34 | 651,353 | 03/09/2011 10:33:15 | 630 | 47 | Excel - Code for a row line in source | All
I am trying to change the "delimiters" in my csv file, so I can open it as an excel file.
I know the delimiter to separeate the columns is ';'. But what is the delimiter for a new line?
Thanks | excel | csv | delimiter | null | null | null | open | Excel - Code for a row line in source
===
All
I am trying to change the "delimiters" in my csv file, so I can open it as an excel file.
I know the delimiter to separeate the columns is ';'. But what is the delimiter for a new line?
Thanks | 0 |
7,098,749 | 08/17/2011 20:05:36 | 207,335 | 11/09/2009 21:57:04 | 1,546 | 44 | Differences between C++ and Java compilation process | I have high level idea on the differences between C++ and Java compilation. But, I want to really understand and dive deep. can you suggest any references or blogs ? | java | c++ | null | null | null | 08/17/2011 20:15:07 | not constructive | Differences between C++ and Java compilation process
===
I have high level idea on the differences between C++ and Java compilation. But, I want to really understand and dive deep. can you suggest any references or blogs ? | 4 |
3,690,171 | 09/11/2010 07:23:16 | 103,264 | 05/08/2009 01:16:16 | 812 | 3 | redirect htaccess or php? | How do you do this...
When the user enters
http://domain.com/mycompanyname
browser redirects to
http://manager.domain.com/page.php?company=mycompanyname
| php | linux | .htaccess | redirect | null | null | open | redirect htaccess or php?
===
How do you do this...
When the user enters
http://domain.com/mycompanyname
browser redirects to
http://manager.domain.com/page.php?company=mycompanyname
| 0 |
5,829,909 | 04/29/2011 08:43:03 | 213,269 | 11/17/2009 21:05:19 | 4,503 | 105 | How can I use a TypedActor in a Java application? | I try to implement a `TypedActor` in Java following the examples on [Typed Actors (Java)][1]. But I'm struggling. I have added `akka-actor-1.1-M1.jar`, `akka-typed-actor-1.1-M1.jar`, `scala-library.jar` but it wasn't enough. I got errors in Eclipse so I also added `aspectwerkz-2.0.jar` and `aspectwerkz-core-2.0.jar` to my Build Path.
I try to use a TypedActor with custom constructor.
But now I get an error at compilation:
Exception in thread "main" java.lang.NoSuchMethodError: org.codehaus.aspectwerkz.proxy.Proxy.newInstance([Ljava/lang/Class;[Ljava/lang/Object;ZZ)Ljava/lang/Object;
at akka.actor.TypedActor$.newInstance(TypedActor.scala:596)
at akka.actor.TypedActor$.newInstance(TypedActor.scala:634)
at akka.actor.TypedActor.newInstance(TypedActor.scala)
at com.example.actor.ActorTest.main(ActorTest.java:12)
Here is my code for the `BaseActor`:
import akka.actor.TypedActor;
public class BaseActor extends TypedActor implements BaseService {
private String str;
private int num;
public BaseActor(String str, int num) {
this.str = str;
this.num = num;
System.out.println("booted");
}
public void testData(String str, int num) {
System.out.println(this.str + " " + this.num);
System.out.println(str + " " + num);
}
}
My `interface` for the service:
public interface BaseService {
public void testData(String str, int num);
}
And a test class:
import akka.actor.TypedActor;
import akka.actor.TypedActorFactory;
public class ActorTest {
public static void main(String[] args) {
BaseService service = TypedActor.newInstance(BaseService.class,
new TypedActorFactory() {
public TypedActor create() {
return new BaseActor("someString", 12);
}
});
service.testData("Hello", 6);
}
}
In the example they write:
Service service = TypedActor.newInstance(classOf[Service],
new TypedActorFactory() {
public TypedActor create() {
return new ServiceWithConstructorArgsImpl("someString", 500L));
});
But I don't think that `classOf[Service]` is Java, it's looks more like Scala.
How can I implement an `TypedActor` with a custom constructor?
[1]: http://doc.akka.io/typed-actors-java | java | actor | akka | typedactor | null | null | open | How can I use a TypedActor in a Java application?
===
I try to implement a `TypedActor` in Java following the examples on [Typed Actors (Java)][1]. But I'm struggling. I have added `akka-actor-1.1-M1.jar`, `akka-typed-actor-1.1-M1.jar`, `scala-library.jar` but it wasn't enough. I got errors in Eclipse so I also added `aspectwerkz-2.0.jar` and `aspectwerkz-core-2.0.jar` to my Build Path.
I try to use a TypedActor with custom constructor.
But now I get an error at compilation:
Exception in thread "main" java.lang.NoSuchMethodError: org.codehaus.aspectwerkz.proxy.Proxy.newInstance([Ljava/lang/Class;[Ljava/lang/Object;ZZ)Ljava/lang/Object;
at akka.actor.TypedActor$.newInstance(TypedActor.scala:596)
at akka.actor.TypedActor$.newInstance(TypedActor.scala:634)
at akka.actor.TypedActor.newInstance(TypedActor.scala)
at com.example.actor.ActorTest.main(ActorTest.java:12)
Here is my code for the `BaseActor`:
import akka.actor.TypedActor;
public class BaseActor extends TypedActor implements BaseService {
private String str;
private int num;
public BaseActor(String str, int num) {
this.str = str;
this.num = num;
System.out.println("booted");
}
public void testData(String str, int num) {
System.out.println(this.str + " " + this.num);
System.out.println(str + " " + num);
}
}
My `interface` for the service:
public interface BaseService {
public void testData(String str, int num);
}
And a test class:
import akka.actor.TypedActor;
import akka.actor.TypedActorFactory;
public class ActorTest {
public static void main(String[] args) {
BaseService service = TypedActor.newInstance(BaseService.class,
new TypedActorFactory() {
public TypedActor create() {
return new BaseActor("someString", 12);
}
});
service.testData("Hello", 6);
}
}
In the example they write:
Service service = TypedActor.newInstance(classOf[Service],
new TypedActorFactory() {
public TypedActor create() {
return new ServiceWithConstructorArgsImpl("someString", 500L));
});
But I don't think that `classOf[Service]` is Java, it's looks more like Scala.
How can I implement an `TypedActor` with a custom constructor?
[1]: http://doc.akka.io/typed-actors-java | 0 |
11,220,905 | 06/27/2012 06:57:48 | 1,051,106 | 11/17/2011 05:56:23 | 1 | 0 | Patenting a web app solution based on Google Maps? | I'm developing a web app startup, I've come up with a unique solution to identify zones and locations in countries where there are almost no street references neither zip codes or something similar to locate places easily. This solution will serve as a business-client match zone.
My questions is if this idea and the code made to make it work with Google Maps API can be patented worldwide?
I'm not a US citizen.
Thank you very much.
| google-maps | google-maps-api-3 | null | null | null | 06/27/2012 15:35:10 | off topic | Patenting a web app solution based on Google Maps?
===
I'm developing a web app startup, I've come up with a unique solution to identify zones and locations in countries where there are almost no street references neither zip codes or something similar to locate places easily. This solution will serve as a business-client match zone.
My questions is if this idea and the code made to make it work with Google Maps API can be patented worldwide?
I'm not a US citizen.
Thank you very much.
| 2 |
9,688,080 | 03/13/2012 16:31:41 | 912,703 | 08/25/2011 17:44:50 | 37 | 0 | Why does the value of width gets set to zero when the page is refreshed in chrome? | I wrote some jQuery code in which I was getting the width of images on screen and storing them in a variable. Then I logged that variable in the console to see it's value. When the page loads for the first time, it displays correct value, however if I press F5, it displays 0 as the width.
Here's the HTML:
<body>
<img src="img1.jpg" alt="image">
<img src="img1.jpg" alt="image">
<script type="text/javascript" src="script.js"></script>
</body>
Here's the jQuery code (script.js) :
jQuery(document).ready(function($) {
var imgs = $('img');
var width = imgs[0].width;
console.log(width);
});
The console displays `600` when the page is loaded for the first time but when I press F5 it displays `0`.
Why is it so?
| javascript | jquery | dom | google-chrome | width | null | open | Why does the value of width gets set to zero when the page is refreshed in chrome?
===
I wrote some jQuery code in which I was getting the width of images on screen and storing them in a variable. Then I logged that variable in the console to see it's value. When the page loads for the first time, it displays correct value, however if I press F5, it displays 0 as the width.
Here's the HTML:
<body>
<img src="img1.jpg" alt="image">
<img src="img1.jpg" alt="image">
<script type="text/javascript" src="script.js"></script>
</body>
Here's the jQuery code (script.js) :
jQuery(document).ready(function($) {
var imgs = $('img');
var width = imgs[0].width;
console.log(width);
});
The console displays `600` when the page is loaded for the first time but when I press F5 it displays `0`.
Why is it so?
| 0 |
11,284,129 | 07/01/2012 17:20:55 | 1,484,094 | 06/26/2012 22:13:01 | 8 | 0 | Twitter Bootstrap - Carousel - Do I NEED an active item? | I essentially do not want a specific active item. My items in my carousel are generated from another model. So my items are somewhat dynamic. My active item isnt, and i would prefer not have an active item all-together. Is this possible? | ruby-on-rails-3 | twitter-bootstrap | carousel | null | null | 07/02/2012 20:02:48 | not a real question | Twitter Bootstrap - Carousel - Do I NEED an active item?
===
I essentially do not want a specific active item. My items in my carousel are generated from another model. So my items are somewhat dynamic. My active item isnt, and i would prefer not have an active item all-together. Is this possible? | 1 |
8,528,442 | 12/16/2011 00:28:00 | 1,100,982 | 12/15/2011 23:57:39 | 1 | 0 | Android Accelerometer : onSensorChanged Runs Always | I've written a method to send UDP messages over the network.It's working properly.
After that, i tried to use the Accelerometer Sensor of my Galaxy S smartphone.I get the accelerometer values, show them in the screen. And when the values are changed(onSensorChanged method) , i send them using UDP to the application on my computer.
The problem is that the program sends the sensor values always, not when they are changed.
So, the onSensorChanged method is running always.
I put my phone on the desk, the values are constant in the screen but it continues to send.
How can i fix this ?
onSensorChanged method :
public void onSensorChanged(SensorEvent event) {
float x,y,z;
if (event.sensor.getType()==Sensor.TYPE_ACCELEROMETER){
x=(event.values[0]);
y=(event.values[1]);
z=(event.values[2]);
outputX.setText("x:"+String.format("%.1f",x));
outputY.setText("y:"+String.format("%.1f",y));
outputZ.setText("z:"+String.format("%.1f",z));
sendPacket("192.168.2.40", 10001,
"X:" +String.format("%.1f",x) +
"Y:" +String.format("%.1f",y) +
"Z:" +String.format("%.1f",z));
}
}
Send Method :
public void sendPacket( String ipString, int port,
String message) {
try {
byte[] bytes = null;
bytes = message.getBytes("ASCII");
InetAddress address;
try {
address = InetAddress.getByName(ipString);
} catch (Exception e) {
Log.e("Error","Exception");
return;
}
DatagramPacket packet = new DatagramPacket(bytes, bytes.length,
address, port);
DatagramSocket socket = new DatagramSocket();
socket.send(packet);
socket.close();
} catch (Exception e) {
Log.e("Error","Exception");
return;
}
} | android | accelerometer | null | null | null | null | open | Android Accelerometer : onSensorChanged Runs Always
===
I've written a method to send UDP messages over the network.It's working properly.
After that, i tried to use the Accelerometer Sensor of my Galaxy S smartphone.I get the accelerometer values, show them in the screen. And when the values are changed(onSensorChanged method) , i send them using UDP to the application on my computer.
The problem is that the program sends the sensor values always, not when they are changed.
So, the onSensorChanged method is running always.
I put my phone on the desk, the values are constant in the screen but it continues to send.
How can i fix this ?
onSensorChanged method :
public void onSensorChanged(SensorEvent event) {
float x,y,z;
if (event.sensor.getType()==Sensor.TYPE_ACCELEROMETER){
x=(event.values[0]);
y=(event.values[1]);
z=(event.values[2]);
outputX.setText("x:"+String.format("%.1f",x));
outputY.setText("y:"+String.format("%.1f",y));
outputZ.setText("z:"+String.format("%.1f",z));
sendPacket("192.168.2.40", 10001,
"X:" +String.format("%.1f",x) +
"Y:" +String.format("%.1f",y) +
"Z:" +String.format("%.1f",z));
}
}
Send Method :
public void sendPacket( String ipString, int port,
String message) {
try {
byte[] bytes = null;
bytes = message.getBytes("ASCII");
InetAddress address;
try {
address = InetAddress.getByName(ipString);
} catch (Exception e) {
Log.e("Error","Exception");
return;
}
DatagramPacket packet = new DatagramPacket(bytes, bytes.length,
address, port);
DatagramSocket socket = new DatagramSocket();
socket.send(packet);
socket.close();
} catch (Exception e) {
Log.e("Error","Exception");
return;
}
} | 0 |
11,083,152 | 06/18/2012 12:42:46 | 160,820 | 08/21/2009 14:09:57 | 1,233 | 42 | How to write this code in a better way? | I am new to coldfusion and trying to write a session handler.
I have written colde like. Can you please chack if I can write it in a better way?
<!--- /// Sets available options to select --->
<cffunction name="SetAvailableOption" output="false" access="public">
<cfargument name="Key" required="true" type="string" />
<cfargument name="Value" required="true" type="any" />
<cfif NOT StructKeyExists( Session, this.LOCAL ) >
<cfset Session[this.LOCAL] = StructNew() />
</cfif>
<cfif NOT StructKeyExists( Session[this.LOCAL], "Data" ) >
<cfset Session[this.LOCAL]["Data"] = StructNew() />
</cfif>
<cfif NOT StructKeyExists( Session[this.LOCAL]["Data"], "AvailableOptions" ) >
<cfset Session[this.LOCAL]["Data"]["AvailableOptions"] = StructNew() />
</cfif>
<cfreturn Set( Session[this.LOCAL]["Data"]["AvailableOptions"], Arguments.Key, Arguments.Value ) />
</cffunction>
<!--- /// Return Data value for the supplied key --->
<cffunction name="GetAvailableOption" output="false" access="public">
<cfargument name="Key" required="true" type="string" />
<cfif StructKeyExists( Session, this.LOCAL ) AND
StructKeyExists( Session[this.LOCAL], "Data" ) AND
StructKeyExists( Session[this.LOCAL]["Data"], "AvailableOptions") >
<cfreturn Get(Session[this.LOCAL]["Data"]["AvailableOptions"], Arguments.Key) />
<cfelse>
<cfreturn "" />
</cfif>
</cffunction>
<!--- /// Returns parameter value of supplied key --->
<cffunction name="GetParam" output="false" access="public">
<cfargument name="Key" required="true" type="string" />
<cfargument name="Default" required="false" type="string" default="" />
<cfif StructKeyExists( Session, this.LOCAL ) AND StructKeyExists( Session[this.LOCAL], "Params" ) >
<cfreturn Get(Session[this.LOCAL]["Params"], Arguments.Key, Arguments.Default) />
<cfelse>
<cfreturn Arguments.Default />
</cfif>
</cffunction>
<!--- /// Sets paramter --->
<cffunction name="SetParam" output="false" access="public">
<cfargument name="Key" required="true" type="string" />
<cfargument name="Value" required="true" type="any" />
<cfif NOT StructKeyExists( Session, this.LOCAL ) >
<cfset Session[this.LOCAL] = StructNew() />
</cfif>
<cfif NOT StructKeyExists( Session[this.LOCAL], "Params" ) >
<cfset Session[this.LOCAL]["Params"] = StructNew() />
</cfif>
<cfreturn Set(Session[this.LOCAL]["Params"], Arguments.Key, Arguments.Value) />
</cffunction> | coldfusion | null | null | null | null | 06/19/2012 22:55:21 | not a real question | How to write this code in a better way?
===
I am new to coldfusion and trying to write a session handler.
I have written colde like. Can you please chack if I can write it in a better way?
<!--- /// Sets available options to select --->
<cffunction name="SetAvailableOption" output="false" access="public">
<cfargument name="Key" required="true" type="string" />
<cfargument name="Value" required="true" type="any" />
<cfif NOT StructKeyExists( Session, this.LOCAL ) >
<cfset Session[this.LOCAL] = StructNew() />
</cfif>
<cfif NOT StructKeyExists( Session[this.LOCAL], "Data" ) >
<cfset Session[this.LOCAL]["Data"] = StructNew() />
</cfif>
<cfif NOT StructKeyExists( Session[this.LOCAL]["Data"], "AvailableOptions" ) >
<cfset Session[this.LOCAL]["Data"]["AvailableOptions"] = StructNew() />
</cfif>
<cfreturn Set( Session[this.LOCAL]["Data"]["AvailableOptions"], Arguments.Key, Arguments.Value ) />
</cffunction>
<!--- /// Return Data value for the supplied key --->
<cffunction name="GetAvailableOption" output="false" access="public">
<cfargument name="Key" required="true" type="string" />
<cfif StructKeyExists( Session, this.LOCAL ) AND
StructKeyExists( Session[this.LOCAL], "Data" ) AND
StructKeyExists( Session[this.LOCAL]["Data"], "AvailableOptions") >
<cfreturn Get(Session[this.LOCAL]["Data"]["AvailableOptions"], Arguments.Key) />
<cfelse>
<cfreturn "" />
</cfif>
</cffunction>
<!--- /// Returns parameter value of supplied key --->
<cffunction name="GetParam" output="false" access="public">
<cfargument name="Key" required="true" type="string" />
<cfargument name="Default" required="false" type="string" default="" />
<cfif StructKeyExists( Session, this.LOCAL ) AND StructKeyExists( Session[this.LOCAL], "Params" ) >
<cfreturn Get(Session[this.LOCAL]["Params"], Arguments.Key, Arguments.Default) />
<cfelse>
<cfreturn Arguments.Default />
</cfif>
</cffunction>
<!--- /// Sets paramter --->
<cffunction name="SetParam" output="false" access="public">
<cfargument name="Key" required="true" type="string" />
<cfargument name="Value" required="true" type="any" />
<cfif NOT StructKeyExists( Session, this.LOCAL ) >
<cfset Session[this.LOCAL] = StructNew() />
</cfif>
<cfif NOT StructKeyExists( Session[this.LOCAL], "Params" ) >
<cfset Session[this.LOCAL]["Params"] = StructNew() />
</cfif>
<cfreturn Set(Session[this.LOCAL]["Params"], Arguments.Key, Arguments.Value) />
</cffunction> | 1 |
3,938,995 | 10/15/2010 02:14:14 | 441,885 | 09/07/2010 22:17:31 | 3 | 1 | Powershell Start-Job won't run | I'm trying to run a simple job process in powershell 2.0 and it doesn't be working correctly.
$job = Start-Job { Return "Some string." }
When I call $job, the status says it's running. But the problem is that it never completes.
Tried the same thing on my Windows 7 machine and it completes immediately.
I'm running powershell 2.0 on windows xp.
Does anyone know what is causing this problem? How can I fix this problem?
This is my `$PSVersionTable`
Name Value
---- -----
PSVersion 2.0
PSCompatibleVersions {1.0, 2.0}
BuildVersion 6.0.6002.18111
PSRemotingProtocolVersion 2.1
WSManStackVersion 2.0
CLRVersion 4.0.30319.1
SerializationVersion 1.1.0.1 | powershell | background | start-job | null | null | null | open | Powershell Start-Job won't run
===
I'm trying to run a simple job process in powershell 2.0 and it doesn't be working correctly.
$job = Start-Job { Return "Some string." }
When I call $job, the status says it's running. But the problem is that it never completes.
Tried the same thing on my Windows 7 machine and it completes immediately.
I'm running powershell 2.0 on windows xp.
Does anyone know what is causing this problem? How can I fix this problem?
This is my `$PSVersionTable`
Name Value
---- -----
PSVersion 2.0
PSCompatibleVersions {1.0, 2.0}
BuildVersion 6.0.6002.18111
PSRemotingProtocolVersion 2.1
WSManStackVersion 2.0
CLRVersion 4.0.30319.1
SerializationVersion 1.1.0.1 | 0 |
3,316,755 | 07/23/2010 09:03:44 | 22,194 | 09/25/2008 14:22:55 | 2,290 | 114 | VisualForce: Pass a parameter to a custom component inside a repeater | I can't figure out why this isn't working:
<apex:repeat value="{!MyContacts}" var="c" >
<c:ContactRowComponent contactLastName="{!c.LastName}"/>
</apex:repeat>
(where on the main controller MyContacts returns an array of Contact objects, and on the component contactLastName is defined as a String attribute)
This gives me error:
`Literal value is required for attribute contactLastName in <c:ContactRowComponent> at line 25 column 27`
It seems to be saying that a literal value is required and not a formula? Is what I am trying to do impossible, or am I doing it wrong? | salesforce | custom-component | apex | visualforce | null | null | open | VisualForce: Pass a parameter to a custom component inside a repeater
===
I can't figure out why this isn't working:
<apex:repeat value="{!MyContacts}" var="c" >
<c:ContactRowComponent contactLastName="{!c.LastName}"/>
</apex:repeat>
(where on the main controller MyContacts returns an array of Contact objects, and on the component contactLastName is defined as a String attribute)
This gives me error:
`Literal value is required for attribute contactLastName in <c:ContactRowComponent> at line 25 column 27`
It seems to be saying that a literal value is required and not a formula? Is what I am trying to do impossible, or am I doing it wrong? | 0 |
8,253,834 | 11/24/2011 08:05:15 | 838,485 | 07/11/2011 08:26:57 | 79 | 2 | How to trap custom URL scheme from a webview? | In my application, I have a webview which loads up a page that contains both normal links and custom URL schemes, such as myapp://id=1234.
Right now, I am trying to trap the request within this function:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType{
NSLog(@"NSURLRequest = %@", [[request URL] absoluteString]);
}
Printing out the url as above gives me this:
http://localhost:8888/myapp://id=1234
Which is my localhost setup on MAMP with the custom URL appended to the URL.
I had hoped that I could use [request scheme] directly, but in this case now, it simply returns "http". Is there a way that I can handle custom URL schemes from within my own app?
At this point, I would like to be able to do the following:
1. User is on the webview
2. User taps the custom url link ( myapp://id=1234 )
3. My app handles the custom url and directs the user to another page ( http://www.someotherpage.com/?id=1234 )
Thank you! | iphone | nsurl | nsurlrequest | null | null | null | open | How to trap custom URL scheme from a webview?
===
In my application, I have a webview which loads up a page that contains both normal links and custom URL schemes, such as myapp://id=1234.
Right now, I am trying to trap the request within this function:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType{
NSLog(@"NSURLRequest = %@", [[request URL] absoluteString]);
}
Printing out the url as above gives me this:
http://localhost:8888/myapp://id=1234
Which is my localhost setup on MAMP with the custom URL appended to the URL.
I had hoped that I could use [request scheme] directly, but in this case now, it simply returns "http". Is there a way that I can handle custom URL schemes from within my own app?
At this point, I would like to be able to do the following:
1. User is on the webview
2. User taps the custom url link ( myapp://id=1234 )
3. My app handles the custom url and directs the user to another page ( http://www.someotherpage.com/?id=1234 )
Thank you! | 0 |
9,621,304 | 03/08/2012 16:38:36 | 1,027,943 | 11/03/2011 14:45:21 | 1 | 0 | Java EE -- Configuration issues for a beginner | all. Relative rookie here who has spent the better part of three days just trying to get started with Java EE, and it's driving me up a wall. I've already read through numerous tutorials and consulted several book, so now I am turning to you.
I am starting from complete scratch, having uninstalled NetBeans and Glassfish and the Java EE SDK. My main issue is quite simply configuration. All the resources I've found typically say in a mere throwaway line: "Once you download the SDK, you must configure your environment for Java EE." But HOW? I need it in plain English. Even the most novice guides leave this basic stuff out. Does this mean editing the JAVA_HOME path or what? How does this configuration relate to the Java SE already on my system? Furthermore, I assume I don't need to also download the JDK with EE since I already have a JDK? (I am a Mac user, if that matters.)
I know I have a long, long way to go, so I appreciate any help I can get as I try to get this ball rolling. Much thanks in advance! | java | java-ee-6 | null | null | null | null | open | Java EE -- Configuration issues for a beginner
===
all. Relative rookie here who has spent the better part of three days just trying to get started with Java EE, and it's driving me up a wall. I've already read through numerous tutorials and consulted several book, so now I am turning to you.
I am starting from complete scratch, having uninstalled NetBeans and Glassfish and the Java EE SDK. My main issue is quite simply configuration. All the resources I've found typically say in a mere throwaway line: "Once you download the SDK, you must configure your environment for Java EE." But HOW? I need it in plain English. Even the most novice guides leave this basic stuff out. Does this mean editing the JAVA_HOME path or what? How does this configuration relate to the Java SE already on my system? Furthermore, I assume I don't need to also download the JDK with EE since I already have a JDK? (I am a Mac user, if that matters.)
I know I have a long, long way to go, so I appreciate any help I can get as I try to get this ball rolling. Much thanks in advance! | 0 |
2,719,654 | 04/27/2010 08:12:53 | 24,872 | 10/03/2008 15:00:25 | 173 | 4 | Is it possible to use the Spring MVC on JBoss App server? | Is it possible to use Spring MVC on JBoss App server?
If so, how?
Used the Spring MVC with Tomcat Apache server, but now i have to move my project to a JBoss app server.
But i'm getting an error, and i'm not sure why. It seems like i can't use my classes.
125 ERROR [Engine] StandardWrapperValve[project]: Servlet.service() for servlet project threw exception java.lang.NullPointerException
at java.util.Hashtable.containsKey(Hashtable.java:307)
at com.scap.handle.ControlStatusContainer.deleteUser(ControlStatusContainer.java:70)
at web.shnController.handleRequest(shnController.java:121)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
Anyone got a suggestion?
Thanks in advance. | spring-mvc | jboss | converting | null | null | null | open | Is it possible to use the Spring MVC on JBoss App server?
===
Is it possible to use Spring MVC on JBoss App server?
If so, how?
Used the Spring MVC with Tomcat Apache server, but now i have to move my project to a JBoss app server.
But i'm getting an error, and i'm not sure why. It seems like i can't use my classes.
125 ERROR [Engine] StandardWrapperValve[project]: Servlet.service() for servlet project threw exception java.lang.NullPointerException
at java.util.Hashtable.containsKey(Hashtable.java:307)
at com.scap.handle.ControlStatusContainer.deleteUser(ControlStatusContainer.java:70)
at web.shnController.handleRequest(shnController.java:121)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
Anyone got a suggestion?
Thanks in advance. | 0 |
872,003 | 05/16/2009 08:47:37 | 108,051 | 05/16/2009 04:08:33 | 1 | 0 | chinese mobile software development? | As per my assumption () there are hundreds of millions of Chinese mobile phones (or clones of brand phones) out there. And it seems firmware and OS of those mobile phones are same. Those phones only differ in their design and may be hardware.
I was wondering if there is any development kit or software development support for those mobile phones. What is that OS and/or firmware inside those phones? Are those open source or available online anyway? Do those phones support java? Where to get more information about those phones and their software online?
Thanks a lot in advance. | chinese | mobile | phone | firmware | null | 05/06/2012 18:39:30 | not constructive | chinese mobile software development?
===
As per my assumption () there are hundreds of millions of Chinese mobile phones (or clones of brand phones) out there. And it seems firmware and OS of those mobile phones are same. Those phones only differ in their design and may be hardware.
I was wondering if there is any development kit or software development support for those mobile phones. What is that OS and/or firmware inside those phones? Are those open source or available online anyway? Do those phones support java? Where to get more information about those phones and their software online?
Thanks a lot in advance. | 4 |
8,287,219 | 11/27/2011 16:53:37 | 410,560 | 08/04/2010 09:04:35 | 249 | 6 | Return shared array item without removing reference count | with the code listed above I would call the function **GetItem** and get the item I requested without getting the array deleted. How can I do this?
struct test
{
int hello;
char *wow;
}
test GetItem()
{
boost::shared_array<test> myarray(new test[10]);
...
return myarray[0];
}
void TestFunction()
{
test item = GetItem();
...
}
The code works but in the TestFunction function item will contain NULL in the wow member. This is because when I call return the shared_array invoke the destructor. | c++ | arrays | boost | smart-pointers | null | 11/28/2011 15:41:54 | too localized | Return shared array item without removing reference count
===
with the code listed above I would call the function **GetItem** and get the item I requested without getting the array deleted. How can I do this?
struct test
{
int hello;
char *wow;
}
test GetItem()
{
boost::shared_array<test> myarray(new test[10]);
...
return myarray[0];
}
void TestFunction()
{
test item = GetItem();
...
}
The code works but in the TestFunction function item will contain NULL in the wow member. This is because when I call return the shared_array invoke the destructor. | 3 |
10,717,358 | 05/23/2012 09:44:16 | 1,412,216 | 05/23/2012 09:19:33 | 1 | 0 | Uncaught ReferenceError: AFMA_getSdkConstants is not defined | I'm trying to add an AdMob ad to my android application but whenever I'm opening the activity that is supposed to display the ad I get this error:
I/Ads(11448): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_getSdkConstants();AFMA_buildAdURL({"kw":[],"preqs":4,"session_id":"17111845472336325405","u_sd":2,"seq_num":"5","slotname":"MYUSERIDHERE","u_w":360,"msid":"com.lazyprogrammer.dartscore","adtest":"on","js":"afma-sdk-a-v6.0.1","mv":"8011019.com.android.vending","isu":"70069487A7A68D24BEF2581104A73318","cipa":0,"format":"360x50_mb","net":"wi","smart_h":"auto","app_name":"1.android.com.lazyprogrammer.dartscore","hl":"en","smart_w":"full","u_h":613,"carrier":"26203","ptime":225498,"u_audio":1});</script></head><body></body></html>
E/Ads(11448): JS: Uncaught ReferenceError: AFMA_getSdkConstants is not defined (about:blank:1)<br/>
E/Web Console(11448): Uncaught ReferenceError: AFMA_getSdkConstants is not defined at about:blank:1<br/>
I/Ads(11448): AdLoader timed out after 60000ms while getting the URL.<br/>
D/webviewglue(11448): nativeDestroy view: 0x2bc958<br/>
I/Ads(11448): onFailedToReceiveAd(A network error occurred.)<br/>
I/Ads(11448): AdLoader timed out after 60000ms while getting the URL.<br/>
D/webviewglue(11448): nativeDestroy view: 0x5a1850<br/>
I/Ads(11448): onFailedToReceiveAd(A network error occurred.)
I can't find anything on this problem on google or elsewhere and I don't think I'm doing anything wrong.
Just in case, here is my xml snippet that is supposed to show the ad:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
...
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="MyIDhere"
ads:loadAdOnCreate="true"
ads:testDevices="70069487A7A68D24BEF2581104A73318" />
</RelativeLayout>
Of course I took out all the - I think - unnecessary code for this problem but if it's necessary to see it I'll post it here as well.
I also took out my AdMob UnitID, you probably figured that out but I'm writing this here so that missing UnitId won't be an answer. | android | admob | null | null | null | null | open | Uncaught ReferenceError: AFMA_getSdkConstants is not defined
===
I'm trying to add an AdMob ad to my android application but whenever I'm opening the activity that is supposed to display the ad I get this error:
I/Ads(11448): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_getSdkConstants();AFMA_buildAdURL({"kw":[],"preqs":4,"session_id":"17111845472336325405","u_sd":2,"seq_num":"5","slotname":"MYUSERIDHERE","u_w":360,"msid":"com.lazyprogrammer.dartscore","adtest":"on","js":"afma-sdk-a-v6.0.1","mv":"8011019.com.android.vending","isu":"70069487A7A68D24BEF2581104A73318","cipa":0,"format":"360x50_mb","net":"wi","smart_h":"auto","app_name":"1.android.com.lazyprogrammer.dartscore","hl":"en","smart_w":"full","u_h":613,"carrier":"26203","ptime":225498,"u_audio":1});</script></head><body></body></html>
E/Ads(11448): JS: Uncaught ReferenceError: AFMA_getSdkConstants is not defined (about:blank:1)<br/>
E/Web Console(11448): Uncaught ReferenceError: AFMA_getSdkConstants is not defined at about:blank:1<br/>
I/Ads(11448): AdLoader timed out after 60000ms while getting the URL.<br/>
D/webviewglue(11448): nativeDestroy view: 0x2bc958<br/>
I/Ads(11448): onFailedToReceiveAd(A network error occurred.)<br/>
I/Ads(11448): AdLoader timed out after 60000ms while getting the URL.<br/>
D/webviewglue(11448): nativeDestroy view: 0x5a1850<br/>
I/Ads(11448): onFailedToReceiveAd(A network error occurred.)
I can't find anything on this problem on google or elsewhere and I don't think I'm doing anything wrong.
Just in case, here is my xml snippet that is supposed to show the ad:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
...
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="MyIDhere"
ads:loadAdOnCreate="true"
ads:testDevices="70069487A7A68D24BEF2581104A73318" />
</RelativeLayout>
Of course I took out all the - I think - unnecessary code for this problem but if it's necessary to see it I'll post it here as well.
I also took out my AdMob UnitID, you probably figured that out but I'm writing this here so that missing UnitId won't be an answer. | 0 |
9,823,317 | 03/22/2012 13:32:36 | 851,432 | 07/19/2011 07:10:33 | 1,389 | 79 | What's your 'no framework' Java framework? | **DISCLAIMER:** The title is taken from a similar question on PHP - [What's your 'no framework' PHP framework?][1]. I liked that post and search around Stackoverflow to find something like that, but I can't. That is why I am having a post here. And when I typed the title I got a warning - *The question you're asking appears subjective and is likely to be closed.* I don't want it to be subjective, and that is not my intention.
<hr />
We all get to work with many projects. They can be of any size, from small to large ones. We also need to work with frameworks to reduce our development time and efforts. But, at times, choosing the right framework is became a burden, especially for small applications. We don't want to put a large framework into action on small projects, because they usually prove to be expensive. Many of us may prefer small, minimal and personal set of libraries.
So my question is same as the one from the inspirational question. I am copy-pasting that here with modification for Java. I am more interested in Web applications.
**What is your method when it comes to 'rolling your own' framework for Java applications, and how does it vary depending on the type/scope of a project?**
**What does your code look like for a typical page? What is your file structure? What 3rd party libraries/components do you commonly use, and how do you keep your libraries, classes organized?**
Do you address/implement:
DB abstraction
REST
OOP
MVC
and if so, how?
At what point do you consider using a more popular, existing framework (eg. Spring) instead?
[1]: http://stackoverflow.com/q/694929/851432 | java | frameworks | null | null | null | 03/22/2012 13:47:02 | not constructive | What's your 'no framework' Java framework?
===
**DISCLAIMER:** The title is taken from a similar question on PHP - [What's your 'no framework' PHP framework?][1]. I liked that post and search around Stackoverflow to find something like that, but I can't. That is why I am having a post here. And when I typed the title I got a warning - *The question you're asking appears subjective and is likely to be closed.* I don't want it to be subjective, and that is not my intention.
<hr />
We all get to work with many projects. They can be of any size, from small to large ones. We also need to work with frameworks to reduce our development time and efforts. But, at times, choosing the right framework is became a burden, especially for small applications. We don't want to put a large framework into action on small projects, because they usually prove to be expensive. Many of us may prefer small, minimal and personal set of libraries.
So my question is same as the one from the inspirational question. I am copy-pasting that here with modification for Java. I am more interested in Web applications.
**What is your method when it comes to 'rolling your own' framework for Java applications, and how does it vary depending on the type/scope of a project?**
**What does your code look like for a typical page? What is your file structure? What 3rd party libraries/components do you commonly use, and how do you keep your libraries, classes organized?**
Do you address/implement:
DB abstraction
REST
OOP
MVC
and if so, how?
At what point do you consider using a more popular, existing framework (eg. Spring) instead?
[1]: http://stackoverflow.com/q/694929/851432 | 4 |
4,025,871 | 10/26/2010 16:46:18 | 452,101 | 09/19/2010 19:28:34 | 31 | 1 | When to prefer joins expressed with SelectMany() over joins expressed with the join keyword in Linq | Linq allows to express inner joins by using the join keyword or by using
SelectMany() (i.e. a couple of from keywords) with a where keyword:
<code>
var personsToState = from person in persons join state in statesOfUS
on person.State equals state.USPS
select new { person, State = state.Name };
foreach (var item in personsToState)
{
System.Diagnostics.Debug.WriteLine(item);
}
// The same query can be expressed with the query operator SelectMany(), which is
// expressed as two from clauses and a single where clause connecting the sequences.
var personsToState2 = from person in persons
from state in statesOfUS
where person.State == state.USPS
select new { person, State = state.Name };
foreach (var item in personsToState2)
{
System.Diagnostics.Debug.WriteLine(item);
}
</code>
My question: when is it purposeful to use the join-style and when to use the where-style,
has one style performance advantages over the other style?
| linq | join | null | null | null | null | open | When to prefer joins expressed with SelectMany() over joins expressed with the join keyword in Linq
===
Linq allows to express inner joins by using the join keyword or by using
SelectMany() (i.e. a couple of from keywords) with a where keyword:
<code>
var personsToState = from person in persons join state in statesOfUS
on person.State equals state.USPS
select new { person, State = state.Name };
foreach (var item in personsToState)
{
System.Diagnostics.Debug.WriteLine(item);
}
// The same query can be expressed with the query operator SelectMany(), which is
// expressed as two from clauses and a single where clause connecting the sequences.
var personsToState2 = from person in persons
from state in statesOfUS
where person.State == state.USPS
select new { person, State = state.Name };
foreach (var item in personsToState2)
{
System.Diagnostics.Debug.WriteLine(item);
}
</code>
My question: when is it purposeful to use the join-style and when to use the where-style,
has one style performance advantages over the other style?
| 0 |
4,833,532 | 01/28/2011 22:07:19 | 54,392 | 01/12/2009 23:38:16 | 56 | 5 | ASP.NET MVC 3 - How can I conditionally validate (IValidatableObject) when calling UpdateModel or TryUpdateModel? | I am using EFCodeFirst CTP5 (although this shouldn't make a difference) and ASP.NET MVC 3. I have created the following entities:
public class Company
{
public int CompanyID { get; set; }
public int SubdomainID { get; set; }
public virtual Subdomain Subdomain { get; set; }
}
public class Subdomain : IValidatableObject
{
public int SubdomainID { get; set; }
public virtual ICollection<SubdomainActivity> Activities { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
int activitySum = Activities.Sum(x => x.Value);
if (activitySum != 100)
{
yield return new ValidationResult(string.Format("The Activity percentages must add up to 100. Current sum is {0}", activitySum), new[] { "Activities" });
}
}
}
public class SubdomainActivity
{
public int ActivityID { get; set; }
public int Value { get; set; }
}
Notice that a `Company` has a `Subdomain` and a `Subdomain` has an `ICollection<SubdomainActivity>`.
I have controllers for `Company` and `Subdomain`. In the `SubdomainController` when I call `UpdateModel()` (or `TryUpdateModel()`) on an instance of a `Subdomain` I get the result I want. The `Subdomain` activities are validated that the values sum up to 100.
In the `CompanyController` when I call `UpdateModel()` on an instance of a `Company` it validates that the `Subdomain.Activities` add up to 100 as well, which I don't want. The user can't even edit `Subdomain.Activites` from the `Company` edit view anyway, so it makes no sense to tell them that there was an error with `Subdomain.Activities`.
I would like to be able to add an item to the validationContext.Items IDictionary so that I can conditionally validate based on context or something like that, but I haven't been able to figure out how to do that without writing my own IModelBinder (which I could do I suppose, but seems like overkill). Ultimately I have come up with this workaround in the `CompanyController`, but I am sure there is a correct way to handle this (this is wrapped in a `try` `catch`)
var d = this.companyRepository.GetById(id);
bool good = TryUpdateModel(d);
if (!good)
{
if (ModelState.ContainsKey("Subdomain.Activities"))
ModelState.Remove("Subdomain.Activities");
if (!ModelState.IsValid)
throw new InvalidOperationException(string.Format("The model of type '{0}' could not be updated.", typeof(Company).FullName));
}
this.companyRepository.Save();
As an interesting side note, if I don't check if the model is valid and throw an error then the companyRepository.Save() works fine. In other words EFCodeFirst doesn't validate the Activities, but MVC UpdateModel goes all the way down to Activities on the Subdomain.
Can anyone help me out with a better/correct/recommended way to handle this?
| entity-framework | asp.net-mvc-3 | null | null | null | null | open | ASP.NET MVC 3 - How can I conditionally validate (IValidatableObject) when calling UpdateModel or TryUpdateModel?
===
I am using EFCodeFirst CTP5 (although this shouldn't make a difference) and ASP.NET MVC 3. I have created the following entities:
public class Company
{
public int CompanyID { get; set; }
public int SubdomainID { get; set; }
public virtual Subdomain Subdomain { get; set; }
}
public class Subdomain : IValidatableObject
{
public int SubdomainID { get; set; }
public virtual ICollection<SubdomainActivity> Activities { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
int activitySum = Activities.Sum(x => x.Value);
if (activitySum != 100)
{
yield return new ValidationResult(string.Format("The Activity percentages must add up to 100. Current sum is {0}", activitySum), new[] { "Activities" });
}
}
}
public class SubdomainActivity
{
public int ActivityID { get; set; }
public int Value { get; set; }
}
Notice that a `Company` has a `Subdomain` and a `Subdomain` has an `ICollection<SubdomainActivity>`.
I have controllers for `Company` and `Subdomain`. In the `SubdomainController` when I call `UpdateModel()` (or `TryUpdateModel()`) on an instance of a `Subdomain` I get the result I want. The `Subdomain` activities are validated that the values sum up to 100.
In the `CompanyController` when I call `UpdateModel()` on an instance of a `Company` it validates that the `Subdomain.Activities` add up to 100 as well, which I don't want. The user can't even edit `Subdomain.Activites` from the `Company` edit view anyway, so it makes no sense to tell them that there was an error with `Subdomain.Activities`.
I would like to be able to add an item to the validationContext.Items IDictionary so that I can conditionally validate based on context or something like that, but I haven't been able to figure out how to do that without writing my own IModelBinder (which I could do I suppose, but seems like overkill). Ultimately I have come up with this workaround in the `CompanyController`, but I am sure there is a correct way to handle this (this is wrapped in a `try` `catch`)
var d = this.companyRepository.GetById(id);
bool good = TryUpdateModel(d);
if (!good)
{
if (ModelState.ContainsKey("Subdomain.Activities"))
ModelState.Remove("Subdomain.Activities");
if (!ModelState.IsValid)
throw new InvalidOperationException(string.Format("The model of type '{0}' could not be updated.", typeof(Company).FullName));
}
this.companyRepository.Save();
As an interesting side note, if I don't check if the model is valid and throw an error then the companyRepository.Save() works fine. In other words EFCodeFirst doesn't validate the Activities, but MVC UpdateModel goes all the way down to Activities on the Subdomain.
Can anyone help me out with a better/correct/recommended way to handle this?
| 0 |
7,454,111 | 09/17/2011 10:34:41 | 550,110 | 12/21/2010 15:17:49 | 76 | 0 | Change default code page for debug console in VS10 | Currently it defaults to my system locale, which is 932 (Japanese Shift-JIS) in my case, but I want it to be 65001 (UTF-8) by default.
I can change the default for a given program by inserting a SetConsoleOutputCP line somewhere in the code and then removing it, but doing it for every program is pretty annoying.
Any suggestions? | c++ | visual-studio-2010 | utf-8 | codepages | null | null | open | Change default code page for debug console in VS10
===
Currently it defaults to my system locale, which is 932 (Japanese Shift-JIS) in my case, but I want it to be 65001 (UTF-8) by default.
I can change the default for a given program by inserting a SetConsoleOutputCP line somewhere in the code and then removing it, but doing it for every program is pretty annoying.
Any suggestions? | 0 |
7,866,284 | 10/23/2011 13:02:16 | 892,055 | 08/12/2011 15:23:13 | 8 | 0 | How do you differentiate between different characters within the same string after the occurance of a white space | I have a question I am making a decoder that decodes as follows
"2" as "a", "22" as "b", "222" as "c", "3" as "d" etc, ive written the following logic to implement it
Scanner input = new Scanner(System.in);
String lStr=input.nextLine();
if (lStr.equals("2")||lStr.equals("2222"))
{
output=lStr.replace("2", "a");
output=lStr.replace("2222", "a");
}
if(lStr.equals("22"))
{
output=lStr.replace("22","b");
}
etc
The problem is I wanted the compiler to differentiate between 2, 22, 222 etc after the occurance of a space but when it encounters a space it shows the output as null otherwise the program works fine. How do I deal with that space?
if I give it an input of 222 its output is c but if I give it an input like 2 22 222 its output is null, how do I deal with this situation? | java | java-ee-6 | null | null | null | null | open | How do you differentiate between different characters within the same string after the occurance of a white space
===
I have a question I am making a decoder that decodes as follows
"2" as "a", "22" as "b", "222" as "c", "3" as "d" etc, ive written the following logic to implement it
Scanner input = new Scanner(System.in);
String lStr=input.nextLine();
if (lStr.equals("2")||lStr.equals("2222"))
{
output=lStr.replace("2", "a");
output=lStr.replace("2222", "a");
}
if(lStr.equals("22"))
{
output=lStr.replace("22","b");
}
etc
The problem is I wanted the compiler to differentiate between 2, 22, 222 etc after the occurance of a space but when it encounters a space it shows the output as null otherwise the program works fine. How do I deal with that space?
if I give it an input of 222 its output is c but if I give it an input like 2 22 222 its output is null, how do I deal with this situation? | 0 |
6,759,047 | 07/20/2011 08:28:06 | 600,633 | 02/02/2011 20:57:13 | 123 | 13 | Why must the transpose value of glUniformMatrix4fv in webgl/OpenGL ES be false? | Title explains the most of the questions.
The [OpenGL ES spec][1] says that the transpose value must be false or an INVALID_VALUE is generated. Why then have the parameter?
[1]: http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml | opengl-es | webgl | null | null | null | 04/09/2012 20:44:43 | off topic | Why must the transpose value of glUniformMatrix4fv in webgl/OpenGL ES be false?
===
Title explains the most of the questions.
The [OpenGL ES spec][1] says that the transpose value must be false or an INVALID_VALUE is generated. Why then have the parameter?
[1]: http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml | 2 |
8,338,896 | 12/01/2011 09:16:54 | 36,633 | 11/11/2008 16:39:14 | 416 | 4 | SQL Query Speed | I'm building a report that collates a huge amount of data, the data for the report has taken shape as a view which run's in about 2 to 9 seconds (which is acceptable). I also have a function that returns a set of ids which needs to filter the view:
select *
from vw_report
where employee_id in (select id from dbo.fnc_security(@personRanAsID))
The security function on it's own run's in less than a second. However when I combine the two as I have above the query takes over 15 minutes.
Both the view and the security function do quite a lot of work so originally I thought it might be down to locking, I've tried no lock on the security function but it made no difference.
Any tips or tricks as to where I may be going wrong?
It may be worth noting that when I copy the result of the function into the in part of the statement:
select *
from vw_report
where employee_id in (123, 456, 789)
The speed increases back to 2 to 9 seconds. | sql | performance | reporting | null | null | null | open | SQL Query Speed
===
I'm building a report that collates a huge amount of data, the data for the report has taken shape as a view which run's in about 2 to 9 seconds (which is acceptable). I also have a function that returns a set of ids which needs to filter the view:
select *
from vw_report
where employee_id in (select id from dbo.fnc_security(@personRanAsID))
The security function on it's own run's in less than a second. However when I combine the two as I have above the query takes over 15 minutes.
Both the view and the security function do quite a lot of work so originally I thought it might be down to locking, I've tried no lock on the security function but it made no difference.
Any tips or tricks as to where I may be going wrong?
It may be worth noting that when I copy the result of the function into the in part of the statement:
select *
from vw_report
where employee_id in (123, 456, 789)
The speed increases back to 2 to 9 seconds. | 0 |
9,107,508 | 02/02/2012 05:18:56 | 220,404 | 11/28/2009 09:20:00 | 7 | 1 | SQLUnknown column 'jawab1' in 'field list' | i have a problem in getting an error message "SQLUnknown column 'jawab1' in 'field list'". How to fix?Below is my code.This code aims to enter the data from php to the database. Thank You
<?php
include "../Library/inc.connectiondb.php";
$txtTanya = $_POST['txtTanya'];
$txtPilih1 = $_POST['txtPilih1'];
$txtPilih2 = $_POST['txtPilih2'];
$txtPilih3 = $_POST['txtPilih3'];
$txtPilih4 = $_POST['txtPilih4'];
$rbStatus = $_POST['rbStatus'];
if(trim($txtTanya) == "") {
echo "Ruang pertanyaan masih kosong,tolong isi";
}
else if(trim($txtPilih1) == "") {
echo "Pilihan 1 masih kosong,tolong isi";
}
else if(trim($txtPilih2) == "") {
echo "Pilihan 2 masih kosong,tolong isi";
}
else if(trim($txtPilih3) == "") {
echo "Pilihan 3 masih kosong,tolong isi";
}
else if(trim($txtPilih4) == "") {
echo "Pilihan 4 masih kosong,tolong isi";
}
else {
$sqlSimpan="INSERT INTO polling SET
pertanyaan='$txtTanya',
jawab1='$txtPilih1',
jawab2='$txtPilih2',
jawab3='$txtPilih3',
jawab4='$txtPilih4',
statusaktif='$rbStatus' ";
mysql_query($sqlSimpan,$koneksi) or die ("Gagal Perintah SQL".mysql_error());
echo "DATA POLLING BERJAYA DISIMPAN";
}
?>
jawab1='$txtPilih1',
what wrong with that code?thank you.
| php | mysql | insert | null | null | null | open | SQLUnknown column 'jawab1' in 'field list'
===
i have a problem in getting an error message "SQLUnknown column 'jawab1' in 'field list'". How to fix?Below is my code.This code aims to enter the data from php to the database. Thank You
<?php
include "../Library/inc.connectiondb.php";
$txtTanya = $_POST['txtTanya'];
$txtPilih1 = $_POST['txtPilih1'];
$txtPilih2 = $_POST['txtPilih2'];
$txtPilih3 = $_POST['txtPilih3'];
$txtPilih4 = $_POST['txtPilih4'];
$rbStatus = $_POST['rbStatus'];
if(trim($txtTanya) == "") {
echo "Ruang pertanyaan masih kosong,tolong isi";
}
else if(trim($txtPilih1) == "") {
echo "Pilihan 1 masih kosong,tolong isi";
}
else if(trim($txtPilih2) == "") {
echo "Pilihan 2 masih kosong,tolong isi";
}
else if(trim($txtPilih3) == "") {
echo "Pilihan 3 masih kosong,tolong isi";
}
else if(trim($txtPilih4) == "") {
echo "Pilihan 4 masih kosong,tolong isi";
}
else {
$sqlSimpan="INSERT INTO polling SET
pertanyaan='$txtTanya',
jawab1='$txtPilih1',
jawab2='$txtPilih2',
jawab3='$txtPilih3',
jawab4='$txtPilih4',
statusaktif='$rbStatus' ";
mysql_query($sqlSimpan,$koneksi) or die ("Gagal Perintah SQL".mysql_error());
echo "DATA POLLING BERJAYA DISIMPAN";
}
?>
jawab1='$txtPilih1',
what wrong with that code?thank you.
| 0 |
892,631 | 05/21/2009 12:10:16 | 48,886 | 12/24/2008 11:51:35 | 369 | 15 | I'm looking for some good object orientated books | I'm looking for some good quality OO books, if any exist for VB .Net, that'd be awesome.
Have you read anything that you would recommend? | oop | books | vb.net | null | null | 09/20/2011 15:10:10 | not constructive | I'm looking for some good object orientated books
===
I'm looking for some good quality OO books, if any exist for VB .Net, that'd be awesome.
Have you read anything that you would recommend? | 4 |
7,021,028 | 08/11/2011 05:00:47 | 889,243 | 08/11/2011 05:00:47 | 1 | 0 | cannot convert `int*' to `float*' for argument `1' to `float mean(float*, float)' | #include <iostream>
using namespace std;
float mean(float num[],float n)
{
int i;
int numElements;
float sum=0;
for(i=0;i<numElements;i++)
sum=sum+num[i];
return (sum/n);
}
int main()
{
int numElements;
int minusElements;
float n;
cout << "Enter number of Elements:";
cin >> numElements;
minusElements = numElements - 1 ;
int num[numElements], i,j,temp;
cout << "Enter " << numElements << " numbers:\n";
for(i=0;i<numElements;i++)
cin >> num[i];
cin.get();
for(i=0;i<numElements;i++)
for(i=0;i<minusElements;i++)
{
for(j=i+1;j<numElements;j++)
{
if(num[i]<=num[j])
{
temp=num[i];
num[i]=num[j];
num[j]=temp;
}
}
}
for(i=0;i<numElements;i++)
cout << num[i];
cout <<"\n";
cout << "Mean:"<< mean(num,n);
//cout << "Median:"<<median(i);
cin.get();
}
//Line:57 cannot convert `int*' to `float*' for argument `1' to `float mean(float*, float)' | c++ | null | null | null | null | 08/12/2011 08:46:17 | not a real question | cannot convert `int*' to `float*' for argument `1' to `float mean(float*, float)'
===
#include <iostream>
using namespace std;
float mean(float num[],float n)
{
int i;
int numElements;
float sum=0;
for(i=0;i<numElements;i++)
sum=sum+num[i];
return (sum/n);
}
int main()
{
int numElements;
int minusElements;
float n;
cout << "Enter number of Elements:";
cin >> numElements;
minusElements = numElements - 1 ;
int num[numElements], i,j,temp;
cout << "Enter " << numElements << " numbers:\n";
for(i=0;i<numElements;i++)
cin >> num[i];
cin.get();
for(i=0;i<numElements;i++)
for(i=0;i<minusElements;i++)
{
for(j=i+1;j<numElements;j++)
{
if(num[i]<=num[j])
{
temp=num[i];
num[i]=num[j];
num[j]=temp;
}
}
}
for(i=0;i<numElements;i++)
cout << num[i];
cout <<"\n";
cout << "Mean:"<< mean(num,n);
//cout << "Median:"<<median(i);
cin.get();
}
//Line:57 cannot convert `int*' to `float*' for argument `1' to `float mean(float*, float)' | 1 |
7,275,642 | 09/01/2011 19:44:33 | 607,470 | 02/08/2011 02:18:28 | 303 | 22 | Build vs. Rebuild: aren't the names wrong? | I understand the difference, and SO has a number of postings that explain in detail. But my question is just a curiosity: aren't the names backward? I'd like to think that "build" would mean "build as if its the first time" and "Re-build" would mean "build, considering what I built before" . But, not so, it's the other way around. Is anyone with me on this or am I just marching to a different drummer?
Is this just visual studio, or is this the terminology in other environs (e.g, eclipse, NetBeans).
Call me curious.
| visual-studio | build | rebuild | null | null | 09/02/2011 00:56:55 | not constructive | Build vs. Rebuild: aren't the names wrong?
===
I understand the difference, and SO has a number of postings that explain in detail. But my question is just a curiosity: aren't the names backward? I'd like to think that "build" would mean "build as if its the first time" and "Re-build" would mean "build, considering what I built before" . But, not so, it's the other way around. Is anyone with me on this or am I just marching to a different drummer?
Is this just visual studio, or is this the terminology in other environs (e.g, eclipse, NetBeans).
Call me curious.
| 4 |
10,294,242 | 04/24/2012 08:20:57 | 1,348,094 | 04/21/2012 09:25:11 | 1 | 0 | how can i crop an object in c# with a specified color? | i need a code in c# which can extract a specified color (for example red )then clip the object which contain that color? that is mean searching for red object then cilp it | c# | image | image-processing | cropping | null | 04/25/2012 02:30:42 | not a real question | how can i crop an object in c# with a specified color?
===
i need a code in c# which can extract a specified color (for example red )then clip the object which contain that color? that is mean searching for red object then cilp it | 1 |
7,595,837 | 09/29/2011 10:17:19 | 913,573 | 08/26/2011 07:25:35 | 16 | 0 | R grep pattern regex | I just want to use a regular expression in R to grep an word like:
text=c("Hans",Hansel")
normaly I would use
grep "Hans\b" text
in R I can not use "\b" there is an error, would do you use the grep only Hans but not Hansel | regex | r | grep | null | null | 09/30/2011 00:47:51 | not a real question | R grep pattern regex
===
I just want to use a regular expression in R to grep an word like:
text=c("Hans",Hansel")
normaly I would use
grep "Hans\b" text
in R I can not use "\b" there is an error, would do you use the grep only Hans but not Hansel | 1 |
8,367,337 | 12/03/2011 11:30:11 | 964,326 | 09/26/2011 03:19:33 | 1 | 0 | how to save uitextview in a textfile to make mynotes and display the list of notes saved and open later? | i am making a mynote app which contains uitextview which pulls arabic keyboard ?
how to save my arabic data in uitextview to a file with save button .
how display my all saved files in view.
and how to open saved files? | uitextview | null | null | null | null | 12/03/2011 16:05:47 | not a real question | how to save uitextview in a textfile to make mynotes and display the list of notes saved and open later?
===
i am making a mynote app which contains uitextview which pulls arabic keyboard ?
how to save my arabic data in uitextview to a file with save button .
how display my all saved files in view.
and how to open saved files? | 1 |
7,954,783 | 10/31/2011 14:05:57 | 801,286 | 06/16/2011 10:52:51 | 11 | 0 | What is a best way to increment alphanumeric ID by certain value in C#? | What is a best way to increment alphanumeric ID by certain value in C#?
*For example:*
We've **843342D4343DA123D** and we're going to increment by 10, so we have as result: **843342D4343DA123D10**
Or we've **843342D4343DA123D10** and increments by 50, and result should be **843342D4343DA123D60**
**What is a "cheapest" and fastest way to make it work?** | c# | .net | increment | alphanumeric | null | 11/01/2011 12:18:00 | not a real question | What is a best way to increment alphanumeric ID by certain value in C#?
===
What is a best way to increment alphanumeric ID by certain value in C#?
*For example:*
We've **843342D4343DA123D** and we're going to increment by 10, so we have as result: **843342D4343DA123D10**
Or we've **843342D4343DA123D10** and increments by 50, and result should be **843342D4343DA123D60**
**What is a "cheapest" and fastest way to make it work?** | 1 |
2,588,277 | 04/06/2010 20:59:24 | 290,128 | 03/10/2010 01:20:36 | 95 | 5 | How can I swap or replace multiple strings in code at the same time? | Given the following code sample:
uint8_t i, in, ni;
i = in = 2; ni = 1;
while (2 == i > ni) in++;
How can I replace `i, in, and ni`, respectively with either `in, ni, and i` or `inni, inin, and nini` using emacs, vi, *nix commands, or anything else? | vi | emacs | c | refactoring | bash | null | open | How can I swap or replace multiple strings in code at the same time?
===
Given the following code sample:
uint8_t i, in, ni;
i = in = 2; ni = 1;
while (2 == i > ni) in++;
How can I replace `i, in, and ni`, respectively with either `in, ni, and i` or `inni, inin, and nini` using emacs, vi, *nix commands, or anything else? | 0 |
4,047,835 | 10/28/2010 23:06:20 | 479,771 | 10/18/2010 20:32:20 | 6 | 0 | Vote PHP not working | I have a problem with a vote thing in php
the code of my page is:
<?
$vote = addslashes($_POST['vote']);
if(isset($poll_num) && ctype_digit($poll_num)) {
setcookie("javotou", $poll_num);
}
include("include/session.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<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>
<head>
<?php include("includes/head.php"); ?>
</head>
<body>
<?php include("includes/login-top.php"); ?>
<?php include("includes/header-menu.php"); ?>
<div id="main-barra">
<div id="main-barra-top"><p>Votar</p></div>
<div id="main-barra-texto">
<?php
//$database->query("INSERT poll_questions (poll_num, question, active) VALUES ('1', 'Questao teste', '1')");
//$database->query("INSERT poll_answers (poll_num, choice, activity, votes) VALUES ('1', '1', 'Resposta teste', '0')");
//$database->query("INSERT poll_answers (poll_num, choice, activity, votes) VALUES ('1', '2', 'Resposta teste 2', '0')");
$vote = addslashes($_POST['vote']);
if($session->logged_in){
$q = "SELECT poll_num FROM poll_questions WHERE active = '1'";
if (mysql_num_rows($database->query($q)) == 0) {
echo "Votacao inactiva.";
} else {
if($_COOKIE['javotou'] == 1) {
echo "So podes votar uma vez.";
} else {
if(isset($vote) && ctype_digit($vote)) {
$query = "UPDATE poll_answers SET votes=votes+1 WHERE choice=".$vote."";
if($database->query($query))
{ echo "Voto inserido com sucesso";}
else{ echo "Falhou";}
}
}
}
} else {
echo "Tens que fazer login para poderes votar.";
}
if($session->logged_in && isset($vote) && ctype_digit($vote) || $_GET['resultado'] == 1){
$num_votes_query = 'SELECT SUM(votes) AS sumvotes FROM poll_answers';
$num_votes_query .= ' WHERE poll_num=1';
if ($result = $database->query($num_votes_query)) {
$row = mysql_fetch_array($result);
$sum = $row['sumvotes'];
}
$totals_query = 'SELECT activity, votes FROM poll_answers ';
if ($result = $database->query($totals_query)) {
print "<table>\n";
echo "<tr><th>Resposta</th><th>Votos</th></tr>\n";
while($row = mysql_fetch_array($result)) {
print "<tr><td>" . $row['activity'] . "</td>\n";
print "<td align=\"right\">" . $row['votes'] . "</td></tr>\n";
if($sum) {
$percent = round($row['votes'] * 100 / $sum);
print "<tr><td><img src=\"bargraph.php?pct=$percent\"></td>\n";
print "<td align=\"right\">" . $percent . "%</td></tr>\n";
}
}
print "</table>\n";
}
} else {
echo "<form action=\"\" name=\"votacao\" method=\"post\">";
$form_query = 'SELECT * FROM poll_answers WHERE poll_num = 1';
$pergunta_query = 'SELECT question FROM poll_questions WHERE poll_num = 1';
$result = $database->query($pergunta_query);
$row = mysql_fetch_array($result);
$question = $row['question'];
echo $question;
echo "<br><br>";
if($result = $database->query($form_query)) {
while($row = mysql_fetch_array($result)) {
$choice = $row['choice'];
$activity = $row['activity'];
echo "<input type=\"radio\" name=\"vote\" value=\"$choice\">\"$activity\"<br />\n";
}
}
echo "<input type=\"submit\" value=\"Votar\"/>\n";
echo "</form>";
echo "<p><a href=\"votar.php?resultado=1\">Ver resultado</a></p>";
}
?>
<!-- ZONA ADMIN -->
<?php
if ($session->isadmin()== 'admin') {
if(isset($_POST['nrespostas'])){
if($_POST['respostas'] != "r"){
$respostas = $_POST['respostas'];
echo "<meta http-equiv=\"refresh\" content=\"0;url=http://www.proportuguesegaming.com/votar.php?admin=1&respostas=$respostas\">";
}
else
{ echo "<br />Tens de indicar o numero de respostas<br />";}
}
echo "<form action=\"\" name=\"votacao\" method=\"post\">
<table>
<tr><td>
<select name=\"respostas\">
<option value=\"r\">Nº de Respostas</option>
<option value=\"2\">2</option>
<option value=\"3\">3</option>
<option value=\"4\">4</option>
<option value=\"5\">5</option></select>
</td><td><b><input type=\"submit\" name=\"nrespostas\" value=\"[Criar votacao]\" /></b></td></tr></table>
</form>
";
if ($_GET['admin'] == '1' && $_GET['respostas']) {
$resps = $_GET['respostas'];
if(isset($_POST['enviar'])){
$active = '1';
$data = time();
$autor = $_SESSION['username'];
$question = $_POST['question'];
if(strlen($question) == 0){
echo "<br /><br />Pergunta não inserida<br /><br />";
}
else{
$contagem = '0';
while ($contagem <= $resps) {
$contagem++;
$contador = 3;
$question = $_POST['question'];
$choice = $contagem;
$teste = "choice".$contador."";
$activity = $_POST[''.$teste.''];
echo $question;
echo $activity;
$votes = '0';
echo "activity $activity";
$q2 = "INSERT INTO poll_answers (choice, activity, votes) VALUES ('$choice', '$activity', '$votes')";
if($database->query($q2)){echo "sucssso answews";}else{echo "falha answrrs";}
$contador++;
}
$q = "INSERT INTO poll_questions (question, active) VALUES ('$activity', '$active')";
if($database->query($q))
{ echo "sucesso questoes";}
else{ echo"falha questoes";}
echo "inserido";
}
}
?>
<form action="" name="votacao2" method="post">
<table>
<tr><td><strong>Pergunta</strong></td><td><textarea name="question" cols="50" rows="1" onKeyDown="limitText(this.form.question,this.form.countdown2,50);"
onKeyUp="limitText(this.form.question,this.form.countdown2,50);"></textarea>
<br />Tens <input readonly type="text" name="countdown2" size="3" value="50"> caracteres</td></tr>
<?php
$contador = '2';
$respos = $resps + 2;
while ($contador < $respos) {
$contador++;
echo "<tr><td><strong>Resposta</strong></td><td><textarea name=\"choice$contador\" cols=\"50\" rows=\"1\" onKeyDown=\"limitText(this.form.qchoice$contador,this.form.countdown$contador,50);\"
onKeyUp=\"limitText(this.form.choice$contador,this.form.countdown$contador,50);\"></textarea>
<br />Tens <input readonly type=\"text\" name=\"countdown$contador\" size=\"3\" value=\"50\"> caracteres
</td></tr>
";
}
?>
<tr><td><input type="submit" name="enviar" value="Enviar" /></td></tr>
</table>
</form>
<?php
}
} else if ($_GET['admin'] == '1' && !($session->isadmin() == 'admin')) {
echo "Boa tentativa! <a href=\"votar.php\">Voltar</a>";
} else {
}
?>
</div>
</div>
<?php include("includes/sidebar.php"); ?>
<?php include("includes/footer.php"); ?>
</body>
</html>
I think the only thing not working is this:
$teste = "choice".$contador."";
$activity = $_POST[''.$teste.''];
And I don«t know how to do it, so once again I ask your help.
And also if the whole code is correct, if it may be simplified or be better, but the main question is that $activity variable.
Thanks in advance :) | php | null | null | null | null | 10/30/2010 06:35:55 | too localized | Vote PHP not working
===
I have a problem with a vote thing in php
the code of my page is:
<?
$vote = addslashes($_POST['vote']);
if(isset($poll_num) && ctype_digit($poll_num)) {
setcookie("javotou", $poll_num);
}
include("include/session.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<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>
<head>
<?php include("includes/head.php"); ?>
</head>
<body>
<?php include("includes/login-top.php"); ?>
<?php include("includes/header-menu.php"); ?>
<div id="main-barra">
<div id="main-barra-top"><p>Votar</p></div>
<div id="main-barra-texto">
<?php
//$database->query("INSERT poll_questions (poll_num, question, active) VALUES ('1', 'Questao teste', '1')");
//$database->query("INSERT poll_answers (poll_num, choice, activity, votes) VALUES ('1', '1', 'Resposta teste', '0')");
//$database->query("INSERT poll_answers (poll_num, choice, activity, votes) VALUES ('1', '2', 'Resposta teste 2', '0')");
$vote = addslashes($_POST['vote']);
if($session->logged_in){
$q = "SELECT poll_num FROM poll_questions WHERE active = '1'";
if (mysql_num_rows($database->query($q)) == 0) {
echo "Votacao inactiva.";
} else {
if($_COOKIE['javotou'] == 1) {
echo "So podes votar uma vez.";
} else {
if(isset($vote) && ctype_digit($vote)) {
$query = "UPDATE poll_answers SET votes=votes+1 WHERE choice=".$vote."";
if($database->query($query))
{ echo "Voto inserido com sucesso";}
else{ echo "Falhou";}
}
}
}
} else {
echo "Tens que fazer login para poderes votar.";
}
if($session->logged_in && isset($vote) && ctype_digit($vote) || $_GET['resultado'] == 1){
$num_votes_query = 'SELECT SUM(votes) AS sumvotes FROM poll_answers';
$num_votes_query .= ' WHERE poll_num=1';
if ($result = $database->query($num_votes_query)) {
$row = mysql_fetch_array($result);
$sum = $row['sumvotes'];
}
$totals_query = 'SELECT activity, votes FROM poll_answers ';
if ($result = $database->query($totals_query)) {
print "<table>\n";
echo "<tr><th>Resposta</th><th>Votos</th></tr>\n";
while($row = mysql_fetch_array($result)) {
print "<tr><td>" . $row['activity'] . "</td>\n";
print "<td align=\"right\">" . $row['votes'] . "</td></tr>\n";
if($sum) {
$percent = round($row['votes'] * 100 / $sum);
print "<tr><td><img src=\"bargraph.php?pct=$percent\"></td>\n";
print "<td align=\"right\">" . $percent . "%</td></tr>\n";
}
}
print "</table>\n";
}
} else {
echo "<form action=\"\" name=\"votacao\" method=\"post\">";
$form_query = 'SELECT * FROM poll_answers WHERE poll_num = 1';
$pergunta_query = 'SELECT question FROM poll_questions WHERE poll_num = 1';
$result = $database->query($pergunta_query);
$row = mysql_fetch_array($result);
$question = $row['question'];
echo $question;
echo "<br><br>";
if($result = $database->query($form_query)) {
while($row = mysql_fetch_array($result)) {
$choice = $row['choice'];
$activity = $row['activity'];
echo "<input type=\"radio\" name=\"vote\" value=\"$choice\">\"$activity\"<br />\n";
}
}
echo "<input type=\"submit\" value=\"Votar\"/>\n";
echo "</form>";
echo "<p><a href=\"votar.php?resultado=1\">Ver resultado</a></p>";
}
?>
<!-- ZONA ADMIN -->
<?php
if ($session->isadmin()== 'admin') {
if(isset($_POST['nrespostas'])){
if($_POST['respostas'] != "r"){
$respostas = $_POST['respostas'];
echo "<meta http-equiv=\"refresh\" content=\"0;url=http://www.proportuguesegaming.com/votar.php?admin=1&respostas=$respostas\">";
}
else
{ echo "<br />Tens de indicar o numero de respostas<br />";}
}
echo "<form action=\"\" name=\"votacao\" method=\"post\">
<table>
<tr><td>
<select name=\"respostas\">
<option value=\"r\">Nº de Respostas</option>
<option value=\"2\">2</option>
<option value=\"3\">3</option>
<option value=\"4\">4</option>
<option value=\"5\">5</option></select>
</td><td><b><input type=\"submit\" name=\"nrespostas\" value=\"[Criar votacao]\" /></b></td></tr></table>
</form>
";
if ($_GET['admin'] == '1' && $_GET['respostas']) {
$resps = $_GET['respostas'];
if(isset($_POST['enviar'])){
$active = '1';
$data = time();
$autor = $_SESSION['username'];
$question = $_POST['question'];
if(strlen($question) == 0){
echo "<br /><br />Pergunta não inserida<br /><br />";
}
else{
$contagem = '0';
while ($contagem <= $resps) {
$contagem++;
$contador = 3;
$question = $_POST['question'];
$choice = $contagem;
$teste = "choice".$contador."";
$activity = $_POST[''.$teste.''];
echo $question;
echo $activity;
$votes = '0';
echo "activity $activity";
$q2 = "INSERT INTO poll_answers (choice, activity, votes) VALUES ('$choice', '$activity', '$votes')";
if($database->query($q2)){echo "sucssso answews";}else{echo "falha answrrs";}
$contador++;
}
$q = "INSERT INTO poll_questions (question, active) VALUES ('$activity', '$active')";
if($database->query($q))
{ echo "sucesso questoes";}
else{ echo"falha questoes";}
echo "inserido";
}
}
?>
<form action="" name="votacao2" method="post">
<table>
<tr><td><strong>Pergunta</strong></td><td><textarea name="question" cols="50" rows="1" onKeyDown="limitText(this.form.question,this.form.countdown2,50);"
onKeyUp="limitText(this.form.question,this.form.countdown2,50);"></textarea>
<br />Tens <input readonly type="text" name="countdown2" size="3" value="50"> caracteres</td></tr>
<?php
$contador = '2';
$respos = $resps + 2;
while ($contador < $respos) {
$contador++;
echo "<tr><td><strong>Resposta</strong></td><td><textarea name=\"choice$contador\" cols=\"50\" rows=\"1\" onKeyDown=\"limitText(this.form.qchoice$contador,this.form.countdown$contador,50);\"
onKeyUp=\"limitText(this.form.choice$contador,this.form.countdown$contador,50);\"></textarea>
<br />Tens <input readonly type=\"text\" name=\"countdown$contador\" size=\"3\" value=\"50\"> caracteres
</td></tr>
";
}
?>
<tr><td><input type="submit" name="enviar" value="Enviar" /></td></tr>
</table>
</form>
<?php
}
} else if ($_GET['admin'] == '1' && !($session->isadmin() == 'admin')) {
echo "Boa tentativa! <a href=\"votar.php\">Voltar</a>";
} else {
}
?>
</div>
</div>
<?php include("includes/sidebar.php"); ?>
<?php include("includes/footer.php"); ?>
</body>
</html>
I think the only thing not working is this:
$teste = "choice".$contador."";
$activity = $_POST[''.$teste.''];
And I don«t know how to do it, so once again I ask your help.
And also if the whole code is correct, if it may be simplified or be better, but the main question is that $activity variable.
Thanks in advance :) | 3 |
6,770,533 | 07/21/2011 01:55:38 | 636,195 | 02/27/2011 05:45:01 | 19 | 0 | Java web developer interview questions | I am a Java web developer who has 2 years of experience (a year in C# and the other in Java). And currently I am doing my masters (I will be out for job search after a couple of months). However, since I have only two years of experience, I was planning to apply for junior positions (either as java developer or a java web developer) . But, after I saw [this][1] question, I was amazed that the questions are very easy (of course I will be able to explain each of them very well) and every developer should have to understand them. Do you think only such kind of questions appear for a 2 year junior developer?
Since I am studying with senior developers and few project managers (most of them has 3-7 years of experience), I saw myself that I can do almost an equal job like them, except with some exceptional students. I am not exaggerating things, but expressing what I have seen so far.
Does anyone have a good interview question that might be asked to a java web developer who has experience like me? If it is not going to be hard, I have a plan to apply for mid level jobs. By the way while you guys give me your suggestion I am also googling, not sitting down and wait for your answers.
Thanks
[1]: http://stackoverflow.com/questions/72183/any-good-interview-questions-to-ask-prospective-junior-java-developers | java | spring | jsf | java-ee | interview-questions | 07/21/2011 02:04:02 | off topic | Java web developer interview questions
===
I am a Java web developer who has 2 years of experience (a year in C# and the other in Java). And currently I am doing my masters (I will be out for job search after a couple of months). However, since I have only two years of experience, I was planning to apply for junior positions (either as java developer or a java web developer) . But, after I saw [this][1] question, I was amazed that the questions are very easy (of course I will be able to explain each of them very well) and every developer should have to understand them. Do you think only such kind of questions appear for a 2 year junior developer?
Since I am studying with senior developers and few project managers (most of them has 3-7 years of experience), I saw myself that I can do almost an equal job like them, except with some exceptional students. I am not exaggerating things, but expressing what I have seen so far.
Does anyone have a good interview question that might be asked to a java web developer who has experience like me? If it is not going to be hard, I have a plan to apply for mid level jobs. By the way while you guys give me your suggestion I am also googling, not sitting down and wait for your answers.
Thanks
[1]: http://stackoverflow.com/questions/72183/any-good-interview-questions-to-ask-prospective-junior-java-developers | 2 |
10,767,142 | 05/26/2012 14:37:58 | 1,418,956 | 05/26/2012 11:36:51 | 1 | 0 | Running a PHP script gives 500 internal server error | Recently I installed cPanel on my vps with centOS.Now my PHP files are returning a 500 Internal Server error. HTML files work fine however.
Always when i try to enter php file it says 500 Internal server error...
How can i fix it ? | cpanel | null | null | null | null | 05/27/2012 02:42:13 | off topic | Running a PHP script gives 500 internal server error
===
Recently I installed cPanel on my vps with centOS.Now my PHP files are returning a 500 Internal Server error. HTML files work fine however.
Always when i try to enter php file it says 500 Internal server error...
How can i fix it ? | 2 |
9,317,674 | 02/16/2012 19:21:05 | 727,184 | 04/27/2011 11:58:33 | 170 | 1 | Interactive courses of Ruby and Rails | I had seen a interesting course of Ruby on the Code School.
But I would like to know if there's another ones?
If you know someone, please let me know. | ruby-on-rails | ruby | null | null | null | 02/16/2012 19:44:52 | not constructive | Interactive courses of Ruby and Rails
===
I had seen a interesting course of Ruby on the Code School.
But I would like to know if there's another ones?
If you know someone, please let me know. | 4 |
8,055,106 | 11/08/2011 18:10:21 | 744,044 | 05/08/2011 16:48:45 | 1 | 0 | Write a namespaced function for jQuery that operates on parameters and not selectors | I've been tying to start a library of functions in jQuery to use transversally in my code
I thought that a good way of doing this would be to build a jQuery namespace and add my
methods under that (and provide the namespace for all who would like to contribute).
This is what I came up with:
(function( $ )
{
$.extend
({
mynamespace:
{
myfunction: function(a, b)
{
if (!Math.prototype.newmethod)
{
Math.prototype.newmethod = function(c, d)
{
// newmethod code
}
}
// myfunction code (uses Math.newmethod)
}
}
})
})(jQuery);
Now this worked fine in the small test file where I originally called it (the code did what I wanted it to) but after execution I got the following error:
DOM Exception:
**INVALID_CHARACTER_ERR (5)**
I ignored it, not being sure where it was coming from nor how to fix it (the few references I found on the web associated the problem with IE9 which I was not using) but when I used my new code site-wide everything started breaking with error messages such as
**Uncaught TypeError: undefined is not a function**
and
**Uncaught TypeError: Object function (c, d) { // newmethod code }**
Any ideas as to what I'm doing wrong are welcome
| javascript | jquery | jquery-plugins | prototype | null | null | open | Write a namespaced function for jQuery that operates on parameters and not selectors
===
I've been tying to start a library of functions in jQuery to use transversally in my code
I thought that a good way of doing this would be to build a jQuery namespace and add my
methods under that (and provide the namespace for all who would like to contribute).
This is what I came up with:
(function( $ )
{
$.extend
({
mynamespace:
{
myfunction: function(a, b)
{
if (!Math.prototype.newmethod)
{
Math.prototype.newmethod = function(c, d)
{
// newmethod code
}
}
// myfunction code (uses Math.newmethod)
}
}
})
})(jQuery);
Now this worked fine in the small test file where I originally called it (the code did what I wanted it to) but after execution I got the following error:
DOM Exception:
**INVALID_CHARACTER_ERR (5)**
I ignored it, not being sure where it was coming from nor how to fix it (the few references I found on the web associated the problem with IE9 which I was not using) but when I used my new code site-wide everything started breaking with error messages such as
**Uncaught TypeError: undefined is not a function**
and
**Uncaught TypeError: Object function (c, d) { // newmethod code }**
Any ideas as to what I'm doing wrong are welcome
| 0 |
6,549,127 | 07/01/2011 14:14:00 | 455,096 | 09/22/2010 13:42:10 | 51 | 2 | Getting XML with Grails REST plugin | I'm having trouble working with the REST plugin in grails. Specifically I am trying to convert xml from a get request into a Map in a controller.
The data source I am trying to get data from returns XML that looks like this (this is shortened for simplicity):
<process id="345">
<correctedBy>Joanne W.</correctedBy>
<editBy>Joanne W.</editBy>
<editDate>2009-12-23 00:00:00.0 EST</editDate>
<produceBy>Stephen</produceBy>
<produceDate>2010-01-14 00:00:00.0 EST</produceDate>
</process>
In my controller I have code to make the get request to this service
def getRest = {
def wfRequest
withHttp(uri: "http://myurl:8080") {
wfRequest = get(path : '/application/controller/' + params.id,
requestContentType: XML) { resp, xml ->
render xml
}
}
}
Ok so far, this will return the data from the xml, but all the tags are gone:
Joanne W.Joanne W.2009-12-23 00:00:00.0 ESTStephen2010-01-14 00:00:00.0 EST
Can anyone point me in the right direction on how to access the XML that is returned from this request? I'd like to step through each kay value pair in the "process" node of the xml and populate a map that would look like
[correctedBy: Joanne W., editBy: Joanne W., editDate: 2009-12-23 00:00:00.0 EST, produceBy: Stephen, produceDate: 2010-01-14 00:00:00.0 EST]
I'm finding the rest plugin documentation a little confusing, any help would be **GREATLY** appreciated.
Thanks!
Donald | xml | rest | grails | null | null | null | open | Getting XML with Grails REST plugin
===
I'm having trouble working with the REST plugin in grails. Specifically I am trying to convert xml from a get request into a Map in a controller.
The data source I am trying to get data from returns XML that looks like this (this is shortened for simplicity):
<process id="345">
<correctedBy>Joanne W.</correctedBy>
<editBy>Joanne W.</editBy>
<editDate>2009-12-23 00:00:00.0 EST</editDate>
<produceBy>Stephen</produceBy>
<produceDate>2010-01-14 00:00:00.0 EST</produceDate>
</process>
In my controller I have code to make the get request to this service
def getRest = {
def wfRequest
withHttp(uri: "http://myurl:8080") {
wfRequest = get(path : '/application/controller/' + params.id,
requestContentType: XML) { resp, xml ->
render xml
}
}
}
Ok so far, this will return the data from the xml, but all the tags are gone:
Joanne W.Joanne W.2009-12-23 00:00:00.0 ESTStephen2010-01-14 00:00:00.0 EST
Can anyone point me in the right direction on how to access the XML that is returned from this request? I'd like to step through each kay value pair in the "process" node of the xml and populate a map that would look like
[correctedBy: Joanne W., editBy: Joanne W., editDate: 2009-12-23 00:00:00.0 EST, produceBy: Stephen, produceDate: 2010-01-14 00:00:00.0 EST]
I'm finding the rest plugin documentation a little confusing, any help would be **GREATLY** appreciated.
Thanks!
Donald | 0 |
11,007,328 | 06/13/2012 02:07:33 | 1,282,473 | 03/21/2012 04:08:24 | 13 | 0 | Print from a LAN (wired) desktop PC to a wireless printer | I recently purchased a new router, a Linksys E2500 a/b/g/n. I've got a couple devices hooked up to it, mostly laptops and a new brand new Canon PIXMA MP495 wireless printer/scanner. The printer will work from laptops/tablets. Most of my work I do from a desktop PC wired to the router via ethernet. The desktop runs Ubuntu 12.04 (I have root access of course). Both the Ubuntu PC and the printer have static IP addresses set on the subnet.
I'm trying to find a way that I could print from the wired Ubuntu machine to the wireless printer. Is there some sort of print server software build into the router I have to use? I tried to set it up but I'm not familiar at all with printer protocols. I do not want to hard-wire the printer via ethernet to anything if possible, as it needs to be in a different room. If worst comes to worst, I have a crappy old Belkin router I was going to recycle that I could hard-wire to the printer via ethernet and keep it on its own subnet if needed. But that is not preferred.
Has anybody seen any network rigged up like this before? | ubuntu | printing | wifi | wireless | lan | 06/18/2012 01:54:53 | off topic | Print from a LAN (wired) desktop PC to a wireless printer
===
I recently purchased a new router, a Linksys E2500 a/b/g/n. I've got a couple devices hooked up to it, mostly laptops and a new brand new Canon PIXMA MP495 wireless printer/scanner. The printer will work from laptops/tablets. Most of my work I do from a desktop PC wired to the router via ethernet. The desktop runs Ubuntu 12.04 (I have root access of course). Both the Ubuntu PC and the printer have static IP addresses set on the subnet.
I'm trying to find a way that I could print from the wired Ubuntu machine to the wireless printer. Is there some sort of print server software build into the router I have to use? I tried to set it up but I'm not familiar at all with printer protocols. I do not want to hard-wire the printer via ethernet to anything if possible, as it needs to be in a different room. If worst comes to worst, I have a crappy old Belkin router I was going to recycle that I could hard-wire to the printer via ethernet and keep it on its own subnet if needed. But that is not preferred.
Has anybody seen any network rigged up like this before? | 2 |
8,600,847 | 12/22/2011 07:52:39 | 1,111,227 | 12/22/2011 07:21:25 | 1 | 0 | Design custom field database with high degree of variety | I'm designing a SaaS healthcare application to manage activities in multiple organizations. The admin of each organization is allowed to create custom fields for business concepts.
Example: Patient of org X has attribute A and B while Patient of org Y has attribute M and N
After doing research, I find that there're a few considerable design approaches:
**Option 1**: have a BusinessObjectCustomField for each business table. Example for PatientCustomField
OrgID, CustomFieldID, Value
X, A, 1
X, B, 2
Y, M, 3
Y, N, 4
**Option 2**: use a single table for each business object, but alter table when new custom field is added. As a result, num(column) ~ num(org) * num(average fields per org)
PatientID A B M N
1 1 2 NULL NULL
2 NULL NULL 3 4
**Option 3**: use generic purpose columns to hold data. As a result, num(column) ~ max(fields per org)
PatientID Col1 Col2
1 1 2
2 3 4
**Option 4**: store custom data as XML
PatientID CustomField
1 <custom><A>1</A><B>2</B></custom>
2 <custom><M>3</M><N>4</N></custom>
My design priorities are:
1. Good performance
2. Easy to code
3. Space (since data will be a lot)
Which option should I choose? I know that MS SQL Server supports index for XML data, but does it provide equally good performance as relational indexing?
References:
- http://stackoverflow.com/questions/1126783/what-are-design-patterns-to-support-custom-fields-in-an-application
- http://stackoverflow.com/questions/2924027/db-design-to-store-custom-fields-for-a-table
- http://stackoverflow.com/questions/1600811/implementing-and-indexing-user-defined-fields-in-an-sql-db | sql-server | xml | database | custom-attributes | null | null | open | Design custom field database with high degree of variety
===
I'm designing a SaaS healthcare application to manage activities in multiple organizations. The admin of each organization is allowed to create custom fields for business concepts.
Example: Patient of org X has attribute A and B while Patient of org Y has attribute M and N
After doing research, I find that there're a few considerable design approaches:
**Option 1**: have a BusinessObjectCustomField for each business table. Example for PatientCustomField
OrgID, CustomFieldID, Value
X, A, 1
X, B, 2
Y, M, 3
Y, N, 4
**Option 2**: use a single table for each business object, but alter table when new custom field is added. As a result, num(column) ~ num(org) * num(average fields per org)
PatientID A B M N
1 1 2 NULL NULL
2 NULL NULL 3 4
**Option 3**: use generic purpose columns to hold data. As a result, num(column) ~ max(fields per org)
PatientID Col1 Col2
1 1 2
2 3 4
**Option 4**: store custom data as XML
PatientID CustomField
1 <custom><A>1</A><B>2</B></custom>
2 <custom><M>3</M><N>4</N></custom>
My design priorities are:
1. Good performance
2. Easy to code
3. Space (since data will be a lot)
Which option should I choose? I know that MS SQL Server supports index for XML data, but does it provide equally good performance as relational indexing?
References:
- http://stackoverflow.com/questions/1126783/what-are-design-patterns-to-support-custom-fields-in-an-application
- http://stackoverflow.com/questions/2924027/db-design-to-store-custom-fields-for-a-table
- http://stackoverflow.com/questions/1600811/implementing-and-indexing-user-defined-fields-in-an-sql-db | 0 |
2,438,467 | 03/13/2010 13:17:20 | 50,394 | 12/31/2008 04:52:41 | 6,997 | 329 | What's a good PHP Active Record library? | I've been using CodeIgniter for some quite time, and I've been extremely happy with its Active Record stuff. It's great to query the database with it.
Recently I've started a new project and I can't use such a framework anymore.
Is there a simple PHP Active Record library that does its job and gets out of the way (similar to CodeIgniter's version)? | php | activerecord | codeigniter | null | null | 09/04/2011 22:07:31 | not constructive | What's a good PHP Active Record library?
===
I've been using CodeIgniter for some quite time, and I've been extremely happy with its Active Record stuff. It's great to query the database with it.
Recently I've started a new project and I can't use such a framework anymore.
Is there a simple PHP Active Record library that does its job and gets out of the way (similar to CodeIgniter's version)? | 4 |
11,420,950 | 07/10/2012 19:58:00 | 1,010,943 | 10/24/2011 13:31:08 | 190 | 2 | Kargers random contraction algo Implementation | Below is my implementation of karger random contraction algorithm. The below code outputs the minimum cut correctly (i know it because i have submitted it the assignment and achived full grades :) ).But sometimes it throws Index of outbound exceptions. The number of vertices on which i apllying this implementation is 200 and the error always comes while manipulating the last few indices (i.e the last ten or soo). Below is the code and after that the error. If you want to see my input text file with the vertices please tell and i would attach that too.. Thanks
import java.io.File;
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
public class RandomContraction {
static Integer randomV1 = 0;
static Integer randomV1Index = 0;
static Integer randomV1Size = 0;
static Integer randomV2IndV1 = 0;
static Integer randomV2 = 0;
static Integer randomV2Index =0;
static Integer randomV2Size = 0;
static int totalSize = 0;
static int totalInd = 0;
static ArrayList<ArrayList <Integer>> aList = new ArrayList<ArrayList<Integer>>();
static ArrayList<Integer> tmpList ;
public static void randomGen() {
Random randomNum = new Random ();
totalSize = aList.size();
totalInd = totalSize -1 ;
randomV1Index = randomNum.nextInt(totalInd);
randomV1 = randomV1Index + 1;
randomV1Size = aList.get(randomV1Index).size() - 1;
randomV2IndV1 = randomNum.nextInt(randomV1Size.intValue());
randomV2 = aList.get(randomV1Index).get(randomV2IndV1);
randomV2Index = randomV2 -1;
}
public static void includeV2InV1() {
// Checking function to check if the variables are filled in the tempV2 properly
for (Integer item: tmpList) {
if (item != randomV1){
aList.get(randomV1Index).add(item);
}
}
}
public static void removeV2InV1() {
int index = 0;
// remove v2 which is in v1
if (aList.get(randomV1Index).contains(randomV2)) {
index = aList.get(randomV1Index).indexOf(randomV2);
aList.get(randomV1Index).remove(index);
}
}
public static void replaceV2WithV1() {
int tmpInd =0;
while (tmpInd <= totalInd) {
int index = 0;
if (aList.get(tmpInd).contains(randomV2))
{
index = aList.get(tmpInd).indexOf(randomV2);
aList.get(tmpInd).set(index,randomV1);
}
++tmpInd;
}
}
public static void adjustVerticeValues() {
totalInd = aList.size() -1;
int tmp = 0;
while (tmp <= totalInd) {
int tmp2 = 0;
int tmpVSize = aList.get(tmp).size();
while (tmp2 < tmpVSize) {
if (aList.get(tmp).get(tmp2) > randomV2)
aList.get(tmp).set(tmp2,aList.get(tmp).get(tmp2) - 1);
++ tmp2;
}
++tmp;
}
}
public static void main(String[] args) throws Exception {
Scanner sc =new Scanner(new File("C:/MinCut.txt"));
String line;
sc.useDelimiter("\\n");
int vertexIndex = 0;
int tmp = 0;
while (sc.hasNextLine()) {
int edge = 0;
line = sc.nextLine();
Scanner lineSc = new Scanner(line);
lineSc.useDelimiter("\\s");
vertexIndex = lineSc.nextInt() - 1;
aList.add(new ArrayList<Integer>());
tmp = 0;
while (lineSc.hasNextInt()) {
edge = lineSc.nextInt();
aList.get(vertexIndex).add(edge);
// System.out.print(aList.get(vertexIndex).get(tmp) + " ");
++tmp;
}
}
while (aList.size() > 2) {
randomGen();
System.out.println ("random v2 index in main : " + randomV2Index);
tmpList = new ArrayList <Integer>() ;
removeV2InV1();
includeV2InV1();
totalInd = aList.size()-1;
replaceV2WithV1();
aList.remove(randomV2Index.intValue());
adjustVerticeValues();
tmpList.clear();
}
// I TAKE THE MINIMUM CUT AS THE LEAST OF THESE TWO VALUES
System.out.println(aList.get(1).size());
System.out.println(aList.get(0).size());
aList.clear();
}
}
Error !
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
at java.util.ArrayList.rangeCheck(ArrayList.java:604)
at java.util.ArrayList.remove(ArrayList.java:445)
at org.lec3.RandomContraction.main(RandomContraction.java:137)
| java | homework | graph-algorithm | minimum-cut | null | 07/10/2012 21:06:05 | not a real question | Kargers random contraction algo Implementation
===
Below is my implementation of karger random contraction algorithm. The below code outputs the minimum cut correctly (i know it because i have submitted it the assignment and achived full grades :) ).But sometimes it throws Index of outbound exceptions. The number of vertices on which i apllying this implementation is 200 and the error always comes while manipulating the last few indices (i.e the last ten or soo). Below is the code and after that the error. If you want to see my input text file with the vertices please tell and i would attach that too.. Thanks
import java.io.File;
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
public class RandomContraction {
static Integer randomV1 = 0;
static Integer randomV1Index = 0;
static Integer randomV1Size = 0;
static Integer randomV2IndV1 = 0;
static Integer randomV2 = 0;
static Integer randomV2Index =0;
static Integer randomV2Size = 0;
static int totalSize = 0;
static int totalInd = 0;
static ArrayList<ArrayList <Integer>> aList = new ArrayList<ArrayList<Integer>>();
static ArrayList<Integer> tmpList ;
public static void randomGen() {
Random randomNum = new Random ();
totalSize = aList.size();
totalInd = totalSize -1 ;
randomV1Index = randomNum.nextInt(totalInd);
randomV1 = randomV1Index + 1;
randomV1Size = aList.get(randomV1Index).size() - 1;
randomV2IndV1 = randomNum.nextInt(randomV1Size.intValue());
randomV2 = aList.get(randomV1Index).get(randomV2IndV1);
randomV2Index = randomV2 -1;
}
public static void includeV2InV1() {
// Checking function to check if the variables are filled in the tempV2 properly
for (Integer item: tmpList) {
if (item != randomV1){
aList.get(randomV1Index).add(item);
}
}
}
public static void removeV2InV1() {
int index = 0;
// remove v2 which is in v1
if (aList.get(randomV1Index).contains(randomV2)) {
index = aList.get(randomV1Index).indexOf(randomV2);
aList.get(randomV1Index).remove(index);
}
}
public static void replaceV2WithV1() {
int tmpInd =0;
while (tmpInd <= totalInd) {
int index = 0;
if (aList.get(tmpInd).contains(randomV2))
{
index = aList.get(tmpInd).indexOf(randomV2);
aList.get(tmpInd).set(index,randomV1);
}
++tmpInd;
}
}
public static void adjustVerticeValues() {
totalInd = aList.size() -1;
int tmp = 0;
while (tmp <= totalInd) {
int tmp2 = 0;
int tmpVSize = aList.get(tmp).size();
while (tmp2 < tmpVSize) {
if (aList.get(tmp).get(tmp2) > randomV2)
aList.get(tmp).set(tmp2,aList.get(tmp).get(tmp2) - 1);
++ tmp2;
}
++tmp;
}
}
public static void main(String[] args) throws Exception {
Scanner sc =new Scanner(new File("C:/MinCut.txt"));
String line;
sc.useDelimiter("\\n");
int vertexIndex = 0;
int tmp = 0;
while (sc.hasNextLine()) {
int edge = 0;
line = sc.nextLine();
Scanner lineSc = new Scanner(line);
lineSc.useDelimiter("\\s");
vertexIndex = lineSc.nextInt() - 1;
aList.add(new ArrayList<Integer>());
tmp = 0;
while (lineSc.hasNextInt()) {
edge = lineSc.nextInt();
aList.get(vertexIndex).add(edge);
// System.out.print(aList.get(vertexIndex).get(tmp) + " ");
++tmp;
}
}
while (aList.size() > 2) {
randomGen();
System.out.println ("random v2 index in main : " + randomV2Index);
tmpList = new ArrayList <Integer>() ;
removeV2InV1();
includeV2InV1();
totalInd = aList.size()-1;
replaceV2WithV1();
aList.remove(randomV2Index.intValue());
adjustVerticeValues();
tmpList.clear();
}
// I TAKE THE MINIMUM CUT AS THE LEAST OF THESE TWO VALUES
System.out.println(aList.get(1).size());
System.out.println(aList.get(0).size());
aList.clear();
}
}
Error !
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
at java.util.ArrayList.rangeCheck(ArrayList.java:604)
at java.util.ArrayList.remove(ArrayList.java:445)
at org.lec3.RandomContraction.main(RandomContraction.java:137)
| 1 |
225,475 | 10/22/2008 12:04:08 | 354,645 | 10/22/2008 11:46:57 | 1 | 0 | Protecting user passwords in desktop applications | I'm making a twitter client, and I'm evaluating the various ways of protecting the user's login information.
- Hashing apparently doesn't do it
- Obfuscating in a reversable way is like trying to hide behind my finger
- Plain text sounds and propably is promiscuous
- Requiring the user to type in his password every time would make the application tiresome
Any ideas ?
| passwords | twitter | hashing | null | null | null | open | Protecting user passwords in desktop applications
===
I'm making a twitter client, and I'm evaluating the various ways of protecting the user's login information.
- Hashing apparently doesn't do it
- Obfuscating in a reversable way is like trying to hide behind my finger
- Plain text sounds and propably is promiscuous
- Requiring the user to type in his password every time would make the application tiresome
Any ideas ?
| 0 |
219,096 | 10/20/2008 16:41:08 | 23,372 | 09/29/2008 07:39:23 | 301 | 23 | How to set the Taskbar Grouping Icon | When my application opens too many windows the taskbar groups them into one button. Each window has its own icon, but the grouping icon is the default "unknown"-kind icon.
How can I set the grouping icon? | .net | winforms | taskbar | grouping | icons | null | open | How to set the Taskbar Grouping Icon
===
When my application opens too many windows the taskbar groups them into one button. Each window has its own icon, but the grouping icon is the default "unknown"-kind icon.
How can I set the grouping icon? | 0 |
4,088,774 | 11/03/2010 15:35:53 | 4,227 | 09/02/2008 13:08:22 | 2,934 | 208 | What is the story behind Microsoft not supporting Unix/Linux with Silverlight? | With its semi-crossplatform framework/runtime Silverlight, Microsoft has gone through quite some effort to support MACOS. Why did Microsoft chose to not go the extra mile to support other Unix-based operating systems like Linux too and instead prefers to give support to someone else developing an additional framework/runtime (moonlight)? Are there some legal issues maybe? | linux | silverlight | unix | cross-platform | null | 11/03/2010 15:41:40 | not constructive | What is the story behind Microsoft not supporting Unix/Linux with Silverlight?
===
With its semi-crossplatform framework/runtime Silverlight, Microsoft has gone through quite some effort to support MACOS. Why did Microsoft chose to not go the extra mile to support other Unix-based operating systems like Linux too and instead prefers to give support to someone else developing an additional framework/runtime (moonlight)? Are there some legal issues maybe? | 4 |
8,952,032 | 01/21/2012 09:44:37 | 494,766 | 11/02/2010 13:18:42 | 34 | 0 | C bytes of a char pointer in memory | I would like to count how many bytes a char pointer takes in memory.
The pointer points to a string with 100 chars.
According to the following program a char needs 4 bytes
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char b;
b = 'b';
printf("%d\n",&b);
system("pause");
return 0;
}
Is it the same for pointers ?
So it's 400 bytes saved in memory for a string of 100chars ?
Thanks in advance.
| pointers | allocation | null | null | null | 01/22/2012 01:05:44 | not a real question | C bytes of a char pointer in memory
===
I would like to count how many bytes a char pointer takes in memory.
The pointer points to a string with 100 chars.
According to the following program a char needs 4 bytes
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char b;
b = 'b';
printf("%d\n",&b);
system("pause");
return 0;
}
Is it the same for pointers ?
So it's 400 bytes saved in memory for a string of 100chars ?
Thanks in advance.
| 1 |
9,439,161 | 02/24/2012 22:50:48 | 240,655 | 12/30/2009 05:29:36 | 1,037 | 53 | Why is an IBOutletCollection pointing to static cells from storyboard returning null? | I have defined this in code:
@property (nonatomic, weak) IBOutletCollection(UITableViewCell) NSSet * certaintyCells;
and synthesized. I made absolutely sure that this controller is used in story board, and connected three cells to this collection.
Next, in the `didSelectRowAtIndexPath:` method call, I added this code, with NSLog added for debugging:
NSLog(@"Certainty Cells: %@",certaintyCells);
for (UITableViewCell * cell in certaintyCells) {
[cell.textLabel setTextColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:1]];
[cell setSelectionStyle:UITableViewCellSelectionStyleBlue];
}
The output is this:
Certainty Cells: (null)
And of course, behaviour expected does not happen.
Any ideas as to why this is happening? I did make sure that I am using static cells, and not dynamic prototypes. As a side note, these three cells are also connected to (working) IBOutlets of their own.
Thanks, | iphone | storyboard | iboutlet | null | null | null | open | Why is an IBOutletCollection pointing to static cells from storyboard returning null?
===
I have defined this in code:
@property (nonatomic, weak) IBOutletCollection(UITableViewCell) NSSet * certaintyCells;
and synthesized. I made absolutely sure that this controller is used in story board, and connected three cells to this collection.
Next, in the `didSelectRowAtIndexPath:` method call, I added this code, with NSLog added for debugging:
NSLog(@"Certainty Cells: %@",certaintyCells);
for (UITableViewCell * cell in certaintyCells) {
[cell.textLabel setTextColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:1]];
[cell setSelectionStyle:UITableViewCellSelectionStyleBlue];
}
The output is this:
Certainty Cells: (null)
And of course, behaviour expected does not happen.
Any ideas as to why this is happening? I did make sure that I am using static cells, and not dynamic prototypes. As a side note, these three cells are also connected to (working) IBOutlets of their own.
Thanks, | 0 |
4,930,775 | 02/08/2011 07:59:01 | 607,763 | 02/08/2011 07:59:01 | 1 | 0 | android devolpment using a netbook | how i can use my netbook for android devlopment, when i am running sdk with eclipse it is not loading at all my netbook configurations are os-vista starter, ram- 1gb,1.66ghz precessor | android-emulator | null | null | null | null | 02/03/2012 17:24:18 | off topic | android devolpment using a netbook
===
how i can use my netbook for android devlopment, when i am running sdk with eclipse it is not loading at all my netbook configurations are os-vista starter, ram- 1gb,1.66ghz precessor | 2 |
3,068,894 | 06/18/2010 10:39:41 | 203,316 | 11/05/2009 09:38:55 | 190 | 7 | Which are the fonts available in iphone sdk? | I want to know which all fonts are currently supported by iphone sdk. | iphone | uifont | null | null | null | null | open | Which are the fonts available in iphone sdk?
===
I want to know which all fonts are currently supported by iphone sdk. | 0 |
2,693,180 | 04/22/2010 17:52:04 | 300,414 | 03/24/2010 00:05:12 | 217 | 2 | What is unchecked cast and how do I check it? | I think I get what unchecked cast means (casting from one to another of a different type), but what does it mean to "Check" the cast? How can I check the cast so that I can avoid this warning in Eclipse?
Thanks, | eclipse | java | null | null | null | null | open | What is unchecked cast and how do I check it?
===
I think I get what unchecked cast means (casting from one to another of a different type), but what does it mean to "Check" the cast? How can I check the cast so that I can avoid this warning in Eclipse?
Thanks, | 0 |
11,134,028 | 06/21/2012 08:10:59 | 108,207 | 05/16/2009 17:51:55 | 3,014 | 195 | Deprecated method, what to use instead? | The method `show();` in class Windows for java.awt in deprecated. What can I use instead?
package adventure;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.*;
import java.applet.*;
// Infogar testkommentar mvh Holger 2012-06-20 kl 19.03
public class Adventure extends Frame {
private static final long serialVersionUID=100L;
public Adventure() {
setSize(850, 440);
World world = new DungeonWorld ( this );
Person me = new Person( world, "You", null );
show();
me.goTo("Dungeon");
add( new Player( world, me ) );
addWindowListener(new MyWindowAdapter ());
}
class MyWindowAdapter extends WindowAdapter {
public void windowClosing (WindowEvent e) {
System.exit(0);
}
}
// Load an image from the net, making sure it has already been
// loaded when the method returns
public Image loadPicture ( String imageName ) {
Image im = null;
// Load the image from the net
try {
URL imageSource = new URL( "http://www.student.nada.kth.se/~d99-nro/"
+ imageName );
try {
im = createImage( (ImageProducer) imageSource.getContent());
} catch (IOException e) {}
} catch (MalformedURLException e ) { }
// Wait to ensure that the image is loaded
MediaTracker imageTracker = new MediaTracker( this );
imageTracker.addImage( im, 0 );
try {
imageTracker.waitForID( 0 );
}
catch( InterruptedException e ) { }
return im;
}
// Load and play a sound from /usr/local/hacks/sounds/
public void playSound (String name) {
URL u = null;
try {
u = new URL("file:" + "/usr/local/hacks/sounds/" + name + ".au");
} catch (MalformedURLException e ) { }
AudioClip a = Applet.newAudioClip(u);
a.play();
}
public static void main (String[] args) {
System.out.println("test");
new Adventure();
}
}
| java | graphics | window | deprecated | null | 06/21/2012 14:17:26 | not a real question | Deprecated method, what to use instead?
===
The method `show();` in class Windows for java.awt in deprecated. What can I use instead?
package adventure;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.*;
import java.applet.*;
// Infogar testkommentar mvh Holger 2012-06-20 kl 19.03
public class Adventure extends Frame {
private static final long serialVersionUID=100L;
public Adventure() {
setSize(850, 440);
World world = new DungeonWorld ( this );
Person me = new Person( world, "You", null );
show();
me.goTo("Dungeon");
add( new Player( world, me ) );
addWindowListener(new MyWindowAdapter ());
}
class MyWindowAdapter extends WindowAdapter {
public void windowClosing (WindowEvent e) {
System.exit(0);
}
}
// Load an image from the net, making sure it has already been
// loaded when the method returns
public Image loadPicture ( String imageName ) {
Image im = null;
// Load the image from the net
try {
URL imageSource = new URL( "http://www.student.nada.kth.se/~d99-nro/"
+ imageName );
try {
im = createImage( (ImageProducer) imageSource.getContent());
} catch (IOException e) {}
} catch (MalformedURLException e ) { }
// Wait to ensure that the image is loaded
MediaTracker imageTracker = new MediaTracker( this );
imageTracker.addImage( im, 0 );
try {
imageTracker.waitForID( 0 );
}
catch( InterruptedException e ) { }
return im;
}
// Load and play a sound from /usr/local/hacks/sounds/
public void playSound (String name) {
URL u = null;
try {
u = new URL("file:" + "/usr/local/hacks/sounds/" + name + ".au");
} catch (MalformedURLException e ) { }
AudioClip a = Applet.newAudioClip(u);
a.play();
}
public static void main (String[] args) {
System.out.println("test");
new Adventure();
}
}
| 1 |
1,277,488 | 08/14/2009 11:56:30 | 67,834 | 02/18/2009 13:18:51 | 32 | 3 | Ruby on Rails FilterChain internals - how to make it reloadable? | I'd like to have a more dynamic way of working with filter chains in Ruby on Rails 2.3.2.
At the moment, the filter chain is built as the classes are loaded. I have a very particular need for the filter chain to be rebuilt at some point in time after the classes have loaded.
This is to do with a Rails project (Spree, Radiant may also be affected I'm guessing) that uses extensions which can do things like this **after** the filter chain has been built for MyController:
MyController.class_eval do
before_filter :my_filter_method
end
ApplicationController.class_eval do
before_filter :app_filter_method
end
The problem here is that the `app_filter_method` filter will **not** be added to the MyController filter chain. This is because the filter chain of MyController is built from an earlier copy of the filter chain of ApplicationController. This copy of the filter chain of ApplicationController does **not** yet have the `app_filter_method` filter applied to it.
I can think of 2 places so far that the rebuilding of the FilterChain could happen in:
1) Each time it is called on MyController.filter_chain
2) Reloadable on demand. So MyController.reload_filter_chain will rebuild the filter chain, using the filters from MyController's subclasses in the chain.
I have had a look but haven't come up with a way to do this.
Here are links to the source of filters.rb on GitHub, for Ruby on Rails 2.3.2:
[The filter_chain method (line 573)][1]
[The FilterChain class (line 10)][2]
I was hoping some of you here might have some insight or advice on how to do this.
Any help much appreciated.
Eliot
[1]: http://github.com/rails/rails/blob/73fc42cc0b5e94541480032c2941a50edd4080c2/actionpack/lib/action_controller/filters.rb#L573
[2]: http://github.com/rails/rails/blob/73fc42cc0b5e94541480032c2941a50edd4080c2/actionpack/lib/action_controller/filters.rb#L10 | ruby-on-rails | radiant | filter | null | null | null | open | Ruby on Rails FilterChain internals - how to make it reloadable?
===
I'd like to have a more dynamic way of working with filter chains in Ruby on Rails 2.3.2.
At the moment, the filter chain is built as the classes are loaded. I have a very particular need for the filter chain to be rebuilt at some point in time after the classes have loaded.
This is to do with a Rails project (Spree, Radiant may also be affected I'm guessing) that uses extensions which can do things like this **after** the filter chain has been built for MyController:
MyController.class_eval do
before_filter :my_filter_method
end
ApplicationController.class_eval do
before_filter :app_filter_method
end
The problem here is that the `app_filter_method` filter will **not** be added to the MyController filter chain. This is because the filter chain of MyController is built from an earlier copy of the filter chain of ApplicationController. This copy of the filter chain of ApplicationController does **not** yet have the `app_filter_method` filter applied to it.
I can think of 2 places so far that the rebuilding of the FilterChain could happen in:
1) Each time it is called on MyController.filter_chain
2) Reloadable on demand. So MyController.reload_filter_chain will rebuild the filter chain, using the filters from MyController's subclasses in the chain.
I have had a look but haven't come up with a way to do this.
Here are links to the source of filters.rb on GitHub, for Ruby on Rails 2.3.2:
[The filter_chain method (line 573)][1]
[The FilterChain class (line 10)][2]
I was hoping some of you here might have some insight or advice on how to do this.
Any help much appreciated.
Eliot
[1]: http://github.com/rails/rails/blob/73fc42cc0b5e94541480032c2941a50edd4080c2/actionpack/lib/action_controller/filters.rb#L573
[2]: http://github.com/rails/rails/blob/73fc42cc0b5e94541480032c2941a50edd4080c2/actionpack/lib/action_controller/filters.rb#L10 | 0 |
10,671,126 | 05/20/2012 05:50:21 | 1,380,194 | 05/07/2012 16:21:38 | 19 | 0 | My sql configuration | I have installed my sql 5.5 in my laptop but due to some technical reason it got corrupted now please advise me how do I remove the earlier my sql completely and install a fresh again..! | mysql | null | null | null | null | 05/20/2012 15:50:46 | not a real question | My sql configuration
===
I have installed my sql 5.5 in my laptop but due to some technical reason it got corrupted now please advise me how do I remove the earlier my sql completely and install a fresh again..! | 1 |
11,367,181 | 07/06/2012 17:44:04 | 559,314 | 12/31/2010 15:03:44 | 336 | 8 | Is there way to make PDF files from its XML source in ColdFusion? | I need to make some changes to XML source of a PDF file, and save the result as a PDF in ColdFusion. The first part is easy. I do not know how to convert the XML to PDF just like how LifeCycle does!
The XML source is exactly the same content that you can see in LifeCycle if you click on XML source (for dynamic pdf files of course).
Thx
btw, I know that I can read the actual PDF using CFPDFFORM and populate it with XML data, the problem is , cfpdfform truncates the <xfa:datasets> tag for some reason, so I cant use it. | xml | pdf | coldfusion | lifecycle | cfpdfform | null | open | Is there way to make PDF files from its XML source in ColdFusion?
===
I need to make some changes to XML source of a PDF file, and save the result as a PDF in ColdFusion. The first part is easy. I do not know how to convert the XML to PDF just like how LifeCycle does!
The XML source is exactly the same content that you can see in LifeCycle if you click on XML source (for dynamic pdf files of course).
Thx
btw, I know that I can read the actual PDF using CFPDFFORM and populate it with XML data, the problem is , cfpdfform truncates the <xfa:datasets> tag for some reason, so I cant use it. | 0 |
4,184,558 | 11/15/2010 12:58:41 | 220,129 | 11/27/2009 16:11:09 | 648 | 11 | django - query filter on manytomany is empty | In Django is there a way to filter on a manytomany field being empty or null.
e.g.
class TestModel(models.Model):
name = models.CharField(_('set name'), max_length=200)
manytomany = models.ManyToManyField('AnotherModel', blank=True, null=True)
print TestModel.objects.filter(manytomany__is_null= True)
| django | django-queryset | django-queries | django-filter | null | null | open | django - query filter on manytomany is empty
===
In Django is there a way to filter on a manytomany field being empty or null.
e.g.
class TestModel(models.Model):
name = models.CharField(_('set name'), max_length=200)
manytomany = models.ManyToManyField('AnotherModel', blank=True, null=True)
print TestModel.objects.filter(manytomany__is_null= True)
| 0 |
7,345,728 | 09/08/2011 09:13:57 | 934,464 | 09/08/2011 09:13:57 | 1 | 0 | How can i instance the objects to each other in Autocad, so that one moves itself with the motion of other one? | I would like to bind 2 cylinders f.e. so that when i move or rotate the one, the other one moves itself too, about the point i defined.
Is it possible?
I use the version 2008.
Thanks | autocad | null | null | null | null | 09/10/2011 11:34:08 | off topic | How can i instance the objects to each other in Autocad, so that one moves itself with the motion of other one?
===
I would like to bind 2 cylinders f.e. so that when i move or rotate the one, the other one moves itself too, about the point i defined.
Is it possible?
I use the version 2008.
Thanks | 2 |
5,484,188 | 03/30/2011 08:59:15 | 637,118 | 02/28/2011 04:05:20 | 3 | 0 | Android explorer | i developing an classified booking android application in this i need a Exploring functionality
that enable user to find the image from the sd card,i used the fallowing code..
public class AndroidExplorer extends ListActivity {
private List<String> item = null;
private List<String> path = null;
private String root="/";
private TextView myPath;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myPath = (TextView)findViewById(R.id.path);
try
{
getDir(root);
} catch (IOException e)
{
e.printStackTrace();
}
}
private void getDir(String dirPath) throws IOException
{
myPath.setText("Location: " + dirPath);
item = new ArrayList<String>();
path = new ArrayList<String>();
File f = new File(dirPath);
File[] files = f.listFiles();
if(!dirPath.equals(root))
{
item.add(root);
path.add(root);
item.add("../");
path.add(f.getParent());
}
for(int i=0; i < files.length; i++)
{
File file = files[i];
String FileExt = file.getName();
path.add(file.getPath());
if(file.isDirectory())
item.add(file.getName()+ "/");
// else if(FileExt.endsWith(".jpg"))
// item.add(FileExt);
}
ArrayAdapter<String> fileList =
new ArrayAdapter<String>(this, R.layout.row, item);
setListAdapter(fileList);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
File file = new File(path.get(position));
if (file.isDirectory())
{
if(file.canRead())
try {
getDir(path.get(position));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
else
{
new AlertDialog.Builder(this)
.setIcon(R.drawable.icon)
.setTitle("[" + file.getName() + "] folder can't be read!")
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
//@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
}).show();
}
}
else
{
new AlertDialog.Builder(this)
.setIcon(R.drawable.icon)
.setTitle("[" + file.getPath() + "]")
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
// @Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
}).show();
}
}
}
| android | null | null | null | null | 03/31/2011 04:28:18 | not a real question | Android explorer
===
i developing an classified booking android application in this i need a Exploring functionality
that enable user to find the image from the sd card,i used the fallowing code..
public class AndroidExplorer extends ListActivity {
private List<String> item = null;
private List<String> path = null;
private String root="/";
private TextView myPath;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myPath = (TextView)findViewById(R.id.path);
try
{
getDir(root);
} catch (IOException e)
{
e.printStackTrace();
}
}
private void getDir(String dirPath) throws IOException
{
myPath.setText("Location: " + dirPath);
item = new ArrayList<String>();
path = new ArrayList<String>();
File f = new File(dirPath);
File[] files = f.listFiles();
if(!dirPath.equals(root))
{
item.add(root);
path.add(root);
item.add("../");
path.add(f.getParent());
}
for(int i=0; i < files.length; i++)
{
File file = files[i];
String FileExt = file.getName();
path.add(file.getPath());
if(file.isDirectory())
item.add(file.getName()+ "/");
// else if(FileExt.endsWith(".jpg"))
// item.add(FileExt);
}
ArrayAdapter<String> fileList =
new ArrayAdapter<String>(this, R.layout.row, item);
setListAdapter(fileList);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
File file = new File(path.get(position));
if (file.isDirectory())
{
if(file.canRead())
try {
getDir(path.get(position));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
else
{
new AlertDialog.Builder(this)
.setIcon(R.drawable.icon)
.setTitle("[" + file.getName() + "] folder can't be read!")
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
//@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
}).show();
}
}
else
{
new AlertDialog.Builder(this)
.setIcon(R.drawable.icon)
.setTitle("[" + file.getPath() + "]")
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
// @Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
}).show();
}
}
}
| 1 |
8,693,450 | 01/01/2012 14:06:17 | 584,081 | 01/21/2011 06:59:32 | 203 | 0 | Read bytes from an Exe | void CCCryptoKeyDlg::OnBnClickedButton3()
{
ifstream::pos_type size;
char * buffer;
ifstream file(this->filepath,ios::ate);
if(file.is_open()){
size = file.tellg();
buffer = new char [size];
file.seekg(0,ios::beg);
file.read(buffer, size);
for(int i=0 ;i <size; i++){
if(i <= size){
if(buffer[i] == 'T'){
//do something
}
}
}
}
file.close();
delete[] buffer;
}
i wanna read all the bytes from an exe then check if every byte is = to 'T' then i will continue , now the problem is it's only reading the first byte and it's copying it to buffer , idk whats wrong since the size is = 6138888 , so it should read from 0 to 6138888 but its not it's reading the first byte only! so whats wrong here? | c++ | ifstream | null | null | null | 03/22/2012 23:30:37 | not a real question | Read bytes from an Exe
===
void CCCryptoKeyDlg::OnBnClickedButton3()
{
ifstream::pos_type size;
char * buffer;
ifstream file(this->filepath,ios::ate);
if(file.is_open()){
size = file.tellg();
buffer = new char [size];
file.seekg(0,ios::beg);
file.read(buffer, size);
for(int i=0 ;i <size; i++){
if(i <= size){
if(buffer[i] == 'T'){
//do something
}
}
}
}
file.close();
delete[] buffer;
}
i wanna read all the bytes from an exe then check if every byte is = to 'T' then i will continue , now the problem is it's only reading the first byte and it's copying it to buffer , idk whats wrong since the size is = 6138888 , so it should read from 0 to 6138888 but its not it's reading the first byte only! so whats wrong here? | 1 |
2,860,252 | 05/18/2010 19:05:39 | 325,684 | 04/26/2010 03:42:24 | 20 | 0 | g++ doesn't think I'm passing a reference | When I call a method that takes a reference, g++ complains that I'm not passing a reference. I thought that the caller didn't have to do anything different for PBR. Here's the offending code:
//method definition
void addVertexInfo(VertexInfo &vi){vertexInstances.push_back(vi);}
//method call:
sharedVertices[index]->addVertexInfo(VertexInfo(n1index, n2index));
And here's the error:
`GLUtils/GLMesh.cpp: In member function 'void GLMesh::addPoly(GLIndexedPoly&)':
GLUtils/GLMesh.cpp:110: error: no matching function for call to 'SharedVertexInfo::addVertexInfo(VertexInfo)'
GLUtils/GLMesh.h:93: note: candidates are: void SharedVertexInfo::addVertexInfo(VertexInfo&)`
| c++ | pass-by-reference | g++ | null | null | null | open | g++ doesn't think I'm passing a reference
===
When I call a method that takes a reference, g++ complains that I'm not passing a reference. I thought that the caller didn't have to do anything different for PBR. Here's the offending code:
//method definition
void addVertexInfo(VertexInfo &vi){vertexInstances.push_back(vi);}
//method call:
sharedVertices[index]->addVertexInfo(VertexInfo(n1index, n2index));
And here's the error:
`GLUtils/GLMesh.cpp: In member function 'void GLMesh::addPoly(GLIndexedPoly&)':
GLUtils/GLMesh.cpp:110: error: no matching function for call to 'SharedVertexInfo::addVertexInfo(VertexInfo)'
GLUtils/GLMesh.h:93: note: candidates are: void SharedVertexInfo::addVertexInfo(VertexInfo&)`
| 0 |
7,479,612 | 09/20/2011 03:00:42 | 244,330 | 01/05/2010 22:57:28 | 301 | 5 | How to keep an object parameter unchanged in a Runnable Class in Java? | I have a Runnable class like:
Class R1 implements Runnable {
private final ObjectClass obj;
public R1(ObjectClass obj) {
this.obj = obj;
}
@override
public void run() {
String value = obj.getSomeValue();
// some actions.
}
}
I use a ExecutorService object to execute R1 and put R1 in a queue.
But later outside R1 I change the value in the ObjectClass that I passed in R1 so the the actions in R1 after getSomeValue() aren't behaving as I expected. If I want to keep the value of ObjectClass object in R1 unchanged what can I do? Suppose the object is big and has a lot of get and set methods. | java | multithreading | runnable | null | null | null | open | How to keep an object parameter unchanged in a Runnable Class in Java?
===
I have a Runnable class like:
Class R1 implements Runnable {
private final ObjectClass obj;
public R1(ObjectClass obj) {
this.obj = obj;
}
@override
public void run() {
String value = obj.getSomeValue();
// some actions.
}
}
I use a ExecutorService object to execute R1 and put R1 in a queue.
But later outside R1 I change the value in the ObjectClass that I passed in R1 so the the actions in R1 after getSomeValue() aren't behaving as I expected. If I want to keep the value of ObjectClass object in R1 unchanged what can I do? Suppose the object is big and has a lot of get and set methods. | 0 |
8,458,293 | 12/10/2011 17:11:24 | 808,648 | 06/21/2011 14:39:54 | 11 | 0 | Please help me, ot is imoirtant or me | I can connect to MS SQL from my program by the name of my computer, But when I write IP instead of computer name, it gives an error. Let me note that IP is correct. | sql-server | null | null | null | null | 12/11/2011 02:37:33 | not a real question | Please help me, ot is imoirtant or me
===
I can connect to MS SQL from my program by the name of my computer, But when I write IP instead of computer name, it gives an error. Let me note that IP is correct. | 1 |
11,430,125 | 07/11/2012 09:59:58 | 1,401,950 | 05/17/2012 20:35:28 | 65 | 1 | how to check if a frame was exited by the user clicking the close button? | how to can I check if a frame was exited by the user clicking the close button. I need to know because I have two wx.frames, a child and parent. When the parent frame is closed the how do I close the child frame?
I'm using wxpython | python | gui | wxpython | null | null | null | open | how to check if a frame was exited by the user clicking the close button?
===
how to can I check if a frame was exited by the user clicking the close button. I need to know because I have two wx.frames, a child and parent. When the parent frame is closed the how do I close the child frame?
I'm using wxpython | 0 |
11,171,793 | 06/23/2012 18:06:32 | 1,469,887 | 06/20/2012 16:23:39 | 1 | 0 | MySQL and VB 2010 Ultimate | Can somebody teach me how to connect and manipulate database tables using MySQL 5.x and Visual Basic 2010? Thanks! | mysql | null | null | null | null | 06/23/2012 21:14:55 | not a real question | MySQL and VB 2010 Ultimate
===
Can somebody teach me how to connect and manipulate database tables using MySQL 5.x and Visual Basic 2010? Thanks! | 1 |
3,592,163 | 08/28/2010 19:44:17 | 188,516 | 10/12/2009 15:39:45 | 123 | 1 | What developer sites accept articles and reviews? | Could you please drop here a few links to software developer sites or blogs that accept software reviews or articles?
BR
Murat | .net | blogs | review | null | null | 08/30/2010 11:36:44 | off topic | What developer sites accept articles and reviews?
===
Could you please drop here a few links to software developer sites or blogs that accept software reviews or articles?
BR
Murat | 2 |
8,183,065 | 11/18/2011 13:20:50 | 809,953 | 06/22/2011 08:26:17 | 426 | 17 | How can i set and access config variables in rails 3 | I want to make some environment variables. How can i set/get them?
Thank you | ruby-on-rails | ruby | null | null | null | 11/19/2011 05:09:47 | not a real question | How can i set and access config variables in rails 3
===
I want to make some environment variables. How can i set/get them?
Thank you | 1 |
11,426,330 | 07/11/2012 05:51:53 | 1,400,865 | 05/17/2012 11:32:45 | 51 | 2 | Low memory Warning Issue | All the used viewcontrollers and controls are released and deallocated upto my knowledge and Also tracked through Instrument and generic Analyzer. But my app receives low memory warning Issue.
i have heard abt low memory warning levels.If they exists how to identify them via notification.
Meanwhile my app consumes only 16 mb RAM and works perfectly in simulator bt crashes in device.
Plz join hands. | objective-c | ios | ipad | memory-leaks | low-memory | null | open | Low memory Warning Issue
===
All the used viewcontrollers and controls are released and deallocated upto my knowledge and Also tracked through Instrument and generic Analyzer. But my app receives low memory warning Issue.
i have heard abt low memory warning levels.If they exists how to identify them via notification.
Meanwhile my app consumes only 16 mb RAM and works perfectly in simulator bt crashes in device.
Plz join hands. | 0 |
10,816,032 | 05/30/2012 12:12:36 | 828,963 | 07/05/2011 03:59:29 | 10 | 0 | Make this loop simple (print Letter D in Java using loop) | I try to print letter D on console, but I couldn't help the code is longer than my expectation. Could you help me.... there are another way to reduce this code? Thank you.
This is my code:
<pre>
public class LetterD {
public static void main(String[] args) {
for(int i = 1;i<=14;i++){
for(int j = 1;j<=4;j++) System.out.print("*");
if(i == 1 || i==14) for(int k = 1;k<=7;k++) System.out.print("*");
if(i == 2 || i==13) for(int k = 1;k<=9;k++) System.out.print("*");
if(i == 3 || i==12){
for(int k = 1;k<=6;k++) System.out.print("-");
for(int l = 7;l<=10;l++) System.out.print("*");
}
if(i==4||i==11){
for(int k = 1;k<=7;k++) System.out.print("-");
for(int l = 8;l<=11;l++) System.out.print("*");
}
if(i==5||i==10){
for(int k = 1;k<=8;k++) System.out.print("-");
for(int l = 9;l<=12;l++) System.out.print("*");
}
if(i==6||i==9){
for(int k = 1;k<=9;k++) System.out.print("-");
for(int l = 10;l<=13;l++) System.out.print("*");
}
if(i==7||i==8){
for(int k = 1;k<=10;k++) System.out.print("-");
for(int l = 11;l<=14;l++) System.out.print("*");
}
System.out.println();
}
}
}
</pre> | java | loops | for-loop | null | null | 06/01/2012 09:52:43 | too localized | Make this loop simple (print Letter D in Java using loop)
===
I try to print letter D on console, but I couldn't help the code is longer than my expectation. Could you help me.... there are another way to reduce this code? Thank you.
This is my code:
<pre>
public class LetterD {
public static void main(String[] args) {
for(int i = 1;i<=14;i++){
for(int j = 1;j<=4;j++) System.out.print("*");
if(i == 1 || i==14) for(int k = 1;k<=7;k++) System.out.print("*");
if(i == 2 || i==13) for(int k = 1;k<=9;k++) System.out.print("*");
if(i == 3 || i==12){
for(int k = 1;k<=6;k++) System.out.print("-");
for(int l = 7;l<=10;l++) System.out.print("*");
}
if(i==4||i==11){
for(int k = 1;k<=7;k++) System.out.print("-");
for(int l = 8;l<=11;l++) System.out.print("*");
}
if(i==5||i==10){
for(int k = 1;k<=8;k++) System.out.print("-");
for(int l = 9;l<=12;l++) System.out.print("*");
}
if(i==6||i==9){
for(int k = 1;k<=9;k++) System.out.print("-");
for(int l = 10;l<=13;l++) System.out.print("*");
}
if(i==7||i==8){
for(int k = 1;k<=10;k++) System.out.print("-");
for(int l = 11;l<=14;l++) System.out.print("*");
}
System.out.println();
}
}
}
</pre> | 3 |
9,521,048 | 03/01/2012 17:32:16 | 325,533 | 04/25/2010 19:49:52 | 65 | 1 | empty tbody on click | I am trying to empty all the rows inside the tbody on click of a new row. This is the javascript i am using:
$('#pro tr').click(function() {
$('#pro_basket > tbody').empty();
$.ajax({
type: "post", url: "data.php", data: "index="+index,
success: function(data) {
$('#pro_basket > tbody').after(data);
}
});
});
My table markup is simple:
<table id='pro_basket'>
<thead>
<th>Column 1</th>
<th>Column 2</th>
</thead>
<tbody>
</tbody>
</table>
I want to empty the rows that exist in pro_basket but ` $('#pro_basket > tbody').empty();` isn't really helping. | javascript | jquery | null | null | null | 04/06/2012 17:21:33 | not a real question | empty tbody on click
===
I am trying to empty all the rows inside the tbody on click of a new row. This is the javascript i am using:
$('#pro tr').click(function() {
$('#pro_basket > tbody').empty();
$.ajax({
type: "post", url: "data.php", data: "index="+index,
success: function(data) {
$('#pro_basket > tbody').after(data);
}
});
});
My table markup is simple:
<table id='pro_basket'>
<thead>
<th>Column 1</th>
<th>Column 2</th>
</thead>
<tbody>
</tbody>
</table>
I want to empty the rows that exist in pro_basket but ` $('#pro_basket > tbody').empty();` isn't really helping. | 1 |
10,906,167 | 06/05/2012 22:57:50 | 1,044,876 | 11/14/2011 03:08:40 | 11 | 0 | Windows Phone + SSH Library? | i am willing to create an SSH client for Windows Phone.
I am looking for a good FREE Library i could re-use or an affordable one.
Any ideas?
Thanks in advance! | c# | windows-phone-7 | ssh | null | null | 06/06/2012 13:10:41 | not constructive | Windows Phone + SSH Library?
===
i am willing to create an SSH client for Windows Phone.
I am looking for a good FREE Library i could re-use or an affordable one.
Any ideas?
Thanks in advance! | 4 |
8,588,657 | 12/21/2011 10:52:08 | 1,106,450 | 12/19/2011 17:54:20 | 1 | 2 | Loading a <script> element after the document has loaded | I would like to execute some Javascript after the document has loaded and even after the document.onload functions have been executed.
Situation:
I'm loading a text-edit field through ajax. When the user submits the form, he is redirected to a PHP file. That PHP file redirects him back to "file.php" using header('location: file.php');
What I want to do is to execute some Javascript actions in file.php, but when I print the <script></script> tags the file id displayed blank - nothing is loaded at all. As soon as I leave them out, the page does get loaded.
Any suggestions? | javascript | jquery | load | document.ready | null | 12/21/2011 11:48:29 | not a real question | Loading a <script> element after the document has loaded
===
I would like to execute some Javascript after the document has loaded and even after the document.onload functions have been executed.
Situation:
I'm loading a text-edit field through ajax. When the user submits the form, he is redirected to a PHP file. That PHP file redirects him back to "file.php" using header('location: file.php');
What I want to do is to execute some Javascript actions in file.php, but when I print the <script></script> tags the file id displayed blank - nothing is loaded at all. As soon as I leave them out, the page does get loaded.
Any suggestions? | 1 |
5,786,989 | 04/26/2011 06:55:16 | 152,308 | 08/07/2009 07:07:58 | 122 | 2 | Web hosting provider for Symfony 2? | As everyone knows, PHP 5.3 is not supported by all web hosting providers.
I would be happy to hear about your experience and I would like you to
recommend to me a good web hosting provider.
Any suggestion? | php | php5 | web-hosting | php-5.3 | symfony-2.0 | 04/26/2011 19:51:34 | off topic | Web hosting provider for Symfony 2?
===
As everyone knows, PHP 5.3 is not supported by all web hosting providers.
I would be happy to hear about your experience and I would like you to
recommend to me a good web hosting provider.
Any suggestion? | 2 |
3,680,019 | 09/09/2010 19:44:21 | 172,543 | 09/12/2009 17:00:05 | 518 | 15 | logic for solving a sequence. | sequence goes like this.. `7,8,77,78,87,88,777,778,787,788` and so on.. what can be the logic for finding the nth number of the sequence? I tried that by dividing it by 2 and then by 4 and hence but it doesn't seem to work. | algorithm | logic | null | null | null | 09/12/2010 02:41:41 | off topic | logic for solving a sequence.
===
sequence goes like this.. `7,8,77,78,87,88,777,778,787,788` and so on.. what can be the logic for finding the nth number of the sequence? I tried that by dividing it by 2 and then by 4 and hence but it doesn't seem to work. | 2 |
4,760,681 | 01/21/2011 15:42:41 | 472,537 | 10/11/2010 17:29:30 | 235 | 4 | OpenGL ES rotate the world | How i can rotate the all world by 15 degrees on the Z axis?
| opengl-es | null | null | null | null | null | open | OpenGL ES rotate the world
===
How i can rotate the all world by 15 degrees on the Z axis?
| 0 |
2,838,728 | 05/15/2010 02:51:50 | 266,406 | 02/04/2010 17:21:36 | 61 | 0 | rewrite URL for PUT request | I changed the way my URL are working on my server.
It is now `www.myserver.com/service` instead of `www.myserver.com/test/service`
I have added a RedirectMatch 301 to my Apache conf file to redirect any access to `www.myserver.com/test` to `www.myserver.com/`.
I am receiving file to this server via an HTTP PUT at this URL for example :
`www.myserver.com/test/service/put/myfile.xml`
The server sending the file don't handle the 301 HTTP status code so the files didn't arrived anymore.
Is there a way to rewrite the URL when it is a PUT Request in order to don't miss any file?
Thanks,
Benjamin
[1]: http:// | put | http | apache | null | null | null | open | rewrite URL for PUT request
===
I changed the way my URL are working on my server.
It is now `www.myserver.com/service` instead of `www.myserver.com/test/service`
I have added a RedirectMatch 301 to my Apache conf file to redirect any access to `www.myserver.com/test` to `www.myserver.com/`.
I am receiving file to this server via an HTTP PUT at this URL for example :
`www.myserver.com/test/service/put/myfile.xml`
The server sending the file don't handle the 301 HTTP status code so the files didn't arrived anymore.
Is there a way to rewrite the URL when it is a PUT Request in order to don't miss any file?
Thanks,
Benjamin
[1]: http:// | 0 |
9,451,102 | 02/26/2012 06:35:18 | 617,844 | 02/15/2011 13:22:14 | 1 | 0 | Reading data from Any Excel | Please how can I read data from ANY excel file in C#, like have a program work on any excel file in any location on my drive | c# | excel | null | null | null | 02/26/2012 09:07:02 | not a real question | Reading data from Any Excel
===
Please how can I read data from ANY excel file in C#, like have a program work on any excel file in any location on my drive | 1 |
4,701,558 | 01/15/2011 19:08:48 | 576,960 | 01/15/2011 19:08:48 | 1 | 0 | Are temporary objects in C++ const indeed? | I always believed that temporary objects in C++ are automatically considered as const by the compiler. But recently I experienced that the following example of code:
<code>
function_returning_object().some_non_const_method();
</code>
is valid for C++ compiler. And it makes me wonder - are temporary objects in C++ const indeed? If yes, then why the code above is considered correct by the compiler? | c++ | const | temporary | null | null | null | open | Are temporary objects in C++ const indeed?
===
I always believed that temporary objects in C++ are automatically considered as const by the compiler. But recently I experienced that the following example of code:
<code>
function_returning_object().some_non_const_method();
</code>
is valid for C++ compiler. And it makes me wonder - are temporary objects in C++ const indeed? If yes, then why the code above is considered correct by the compiler? | 0 |
10,559,377 | 05/11/2012 22:25:58 | 1,364,952 | 04/30/2012 02:37:29 | 6 | 0 | jQuery doing what it's suppose to on all the pages except ONE | Here is my script: http://jsfiddle.net/9cnGC/11/
I was wondering if anyone can help me with this fiddle and maybe clean it up a bit so it can run more efficiently?
I believe it is because there is another instance of jQuery running on the page. Which is messing with this script here, but I am not sure what is wrong with it.
Here is the page that has the messed up display logic. http://ben.chmark.com/mdcp/index.php/prescriptions/transfer-prescription
It runs fine on all the other pages except this one. I'm stumped :(
Thanks in advance | javascript | jquery | html | css | null | 05/14/2012 13:24:34 | too localized | jQuery doing what it's suppose to on all the pages except ONE
===
Here is my script: http://jsfiddle.net/9cnGC/11/
I was wondering if anyone can help me with this fiddle and maybe clean it up a bit so it can run more efficiently?
I believe it is because there is another instance of jQuery running on the page. Which is messing with this script here, but I am not sure what is wrong with it.
Here is the page that has the messed up display logic. http://ben.chmark.com/mdcp/index.php/prescriptions/transfer-prescription
It runs fine on all the other pages except this one. I'm stumped :(
Thanks in advance | 3 |
8,398,455 | 12/06/2011 10:34:17 | 994,894 | 10/14/2011 06:56:15 | 1 | 0 | Add offline dictionary | I want to add offline dictionary feature in my source code. I am using cocos2dx. but I am not getting hot to add it? Is it require any api and from where I will get it? Kindly help..
Thanks, | iphone | null | null | null | null | 12/07/2011 00:31:55 | not a real question | Add offline dictionary
===
I want to add offline dictionary feature in my source code. I am using cocos2dx. but I am not getting hot to add it? Is it require any api and from where I will get it? Kindly help..
Thanks, | 1 |
3,897,870 | 10/09/2010 21:04:40 | 471,162 | 10/09/2010 21:04:40 | 1 | 0 | Split string of 2 words in separate words [but sometimes there is only word in the string...] | I have strings like "AMS.I-I.D. ver.5" and "AM0011 ver. 2", of which the "ver. *" needs to be stripped.
i have done that with: (^A.*)(ver.\s\d{1,2})
the problem occurs when there is no version nr. like "AM0003".
how can i make the (ver.\s\d{1,2}) part optional?
help much appreciated, tried everything already.
henk | regex | string | split | null | null | null | open | Split string of 2 words in separate words [but sometimes there is only word in the string...]
===
I have strings like "AMS.I-I.D. ver.5" and "AM0011 ver. 2", of which the "ver. *" needs to be stripped.
i have done that with: (^A.*)(ver.\s\d{1,2})
the problem occurs when there is no version nr. like "AM0003".
how can i make the (ver.\s\d{1,2}) part optional?
help much appreciated, tried everything already.
henk | 0 |
6,352,618 | 06/15/2011 03:09:50 | 798,842 | 06/15/2011 03:09:50 | 1 | 0 | Do i need a mac as i am outsourcing development? | I am outsourcing the development of my app but a technical req. of the apple dev. program is a mac. Is this relevant to me?I use a hp laptop. | iphone | osx | application | outsourcing | null | 06/15/2011 03:22:01 | off topic | Do i need a mac as i am outsourcing development?
===
I am outsourcing the development of my app but a technical req. of the apple dev. program is a mac. Is this relevant to me?I use a hp laptop. | 2 |
6,952,799 | 08/05/2011 07:19:35 | 880,067 | 08/05/2011 07:16:17 | 1 | 0 | getElementById("") from dynamic conteiner php | i make one slide show in php..... somewhere in my code generate dynamic...
<div id="slider-container"> </div>
this make below code: (show from safari inspect element)
------------------------------------------------------------------------------------------
<table cellpadding="0" cellspacing="0" border="0" id="slider-table" style="-webkit-transition-property: margin-left; -webkit-transition-duration: 1s; display: block; margin-left: -11484px; ">
<tbody>
<tr>
<td class="slide" id="slide_0_div"></td>
<img src="photos/Cars/resized/ronn-motor-scorpion-slide-1024.jpg">
<td class="slide" id="slide_1_div"></td>
<img src="photos/Cars/resized/car3-slide-1024.jpg">
now i want to cache id from image or url from image which is now display in my sceen..
how i can get that?
all this table with images g | php | getelementbyid | null | null | null | 08/05/2011 09:39:46 | not a real question | getElementById("") from dynamic conteiner php
===
i make one slide show in php..... somewhere in my code generate dynamic...
<div id="slider-container"> </div>
this make below code: (show from safari inspect element)
------------------------------------------------------------------------------------------
<table cellpadding="0" cellspacing="0" border="0" id="slider-table" style="-webkit-transition-property: margin-left; -webkit-transition-duration: 1s; display: block; margin-left: -11484px; ">
<tbody>
<tr>
<td class="slide" id="slide_0_div"></td>
<img src="photos/Cars/resized/ronn-motor-scorpion-slide-1024.jpg">
<td class="slide" id="slide_1_div"></td>
<img src="photos/Cars/resized/car3-slide-1024.jpg">
now i want to cache id from image or url from image which is now display in my sceen..
how i can get that?
all this table with images g | 1 |
5,722,588 | 04/19/2011 20:56:13 | 715,992 | 04/19/2011 20:56:13 | 1 | 0 | Format number in PHP | I would like to format number with decimal places to format without decimal places, example: 146.5 to 146500000. How can i achieve this in PHP?
Thank you.
| php | null | null | null | null | null | open | Format number in PHP
===
I would like to format number with decimal places to format without decimal places, example: 146.5 to 146500000. How can i achieve this in PHP?
Thank you.
| 0 |
9,141,395 | 02/04/2012 13:58:20 | 1,189,409 | 02/04/2012 13:54:24 | 1 | 0 | Scheme/Prolog finding all positions of an element in a list | I need help finding the first position of an element in a list and then finding all positions of the same element in both Scheme and Prolog for a really late exam for a course I did half a year ago and can't remember ANYTHING :(
Any ideas? | list | scheme | prolog | position | element | 02/11/2012 05:17:01 | not a real question | Scheme/Prolog finding all positions of an element in a list
===
I need help finding the first position of an element in a list and then finding all positions of the same element in both Scheme and Prolog for a really late exam for a course I did half a year ago and can't remember ANYTHING :(
Any ideas? | 1 |
4,826,771 | 01/28/2011 09:46:08 | 286,295 | 03/04/2010 13:46:51 | 109 | 3 | RewriteRule help needed | Could anyone help me with this RewriteRule:
mydomain.com/article/12 -> mydomain.com/?news=12
mydomain.com/page/55/article/12 -> mydomain.com/?page=55&news=12
Here is my unsuccessful attempt:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule page/([0-9]+)/article/([0-9]+) /?page=$1&news=$2
RewriteRule article/([0-9]+) /?news=$1
only the latter has any effect.. My regex experience is not that great :\
| .htaccess | mod-rewrite | url-rewriting | null | null | 01/28/2011 12:35:06 | too localized | RewriteRule help needed
===
Could anyone help me with this RewriteRule:
mydomain.com/article/12 -> mydomain.com/?news=12
mydomain.com/page/55/article/12 -> mydomain.com/?page=55&news=12
Here is my unsuccessful attempt:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule page/([0-9]+)/article/([0-9]+) /?page=$1&news=$2
RewriteRule article/([0-9]+) /?news=$1
only the latter has any effect.. My regex experience is not that great :\
| 3 |
3,886,734 | 10/07/2010 23:45:56 | 188,826 | 10/13/2009 04:01:36 | 361 | 2 | ASP.NET MVC 3 Publish doesn't work | Looks like Publish doesn't copy Razor views at ASP.NET MVC 3 Beta. Is it a known limitation of Beta? Will it be fixed at release? | c# | .net | asp.net-mvc | null | null | null | open | ASP.NET MVC 3 Publish doesn't work
===
Looks like Publish doesn't copy Razor views at ASP.NET MVC 3 Beta. Is it a known limitation of Beta? Will it be fixed at release? | 0 |
11,028,147 | 06/14/2012 06:57:35 | 1,427,808 | 05/31/2012 07:48:31 | 1 | 0 | how to create custom annotations with logics inside in JAVA | I want to create a annotation which searches for the method name starting with a word given in the annotation and execute the method.
I am new to annotations and i know that there are some inbuilt annotations like @override,@suppressWarnigs, @documented, @Retention, @deprecated, @target.
Are there any more annotations.
Help me please
| java | null | null | null | null | 06/15/2012 01:34:10 | not a real question | how to create custom annotations with logics inside in JAVA
===
I want to create a annotation which searches for the method name starting with a word given in the annotation and execute the method.
I am new to annotations and i know that there are some inbuilt annotations like @override,@suppressWarnigs, @documented, @Retention, @deprecated, @target.
Are there any more annotations.
Help me please
| 1 |
5,602,857 | 04/09/2011 04:22:55 | 699,610 | 04/09/2011 03:52:32 | 1 | 0 | PHP not working with MySQL query? | This is a really simple MySQL query that I always use, but somehow for one of my website scripts, it just does not work. Not just for one place in the webpage, but multiple areas including the login and content pulling. I checked everything including if I had my site connecting to the MySQL database server correctly or not (because the register worked but the login does not) I did a quick test to see if it worked properly:
$usrn=$_POST['username'];
$pswd=$_POST['password'];
$query = "SELECT * FROM users WHERE user='$usrn' AND password='$pswd' DESC LIMIT 0,1";
$result = mysql_query($query);
$i=0;
while ($i < 1) {
$usr=@mysql_result($result,$i,"user");
$psw=@mysql_result($result,$i,"password");
echo $usrn."|".$usr."|".$pswd."|".$psw;
$i++;
}
In this script, it will output something like:
username||password|
which means that there was nothing to output on the $usr and $psw which usually worked on my other websites.
also, when I included the following:
$num = mysql_numrows($result);
it would give me an error message:
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /index.php on line 906 | php | mysql | null | null | null | null | open | PHP not working with MySQL query?
===
This is a really simple MySQL query that I always use, but somehow for one of my website scripts, it just does not work. Not just for one place in the webpage, but multiple areas including the login and content pulling. I checked everything including if I had my site connecting to the MySQL database server correctly or not (because the register worked but the login does not) I did a quick test to see if it worked properly:
$usrn=$_POST['username'];
$pswd=$_POST['password'];
$query = "SELECT * FROM users WHERE user='$usrn' AND password='$pswd' DESC LIMIT 0,1";
$result = mysql_query($query);
$i=0;
while ($i < 1) {
$usr=@mysql_result($result,$i,"user");
$psw=@mysql_result($result,$i,"password");
echo $usrn."|".$usr."|".$pswd."|".$psw;
$i++;
}
In this script, it will output something like:
username||password|
which means that there was nothing to output on the $usr and $psw which usually worked on my other websites.
also, when I included the following:
$num = mysql_numrows($result);
it would give me an error message:
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /index.php on line 906 | 0 |
8,674,299 | 12/29/2011 22:36:03 | 483,409 | 10/21/2010 18:39:53 | 84 | 0 | why cant they tell the origin of botnets? |
I was reading about bot-nets and was wondering why it is not possible to find the origin of these nets and route them out by identifying the origin computer which sets these up ?
I perhaps don't understand them very much so pardon my naive question.
Theoritically all traffic that originates from every computer has to go through an ISP, a bunch of intermediate routers and finally reach it's destination host. So if the ISPs monitor incoming and outgoing addresses they should be able to tell which IP addresses is making all these connections to a large number of destinations or some such heuristic...
In general these backbone providers and ISPS together essentially know where the connections from each computer go, so why not follow them ?
| security | botnet | null | null | null | 12/29/2011 22:55:23 | off topic | why cant they tell the origin of botnets?
===
I was reading about bot-nets and was wondering why it is not possible to find the origin of these nets and route them out by identifying the origin computer which sets these up ?
I perhaps don't understand them very much so pardon my naive question.
Theoritically all traffic that originates from every computer has to go through an ISP, a bunch of intermediate routers and finally reach it's destination host. So if the ISPs monitor incoming and outgoing addresses they should be able to tell which IP addresses is making all these connections to a large number of destinations or some such heuristic...
In general these backbone providers and ISPS together essentially know where the connections from each computer go, so why not follow them ?
| 2 |
9,702,361 | 03/14/2012 12:54:01 | 1,140,157 | 01/10/2012 05:44:25 | 208 | 3 | How to assign the NSArray string object values to other NSString variables | NSMutableArray *nameArray = [[NSMutableArray alloc] init];
[nameArray addObject:@"abc"];
[nameArray addObject:@"cdf"];
[nameArray addObject:@"jkl"];
//Use a for each loop to iterate through the array
for (NSString *s in nameArray) {
NSLog(@"value is %@", s);
}
The above code shows all the values of nameArray. But I want to assign all those values to these NSString:
NSString *a;
NSString *b;
NSString *cd;
How to achieve this? | iphone | objective-c | ios | xcode | null | null | open | How to assign the NSArray string object values to other NSString variables
===
NSMutableArray *nameArray = [[NSMutableArray alloc] init];
[nameArray addObject:@"abc"];
[nameArray addObject:@"cdf"];
[nameArray addObject:@"jkl"];
//Use a for each loop to iterate through the array
for (NSString *s in nameArray) {
NSLog(@"value is %@", s);
}
The above code shows all the values of nameArray. But I want to assign all those values to these NSString:
NSString *a;
NSString *b;
NSString *cd;
How to achieve this? | 0 |
9,544,602 | 03/03/2012 08:14:07 | 419,284 | 08/13/2010 07:22:32 | 139 | 2 | The difference between "object" and "object*" | graph.h
struct Edge {
int from;
int to;
int elabel;
unsigned int id;
Edge(): from(0), to(0), elabel(0), id(0) {};
};
What is the difference between vector<Edge> and vector<Edge*>, i know vector<Edge> is an array store Edge object, but what is the Edge* object? Thanks:)
| c++ | null | null | null | null | 03/03/2012 16:02:36 | not constructive | The difference between "object" and "object*"
===
graph.h
struct Edge {
int from;
int to;
int elabel;
unsigned int id;
Edge(): from(0), to(0), elabel(0), id(0) {};
};
What is the difference between vector<Edge> and vector<Edge*>, i know vector<Edge> is an array store Edge object, but what is the Edge* object? Thanks:)
| 4 |
11,498,579 | 07/16/2012 05:34:10 | 1,527,963 | 07/16/2012 05:22:46 | 1 | 0 | What the best way to make a centralized search for entire site like not same but like Facebook? | Would some one please tell me the best way to make a centralized search for entire site like not same but like Facebook. I want to search the member(s), location(s), blog(s) and event(s) through a single search form. There is several way to do this but I need to make it easy and with a optimized database, I don't want to use multiple joins or clauses into this.
Thanks in Advance
| php | mysql | facebook | search | null | 07/18/2012 02:29:41 | not a real question | What the best way to make a centralized search for entire site like not same but like Facebook?
===
Would some one please tell me the best way to make a centralized search for entire site like not same but like Facebook. I want to search the member(s), location(s), blog(s) and event(s) through a single search form. There is several way to do this but I need to make it easy and with a optimized database, I don't want to use multiple joins or clauses into this.
Thanks in Advance
| 1 |
7,964,785 | 11/01/2011 09:49:20 | 59,159 | 01/26/2009 23:11:48 | 186 | 12 | Javascript canvas animation slowing down and hogging memory | I'm experimenting with moving shapes in javascript with a canvas tag.
I have one half circle (only stroked) which rotates on set intervals.
I've written the code so many more can be added. I can give starting rotations and a lot of other handy parameters.
I've tried this with twelve circles and it looks exactly like I want. Problem is, the animation slows down and the framerate goes down quite fast. And it uses heaps and heaps of memory. Any ideas on how to optimize this code to not consume so much?
The CODE:
http://jsfiddle.net/xaddict/fLE8z/
Thanks for all help! | javascript | html5 | optimization | animation | canvas | 11/01/2011 14:57:22 | off topic | Javascript canvas animation slowing down and hogging memory
===
I'm experimenting with moving shapes in javascript with a canvas tag.
I have one half circle (only stroked) which rotates on set intervals.
I've written the code so many more can be added. I can give starting rotations and a lot of other handy parameters.
I've tried this with twelve circles and it looks exactly like I want. Problem is, the animation slows down and the framerate goes down quite fast. And it uses heaps and heaps of memory. Any ideas on how to optimize this code to not consume so much?
The CODE:
http://jsfiddle.net/xaddict/fLE8z/
Thanks for all help! | 2 |
7,081,209 | 08/16/2011 16:02:14 | 897,057 | 08/16/2011 16:02:14 | 1 | 0 | What is a good resource to learn front end mobile app / browser app development? | When I search for app development I find mostly articles and videos that cover the back end. I am interested in learning just front end development for apps on ios devices and apps on browsers as well. Although these use HTML(5)/CSS/JavaScript there must be special requirements unique to building "web apps" as opposed to web sites. I would like to learn these and see some examples of the entire process from a front end perspective. | ios | application | frontend | null | null | 08/25/2011 21:30:22 | not constructive | What is a good resource to learn front end mobile app / browser app development?
===
When I search for app development I find mostly articles and videos that cover the back end. I am interested in learning just front end development for apps on ios devices and apps on browsers as well. Although these use HTML(5)/CSS/JavaScript there must be special requirements unique to building "web apps" as opposed to web sites. I would like to learn these and see some examples of the entire process from a front end perspective. | 4 |
7,028,861 | 08/11/2011 15:45:25 | 645,244 | 03/04/2011 18:30:28 | 124 | 2 | VB using a ADO Recordset inside a vb function, checking for null | I have some weird behavior that has me perplexed. I created a function in vb (Microsoft Word Macro version of VB) which looks like this:
Public Function isitnullorempty(newstring As String) As Boolean
If IsNull(newstring) Or IsEmpty(newstring) Or newstring = "" Then
isitnullorempty = False
Else
isitnullorempty = True
End If
End Function
It seems to work as expected if I create a variable and then set it to null, "", or leaving it empty. I manipulate the variable and then do MSGBOX isitnullorempty(variable) and it echos what I expect. It doesn't behave the same way when I put a recordset inside the function however. I've even tried to make a variable set it to the record set and then test it but that doesn't work either. If I try to invoke the following
'ADO query code here (This is an ODBC connection)
DO While (Not oRecordset.EOF)
MsgBox isitnullorempty(oRecordset.Fields("CustomerTypeRefFullName"))
oRecordset.MoveNext
Loop
This yields the error: Invalid use of Null.
So two fold question.
Is there already a vb function that exists which does what I want?
Why does my code behave this way?
Weirder yet is that if I do the test individually outside of the function, it works. | function | vba | error-message | null | null | null | open | VB using a ADO Recordset inside a vb function, checking for null
===
I have some weird behavior that has me perplexed. I created a function in vb (Microsoft Word Macro version of VB) which looks like this:
Public Function isitnullorempty(newstring As String) As Boolean
If IsNull(newstring) Or IsEmpty(newstring) Or newstring = "" Then
isitnullorempty = False
Else
isitnullorempty = True
End If
End Function
It seems to work as expected if I create a variable and then set it to null, "", or leaving it empty. I manipulate the variable and then do MSGBOX isitnullorempty(variable) and it echos what I expect. It doesn't behave the same way when I put a recordset inside the function however. I've even tried to make a variable set it to the record set and then test it but that doesn't work either. If I try to invoke the following
'ADO query code here (This is an ODBC connection)
DO While (Not oRecordset.EOF)
MsgBox isitnullorempty(oRecordset.Fields("CustomerTypeRefFullName"))
oRecordset.MoveNext
Loop
This yields the error: Invalid use of Null.
So two fold question.
Is there already a vb function that exists which does what I want?
Why does my code behave this way?
Weirder yet is that if I do the test individually outside of the function, it works. | 0 |
9,578,763 | 03/06/2012 06:09:15 | 1,163,282 | 01/22/2012 09:30:04 | 218 | 0 | I need to replace a C# switch with something more compact | I have the following code:
switch (pk.Substring(2, 2))
{
case "00":
ViewBag.Type = _reference.Get("14", model.Type).Value;
break;
case "01":
ViewBag.Type = _reference.Get("18", model.Type).Value;
break;
}
It does the job but does not look very clean to me. Is there some way I could make this code a bit smaller. I was thinking to just have the number 14 or 18 as a variable but I am not sure the best way to code if I should use if-else or some other way. | c# | null | null | null | null | null | open | I need to replace a C# switch with something more compact
===
I have the following code:
switch (pk.Substring(2, 2))
{
case "00":
ViewBag.Type = _reference.Get("14", model.Type).Value;
break;
case "01":
ViewBag.Type = _reference.Get("18", model.Type).Value;
break;
}
It does the job but does not look very clean to me. Is there some way I could make this code a bit smaller. I was thinking to just have the number 14 or 18 as a variable but I am not sure the best way to code if I should use if-else or some other way. | 0 |
11,486,569 | 07/14/2012 19:04:08 | 1,247,110 | 03/03/2012 17:09:05 | 13 | 0 | How to go about adding a navbar to this page? | I'm making a relatively simple website and I've ran into trouble where I least expected it. My navigation bar, after being redone 3 times, still didn't give me the result I was looking for. I copied some code and plopped a placeholder in there for now, but I'd like to get a pointer as to how I can achieve the look I'm shooting for.
Website: http://authorsisland.comyr.com/
What I want it to look like:  | html | css | null | null | null | 07/15/2012 04:08:40 | too localized | How to go about adding a navbar to this page?
===
I'm making a relatively simple website and I've ran into trouble where I least expected it. My navigation bar, after being redone 3 times, still didn't give me the result I was looking for. I copied some code and plopped a placeholder in there for now, but I'd like to get a pointer as to how I can achieve the look I'm shooting for.
Website: http://authorsisland.comyr.com/
What I want it to look like:  | 3 |
8,708,514 | 01/03/2012 06:04:03 | 1,122,530 | 12/30/2011 07:12:39 | 16 | 0 | Step by Step walkthrough to host WCF service in Windows Azure | I need to host my **WCF** service in **Azure** and as a beginner I want to know the steps involved in hosting and configuring the service.(also interested to know about **WorkerRole** and **WebRole**). Plz help me out. | c# | wcf | azure | null | null | 01/03/2012 08:51:35 | not a real question | Step by Step walkthrough to host WCF service in Windows Azure
===
I need to host my **WCF** service in **Azure** and as a beginner I want to know the steps involved in hosting and configuring the service.(also interested to know about **WorkerRole** and **WebRole**). Plz help me out. | 1 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.