« first day (1683 days earlier)      last day (3262 days later) » 

4:00 PM
Well, then, in bar, "return $array";
You are applying the side-effect function, but not returning it.
 
Anonymous
Then I would miss the use of array_walk, if I do return $array
 
Don't listen to @Haskell
 
@Andrea That was not my intention, if you read the discussions over, you'll see that.
 
array_walk returns a boolean
 
Andrea, don't be bad with me. :'(
 
Anonymous
4:01 PM
areay_walk :)
 
I'm just guessing design is important in a programming language. You know that. :/
 
@samaYo What you want is array_map, it applies a function to each element and returns a new array
array_walk merely calls the function for each element, it doesn't do anything with the return value
 
posted on May 26, 2015 by kbironneau

/* by LeyendaV */

 
PHP can be better. We can do it, I don't want to underserve the work of nobody, it evolved so much, but the others just guessed that design was trivial and not important.
 
<?php
class foo{
    static function bar($find = null, $replace = null){
        $array = ['foo', 'bar', 'tar'];
        return array_map($array, function($item) {
            return (object) $item;
        });
    }
}

var_dump(foo::bar());
 
Anonymous
4:03 PM
I will check that out, thanks @Andrea
 
@HaskellCamargo we know PHP could be better
this room is filled with people who actively try to improve it
 
And me too. That's why I'm (was) making Rawr: to solve a big part of the problems.
PHP is like a soon for me. Don't understand me bad.
And know I didn't give of build a preprocessor for that, but Sherif just guessed it would be useless. :/
If I undeserved your work, sorry.
 
Anonymous
I guess I really need to speed up my learning C efforts to understand php better.
 
@samaYo C is only necessary to understand PHP's internals
@samaYo Actually, what were you trying to do with array_walk?
 
Anonymous
@Andrea Yeah, but knowing how it works behind the scene, certainly should improve anyone's understanding.
 
4:09 PM
 
Anonymous
@Andrea Just some stupid stuff :)
 
These things get me sad...
 
Anonymous
@Andrea fyi your example is wrong :)
 
@samaYo No, it's important, in order to understand how to help
@HaskellCamargo ignore Sherif, then
4
 
hey
 
4:11 PM
generator people, how would async http client with generators api look like in php7?
 
Is this right place to ask.. questions? xD
 
"Discussion for all things PHP". I think it is.
 
Anonymous
static function url($find = null, $replace = null){
	$url = parse_url(/* foo.com/bar?blabla */);

	array_walk($url, function($find, $replace) use ($url){
 	$u = [key($url) => str_replace($find, $replace, reset($url))];
 	($find != null) ?: (object) $u;
 	return $u;
 });

}
 
Anonymous
@Andrea I'm a noob, what can I say :/
 
Anonymous
echo foo::url()->path; // bar
 
4:14 PM
@samaYo this code looks like its intentionally complicated to confuse the reader ;)
can you even return stuff from array walk?
 
@samaYo Ah, array_walk doesn't do anything with the return value. You'll need to get the data out some other way.
 
Anonymous
@beberlei It's actually just a sketch like the variable $u and other nonesense are just to for quick test.. & array walk only return bool
 
What is meaning of this? ?: It's operator?
 
It is the ternary operator.
 
Anonymous
Or better yet, short form for the ternary op.
 
4:17 PM
It also follows the syntax: <condition> ? <ifTrue> : <else>
 
short ternary operator
 
@beberlei /cc @rdlowrey
 
$a ?: $b is $a ? $a : b
 
okk
 
user895378
@beberlei it would look nothing like my old async lib because I made it in 5.4 land and without generators :)
 
4:19 PM
5.4? shudders
 
user895378
In general you would just return a Promise from $client->request($uri); and use that in conjunction with an async platform so the code would look something like this:
 
@rdlowrey but you don't have a single method interface in mind that would show case it or something?
 
user895378
function main() {
    $client = new AsyncHttpClient;
    $response = yield $client->request("http://example.com");
}
someAsyncLib(resolve(main()));
 
i am trying to convince guzzle and buzz to wrap my interfaces, so that i can stop caring about http client implementations finally
 
user895378
@beberlei TBH I don't think very highly of the guzzle async implementation. That said the right approach is just to return a promise.
 
user895378
4:21 PM
If the async client returns a promise then a good library can resolve it.
 
@rdlowrey which version of guzzle? its six different ones already ;)
 
user895378
that too ...
 
"7" different ones
 
the v6 api is ClientInterface { public function sendAsync($request, $options): Promise }
 
user895378
The problem with what guzzle does is that for async to be useful everything in your application needs to run on the same event loop.
 
user895378
4:22 PM
And if you're using curl under the hood it's simply not possible to do that with your async http requests (without polling, anyway, and at that point it ceases to be async and starts being busy waiting).
 
Anonymous
@brata there is also another one for php7 ??
 
hm ok then this part of the interfaces doenst need make sense
 
what
 
guzzle wraps a pool around this to manage the busy waiting
 
user895378
right
 
user895378
4:23 PM
It's faux-async
 
its not possible to have $n multi handles and just start curl_select() when you reveal the promise?
i never needed anything else then busy waiting curl before
 
Anonymous
@brata I have slow connection, but @Andrea is the author of it I think it's called "clossal operator" .. not sure :/
 
I have slow connnection too xD
 
i should remove the async interface from the interfaces for now, not sure you can do something sane there
 
7kb per second
 
4:25 PM
without depending on the implementation
 
You're thinking of null-coalesce: ??
 
user895378
@beberlei It is possible, but if you use curl_select() you can't mix that with other libs that need to select using something that isn't curl_select() ... so it's not true async. It's two separate systems
 
 
user895378
@beberlei right ... which is fine ... very few people do. But, for example, if you run a reactphp server then you can't use curl_select() except to schedule periodic polling ... which is the busy-waiting problem.
 
@Fabor politics
 
Anonymous
4:26 PM
@Andrea Yeah that one / cc @brata null-coalesce operator it uses double ?? question marks.
 
user895378
Anything based on userland ext/curl is fundamentally not compatible with other async libraries that aren't based on ext/curl.
 
user895378
In libcurl at the C level you can actually specific specific event loops for the library to use under the hood ... this is something that could likely be exposed in userland ext/curl to allow interoperation so that curl could be used in conjunction with other async libs but it's not something I care to look into TBH.
 
I'm needing to do a 10 byte conversion of random binary data to a Base32 encoded value for a two-factor implementation. Anyone else done this before and know of a good implementation?
/cc @ircmaxell
This looks like it might be good: github.com/ChristianRiesen/base32
 
Hello :)
 
4:45 PM
@Fabor PHP vs. Ruby. Which one is at which end varies.
 
Anonymous
static function url($find = null, $replace = null){
	$url = parse_url(self::server('REQUEST_URI'));
	return (object) array_map(function() use ($url, $find, $replace) {
		return str_replace($find, $replace, reset($url));
	}, $url);
}
 
Anonymous
\0/ @Andrea
 
@samaYo can u tell me what does that 2 statements do?
 
morning
 
I don't know how they work :(
 
Anonymous
4:48 PM
@ZahidSaeed which 2 statements?
 
return (object) array_map...
U used return in return statement
I have seen lots of developers doing that but I can't figure out what they do
 
Anonymous
I don't know, for the most part I just type as many letter combinations of as possible while pressing F5 until something works :P
 
SEO question: Google shows a link with wrong get parameters when searching for a product on the customers website, is there a way to check which page linked to that url? Because I assume it must be linked like that in some place for google to list it that way, but I can't find it and its not in the menu anyway..
 
That's a scary statement
 
Anonymous
I think link:yourwebsite shows something similar in google.
 
4:52 PM
Does anyone how can I fetch the user IP address and then set the timezone according to his/her country :P
Using PHP
 
@samaYo where would I type that?
oh I see
 
Anonymous
@MarcelBurkhard in google.
 
@samaYo doesnt work though..
 
Anonymous
@ZahidSaeed The way I understand it, is that when you use two returns, basically the inner-most return exists the scope, and the second exists the function from the class (as in my example)
 
Anonymous
It should .. let me check
 
4:53 PM
ok
 
@samaYo well it says "did not match any documents." which doesn't necessarily mean it's not working, it's just not helping me :D
/me punch myself for describing a problem as "doesnt work"
 
@samaYo did u found out ?
 
Anonymous
@ZahidSaeed no, that was not for what I said to you.
 
oh :(
Well no problem
But can u help me with the second problem ?
 
Anonymous
I'll try
 
4:57 PM
How can I change the timezone according to the user IP address ?
 
@beberlei If I could get Guzzle to implement the Thenable interface, I would think that would solve some of your problems.
 
Anonymous
I doubt that is possible. How does an IP tell you from which timezone your site visitor is?
 
@ZahidSaeed i use this pellepim.bitbucket.org/jstz
 
@ZahidSaeed you need to split up problems into bits :) You could find out where the ip is geographically located and then set a default timezone for that, however as the ip -> location method is very unprecise users should be able to change the timezone
 
its not based on ip adress though
 
Anonymous
4:59 PM
It could also be an old link, that google has not yet removed. I had an old site with link as site.com/date/month/year/title_slug then I changed to site.com/title_slug the first one remained for some months, before it was replaced, but I basically got the error you are getting now @MarcelBurkhard
 
Thanks @Marcel
 
@samaYo yeah I thought of that, it's not an old link though.. the category id doesn't match the products category and I have confirmed that it was never in that category... weird
 
@ZahidSaeed You would probably be better off just using some Javascript to get the users timezone it, and transmit it to the server: var offset = new Date().getTimezoneOffset();
 
@ZahidSaeed You can make a best guess using a geoip service, but sometimes you'll only get a country out of that, and then sometimes that's out of date. Doing client-side detection of the timezone is going to be a way better idea.
 
5:02 PM
wow ! :)
 
@beberlei Then you could use promises from Guzzle or any library that implemented the interface.
 
@Charles additionally accessing the geoip service will add latency and has some issues concerning privacy
 
For example, geoip for the gateway at work only gives the country, and worse, when you get the rough lat/long, it places us in the middle of the country, two timezones away...
 
Anonymous
Why isn't anyone recommending the HTML5 geolocation API ?
 
Anonymous
/ no love for html5
 
5:04 PM
@samaYo we were talking ip not gps :P
@samaYo but I'm not that familiar with geolocation so I am probably wrong about that :D
 
@Trowski yeah that'd be awesome. the problem is always getting the big ones to actually use your interfaces :)
 
@samaYo "For privacy reasons, the user is asked for permission to report location information." Sounds like quite the barrier...
 
Should I go with PHP Procedural Programming or OOP or PDO ?
I usually work with Procedural Programming. But I'm still confused
 
Anonymous
:)
 
Can anyone help with this ?
 
5:07 PM
@ZahidSaeed OOP allows for better maintainability for your code
 
Anonymous
@ZahidSaeed PDO and OOP are in the same category
 
and PDO is just another way to access your database
 
But procedural is also reusable and maintainable
Don't u think so ? :)
 
@beberlei I've talked to Michael Dowling about it, so I think I could get him on board for Guzzle. The maintainer of React's promise library has also spoken to me about it, so there's good chances there.
 
Anonymous
@MarcelBurkhard Are you in github?
 
5:08 PM
@ZahidSaeed well I know that it is not. Of course there is the kind of person that makes object oriented code worse than the other guy with procedural but still
@samaYo yeah but I don't have anything to show yet :P
 
@Trowski sounds good :)
 
@beberlei I'll submit some pulls and see what I can do.
 
@samaYo my stackoverflow profile has a link to my github (which I must repeat is kinda uninteresting)
 
@Trowski question about the name, thenableinterface is very clumsy, why not Promise?
also, Thenable is alrady an interfacy name, like countable
throwable
no need to suffix Interface imho :)
 
@ZahidSaeed if you follow OOP design principles (most importantly "S.O.L.I.D.") you can easily let your code test itself using PHPUnit and it will be very easy to change stuff later on...
 
5:11 PM
hi everyone. hope you all are good.
I have little confusion and i want to ask,
actually i have a class for database connectivity when i create an object it automatically make a connection.
on other hand i have a cron script which execute for a while like 2 hours and sometimes it through an exception "failed sending query packet".
after googling i found that i need to ping. for this i found $mysqli->ping(); which return a bool value. true or false;
now my confusion is that is ping() only tell me that connection is alive or it will reconnect automatically? thanks
 
Anonymous
@MarcelBurkhard Sorry, I am theethering my phone for internet, so I have like 12kb/s. Do you have any projects in mind? I have some free time to learn and would be glad to be part of something for fun
 
@samaYo I'm currently very busy at work and lack the energy to do something useful at home, sry. But there is so much you can learn, try Test driven development for example :D
@samaYo and also SOLID OOP and what I find very important lately: short functions like he describes: vimeo.com/13702091
 
Anonymous
@MarcelBurkhard hehe that was 2 years ago. I am now capable of writting better tests.
 
@samaYo what was 2 years ago? ^^
 
@beberlei I agree, Thenable would be much better.
I added Interface since a lot of libraries add that to interfaces, but for something like this it would probably be better without.
 
5:16 PM
Can I help someone ? ;)
I'm just a younger developer of age 19 :)
 
Anonymous
@MarcelBurkhard I figured you had seen the test I tried to write for github.com/samayo/bulletproof why else would you ask me to learn TDD if not for that?
 
@samaYo you seemed to lack ideas what you should learn, I haven't seen your github profile
@samaYo apparently my last project was a FooManager
 
@beberlei I avoided simply promise because there are other names for thenables such as Future. I'll change the name before I do any PRs.
 
I'm not that creative :D
 
Anonymous
:)
 
5:27 PM
Morning
 
Morning ?
It's 10:30 PM here !
 
Afternoon, you mean.
2:30pm.
 
oh :)
Morning :)
 
I see.
 
5:31 PM
I used to say "Good (UGT) Morning!" but noone ever gave a shit so I stopped...
and its 7:30 pm here
 
@MarcelBurkhard morning
 
hi!!! can i ask a question, i am confuse in something!! :( :(
 
Anonymous
@king4aol yesssssss
 
Bring it on @king4aol
 
Anonymous
@MarcelBurkhard btw 1 week left for my dell xps \o/
 
5:34 PM
actually i have a class for database connectivity when i create an object it automatically make a connection.
on other hand i have a cron script which execute for a while like 2 hours and sometimes it through an exception "failed sending query packet".
after googling i found that i need to ping. for this i found $mysqli->ping(); which return a bool value. true or false;
now my confusion is that is ping() only tell me that connection is alive or it will reconnect automatically? thanks
 
Sounds like ping will try to keep the connection alive
 
"Object Not Found in Memory"
 
@king4aol Have you read the docs?
 
@samaYo oh nice [x] jealous
@samaYo 3200x1800?
 
Anonymous
@MarcelBurkhard yeah, and no worries, I'll send you hi res pictures :P
 
5:38 PM
Does anyone know anything about ImageMagick/Ghostscript - I need to use this so I can upload .pdf's and convert them into .jpg's to display it. Do I need to get my host provider to install/configure this server side, or can I include it into the project somehow.
 
@samaYo I'm fine with 2560x1440 actually, but full hd would suck... thus laptop price/value is clear NO for me right now
 
@BigRabbit Both need to be installed by your hosting provider
 
because I wouldn't even use it a lot
 
@PeeHaa great thanks
 
Somebody please help me.
1
Q: Why it's echoing blank in following function code? Not able to understand some steps from code. Please explain

user2839497I've one HTML string <img src="http://54.174.50.242/file/pic/emoticon/default/smile.png" alt="Smile" title="Smile" title="v_middle" /> I'm getting blank for the above HTML string. why so I'm not understanding. The above string is passed as an argument to the below function i.e. the variable $fee...

 
Anonymous
5:44 PM
@MarcelBurkhard same here about the $, but I would use it A Lot, I'm having second thoughts about getting the 2560x1440 HD ( non touch version ) as I need moaar batter life.
 
@BigRabbit Getting them to install GhostScript should be a lot easier than getting them to install ImageMagick.
 
Anonymous
@MarcelBurkhard also third thought about getting a mac instead.
 
Anonymous
/ mac book pro
 
GODDAMNIT! My main laptop really died just now :(
 
@Danack I thought that GhostScript was relent on ImageMagick, in such that it provides .pdf functionality/manipulation to ImageMagick?
 
5:47 PM
@BigRabbit the other way round. ImageMagick uses GhostScript (or other delegates) to process PDF images. You can call GhostScript directly.
 
Anonymous
@PeeHaa I hope it was mac book, so I have one reason not to buy it :)
 
@samaYo Nope I will be forced now to use my mac book :(
 
@samaYo mac ? god no ^^
 
Anonymous
damn
 
Although I like the alternative of sitting with my desktop on my lap on the couch better
 
5:48 PM
@PeeHaa compared to using the mac book that sounds very reasonable
@samaYo yeah no brainer then, just make sure you don't drop it :D
 
Anonymous
@MarcelBurkhard It seems a lot of people use mac here, specially the internals and they say it's awesome. Can't argue with that
 
Yeah I tend to agree
@samaYo @bwoebi is not everybody :P
 
Anonymous
plus @Danack
 
@Danack ah ok, so will I only need Ghostscript than, or should I also get ImageMagick just to be safe?
 
@PeeHaa :-P
 
Anonymous
5:50 PM
I think @NikiC also uses mac
 
@bwoebi :D
 
@samaYo well the truth is it doesn't matter that much, HOWEVER I personally don't like that everything is different just for the f... of it and it would take time getting used to and I would need to dual boot for games
 
Anonymous
also LeviMorrison ...
 
basically when you are already not using Windows: why wouldn't you use linux?
 
@BigRabbit If all you need to do is convert pdfs to jpgs/pngs then ghostscript would be 'fine'. It would be a little annoying to use compared to doing it through Imgick as you'd need to convert the PDF to individual pages, and then scan the directory to see how many were made, as opposed to being able to load the pdfs as an image and see how many pages are in it etc.
 
5:52 PM
@samaYo Levi does, but Nikita doesn't AFAIK
 
Also, you ought to get a real host where you can install software you want...
 
Anonymous
In general more people in this room use pc strawpoll.me/4344360/r
 
@samaYo You forgot "who bothered to answer the poll"
 
Guys I tried to use var offset = new Date.getTimezoneOffset();
But it returns me -300
 
5:55 PM
Let me guess: syntax error
 
How can I convert it into Timezone name ?
I forgot ()
 
@Danack I think it would be a lot easier to just upload the PDF as an image and than see how many pages are in it - so I would require imagemagick just for the ease of doing things. What do you mean a real host sorry, but I thought I already have a real host? - I am still quite new to all of this and kind of just got thrown into the mix of things without any help, sorry for my lack of understanding.
 
Still syntax error
 
I'm not asking about syntax error
 
> Parse error: syntax error, unexpected 'var' (T_VAR) in...
 
5:57 PM
Tell me the solution
var offset = new Date().getTimezoneOffset()
 
@ZahidSaeed You can't sanely do that reliably.
 
Then how can I change timezone according to the user country ? :'(
 
PHP side, you can iterate over the list of timezones that have the same minute offset, however there can sometimes be multiples, then you have DST to worry about.
You are really, really, really better off just asking the user to enter their timezone information after giving them some hints about which ones it can be.
 
How do u guys do this ?
I'm asking for BEST solution with BEST Practice
 
Do what everybody does. Stay as far from time zone hell as possible
 
6:00 PM
haha
Actually I'm creating a POS
And I wanted to show the user current time when they login
 
@ZahidSaeed the time you get from javascript will already be in the users timezone
you could submit that through an ajax call and set it in the php session array
 
@BigRabbit If you're paying someone to manage your server, but you can decide what get's installed that would count as a real server. A lot of people seem to have shared hosting, where they can only ask, but not demand, what gets installed on the server - and that would be not a real host.
 
@Danack yeah and a customers host decided he doesn't like wkhtmltopdf, but ghostscript is ok... argh ^^
dompdf/mpdf/tcpdf are all slow as ...
 
To be clear, you will need the PHP extension Imagick installed to use ImageMagick, not just ImageMagick itself. I, personally, don't believe it is appropriate to have it loaded in the webserver. It is far better to have it do it's processing in a background script, invoked through something like supervisord supervisord.org
 
But what if the user changes the current time of their computer and then login ?
 
6:04 PM
@ZahidSaeed why would that be a problem?
 
@ZahidSaeed That is so amazingly rare that you should not consider it a thing.
 
If he wants the wrong time to be shown so be it
@ZahidSaeed you can then use the timezone "Etc/GMT+n" to match the users time
 
I always try to secure
 
@ZahidSaeed secure from what?
@ZahidSaeed just use server time?
 
Yeah. I guess you are right :)
@Marcel how old r u ?
 
6:11 PM
@ZahidSaeed 21
 
How long have u been working with PHP?
 
@Danack thanks for the explanation. I think (for my sake, being the only one with any programming knowledge in a very small business) it will be easier to have it all loaded into the web server in comparison to implementing another system.
 
@ZahidSaeed well 1 1/2 year at my job now and a bit previously to that, but mostly java back then
 
Can u give me a suggestion what should I learn next >
?
 
@ZahidSaeed OOP with PDO :)
@ZahidSaeed this is also a good read: stackoverflow.com/a/16356866/982075
@tereško thanks for making me aware of the Clean Code talks btw. invaluable!
 
6:15 PM
your're welcome
 
What is MVC ?
 
lol
 
@ZahidSaeed ok, no offense but first learn how to google, because to be successful at this you will need a lot of googling :D
 
M, V and C are a technology concept that enables @tereško to yell at you.
 
6:16 PM
Yes. I do
 
@MarcelBurkhard you can also try going through the rest of the materials listed here: stackoverflow.com/a/16356866/727208
 
@tereško haha I just posted that link to Zahid 9 lines above
 
oh
lol
fak
 
6:17 PM
:)
 
and it reminded me to thank you
 
@samaYo lolwut
I certainly do not use a mac
 
@MarcelBurkhard there's a gist -> gist.github.com/Hamz-a/0b7d2e552812640dd8ef should SO burn
 
let's just hope that never happens
 
^^
google cache is obvious though
 
> they must have it running locally with full offline db :)
 
yo
dat chat history today
 
@marcio hmm?
 
@bwoebi I'm glad to be busy enough not to read the entire discussion raised earlier
 
6:51 PM
Hey!
@marcio, everybody wants to kill me. D:
 
then stop trying to be killed :D
 
That is true.
They all think I'm a functional purist and PHP-hater. :'(
 
@NikiC will you still try to spec reserve the void keyword?
 
@marcio yes
 
also @LeviMorrison instead of trying to block void why don't you try to spec reserve enum instead? By the line of your argumentation you are going to have trouble with your RFC later.
 
6:59 PM
Marcio, I was thinking in a specific grammar for the preprocessor, similar to Flex grammar and make the preprocessor able to recognize language tokens.
 

« first day (1683 days earlier)      last day (3262 days later) »