« first day (1445 days earlier)      last day (3503 days later) » 

12:14 PM
@DaveRandom Dave, u still there? :)
does this look "right" for you? :
 
I always here. Like a bad smell.
 
$db = connectToDb('mydb');
    $id = $_POST['id'];
    $lat = $_POST['lat'];
    $lng = $_POST['lng'];

    if(hasGeo($db,$id)){
        $query = $db->prepare("UPDATE `geo` SET `geo_position`=:geo WHERE geo_id=:id");
        if($query->execute(['geo'=>"POINT($lat $lng)",'id'=>$id])){
            echo json_encode("OK");
        }else{
            echo "FAIL UPDATE";
        }
    }else{
        $query = $db->prepare("INSERT INTO `geo`(`geo_position`, `geo_id`) VALUES (:geo,:id)");
        if($query->execute(['geo'=>"POINT($lat $lng)",'id'=>$id])){
hasGeo returns true if the id already has a geo data, or false if not
didn't smell your presence tbh...
;P
 
@Julo0sS The 'geo'=>"POINT($lat $lng)" won't work. You would need to do:
$query = $db->prepare("UPDATE `geo` SET `geo_position`= POINT(:lat, :lng) WHERE geo_id = :id");
if($query->execute(['lat' => $lat, 'lng' => $lng, 'id' => $id])){
 
why would it fail like this? cannot give string into the values array?
 
Parameters are not evaluated as expressions, they are just values. You code would be interpreted as one big string rather than a function call
 
12:20 PM
ok i see
then, what does it change to build queries this way, with the :var instead of $var into the prepare of statement?
 
Well, there are two main benefits. The first, and the usual reason that people tell you to do this, is that it mitigates SQL injection vulnerabilities. The second is more subtle and less often useful, although it is useful... When you prepare a statement, it parses the query string and creates an execution plan, in other words it does most of the work apart from actually running the operation
So if you need to run the same query over and over again (say you were updating many rows in that table, which different IDs) you can just keep passing in the values and it's more efficient
 
ok
thx
and... (or "but"?)
it fails :P
lol
 
Error message or it didn't happen ;-)
 
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') WHERE geo_id='230'' at line 1' in setGeo.php:14
Stack trace:
#0 setGeo.php(14): PDOStatement->execute(Array)
#1 {main}
thrown in setGeo.php on line 14
@DaveRandom line 14 : if($query->execute(['lat'=>$lat,'lng'=>$lng,'id'=>$id]))
 
@Julo0sS You need to turn off emulated prepares, for a start
That error should occur on the line before
Also, can you pastebin the entire file?
 
12:28 PM
@DaveRandom $query = $db->prepare("UPDATE geo SET geo_position=POINT(:lat :lng) WHERE geo_id=:id");
 
probably comman missing in POINT()
 
^ this @Julo0sS
 
=> SET geo_position='POINT(:lat :lng)',... then?
 
hi any one know how to execute c++ program on browser with php script.
i am using mamp
 
12:31 PM
@Julo0sS It's a function call, the arguments need to be separated by a comma...
 
@MandeepGill you cannot. Php code is not getting to a browser, therefore it has no control over what browser executes
 
omfg
u right
 
why ? there are functions like shell_exec, exec
 
Yeh, not in the browser, on a remote machine where the C++ binary isn't and security settings won't let you execute arbitrary external code
 
Okay
 
12:33 PM
php can let you execute command/programs on server, but not on the client's browser
 
thx
but now, lets go back to the previous one... the data that getGeoX.php returns is "undefined"...
 
hmm, any solution ? i created program in c for screenshot capturing and want to make web application where user can track time and it auto capture screenshot after added time.
 
@Julo0sS That's a JS problem, presumably. PHP doesn't ever use the term "undefined"
 
@Julo0sS did you try looking in the response data in the network tab (developer tools)
 
yep
this response is ok
its the right value
 
12:36 PM
389
Q: Using HTML5/Canvas/JavaScript to take screenshots

joelvhGoogle's "Report a Bug" or "Feedback Tool" lets you select an area of your browser window to create a screenshot that is submitted with your feedback about a bug. Screenshot by Jason Small, posted in a duplicate question. How are they doing this? Google's JavaScript feedback API is loaded fr...

 
what i do is :
lat = myFunction(vars);
alert(lat);

It alerts "undefined"
 
@MandeepGill sounds like malware =]
 
@Julo0sS That means that either your function doesn't return anything, or the value it returns does not have a value.
 
No, creating web app for time-track but need to take screenshots from desktop.
 
the response from my ajax call to my file returns the right data, i assign it into a var and return it with json_encode
 
12:38 PM
@MandeepGill Maybe doable with Java (but don't). Your only option for something like that is to provide a desktop application for download.
 
@DaveRandom Thanks
 

JavaScript

Topic: Anything JavaScript, ECMAScript including Node, React, ...
 
@Julo0sS Need to see the JS ajax code
 
function getGeoY(id){
$.ajax({
type : 'POST',
url : './php/utils/getGeoY.php',
data : {'id':id},
dataType : 'json',
error : function(response){
return false;
},
success : function(response){
return response;
}
});
}
idk why... but today... i feel... stupid^^ x)
 
/me wonders where the response is returned
 
12:40 PM
614
Q: How to return the response from an Ajax call?

Felix KlingI have a function foo which makes an Ajax request. How can I return the response from foo? I tried to return the value from the success callback as well as assigning the response to a local variable inside the function and return that one, but none of those ways actually return the response. f...

 
lol
 
@Julo0sS check the network tab and see what exactly gets returned
also, you probably should set the correct content type header
 
@tereško Response : 5.3321215510368
(omg you'll soon know where i am...)
 
that doesn't look like JSON
 
this is the lng of a point...
this is a float "as text"
comes from a POINT in my db
 
12:44 PM
oh, right
you need to cast it as float or bind the result
 
@tereško that's why i said that you'd soon know where i am :P ^^
 
@Julo0sS the success part looks faulty. Where does it return the response to?
 
when i alert the response in my success part of my ajax it alerts the right data... the problem seems to occur when i send my response to my var
@RonniSkansing it returns to a variable : var lat = getGeoX(id);
 
That is pretty confusing as the code you pasted is a getGeoY, and it does not return anything. It does call a jquery ajax something
 
why does nobody read the link I posted :(
 
12:50 PM
lol, getGeoX or getGeoY are quite the same
i did read it florian
 
@FlorianMargaine I read it ;)
and it is the solution
 
even if i do it the way it is mentionned, put the data in a temp var and return it after the statement, it is not better for me
 
fiouh, thanks
@Julo0sS .............
because that's the way IT DOES NOT WORK
that's in the question
read the answer after that
 
12:52 PM
how you doing @RonniSkansing
 
Fine thanks. How about you?
 
im good.
im trying to solve my sql query
do you know about it
 
No, I do not know about it. Have you put the minimal amount of paste in a pastie/pastebin?
 
SELECT t.id as event_id, m.* FROM event t INNER JOIN event_time m ON m.eventid = t.id WHERE m.id = (SELECT * FROM event_time WHERE start>'2014-09-30 13:44:22' AND eventid = t.id ORDER BY start ASC LIMIT 1) AND t.approved='yes'
well this is my query
it says error #1241 - Operand should contain 1 column(s)
 
@FlorianMargaine okay, found what i was looking for into this, thx, but now it stops my googlemap loading :/ wthhhhhhh that makes me crazy
the whole day on GoogleMap :[[
 
12:57 PM
@Julo0sS can you help me to see what is error in that sql
 
@FaizRasool do not spam ping random people to help you
 
@Julo0sS can you help me to see what is error in that sql
?
 
lol
maybe, i could, if i was not so bad with sql today^^ x)
 
Morning
 
Morning PeeHaa
 
1:01 PM
morning
sql..
 
@RonniSkansing @DaveRandom this is the whole thing behind these functions :
Now it fails, the google Map does not appear anymore... i have the google logo, the terms of use, but NO MORE MAP, when it failed (ajax) and i had undefined, the map was there, now my ajax does not fail anymore, the map does not appear... :'(
http://pastebin.com/cnVzELtc
 
morning
 
hi PeeHaa
 
@FaizRasool Your subquery should select only the field you're comparing to. You might also need to use IN instead of = if the query returns more than one row.
 
1:28 PM
@FaizRasool subquery :'(
 
Anyone know of a "formal" list/definition of collection operations, such as map, filter, etc.?
I was trying to find "primitive collection operations" but got a lot of language APIs. Looking for something more general.
 
@DanLugg for something new? or ?
@TheRealHamza o/
 
Not sure what you mean, just for reference.
 
@DanLugg how about higher order function
 
@Naruto what does this means?
 
1:35 PM
Yea, that's basically what I'm looking at; of the higher-order functions, I was trying to find a list of those typically referred to as "primitive" -- I know map is in there, same with filter. I think reduce too.
Er.. wait.
No, I'm a dog at a computer.
 
@TheRealHamza It's like saying hi? The head is o and the arm up is / ? :D that creates o/
@DanLugg Collector? ^^
 
What?
 
ow nvm, I misunderstood your question
 
I need to find a name for a generic object that eases drawing to a canvas (html/js)
 
PeeHaaCanvas
 
1:40 PM
:P
I wanted to call it drawer but that is only confusing :P
 
@FlorianMargaine u there?
 
hmm maybe Painter
 
@PeeHaa Instrument
 
@RonniSkansing : idk why i have the same error as earlier with my ajax return... may you have a look at this please? :
var lng = getGeoY(myId);
function getGeoY(id){
return $.ajax({
type : 'POST',
url : './php/utils/getGeoY.php',
data : {'id':id},
dataType : 'json'
});
}
 
That's a bit too ambiguous
 
1:43 PM
@DanLugg reduce is primitive, everything else (that doesn't short circuit) can be built with it
 
@NikiC map/filter aren't?
Oh. Wait, I see. Derp.
 
@DanLugg map can be built with reduce
 
@Julo0sS undefined?
 
Mapping is just reducing to another collection.
^^ Yea.
 
yup, exactly ;)
 
1:45 PM
lng = [object Object]
 
reduce is really just iterate...
 
Iterate (and persist)
 
@Julo0sS but that is not the same as before?
 
persist is up to the callable
 
True, but of course, when dealing with the map and filter implementations...
 
1:46 PM
yup
 
@RonniSkansing almost same, when i alert response from my ajax in success part (if i make a success part) the alert is ok, but not the var
 
It's a much more interesting world when you finally understand certain relationships and abstractions :-)
@NikiC Why the "doesn't short circuit" caveat?
 
@DanLugg Don't forget that a monad is nothing more than a monoid in the category of endofunctors.
 
@Julo0sS have you console.log(yourVariable) the object you get back? Avoid using alert for debugging
 
@DanLugg things like every() can short-circuit on the first false, where with reduce you'd still need to visit every element
 
1:48 PM
@DanLugg Meaning that functionals like any/all should ideally short-circuit, while reduce will require running through the whole iterator
 
Ahh, so (in the parlance with which I'm familiar) any() and all() assertions ^^
 
yup
 
Where would you say sort/orderBy falls into this?
That seems to be a fold, but it's multiple passes (implementation dependent of course)...
 
@RonniSkansing console log gives me the right value
(in success part)
 
@NikiC :-), interesting read.
 
1:51 PM
sorting via an iterator is weird
 
hi guys, bit of a fringe PHP question here. I'm having issues with my simple apache vhost. I can resolve the domain for any subdomain but for the root (i.e. no subdomain) i get nothing. Any ideas? I'm using ServerName example.com ServerAlias *.example.com
 
@ircmaxell yes ... only reasonable if it's a random-access "iterator"
 
@ircmaxell And hard, and seemingly impossible with reentrance.
 
so: example.com fails but yourface.example.com does not and resolves as expected
 
1:52 PM
@DanLugg it's possible for finite iterators, as long as you keep every element in memory ^^
@NikiC not arguing that what I built isn't reasonable :-P
 
@ircmaxell But there's no way to assert that a generator is finite without first iterating it entirely.
 
@DanLugg I think you can implement a great insertion sort with reduce :P
 
@DanLugg correct
 
Poopy poop.
Neat sauce... I should really revisit the idea of going back for comp sci.
 
and if you do a var_dump on the iterator tree produced by my merge iterator implementation, it's just silly
 
1:54 PM
 
well
 
@RonniSkansing it has no sense...
 
@JoeWatkins when you get into Manchester?
 
@Julo0sS ?
 
@RonniSkansing same issue
[object Object]
and console log ok
maybe it's async problem
my ajax is default, i should try "async:false"
 
2:01 PM
@Julo0sS console.log(x) in one place and alert(x) in another place is not fair. That is not a way debug =/
 
posted on September 30, 2014 by kbironneau

/* by Jrich */

 
please read the answer again, it pretty well explains the async problem you have
and stop using alert for debugging please.
 
i used console, console gives me the object in question :
readyState

4

responseJSON

50.244641280083

responseText

"50.244641280083"

status

200

statusText

"OK"

abort

function(e)

... ... .. ...

English is not my 1st language, and i must admit that i sometimes don't understand all in the texts, but i tried his solution with .done & .fail and no effect neither... as i see my "object" returned, it has the data in it... but can't get it in a proper format...
 
Hello guys, is there any facility to check the execution order of functions in php?
 
@JoeWatkins @NikiC I was thinking on my commute in, I should be able to generate a PECL extension from the IR that Recki spits out... Do you think that's worth it?
 
2:11 PM
Actually, i am not able to knowing what functions are executing in my application.
 
@Pradeep echo?
A debugger?
 
Yaa I need a debugger.
But debugger is telling only errors and notices.
i want what functions are executing and their order of executing.
 
1 min ago, by PeeHaa
A debugger?
@Pradeep What makes you think that?
 
@PeeHaa : I am trying to customize wordpress plugin. I want to know what functions are executing after pressing submit button.
Is it possible?
 
haha yes
 
2:14 PM
@Pradeep yes use a debugger
 
setup xdebug, and make sure to bring popcorn
 
@ircmaxell Don't think so. The primary work with pecl extensions is the interfacing (especially when implementing classes), rather than the algorithmic side. So I don't think it would be terribly useful
 
@PeeHaa : Debugger is giving only errors and notices. It is not showing what functions are executing and their order of executing
 
2 mins ago, by PeeHaa
@Pradeep What makes you think that?
 
@NikiC well, I was trying to think of a way to move the compile step out of process, to generate an object file that can be linked instead. And generating a PECL extension should do that, no? Not so that people could modify it (not a skeleton generator), but so that it could be compiled via GCC and included normally...
 
2:16 PM
@PeeHaa: I am not that good in english. Can you please elaborate What makes you think that?
 
@ircmaxell As a means of getting object files it sounds reasonable
Just not as a means of converting PHP code to PECL
 
yeah, that's what I meant. I don't intend to generate human readable C code
 
k
 
once I'm done writing my talks, I may try a proof-of-concept
 
2:18 PM
@Pradeep It doesn't work like that. I asked you a question. You cannot not answer the question and ask a question to me instead. Only jesus can pull that off ;)
xdebug.org or phpdbg.com both do what you want
 
@RonniSkansing: can you help me?
 
I do no think so. What kind of help are you looking for? I tell you, going trough all functions in wp until it hits your plugin is a mess. A big mess. Setup a debugger (what you think is a debugger is not). And set a breakpoint in the code where you want to inspect.
 
I mean. is there any facility to find what functions are executing after clicking a particular button in php?
 
yes, setup a debugger. Learn to use it.
 
@RonniSkansing: thank you
 
2:21 PM
But why do you want to know which functions are executed?
Maybe you can solve your bug/problem in a easier fashion
but it would imo be worth learning to use a debugger either way
 
@RonniSkansing: I want to customize the wordpress plugin. I am not able to know what functions are executing after pressing checkout button.
If i know the functions which are executing after pressing the button, then i can change those functions.
 
@ircmaxell I get in sometime early evening on friday I think ...
 
@Pradeep no, cause then when you update the plugin and it will overwrite your changes, and you must update.. all the time, and either know how the plugins work our pray to the wp gods (who are false idols) that your site does not break..
 
ah cool
 
that sounds interesting ...
 
2:24 PM
@RonniSkansing: I will not update any more.
 
@Pradeep then your site will be overrun by bots and the site will be hacked/exploited
 
@JoeWatkins I may try a POC at some point...
 
@RonniSkansing: then what will i do to solve my problem?
 
@Pradeep what is it you want to customize?
and could you explain your problem, that would be great =]
 
I want to add a payment gateway for group buying plugin.
Group buying plugin has paypal by default.
 
2:27 PM
woocommerce?
 
Yes
 
lol
 
By seeing the paypal code, i want to add ipay88.
 
@Pradeep so.. let me just get it right. You are using a woocommerce, and then have a plugin that ads a group payment option, but it only allows for paypal, and you want to add ipay88?
 
Yes @RonniSkansing
 
2:30 PM
hello
 
@Pradeep read the source of the group payment (any docs?) and make sure you already know the Wordpress "Api" and the woocmmerce "api" and see if it exposes any hooks to add payment options and build a plugin.
 
can i participate in this chat regarding google plus login?
 
in JavaScript - OnlySeriousStuff, 2 mins ago, by Benjamin Gruenbaum
@Jhawins is interested in mentoring newbies in PHP. Anyone interested in free php/mysql lessons - ping him, he'll appreciate it.
 
@JoeWatkins gist.github.com/ircmaxell/a1f74c50adfe081d58b1 thoughts to that response?
 
@RonniSkansing: That i will do. Not a problem. Is debugger tells what functions are executing after pressing particular button?
 
2:33 PM
I have implemented google plus login in my symfony1.4 , that is existing project of my company, is there anyway to read request_uri from google app console , so that i can remove it from my php code.
 
@Pradeep for this you do not need the debugger, you need to do what I just said.
Are you familiar with writting plugins for wp and woocommerce?
 
@RonniSkansing: I am just a beginner in writing wp plugins
 
Okay. But whatever you do, do not edit the original files
 
@ircmaxell reads good to me ... I dunno what it will look like once on phpclasses
 
:-)
sent
 
3:02 PM
I guess I am wrong...
at least according to the downvoter
 
I got downvoted at first aswell ..
I got reddit gold :o
 
nice
I got that when I got unbanned for a little while... not worth it, but nice
I just really can't stand futures. They are a nightmare to work with, resulting in really weird intertwined code. Promises can get just as bad, but they also can be incredibly expressive (which futures can't be)
 
 
3:18 PM
yup
 
...
That entire file is one giant WTFOMFGBBQ btw
 
I think I have said it before, but lemme repeat: fuck pmjones
 
What's pmjones? … oh… it's somebody.
 
@pmjones Any particular reason for doing this? https://github.com/auraphp/Aura.Sql/blob/52a9f7dba31749f3bf7c6dbdaad85b1ce0adaab5/src/ExtendedPdo.php#L42
 
@ircmaxell I think you got the wrong link. You probably tried to do use this https://github.com/auraphp :P
@ircmaxell I'm sure there was, but damned if I remember any more. (A "con" of having a long-lived codebase.) Suggestions?
yeah kill the entire class with fire...
 
3:25 PM
eih, play nice
 
@ircmaxell github.com/amphp/amp/blob/master/lib/Future.php like that…? (your tweet about futures)
 
@bwoebi that's a promise named as a future
 
@ircmaxell In general I am agree, however I would love to have a decent self hosted git gui solution in php
 
hehe
 
3:27 PM
@ircmaxell oh, well. damned naming.
 
it actually might be a fun challenge
 
@tereško "fun"
 
:D
same way as Jackass is "fun"
 
@bwoebi yeah, futures you need to ask if they are done, and need to ask for the value when they are done (and if you ask when they aren't done, you'll just block)
 
:p
> just noticed that one thing
no you didn't ;)
 
3:29 PM
@PeeHaa don't get me wrong, I'm not saying porting is evil. Just it shouldn't be everything that's being done...
 
@ircmaxell I agree with that 100%. It just sucks that most shiny things are not built using php
 
@ircmaxell agree with you to let them die.
 
At least that what I see. Maybe I am just getting old and grumpy and only see crap. crap everywhere and just don't know enough of other languages to see everything over there is also crap :P
 
@PeeHaa here's a hint. Everything is crap. Some things just shine a little bit more. But under that polish, is still pure turd
@ircmaxell Dude, a cursory glance from you is a full review from most anyone else.
 
:D
 
3:35 PM
@PeeHaa I can never remember your twitter handle... You do tweet right?
 
@ircmaxell twitter.com/PHPeeHaa :-)
 
ah that's right
you got tweet credit :-)
 
@ircmaxell The thing is the stuff I found even remotely interesting last year in userland bascailly came out of this room in one way or another
I know we have some smart people in here, but the community should be broader with more sane people. Or I am just being a circlejerk
 
@PeeHaa I see that as a testament to this community here more than anything else...
The question is, how do we scale this
 
@ircmaxell yay twitcred \o/
 
3:38 PM
actually, it's something I'm going to be talking about on Saturday
 
cool
@ircmaxell Is that the "how php made the world a better place" talk?
 
something like htat
 
ow keynote. noice
 
it's still not done yet. No where near
 
@ircmaxell But no pressure right? :)
 
3:42 PM
none at all
other than the ulcer
 
:)
brb need to get food and beer if I want to survive the next part of my week off
 
and everything else in my life right now that's pure pressure
 
@ircmaxell going to leak some more details before Saturday? :-)
 
3:56 PM
I like details ... but not leaks ...
 
I'm not leaking anything
there's nothing to leak
 
wtf, glob() doesn't return dotfiles
TIL
Undocumented, I might add
 
Holy shit @ircmaxell. How the hell did you survive this?
 
php -r "var_dump(glob('$HOME/{.}*', GLOB_BRACE));"
 
Those were some epic apocalyptical clouds
 
4:02 PM
@PeeHaa easy, nothing happened
 
@JoeWatkins Yeh, but still... undocumented behaviour is undocumented.
 
it is
 
Also I sort of wish there was a rm -rf function (unless I'm missing one)
@JoeWatkins The fact that this can be done is documented, that fact that it needs to be done in order to get dotfiles is not...
 
> The glob() function searches for all the pathnames matching pattern according to the rules used by the libc glob() function, which is similar to the rules used by common shells.
 
@DaveRandom real_rmdir()? :p
 
4:05 PM
silly assumption that the reader knows how libc's glob() works in detail ...
 
^ that
 
@JoeWatkins come on, you don't know the semantics of all libc functions by heart?
 
it's not something I would admit too ...
 
:-P
 
4:27 PM
/me sleeps, been up since 4:30 this morning, on pc since 5:30 ... knackered ... lata chaps ...
 
gn
 
night joe
 
4:42 PM
Every now and then, I like to drop several setTimeout(fn, 2000) into my Node.js applications, to remind myself how far we’ve come from PHP.
 
hehehehehehe
 
@ircmaxell I don't disagree, my point is that futures seem a more natural fit to most PHP programs already written in a very linear fashion
 
@ircmaxell And what's the problem with allowing a ->wait() function on a group of Promises over Futures?
 
@bwoebi just tweeted about that
 
:-)
 
4:52 PM
@ircmaxell are you trying to imply that one should actually READ your tweets too, instead of just following ?!
 
:-P
@naderman You can also pretty easily promote a promise to a "future", but it's quite hard to promote a future to a promise...
 
@ircmaxell's encounter with phpclasses today made me think about an idea I had a long time ago to create a new site which basically will be "repository" for no utter shit php libraries. Is there already something out there like this? Is this an ok idea?
 
there are a few places that try to do that
 
links?
 
honestly, I'd rather see a way to rate and provide feedback on packagist
so you could see review badges, etc
 
4:56 PM
@ircmaxell I was thinking about something that uses packagist instead, but curated
A bit like SO
 
Weren't some of the PSR guys doing something similar to that?
 
phpplague the "league"
 
A place for repo's they approved of.
heh
 
Don't get me wrong though, I'd love a room 11 approved repo list.
 
4:58 PM
@Fabien yeah I want somebody like that, but not curated by only them
I like what they are trying to do, but for some reason they always give me a bad taste in my mouth
Not implying whether that is justified or not. Just sayin
I want something more open
 

« first day (1445 days earlier)      last day (3503 days later) »