Hi
I am trying to get the IP address of the website visitor in PHP. I'm expecting $_SERVER['REMOTE_HOST'] to return something like 127.0.0.1, but it's returning ::1.
Kind regards
Peter
Hi folks,
I have been playing with other frameworks, such as NodeJS, lately.
I love the possibility to return a response, and still being able to do further operations.
e.g.
def view(request):
do_something()
return HttpResponse()
do_more_stuff() #not possible!!!
Maybe Django already offers a way to perform operations after returning a request, if that is the case that would be great.
Help would be very much appreciated! =D
I have this element:
<div class="isthisyou" id="unique_identifier"></div>
I want to use jQuery to insert a link into the div:
$('isthisyou').append('<a href="auth/create_account/'+this.id+'">Is this you?</a>');
Right now this.id is returning undefined instead of unique_identifier. What am I doing wrong?
Thanks!
I have a collection with an index on :created_at (which in this particular case should be a date)
From rails what is the proper way to save an entry and then retrieve it by the date?
I'm trying something like:
Model:
field :created_at, :type = Time
script:
Col.create(:created_at = Time.parse(another_model.created_at).to_s
and
Col.find(:all, :conditions = { :created_at = Time.parse(same thing) })
and it's not returning anything
I have an seen how NSXMLDocument can parse and html document, and provide easy methods for returning parts of the html structure.
Is there a similar method that can be used for the iPhone, as NSXMLDocument is not available?
If I have a HTTP based RESTful service and I want to POST a search resource and use the PRG pattern for returning the URL to the search-result resource, I have to persist the search-result resource on the server.
Is this a good idea?
If I do persist the search-result resource how long is it persisted for?
Can I control this by a HTTP header of some kind?
Cheers
AWC
I'm using MonoTouch. When I rotate to LandscapeRight/Left I want to change the location of some of my buttons but I'm not having any success. I'm replacing the button.Bounds with a new rectangleF and setting that value in the WillRotate, but that's not working.
I am returning true in my ShouldAutorotateToInterfaceOrientation handler.
In principal what I'm trying to do is allow as much as possible to automatically rotate but then fix a couple of buttons that end up in a bad place.
What is the best or most concise method for returning a string repeated an arbitrary amount of times?
The following is my best shot so far:
function repeat(s, n){
var a = [];
while(a.length < n){
a.push(s);
}
return a.join('');
}
In ASP.Net MVC action methods can return json objects simply by returning something like so:
JSon([whatever])
How do I return a JSon representation of say List<String> with webforms either through a service or through a method in the code behind of an aspx page? This seems incredibly confusing compared to ASP.Net MVC.
Is there a way to specify code to be run whenever an error occurs in Matlab? Googling I came across RunTimeErrorFcn and daqcallback, but I believe these are specific to the Data Acquisition Toolbox. I want something for when I just trip over a bug, like an access to an unassigned variable. (I use a library called PsychToolbox that takes over the GPU, so I want to be able to clear its screen before returning to the command prompt.)
I was wondering if there is a way to depict that, on an activity that has a decision; one of the branches completely terminates with the activity. This would be similar to a subroutine just returning control to the invoker when a condition is met.
sub activity() {
...
...
if ( condition ) {
...
} else {
return;//This branch finishes the activity
}
...
}
Thanks,
Carlos
Are there known issues with navigator.onLine on Android 2.1? I have a Droid on airplane mode, but navigator.onLine appears to be returning true anyway. (I'm using an HTML manifest to cache the page, and its behavior works fine in Mobile Safari and Firefox in offline mode.)
I'm trying to iterate through an array of elements. jQuery's documentation says:
jquery.Each() documentation
Returning non-false is the same as a continue statement in a for loop, it will skip immediately to the next iteration.
I've tried calling 'return non-false;' and 'non-false;' (sans return) neither of which skip to the next iteration. Instead, they break the loop. What am i missing?
Hello all ,
I am using this function SQLRTTESTCONNECTION2() to connect to SQL server.
Its returning me as value 1 ,which means failure to establish a connection.
What could be possible cause for this?Any ideas please?
Hello,
gcc 4.4.2 c89
I have the following enum:
enum drop_options_e
{
drop_ssm,
drop_snm,
drop_ssb
};
I am just wondering that is the best way to get the string representation value from the enum.
So basically, instead of returning the value of 0 for drop_ssm, I could get the 'drop_ssm' instead.
Many thanks for any advice,
I want to check if user input a positive integer number.
1 = true
+10 = true
.1 = false
-1 = false
10.5 = false
Just a positive number.
No characters.
No special character.
No dot.
No minus sign.
I tried is_int() function but it is returning false even on positive integers. Is there a string to int problem?
Thanks
Is it possible to query App Engine's Datastore from outside the cloud, i.e. a client application?
I could possibly write an app to be housed within AppStore and query the Datastore returning XML-formatted data; I want to know, however, if there are any Datastore endpoints which would allow me to do it directly.
Also, in case it is possible, am I able to do so via SSL?
I am wondering what the idiomatic way to render special language characters is using Handlebars.js templates. When I render the normal html I can use something like the Spanish lowercase e, é, and it renders as expected. When I pass the same text as a string to my Handlebars template I just see the characters é.
I have tried creating a Handlebars helper that used jquery to render the text using .html() then returning the .html() of the tmp element and I get the same results.
I have a simple standalone model that doesn't inherit from ActiveRecord or anything else, called SmsSender. As the name suggests, it delivers text messages to an SMS gateway.
I also have an ActiveRecord model called SmsMessage which has an instance method called deliver:
def deliver
SmsSender.deliver_message(self)
self.update_attributes :status => "Sent"
end
The above is returning uninitialized constant SmsSender. I'm sure this is dead simple, but how can I access the SmsSender class from within my model?
I have inside a controller
PostLogicController.cs
public ActionResult GetCreateNormalPost()
{
return PartialView("CreateNormalPost", null);
}
CreateNormalPost is inside the folder Post (which belongs to another post controller). How do I go about returning the CreateNormalPost.ascx?
My folders are structured as follows:
Controllers
PostController.cs
PostLogicController.cs
Views
Post
Index.aspx
CreateNormalPost.ascx
There is no folder for PostLogicController.
I'm trying to get Fiddler to work with my company's proxy. Every external request is returning 407.
So far I've tried adding oSession.oRequest["Proxy-Authorization"] = "YOURCREDENTIALS"; to the customized rules where I used my USERNAME:PASSWORD in base64. Still no luck.
Any ideas? Thanks.
What's the HTML character entity for the # sign? I've looked around for "pound" (keeps returning the currency), and "hash" and "number", but what I try doesn't seem to turn into the right character.
I am learning how to write test cases using Rspec. I have a simple Post Comments Scaffold where a Post can have many Comments. I am testing this using Rspec. How should i go about checking for Post :has_many :comments. Should I stub Post.comments method and then check this with by returning a mock object of array of comment objects? Is testing for AR associations really required ?
In perl suppose I have a string like 'hello\tworld\n', and what I want is:
'hello world
'
That is, "hello", then a literal tab character, then "world", then a literal newline. Or equivalently, "hello\tworld\n" (note the double quotes).
In other words, is there a function for taking a string with escape sequences and returning an equivalent string with all the escape sequences interpolated?
I.e.
Month Returns
January 1
February 2
March 3
April 4
May 5
June 6
July 7
August 8
September 9
October 10
November 11
December 12
I've seen examples using mktime when given the number of the month and returning the month string, but not the reverse.