« first day (1416 days earlier)      last day (3526 days later) » 

ASR
11:00 AM
@Sippy ok thanks i am beginner, started learning
@towc thanks
 
That's okay, you need to make sure that all your elements have closing tags. For now, it's easier to make sure that every time you use a tag, such as <div>, you also close it, using for example </div>.
When you get more used to it you will learn that some can be closed in the initial tag, like img tags etc, <img src="example.png" />
 
!!nudge 37 get wrecked!
 
@towc Nudge #1 registered.
 
lol.
gl towc
 
thx
 
ASR
11:04 AM
@Sippy ok
 
11:21 AM
what? 2048 done in 4 minutes (no AI)? is this a world record?
 
wat
that's nuts.
 
apparently the wr is 1:34 :(
probably done randomly and hoped for it to work
 
Nah
I think if you work out probability of random moves solving that game
It'd be like 1 in 10 billion or something
Maybe more
 
probably not random, but likely used an AI
 
46
Q: Probability that random moves in the game 2048 will win

N. OwadI have recently played the game 2048, created by Gabriele Cirulli, which is fun. I suggest trying if you have not. But my brother posed this question to me about the game: If he were to write a script that made random moves in the game 2048, what is the probability that it would win the game?...

Roflmao
That happened
 
11:28 AM
XD
 
I think 1:34 sounds human enough
Pretty incredible though
 
this is 1:36
can't really tell if sped up or not
but doesn't look like it
I think that a lot of luck is involved
 
Some luck based on where tiles spawn
True.
I think that's an AI
Movement is too fast for human .. lol
 
@Sippy even tho at some points it waits... something an AI wouldn't do
 
Could be calculating
It looks extremely efficient
Unless it's ported to PC and they're just using arrow keys
Then fair enough
 
11:31 AM
of course it's on pc
I only play it on pc only
 
Oh haha
 
also, if the script would stop for calculations the css animation would be delayed
lol
dice bucket challenge
 
Hello all
 
@towc At least they didn't waste any water lol
 
Can I discuss jQuery here, the jQuery room is inactive
 
11:38 AM
Yes.
 
Thanks sippy
 
But @monkeyinsight might attack you
He doesn't like Jquery.
 
neither do I actually
 
Well I think I need some advice from you experienced people
 
ok, go on
 
11:40 AM
I have developed a application using wxPython and python
it is a desktop app
It is a GUI app with images and buttons
and upon clicking a button
a request is made to a server and
the server returns a value
that value is diaplyed in a text area in my gui
 
@towc nudge get wrecked!
 
also this value is updated every second
 
!!nudge 10 not too fast
 
@towc Nudge #2 registered.
 
Did I do something wrong?
 
11:42 AM
show us the code
 
@ρss Is that your question, pss?
 
No that app is already completed by me
it a wxpython and python product
My question is now my boss wants a similar web app
So I need some advice where to begin with
I read here and there on internet abt jQuery for interface development
I have created my web interface using CSS, html and jquery already
Now I want to do the server stuff
 
> CSS, html and jquery
 
Okay
 
I want to make queries to the server and get the response and display them in the text area of my web app
 
11:45 AM
So you haven't connected your web app to the back end at all?
 
I am stuck here
I think i need ajax
 
You just have html pages that link to eachother?/
 
@ρss that's what most web applications do yes
@ρss doing ajax requests is one way to do that indeed
you send a request to the server and get a response
what's the problem?
 
For eg: my server has an API
I just need to visit some url like eg: 192.168.150.0/location
then it returns some json data
 
$.getJSON("http://192.168.150.0/location).done(function(data) { ... });
 
11:47 AM
I just need it to be displayed on the text area in my web gui
$.getJSON("http://192.168.150.0/location).done(function(data) { ... }); this exactly isn't working unfortunately
I need to authenticate first
 
Authenticate using what?
 
So I made a query like : $.ajax( {
url:'https://192.168.150.33:443'
username: 'admin'
password: 'password'
})
 
ok, going to do the exam!
 
GL TOWC!
 
By authenticate I mean, if I visit the link in a web browser I first have to enter username and password
and then if authenticated
 
11:49 AM
Forms authentication then
 
I can visit the url without authentication, untill i close my browser
 
What web tech are you actually using?
Just javascript, html and css?
On static pages?
 
yes
I just watched tutorials on these topics
 
@ρss how do you handle authentication
is it HTTP auth or your own auth
 
it is https
 
11:51 AM
0
Q: return a promise from inside a for loop

Maurizio In denmarkI have a recursive function and I am trying to make it run in sequence, returning the promise every time. The code is recursive and works well but works only for the first item in the for loop. Example: folder: 1 - OK folder: 11 - OK folder: 111 - OK folder: 111 - OK folder: 2 - NOT OK ...

 
@towc nudge not too fast
 
for example if I go to the server like https:// serverip/api
it will prompt for username and password
I enter the credentials and it will display the json data
 
95
Q: How to use Basic Auth and Jquery and Ajax

PatrioticcowI am trying to create a basic auth through browser, but I can't really get there. If this script won't be here the browser auth will take over, but I want to tell the browser that the user is about to make the authentication. The address should be something like: http://username:password@serve...

 
then by chaning the urls I can get data for different locations
@BartekBanachewicz In my case I don't have a unique url for login
This is a dummy method: I have a button in my page and here is the script:
$('#mybutton').click(function(){
$.ajax( {
url:'https://192.168.150.0/api'
username: 'admin'
password: 'password'
})
.done(function() {
alert( "second success" );
})
.fail(function() {
alert( "error" );
})
.always(function() {
alert( "finished" );
});
});
It always alerts 'error'
 
Is that your exact code?
 
11:58 AM
yes, I am not sure if it is correct just read few tuts and topics in internet
the url is full address with https:// serverip/api
 
$.ajax( {
    url:'192.168.150.0/api',
    username: 'admin',
    password: 'password'
})
commas after things in ajax.
 
ok wait
 
Programming becomes a compulsory subject in british schools, lol
 
@Connor Seriously?
 
yeah
 
12:00 PM
Oh good
Let's hope they don't teach them about SO.
 
@Sippy there in no effect
 
For those of you who don't know
Key Stage 1 ends at age 7
Or 8
Create and debug by age 8
I'm gonna be out of a fucking job.
 
it starts at 5 actually
 
12:02 PM
And ends at 7 or 8 ..
 
that's what i've heard anyway
 
@Sippy
What I understand is
$.ajax( {
url:'192.168.150.0/api',
username: 'admin',
password: 'password'
}) this will log me in to the server? But how to get the result back from server?
 
pay of programmers might then decrease lol
 
OHHHHHH
 
@ρss success: function(){}
 
12:03 PM
@ρss You need success method
Can you imagine primary school teachers teaching programming though .. hahahaha
 
$.ajax( {
url:'192.168.150.0/api',
username: 'admin',
password: 'password'
}).success(function(response){})
 
@Johnny000 Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
Or not, if not knowing if it finished or failed is not important to you and you are a disgusting human being
 
@Johnny000 No....
 
:(
 
12:04 PM
$.ajax( {
    url:'192.168.150.0/api',
    username: 'admin',
    password: 'password',
    success: function() {}
})
 
$.ajax( {
    url:'192.168.150.0/api',
    username: 'admin',
    password: 'password',
    success: function() { alert('success!'); }
})
 
why not use the chaining?
 
I am doing exactly and it doest alerts anything
 
or success: function() { alert('congratulations! you copied and pasted the code correctly!') }
 
@AwalGarg lol
 
12:06 PM
$.ajax( {
    url:'192.168.150.0/api',
    username: 'admin',
    password: 'password',
    success: function() { console.log('success!'); }
})
 
xD ^ such an awesome change.
 
I can login via web browser but why this script can't do that
 
@Johnny000 Because the following method gets called on whatever gets returned from $.ajax, which is probably $
 
@ρss try method: 'POST'
 
ok
 
12:07 PM
Even if it returned a promise, you couldn't simply follow up with a call to the success method, you'd have to call "then" and pass the callbacks to it
 
I strongly suspect dropping the $ and using Vanilla would make it work.
 
@Neil i see thx
 
Same thing with POST
no alert
 
That's simply how javascript works, since an ajax request isn't synchronous, so it can't be called directly but rather be called
 
12:09 PM
@Sippy I was wondering what was going to keep idiots from doing document.body.innerHTML = 'www.goatse.com';
 
@Neil Banhammers, I guess.. there's quite a lot of mods on SO.
 
@Sippy A guy could get through many questions by then. I still think it could be abused
Maybe they're using a library that prevents such things
or maybe they're using iframes
 
@Neil It could, I agree. They could also redirect.
 
@Connor I tried POST and it is same, no alerts
 
@ρss learn to debug then
 
12:11 PM
@Neil they're using iframes afaik
 
XHR ftw
 
@ρss Then it must be failing
 
how can it fail
 
@Sippy The intention behind the idea was noble no doubt, but the idea is crap. The editor they provide sucks and so many threats that solving them would impose unintentional limitations at best. Just let embed jsfiddle...
 
If it fails ..
There are a lot of reasons.
 
12:12 PM
I can login via web browser
I used same credentials
 
@AwalGarg I did just think why didn't they just allow embedding of the solution which already works ..
 
@ρss Add an error function like you did with success, see if it alerts anything then
 
hi
 
yes it does
I did it earlier with Sippy
 
Well there ya go
What type of http error code did you get?
 
12:13 PM
please wait
I have to di it again#
 
error: function (XMLHttpRequest, textStatus, errorThrown) {
							alert(textStatus);
						}
Wrong one not paying attention
 
@ρss In case you don't already know, you can use the network tab in dev tools to inspect the requests made and their response too.
 
And that.
And the console.
For programmer errors
 
Asynchronous actions have always been rather difficult to debug, javascript or otherwise
 
@ρss error: function (xhr, ajaxOptions, thrownError) { alert(xhr.status); alert(thrownError); }
 
12:16 PM
@Neil why?
 
Moreso if there is a chance of failing
@AwalGarg Because if you could just step over the line causing the error, it would be a lot more transparent..
 
@Sippy thanks

the error code is 0
 
Response is empty
 
@ρss Http error code is 0?
That isn't a valid code is it?
 
Yeah
It means it was accepted and gracefully closed
 
12:17 PM
@Neil I usually make the server send a lot of debug information which helps.
 
I thought that's what 200 meant
 
Ok, I am just learning from you all guys
 
200 is ok
Which means the response isn't empty
As in, the server responded, instead of closing the connection
 
@AwalGarg So you have to dedicate a lot more energy to be able to make debugging easy.. I consider the whole process difficult just the same
 
Hu ? Are you guys talking of http status code ? There's no 0
 
12:19 PM
A server gave me a -50 once. I looked it up and apparently -50 http error code means you did something incredibly stupid
 
@dystroy xhr uses 0 when there's no internet connection
 
@Neil It's just ok for development. Also, I don't like a lot of ajax on the same page. I have dealt with some lite amount of them so maybe it was easier for me...
 
@Neil Haha, what did you do? :D
 
@Sippy Just kidding :P
 
^absolutely no 0 exists
 
12:21 PM
@Neil Fuck.
 
@Neil hey you can't just kid like that... I thought you were serious.
xD
 
Though the server can return whatever the hell it wants, even if it isn't kosher
 
Not sure if negative values are allowed, but I could put error code 999 if I wanted
That said, don't do that ever
 
oh yeah... with PHP, I was once experimenting and did - header("Resource: The answer is", 42); :P
 
12:23 PM
http is fairly flexible on that point. Whatever it doesn't understand, it ignores and sends it anyway
Assuming it is in the proper format of course
 
@Neil but be careful when dealing with boundary values for multipart form data. You specify one wrong character and boom!
 
Well this also retuns 0:

$('#mybutton').click(function(){
$.ajax
({
type: "GET",
url: "https://google.com",

success: function (){
alert('Thanks for your comment!');
},
error: function (xhr, ajaxOptions, thrownError) { alert(xhr.status); alert(thrownError); }
});
});
 
@AwalGarg A lot of programming = specify one wrong character and boom .. :P
 
I would like to see browsers support more http actions other than the traditional GET, POST, PUT, DELETE, etc.
 
like what?
 
12:25 PM
^
 
It should support any action word in theory
 
like FUCK
 
like "SYNC" or "UPDATE"
 
Most browsers in most contexts don't really need to implement any other verbs do they?
 
PENETRATE
 
12:26 PM
whatever you want. write the server to understand such commands
http supports any method word, though browsers generally won't
 
var xhr = new XMLHttpRequest();
xhr.open("siteName", 'FUCK');
 
Is it common to use node.js integrated in PHP ?
 
@Sippy Well lets say that the ones that are available cover 95% of my cases
 
@AwalGarg use the LOTION first
 
If it doesn't, rather than use GET, I just use POST instead or something, it isn't ever really a big deal
 
12:27 PM
@Johnny000 hahaha sure.
 
though it would be nice to write methods according to what you're actually doing
 
@Neil So why implement new verbs?
Mm
Programmers do love verbosity.
 
Well I don't mean to establish new verbs, I just mean to let the programmer write whatever he wants
 
j/k
 
I want an excuse to use this
 
12:29 PM
xD
 
Stuck on web forms project atm
much cri
 
Let the current verbs have well-established meanings, and verbs that don't conform to those have whatever name the programmer wants
 
@Sippy hard coded forms are the best. Don't be lazy.
 
@AwalGarg Back under your bridge, you.
 
@Sippy hahahaha... nope.
 
12:30 PM
:P
 
POST generally never means "just pass data to the server", which is what it was initially intended
 
but you can try machform (its commercial though).
@Neil Even HTML has changed from what it was intended to be, so that's fine.
 
@AwalGarg It's a legacy app and I cannot be bothered rewriting it. :(
 
@AwalGarg True, but it seems if the protocol http allows it, I should be able to use http that way
 
@Neil But then, we would miss a lot of cool things. You can't get something for nothing.
 
12:34 PM
@AwalGarg Like what?
 
The way AJAX is normally used now (in forms specially), things would have to change.
@Neil It has to do with the internal processing of the code, which I don't know much about.
 
vs7
Hi ,
 
Hi ,
 
Nah. The whole reason GET, POST, PUT, DELETE formed was because allowing any possible action was too flexible. People needed a set of values in order to build a standard around. We've gone from creating these methods for convenience to making these the only allowable methods
 
vs7
how can i convert: page/2

into

array([0]=>page,[1]=>2)
 
12:36 PM
I'm saying, dont' do away with GET, POST, PUT, DELETE. Just allow other verbs
 
@vs7 IIRC, that is the objective array syntax for PHP, isn't it?
 
@Neil Better worded, you mean allow custom verbs.
It'd make way for a whole new generation of misnamed verbs! :D
 
vs7
@AwalGarg sorry for that I need that page/2 into JS array
something like php explode
 
@Neil I guess that might be feasible, but don't you think with a simple addition in the request sent, we can tell the server that this is a request for an UPDATE... and then the server can behave accordingly.
 
vs7
so that i can compare some condition
 
@Sippy Sure, that's a good name for them
@AwalGarg It does little good to send an UPDATE request if the server doesn't know what the hell to do with it
It's kind of implicit that the server has to be able to respond to custom requests too
 
@Neil I meant, send POST and add a field which says that "treat this as an update request". And then, the server can check if that field is present, and if it is, process it accordingly.
 
@AwalGarg Neil's point is that you needn't add that extra field if your server could just process an UPDATE request in the first place.
 
It may make talking with the server that much clearer. Rather than use a POST to update the server with a specific url as to ask the server to update my data and send me data to update, I could use a simple url and use "SYNC" action instead
 
@Sippy I know and I agree to that. I was just saying this could be an option...
 
12:42 PM
@AwalGarg This is how we do things now
 
^ right.
 
The server accepts all POST requests, and an additional parameter distinguishes what type of POST request it is
 
@Neil hehe sry.
 
@AwalGarg Don't apologize. :)
 
:P
 
12:43 PM
Restful applications are supposed to minimize multiple requests with the same URL
 
RESTful APIs you can do custom verbs with, really.
Just read the verb out of the request and match it, do the routing yourself
 
routing yourself could be a nice option I think, but I don't know much about it.
 
It's extremely easy.
Easiest way I can think of is just split the request string
 
But Neil's point stands... allowing cutom verbs with requests would certainly be a nice add.
 
@Neil except... badly configured servers.
 
12:45 PM
Works fine for an API as it should have a safe URI structure
 
reminds me of a bad apache config that was shown in every blog, and copy pasted for many servers, that had a big security flaw
 
@AwalGarg Mm, maybe it will be added in the near future ^_^
Can't think of many reasons why not
 
!!afk
 
if (typeof Object.create !== 'function') {
Object.create = function (o) {
var F = function () {};
F.prototype = o;
return new F();
};
Can anyone tell me what is this function doing please
 
@FlorianMargaine I heard about that
 
12:49 PM
Is this the function used for creating a new object ?
 
Wow this Runnable code Snippets in Q&A is awesome!
 
vs7
@Johnny000 its coming like that : ["", "page", "2"] '
 
@CustomizedName To create a new object, you just have to do {}
Don't get bogged down in those types of details at least for now
 
Does jQuery's remove also destorys event handler attached ?
 
@Neil reading JS the good parts, there description for the method isn't really clear
 
vs7
12:51 PM
oh the console gave me PATH as : "/page/2"
 
read the code
or the doc
 
@RoyiNamir yes
 
@vs7 :D
 
RTFM was the answer
 
12:52 PM
yes it was written in the docs thanks
 
vs7
location_response = $location.path();
console.log(location_response);
location_response = location_response.split('/');

@Johnny000
 
err cleanData
 
@CustomizedName Looks like the function constructor to me
 
sory that i was lazy , thought that i wont find it that quickly
 
@FlorianMargaine how are you doing mate?
 
12:53 PM
@CustomizedName I don't know if that's what it does or not honestly.
 
Hi all, I read some post on SO and now I think I have to provide the basic authentication to login to the server. Finally now my code is:

$.ajax
({
type: "GET",
url: "https://192.168.150.0/Api",
dataType: 'json',
async: false,
headers: {
"Authorization": "Basic " + btoa('admin' + ":" + 'password')
},

success: function (){
alert('Thanks for your comment!');
},
error: function (xhr, ajaxOptions, thrownError) { alert(xhr.status); alert(thrownError); }
});

But now I get 401 Authorization required error in console? I am providing the correct credentials. I can log in via web browser using th
 
@vs7 whats not working?
 
@dievardump switching job in 3 weeks!
impatient
 
Where are you going?
 
@RoyiNamir jquery source is usually quick to read
@dievardump commerce guys
 
12:53 PM
to do what?
 
vs7
I need to remove first slash I think
for ['page',2]
 
@dievardump dev/consulting
fridays are open source days, so gonna be fun
 
Good pay?
 
better than where I am
 
Fun projects?
 
12:55 PM
open source projects, should be fun
and good team, that I know
 
then check when you get the string if the first char is a slash and if yes remove it ;) @vs7
 
do you know Damien Tournoud maybe?
 
Nope
 
meh
I'll work with people who know their stuff
that's great
 
cool
Company name is?
 
vs7
12:58 PM
I used 1st and 2nd index rather than removing first slash
:P
 
@dievardump commerce guys
 
never mind then..
 
@FlorianMargaine Interesting name for a company :D
 
Oh that's actually the real name
 
vs7
12:59 PM
thanks @Johnny000
 
yeah :P
 
:(:( the website
 
you don't like it?
I find it nice
 

« first day (1416 days earlier)      last day (3526 days later) »