So I made my first iphone application; I want to test for memory leaks and the general feel and design of the user interface, so how do I put it on my iphone?
How can I reduce the amount of similar commands into a loop?
Something like
pictureBox7.BackColor = Color.FromArgb(187, 187, 187);
pictureBox9.BackColor = Color.FromArgb(187, 187, 187);
pictureBox10.BackColor = Color.FromArgb(187, 187, 187);
pictureBox11.BackColor = Color.FromArgb(187, 187, 187);
pictureBox12.BackColor = Color.FromArgb(187, 187, 187);
pictureBox13.BackColor = Color.FromArgb(187, 187, 187);
G2g for now, will add on later.
Consider this very simple logging class:
class MockLog
def self.log_stub_method(*args)
args.each do |a|
define_method "#{a}" do |msg|
t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
$stderr.puts "[#{a.upcase}] \u00bb [#{t}] #{msg}"
end
end
end
log_stub_method :fatal, :error, :warn, :info, :debug
end
Let's add logging to all our classes:
class Module
def has_logging()
class_eval {
@log = MockLog.new
def log
self.class.instance_variable_get :@log
end
}
end
end
Now, why doesn't this work?
class Foo
has_logging
end
Foo.new.log.nil? # => false, as expected
class Bar < Foo
end
Bar.new.log.nil? # => true?! Why wasn't the `log` method inherited?
Trying to figure out how to install rails plugins manually on windows so I have a few questions.
What does the directory need to be named in vendor/plugins? Is it arbitrary or is it linked to something within the plugin config files or is that what you set in the environment.rb?
Once I've copied the files to the correct directory, do I always need to run something inside like init.rb or is it good to go?
What's the difference between 'require' and 'include'?
Thanks!
With the latest changes to the developer agreement by Apple, how inherant is the risk of using any kind of framework to develop Apps for devices now? Should shops risk using things like MonoTouch, Three20, Appcelerator since this change?
How are some iPhone/iPad developers here handling it?
http://www.pcworld.com/article/193916/apples_new_iphone_app_policy_unreasonable_and_unjustifiable.html
http://www.wired.com/gadgetlab/2010/04/iphone-flash-policy-steve-jobs/
http://37signals.com/svn/posts/2273-five-rational-arguments-against-apples-331-policy
No matter the cin it continues to to output 0 for score. Why is that? I tried returning the "return 0;" but still no go :/
#include "stdafx.h"
#include <iostream>
using namespace std;
// Variables
int enemiesKilled;
const int KILLS = 150;
int score = enemiesKilled * KILLS;
int main()
{
cout << "How many enemies did you kill?" << endl;
cin >> enemiesKilled;
cout << "Your score: " << score << endl;
return 0;
}
//Table select
$("#reports-table tr").click(
function() {
var detail_id = $(this).attr('id');
$(this).addClass("selected");
$(this).siblings().removeClass("selected");
$('#reports-right').show().load('/members/details/'+detail_id);
$('#reports-table').width(680);
}
);
I currently am using this code to add a selected class to a table row and show details of the row clicked in a right 'aside'. The problem is, I have action buttons in the row--when they are clicked, becausee they are children of the tr, this function still runs...
How can I exclude a certain class?
Hi,
I am trying to have an EditText widget next to a button with a text view underneath. The EditText should resize and fill the screen accordingly, while the button's width is always only what it needs to be by setting the width to wrap_content.
The layout should not be relative. Below is the code I have so far some of which was found here on StackOverflow. Removing the text view gives the desired appearance for the EditText and button, but when the TextView is added the view goes to ... well.
Not sure why the code is not showing? I put it into a < code< pre block without success.
http://pastebin.com/WgH6qrTm
Hi!
I'm learning HTML and I wanted to practice by recreating a invoice sent to me by Electronics Expo.
However, I used the background-image property and repeated it by repeat-x and now, the background stretches across the page so much that it has a horizontal bar to drag.
http://htmlpocketreference.110mb.com/index.html
You can see what I did in my link above.
Also, I would really appreciate some advice on simplifying my CSS coding. It seems really messy and I have to move every element once something changes. -.-
Thanks!
for (Player p : players)
{
p.addCard(deck.dealCard());
p.addCard(deck.dealCard());
}
and
for (int i = 0; i < players.size() ; i++)
{
Player p = players.get(i);
p.addCard(deck.dealCard());
p.addCard(deck.dealCard());
}
The second code yeilds a null pointer exception, what can be done to make the bottom one equivalent ?
I have the following at the top of my view:
<%= GMap.header %>
Heroku is giving me an ActionView::TemplateError on that line.... this works on my own machine but not on Heroku.... why is that? Is there something about Heroku that doesn't allow?
In the final compile on the browser, the above code translates into this on the client side:
<script src="http://maps.google.com/maps?file=api&v=2.x&key=XXXXX;hl=&sensor=false" type="text/javascript">
</script>
<script src="/javascripts/ym4r-gm.js" type="text/javascript"></script>
Added the for the facebook badge to the site and now it's thrown my placement for the footer off .. it's working fine in Chrome, but IE, FFox and Opera all experiencing problems...
Here is a screenshot:
The footer (brown bar) is supposed to be at the bottom...
Here is the CSS :
/* footer */
#footer{
background:url(../images/bg-footer.png) no-repeat;
height:26px;
overflow:hidden;
padding:35px 0 0 55px;
font-size:11px;
}
#footer p{
margin:0;
display:inline;
color:#766623;
}
#footer ul{
margin:0;
padding:0;
list-style:none;
display:inline;
}
#footer li{
display:inline;
background:url(../images/sep-f-nav.gif) no-repeat 100% 55%;
padding:0 6px 0 0;
position:relative;
}
* html #footer li{
padding:0 3px 0 3px;
}
*+html #footer li{
padding:0 3px 0 3px;
}
#footer a{
color:#30481f;
text-decoration:none;
}
#footer a:hover{
text-decoration:underline;
/*Facebook badge Holder*/
.fb-area{
width:287px;
padding:0 0;
margin:0 0;
min-height:100%;
}
What's the best way to prevent a dictionary attack? I've thought up several implementations but they all seem to have some flaw in them:
Lock out a user after X failed login attempts. Problem: easy to turn into a denial of service attack, locking out many users in a short amount of time.
Incrementally increase response time per failed login attempt on a username. Problem: dictionary attacks might use the same password but different usernames.
Incrementally increase response time per failed login attempt from an IP address. Problem: easy to get around by spoofing IP address.
Incrementally increase response time per failed login attempt within a session. Problem: easy to get around by creating a dictionary attack that fires up a new session on each attempt.
I have a text file made of 3 lines:
Line 1
Line 3
(Line 1, a blank line, and Line 3)
vector<string> text;
vector<string>::iterator it;
ifstream file("test.txt");
string str;
while (getline(file, str))
{
if (str.length() == 0)
str = "\n";
// since getline discards the newline character, replacing blank strings with newline
text.push_back(str);
} // while
for (it=text.begin(); it < text.end(); it++)
cout << (*it);
Prints out:
Line 1
Line 3
I'm not sure why the string with only a newline was not printed out. Any help would be appreciated. Thanks.
I need to access the users location in this method contained in the mainViewController
-(void)loadAnnotations{
[mapView removeAnnotations:mapView.annotations];
CLLocationCoordinate2D workingCoordinate;
workingCoordinate.latitude= //here i need the users latitude
workingCoordinate.longitude= //here i need the users longitude
NSLog(@" this is %@", workingCoordinate.latitude);
iProspectLiteAnnotation *tempMine = [[iProspectLiteAnnotation alloc] initWithCoordinate:workingCoordinate];
[tempMine setTitle:@"Present Location"];
[tempMine setAnnotationType:iProspectLiteAnnotationTypeUser];
[mapView addAnnotation:tempMine];
}
however the mainViewController is already set to
<fipsideViewControllerDelegate>
What should I add to the header file and the implementation file to poll the location Manager for the users current latitude and longitude?
I'm using Doctrine 2 with my Zend Framework application and a typical query result could yield a million (or more) search results.
I want to use Zend_Paginator in line with this result set. However, I don't want to return all the results as an array and use the Array adapter as this would be inefficient, instead I would like to supply the paginator the total amount of rows then and array of results based on limit/offset amounts.
Is this doable using the Array adapter or would I need to create my own pagination adapter?
I've been searching around for a few weeks now for a tool that either is fully built or a direction of something I could build for dynamically extracting data via a web interface. Basically, what I'm looking for is a way to give users a list of all available data objects from our database and then let them pick ones from the list they'd like to view and set parameters then export the results to an excel file.
Right now we're doing it purely with SQL statements but we have hundreds of objects so as you might imagine, those statements are really complex and prone to errors. It would be great if there was a tool available to do this or if someone had an idea of an easy way to organize this. Any help would be greatly appreciated.
We've looked at BI tools like QlikView and Tableau but that is probably overkill for what we're trying to do. The open-source BI tools we've looked at seemed really primitive in their functionality. The other thing we looked at was MSAS (our DB is SQL Server) but I'd prefer something that was more database-agnostic and lived on a web server instead of on the database.
I can't get around an issue instantiating a new class by using a string variable and PHP 5.3. namespaces. For example, this works;
$class = 'Reflection';
$object = new $class();
However, this does not;
$class = '\Application\Log\MyClass';
$object = new $class();
A fatal error gets thrown stating the class cannot be found. However it obviously can be instantiated if using the FQN i.e.;
$object = new \Application\Log\MyClass;
I've found this to be aparrent on PHP 5.3.2-1 but not not in later versions. Is there a work around for this?
Hello,
I am trying to access a Linux system's NOR flash memory. I tried use __raw_readl(xxxxx) (through io_p2v) to read NOR memory data, but I failed.
Is there any way I can access that memory?
Will driver /dev/mem work for this? I guess not. it is only for the RAM maybe.
Can anyone help?
I hosted a QWinWidget in a CView and want it to stay at a designated position when resizing. But QWinWidget always moves to (0, 0), i.e. left-top corner of the CView.
I tried to debug in this way:
QWinWidget* pWidget = new QWinWidget(pCView);
pWidget->move(50, 50);
QPoint pos = pWidget->pos();
Note that: the pos is always (0, 0).
Why is that?
I have a standard query that gets the current user object:
@user = User.find_by_email(session[:email])
but I'm putting it as the first line in every single controller action which is obviously not the best way to do this. What is the best way to refactor this?
Do I put this as a method in the Application controller (and if so, can you just show me a quick example)?
Do I put the entire @user object into the session (has about 50 columns and some sensitive ones like is_admin)?
Or is there another way to remove this kind of redundancy?
I don't even know if that's the right term.
May it be known that I'm a major novice!
I have three tables: users, profiles, and survey. Each one has user_id as it's first field, (auto-increment for users), and they're all tied by a foreign key constraint, CASCADE on DELETE.
Currently, for each user, let's say user_id 1, they have a corresponding db entry in the other tables. For profiles it lists all their information, and the survey table holds all their survey information.
Now I must change things...darn scope creep. Users need the ability to have multiple survey results. I imagine that this would be similar to a comment table for a blog...
My entire app runs around the idea that a single user is linked to a constraining profile and survey.
How should I structure my db?
How should I design my app's db so that a user can have multiple tests/profiles for the test?
Please assist! Any advice, information and personal-knowledge is appreciated!
Right now the only way I know how to accompany my client is to create a pseudo-user for each test (so unnecessary) and list them in a view table (called "your tests")-- these are obtained from the db by saying: where user_id=manager_id
Deleting or moving rows for a UITableView that is backed with local data (e.g., NSArray) is easy and instantaneous:
Remove the value from the array.
Call deleteRowsAtIndexPaths:withRowAnimation:.
Profit!
But my table view communicates with a web service, which means once the "Delete" button on that row gets tapped, I have to forward a request on to the server (via ASIHTTPRequest, of course), get the response, and then tell the table view to run its little delete-row animation, all with a few seconds of latency in between.
From a high-level, what's the best way to do that? Throw some callback selector into ASIHTTPRequest's userInfo dictionary? KVO?
Bonus points for some nice UI touch, like some kind of spinner on the soon-to-be-deleted cell.
I want to create a Rails 3 route with entirely optional parameters. The example route is:
match '(/name/:name)(/height/:height)(/weight/:weight)' => 'people#index'
The route works if I specify it as:
match '/people(/name/:name)(/height/:height)(/weight/:weight)' => 'people#index'
But I want to have this as the root URL. Thanks.
I have this design:
public interface IFactory<T> {
T Create();
T CreateWithSensibleDefaults();
}
public class AppleFactory : IFactory<Apple> { ... }
public class BananaFactory : IFactory<Banana> { ... }
// ...
The fictitious Apple and Banana here do not necessarily share any common types (other than object, of course).
I don't want clients to have to depend on specific factories, so instead, you can just ask a FactoryManager for a new type. It has a FactoryForType method:
IFactory<T> FactoryForType<T>();
Now you can invoke the appropriate interface methods with something like FactoryForType<Apple>().Create(). So far, so good.
But there's a problem at the implementation level: how do I store this mapping from types to IFactory<T>s? The naive answer is an IDictionary<Type, IFactory<T>>, but that doesn't work since there's no type covariance on the T (I'm using C# 3.5). Am I just stuck with an IDictionary<Type, object> and doing the casting manually?