All my previous projects have had this workflow on Contact pages
User submits form
Controller gets $_POST details
Controller validates details (and sets error messages if necessary)
Controller sends email
Controller redirects to thanks page
Is this the standard workflow?
I used to validate everything in controllers, and then did some more reading and they recommended against it. Therefore, should I send the $_POST details to a helper type object and let it do all the work (validation/sending)?
Hello there,
I'm working with a page that has several links that contain the same href text, and I need to select the second anchor element on the page that contains said href text. Here's a simplified version of the link structure of the page:
<a href="same/link/to/stuff/">same link</a>
<a href="same/link/to/stuff/">same link</a>
How do I fashion my selector so that it only selects the second anchor in the above example?
Thanks!!
I am aware of array_walk() and array_map(). However when using the former like so (on an old project) it failed
array_walk($_POST, 'mysql_real_escape_string');
Warning: mysql_real_escape_string()
expects parameter 2 to be resource,
string given.
So I went with this slightly more ugly version
foreach($_POST as $key => $value) {
$_POST[$key] = mysql_real_escape_string($value);
}
So why didn't the first way work? What is the best way to map values of an array to a function?
How to make this method return boolean value, depending on query return. False - nothing, True - data exists. Before i just returned int from uniqueQuote.Count() but does not look like great method. Thank you!
private bool CheckEnquiryUser(int enquiryId, Guid userId)
{
int selectedEnquiryId = enquiryId;
Guid currentUserId = userId;
Entities ctx3 = new Entities();
var uniqueQuote = from quot in ctx3.Enquiries.Include("aspnet_Users")
where quot.EnquiryId == selectedEnquiryId &&
quot.aspnet_Users.UserId == currentUserId
select quot;
bool exist = uniqueQuote;
return exist;
Some mac apps, like iTunes and Spotify, react to the play/pause/next/previous buttons on some Apple keyboards.
Presumably they're tapping into some sort of NSNotification, how can I do the same?
let's say I have a list
li = [{'q':'apple','code':'2B'},
{'q':'orange','code':'2A'},
{'q':'plum','code':'2A'}]
What is the most efficient way to return the count of unique "codes" in this list?
In this case, the unique codes is 2, because only 2B and 2A are unique.
I could put everything in a list and compare, but is this really efficient?
I need a way to get user home directory in C++ program running on Linux. If the same code works on Unix, it would be nice. I don't want to use HOME environment value.
AFAIK, root home directory is /root. Is it OK to create some files/folders in this directory, in the case my program is running by root user?
Hi,
I'm looking at Silverlight architectures and RIA Services looks interesting, but I am a bit concerned about its prelease status and how the feature set will change.
We need our client app to be as responsive as possible over a slow network link, so a high priority is a solid sync system for pushing model state changes from the client back to the server. Will RIA Services help us in this regard or will I have to roll my own logic to do this ? Are there any other frameworks that can assist with this? Is the feature set involved in these requirements liable to change much in the next couple of months?
If it makes any difference, our frontend is 100% Silverlight, so we dont need to worry about exposing SOAP APIs from the server or anything like that. It appears to me that RIA so far is a bit more mature for Silverlight use. Is this correct?
After adding items, attempting to view my cart leads me to this error:
nil can't be coerced into Float
with the math line in this method in my line_item model highlighted:
def total_price
product.price * quantity
end
line items create action
def create
product = Product.find(params[:product_id])
@line_item = @cart.add_product(product.id)
@line_item.quantity = params[:quantity]
view
<div id= "text_field"><%= text_field_tag 'quantity' %> </div>
<%= button_to 'Add to Cart', line_items_path(:product_id => product) %>
This has held me back for a couple days. (I'm new). Thanks.
Hello everyone.
The Cocoa framework has a convention to always call self = [super init] in the init method of an inherited class, because [super init] may return a new instance.
What will happen if I do this?
@interface MyClass : NSObject /* or any other class */ {
int ivar_;
}
@end
@implementation MyClass
- (id)init {
ivar_ = 12345;
if ((self = [super init])) {
NSLog(@"ivar_'s value is %d", ivar_);
}
return self;
}
@end
In the case when [super init] returns a new instance, what will I see in the console? ivar_'s value is 0?
I can't think of a way to check this myself, because I don't know which class may return a new instance from its init method. Also, can't seem to find explicit clarification for this scenario in the docs.
Could anyone help me out? Thanks!
I am writing an abstract superclass where literally every method is going to be overridden. There is some default functionality I could implement, but most of the time it's enough to leave the implementation to the subclass writer.
Since just about every method is going to be overwritten, how much should I make virtual and how much should I just leave as regular methods? In the current incarnation, everything is virtual, but I still haven't let this loose to anyone to use, so the design is flexible.
What advantages/disadvantages are there to virtual functions? Links to good reading material about this would be appreciated.
I have a simple MySQL table thats contains a list of categories, level is determined by parent_id:
id name parent_id
---------------------------
1 Home 0
2 About 1
3 Contact 1
4 Legal 2
5 Privacy 4
6 Products 1
7 Support 1
I'm attempting to make a breadcrumb trail. So i have the 'id' of the child, I want to get all available parents (iterating up the chain until we reach 0 "Home"). There could be any number or child rows going to an unlimited depth.
Currently I am using an SQL call for each parent, this is messy. Is there a way in SQL to do this all on one query?
My program is written in C++. compiled with gcc, using -g3 -O0 -ggdb flags. When it crashes, I want to open its core dump. Does it create core dump file, or I need to do something to enable core dump creation, in the program itself, or on computer where it is executed? Where this file is created, and what is its name?
.NET contains its own equality comparison functionality, however I don't really understand how it works.
If the desired Equals() and == behaviour is to verify that every field of an object is equal to every field of another object, is it necessary to override Equals() with a method that does this explicitly?
Are you able to use open id to log into the local development server with google app engine sdk version 1.4.1 and python 2.5?
When I execute this
self.redirect(users.create_login_url(continue_url, None, openid_url))
I get redirected to http://localhost/_ah/login rather than the openid url.
The openid url and continue url are valid.
My app.yaml looks like this
- url: /_ah/login_required
script: do_openid_login.py
- url: /users/(.*)
script: routers/user_router.py
login: required
If I browse to http://localhost/users/ I am also redirected to http://localhost/_ah/login rather than http://localhost/_ah/login_required
Is there a config issue or does openid not work locally?
I have to develop a new (desktop) app for a small business. This business currently has an Access database with millions of records. The file size is about 1.5 GB. The boss told me that searching on this DB is very slow. The DB consists of a single table with about 20 fields.
I also think the overall DB design isn't great. I thought to use another DB server with a new design to improve both performance and efficiency.
Considering this is a relatively small business, I don't want to spend much for a DB license, so I want to ask you what would you do.
Continue to use Access, maybe improving and optimizing the DB in some way
Buy a DB server license (in this case, which one?)
? (any idea?)
I have noticed that the quality of the images produced by the JPEGEncoder does not match that of other encoders available (i.e. php's built in image compression functions from the gd library)
Any explanation ? or hints/workarounds for improving the quality of compressed images by JPEGEncoder ??
With a long but plain html document opened on a mobile device (webkit), how do I ensure that text doesn't crop vertically when scrolling?
I think this should be possible by either adjusting line spacing or adding extra padding.
TIA.
Hi:
My program uses sockets for inter-process communication. There is one server listening on a socket port(B) on localhost waiting for a list of TCP clients to connect. And on the other end of the server is another a socket(A) that sends out data to internet. The server is designed to take everything the TCP clients send him and forward to a server on the internet. My question is if two of the TCP clients happened to send data at the same time, is this going to be a problem for the server's outgoing socket(A)?
Thanks
Hi, I'm trying to use the PageFormat information to modify my javax.swing based printout prior to printing it. I am stumped as to how I can get the PageFormat from the PrintJob (which is obtained using getPrinterJob() and printDialog()). I know there is the getPageFormat method, but I can't figure out how to get the PrintRequestAttributeSet (which is not the printJob.getPrintService().getPrintAttributes()). Honestly, all I really want to know is the width and height of the page. Any ideas on how I can do that? Thanks.