I want to override the getattr method on a class to do something fancy but I don't want to break the default behavior.
What's the correct way to do this?
I am currently involved in a project which requires me to repeatedly take snapshots of the screen. I am using qt's grabScreen function to do the same.
The screen freezes for half a second every time the program takes a snapshot causing the computer to seem to be very slow :(
Can anybody suggest me a better method of doing this ?
I'm currently using this method:
class Foo {
private static $num_instatnces = 0;
function __construct() {
self::$num_instances++;
}
}
which seems to work, but I'm wondering if there's a built in way....
string s = "string";
Console.WriteLine(s[1]); // returns t
char[] chars = s.ToCharArray();
Console.WriteLine(chars[1]); // also returns t
so what is the point in this method?
I am trying to obtain an instance of my live wallpaper engine in another class,
here is my code...
In the other class:
WallpaperEngine wpe = (WallpaperEngine) LiveWallpaperService.onCreateEngine();
In LiveWallpaperService:
@Override
public Engine onCreateEngine() {
// TODO Auto-generated method stub
return new WallpaperEngine();
}
But when I refer to an object in my engine (i.e, "wpe.variable"), I get a NullPointerException and the wallpaper force closes.
Some guy called one of my Snipplr submissions "crap" because I used if ($_SERVER['REQUEST_METHOD'] == 'POST') instead of if ($_POST)
Checking the request method seems more correct to me because that's what I really want to do. Is there some operational difference between the two or is this just a code clarity issue?
i want to create a table where first column have timing in below style
timing | user1 | user2 | user3
-------------------------------
9 AM | | |
10 AM | | |
. | | |
. | | |
. | | |
6 PM | | |
7 PM | | |
is it possible to use range() for creating timing list, if yes then please tell me , or if not then suggest me better method.
Thanks always
i am trying to generate a hex color value from an integer input, and I'm not sure I'm using the concat method correctly. when i output the string theColor, i only get "0x", any ideas?
public String generateColor(String redVal, String blueVal,
String greenVal, String alphaVal){
String theColor = "0x";
theColor.concat(alphaVal);
theColor.concat(redVal);
theColor.concat(greenVal);
theColor.concat(blueVal);
return theColor;
}
Hi all, is there a method (maybe with Google Collections) to obtain the min value of a Map(Key, Double)
In traditional way, I would have to sort the map according to the values, and take the first/last one.
thanks
Just using it as a method parameter is fine but what about an easy way to use it in strings?
For instance say I have this:
11 void myTest()
12 {
13 if(!testCondition)
14 logError("testcondition failed");
15 }
And I want the output to be:
"myTest line 14: testcondition failed"
How can I write logError? Does it have to be some monstrosity of a macro?
I have a class where I'm using __set. Because I don't want it to set just anything, I have an array of approved variables that it checks before it will actually set a class property.
However, on construct, I want the __construct method to set several class properties, some of which are not in the approved list. So when construct happens, and I do $this->var = $value, I of course get my exception that I'm not allowed to set that variable.
Can I get around this somehow?
Hi
im looking to find how to implement this scenario:
i have logic code that is inside function,
now i like to be able to execute this function in a separate thread.
now what i have is a raw implementation of this ..
i simple Init the Thread that in its Start/Run method i keep the function logic .
how can i make it more generic ? so i could send the function ( mybe function pointer )
to generic thread factory/pool ?
in c++
Hello
I'd like my dates in the mm/dd/year format in text fields. However, they currently displays as 2010-03-26.
Is there a global setting I can set to change this?
I tried the following, which seems to update the .to_s method, but form fields stay the same.
ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS.merge!(:default => '%m/%d/%Y')
Thanks
I wanted to set up a simple data communication between two C# applications, and I'm not sure what the best method is in doing so. I've previously used Java Sockets and ServerSockets to get the job done, but I'm new to C#, so I've come for advice :) It's going to be two way communication with two clients exchanging strings or something of the like.
I have a DELETE query which deletes a record from a mysql db.
is there any way to make sure if the delete was performed or not?
I mean, for a query to FIND stuff you do
$res=mysql_query($var);
$nr=mysql_num_rows($res);
and you get nr of rows returned.
Is there any similiar method for deletion of records?
Thanks
All I can find information on for the URLLoader object in Actionsript 3.0 involves loading XML files, which I don't want to do. I'm trying to load in a .txt file that I want to parse, line by line with each line being delimited by a comma. Anyone know a method of doing this or a place where I can find some information on how to do this? Thanks!
Lets us take instances of two classes
public abstract class Shapes
{
public abstract void draw(Graphics g);
}
public class Rectangle extends Shapes
{
public void draw(Graphics g)
{
//implementation of the method
}
}
here the class Rectangle has extended class Shapes and implicitly it extends class Object.I know no other extension is possible but cant we call inheriting classes Shapes and Object multiple inheritance?(Since inheriting two classes is multiple inheritance from one perspective)
What are some alternative methods to generate 1000 distinct random integers in the range [0,8000] as opposed to the following:
naive method: generating a number and checking if it's already in the array. O(n^2)
linear shuffle: generate sequence 0 to 8000, shuffle, take the first 1000. O(n)
I import oourafft.h and oourafft.m class, but get strange error while ooura initialize.
OouraFFT * myFFT = [OouraFFT initForSignalsOfLength:1024 numberOfWindows:10];
OouraFFT may not respond to +initForSignalsOfLength: numberOfWindows
Messages without matching method signature will be assumed to return 'id' and accept argument - Warning
I think that it some kind of error import .h file
When I run the following javascript in IE, I get "Error: Object doesn't support this property or method" on "data.every(...)".
It works in Chrome/Firefox.
I'm have difficulty adding a subview UIView from within the viewDidLoad method of a UITableViewController
This works:
[self.view addSubview:self.progView];
But you can see the table cell lines bleed through the UIView progView.
I've tried this approach:
[self.view.superview insertSubview:self.progView aboveSubview:self.view];
Which is an attempt to add the progView UIView to the superview, above the current view. When I try this I get this the UIView never appears.
Hi,
I'm having a bit of a strange problem with an application using the Files.probeContentType(path)-method to test for file type: On both my Ubuntu and Fedora systems, it works fine, but when moved to a RedHat Enterprise server (2.6.18-194.el5 #1 x86_64 x86_64 x86_64 GNU/Linux), it only returns null. I'm using java 7 early access (1.7.0-ea-b84). I have to use this version due to functionality that isn't included in 1.6.
Does anyone have an idea of what might be the problem here?
I have the following code block code when the document is ready:
$(document).ready(function() {
createDivs(); // creates some divs with class 'foo';
// iterate
$(".foo").each(function(index) {
alert(index + " - " + $(this).text());
});
}
I find that the "iterate" part misses the divs I created in the createDivs() method entirely! Is there some timing issue I'm not aware of? Why doesn't jquery see the divs that were just created?
Under what circumstances would java.util.zip.ZipFile.close() throw an IOException? Its method signature indicates that it can be thrown, but from the source code there doesn't seem to be any place where this could happen, unless it's in native code. What corrective action, if any, could be taken at the point where that exception is caught?