« first day (2353 days earlier)      last day (2588 days later) » 
00:00 - 15:0015:00 - 00:00

12:15 AM
@bwoebi @kelunik lift is a terrible name, I lifted it from Q or some other JS lib (pun intended :-D). Let's find a better name or just drop it since it sort of goes against Amp's style.
 
Problem from array_diff function – #74313
 
@kelunik map is one of those basic combinators that we should probably keep even if the implementation is simple. Especially if we get rid of lift… then we'd definitely want to have map.
 
 
5 hours later…
5:10 AM
E_REALLY_QUIET
 
 
1 hour later…
6:32 AM
morning r11
Happy birthday @PeeHaa
10
 
Can anyone tell me how the Kahoot system works?
I want to know how you can 'host' a game session like this and make users keep connected to it and exchange data seamlessly between the server and client.
I think sessions might be useful but have no clue about whether or not I'm right.
 
oh, happy birthday @PeeHee \o/
 
7:06 AM
Fatal error: Declaration of test2::test() must be compatible with test1::test() – #74315
 
@Jeeves booo morning
 
@Linus Lol I think you have Alzheimers myria.
 
7:26 AM
kahoot uses nodejs
 
8:00 AM
@Trowski Yes, I think I'd drop lift and provide filter and map.
 
posted on March 26, 2017

New Cyanide and Happiness Comic

 
@Trowski TBH we don't have a single use of either in our libraries as far as I can tell.
I'd drop both, we can always add things later. /cc @bwoebi
 
Tnx @Linus @Saitama \o/
 
8:16 AM
;)
is party going on?
 
o/
 
@Linus yessss :-)
 
:)
 
I think imma start with a whisky now
 
neo
8:34 AM
noobie issue... is ther any websites that helps to follow secure coding standards ?
i mean i can create a user registration system from my common sense.
there are a lot of sample projects that implement user registration system
reading all these codes and understanding the common standards in very tuff
is there any sites that just show basic idea like flow chart so that i can personally code from the idea ?
 
9:10 AM
umm.. unrelated... I want some fantasy-action or fantasy-thriller anime suggestions ^ ^
 
@kelunik let's keep map() and filter() though as they're indeed quite generic and may be helpful
 
9:30 AM
@bwoebi We don't have filter right now.
@bwoebi I want to remove anything that has no single use. Keeping the API small means less to read for people and thus less to learn.
 
I am agree with @kelunik if there ever becomes demand for it either add it or create a dedicated repo for nicetiws like that
 
You may be right. I'm thinking about it… and actually map() is just equivalent to $promises = array_map(function($promise) { return \Amp\pipe($promise, function() { … }) }, $promises);
 
It like is all niceties
s/like/really
!!DAVE
 
suggest me good tool/templates for rest api document.
 
!!dave
 
9:35 AM
Hmm shouldn't that work now?
 
@DaveRandom should work on DNS lib.
 
for rest development i use slim framework
 
I thought dave made it case insensitive
 
oh.. idk,,, :/
 
Well clearly he fucked up :p
Maaybe it's because it's an alias instead of a command cc @DaveRandom
 
9:45 AM
Well I just wanna share.. Rasmus Ledorf said that "All PHP frameworks suck" while deploying v7. From that day I stopped learning laravel and I am happy about it. What is your guys take?
Worth ?
 
Lerdorf doesnt have anything to do with php development :p
 
/me reading PHP 7.1 code … what's this ? namespace… lol.
?\Throwable reads absolutely weirdly
 
Wat
Wth is that?
 
yeah, it's nullables…
 
Oh lol
Yeah that got me
:-)
 
9:50 AM
That's what I hated about ? in favor of |null in the first place…
 
I hate that instead of a sensible general solution it's yet another special-cased one off
 
@PeeHaa :P
 
@PaulCrovella that too
 
is an anime recommendations thing for Jeeves acceptable? :P
 
9:58 AM
i cri everytime
 
@bwoebi Maybe null maybe Throwable?
 
9 mins ago, by bwoebi
yeah, it's nullables…
 
Yeah, IDK what's that
 
@PaulCrovella It's a valid special case. I use it quite often.
 
@kelunik That's no reason for not just having a general and more readable case.
 
10:02 AM
^
 
@bwoebi It is. Nullability existed before, combined types add additional complexity to the type system.
@bwoebi And I don't agree with the readability. The leading backslash harms the readability, not the ?.
 
@kelunik The combination of both does … the leading backslash always existed (and don't tell me to use; this now) and ? prefix is new.
 
@bwoebi A leading backslash is also ugly without ?.
 
no
 
I even backslash functions, easier to refactor code automatically :-)
 
Anonymous
10:17 AM
Happy Mother's Day @DaveRandom <3
 
Does anyone know how i could make a script wait until a file exists?
i try this but it doesnt work:
 
@zeddex What's supposed to create the file?
 
I manually add it into the dir
in xampp
 
"I know that there are people who like JavaScript, and I hope that these people find the mental health services that they so desperately need. I don’t know all of the answers in life, but I do know all of the things which aren’t the answers, and JavaScript falls into the same category as Scientology, homeopathic medicine, and making dogs wear tiny sweaters due to a misplaced belief that this is what dogs would do if they had access to looms and opposable thumbs."
 
i was going to be generating txts with a exe and exec
 
any ideas?
even if i have test.txt in the dir then run the script only the first echo ever happens
 
The fuck is that text file bro ??
 
@SebastianBergmann Same for php? :-D
 
mornning
 
bob
10:45 AM
Morning all
 
@SebastianBergmann lol
I tend to disagree, but eh :D
 
Anyone here trying to be Java junior dev? :-) /cc @DaveRandom
 
@DejanMarjanovic lol
I like that ping
 
:-D
In Germany it's usually Java Engineer and PHP Developer, therefore, you get more money because of the title :-D
 
problem solved
needed do while stuff
i never really use loops like that, it's working now though
 
10:55 AM
@zeddex You should sleep(1) or so if you're going that path...
 
it seems to be instant when the file exists, why would you need to wait a second?
to avoid errors?
function WaitForFile($file){
set_time_limit(0);
echo "Script began looking for the file ({$file}): " . date("d-m-Y h:i:s") . "<br>";
do {
if (file_exists($file)) {
echo "The file ({$file}) was found: " . date("d-m-Y h:i:s") . "<br>";
break;
}
} while(true);
}
WaitForFile("test.txt");
that is my final function
seems to work well
 
It works well for heating your room. :)
 
++heating if its an amd cpu ^ ^
 
Dear lord.
 
so the sleep lowers the cpu usage somehow?
 
11:03 AM
@zeddex You're doing an infinite loop with no sleep state
You'll reach 100% CPU (or close) pretty quickly.
And maintain that level until the file is created.
 
is that because it runs lots of times rather than a few?
 
@MadaraUchiha have you watched any recent animes?
 
@Saitama No 😬 No time
 
i always see people using loops without sleep
 
@MadaraUchiha ugh.. adulthood is hard...
 
11:04 AM
@zeddex Infinite loops?
A loop with no stopping condition?
 
where in my code would you add the sleep(1) part?
 
@zeddex Oh, I wouldn't do it in PHP at all.
Doing something like that synchronously is silly in my eyes.
 
filthy js peasant
 
I'd go for a language with await, C#, NodeJS, even PHP with AMP (but AMP is a bit complicated for a beginner)
 
k
 
11:06 AM
@MadaraUchiha also dart ^ ^
 
function WaitForFile($file){
set_time_limit(0);
echo "Script began looking for the file ({$file}): " . date("d-m-Y h:i:s") . "<br>";
do {
if (file_exists($file)) {
echo "The file ({$file}) was found: " . date("d-m-Y h:i:s") . "<br>";
break;
}
sleep(1);
} while(true);
}
like this?
after the if statement?
 
@zeddex Please format code when posting in chat.
 
I would just use inotify for that
 
Paste, CTRL+K, Enter
 
sorry i just copied directly from notepad++
 
11:08 AM
25 secs ago, by Madara Uchiha
Paste, CTRL+K, Enter
 
is there any way to set mt_rand(0, 10) indentation in phpstorm :P
 
you wait a second after the if statement though right?
 
user6845426
I have a html form attached with a php script. Every time I refresh the page the form re-sends ending in duplicates/empty data. Does anyone know a work around?
 
!!? post redirect get
 
Search for "post redirect get" (https://www.google.com/search?q=post+redirect+get&lr=lang_en)
• Post/Redirect/Get - Wikipedia - Post/Redirect/Get (PRG) is a web development design pattern that prevents some duplicate form submi… (https://en.wikipedia.org/wiki/Post/Redirect/Get)
• php - Simple Post-Redirect-Get code example - Sta… - 10 nov. 2010 - I have found many sites that describes PRG, but no simple PHP code … Simplest scenar… (http://stackoverflow.com/questions/4142809/simple-post-redirect-get-code-example)
 
user6845426
11:12 AM
ooo thanks
 
@zeddex Try it and see. You should know that whether it works or not, it's a really bad, odd way of doing this.
 
bob
just a quick question I'm creating a directory folder on photo upload, however it creates the folder when the form is submitted even if it has errors. any idea how i can prevent the folder being created until everything is accepted?
 
@bob Don't create the directory before you're sure you need to?
 
bob
@MadaraUchiha That's what i thought i was doing.. here's the script pastebin.com/zJnFnr9V line 7
 
seems to work great, without it the cpu is still not too bad, probably why i didn't notice it since it's in xampp atm but i will use the sleep(1) now which has less cpu usage.
thanks everyone
 
11:17 AM
@zeddex I still want to stress how bad a solution that is.
There are much much better tools for this job.
@bob You're creating the directory at line 7, before any sort of check
 
bob
@MadaraUchiha I just notice. haha
 
You aren't checking for errors or doing anything to being sure you need to.
 
ok thanks, it wasn't going to be web based so i wasn't too bothered. For a online tool i probably wouldn't ever use it.
in xampp i exec a lot of exe commandline tools etc
anyway i have to do a bit of work soon, nice talking to you everyone
bye
 
@MadaraUchiha await doesn't help you. You need something that notifies you on creation like inotify.
 
@kelunik await itself doesn't help you, but languages with await usually have simple tools to do what he wants, without blowing the cooling unit.
 
11:25 AM
Amp doesn't have something like that. :P
 
@kelunik That's a darn shame :D
Doesn't AMP have an async inotify-like support?
 
ThW
Morning
 
user6845426
11:42 AM
I know its not that right chat but is someone able to take a quick look at my ajax request and shout at me where i've done it wrong
 
11:57 AM
@MadaraUchiha well, the main issue is that you need an extension for i- and fanotify
 
@bwoebi nods that makes sense.
 
AFAIK such extensions do exist in PECL, but due to them not being available by default, there's much lower interest in it … but feel free to write a lib on top of them
 
@MadaraUchiha The only component that would currently benefit is amphp/dns to reload the /etc/resolv.conf and /etc/hosts files.
 
@kelunik aerys could also benefit from it for reload in dev envs
 
And, you know, userland.
 
12:02 PM
sure
 
I didn't have any use case for it yet.
If you need to watch files, changes are good you're doing something wrong.
 
It depends on what you're doing with it …
 
and you're going to be disappointed when you try it using nfs
 
@bwoebi I said "changes are good" to account for hot code reload.
 
Oh, I thought you mistyped chances ^^
 
12:15 PM
I did. Twice.
 
12:26 PM
Hmm
You can do that? HMR in PHP?
As in, if I have a class in a given namespace, is it possible to "unrequire" it and require it again?
 
No, but you can spawn new Aerys workers.
 
hello
 
@MadaraUchiha Well, you could do something like that with php.net/manual/de/book.uopz.php
 
joe will hurt you though
 
@kelunik Wait, so how does it help you with HMR?
If you already have a class loaded in the PHP process, you can't reload it.
(without cheating with uopz that is)
 
12:40 PM
@MadaraUchiha Aerys runs multiple workers. We just spawn new workers loading the new code and shutdown old workers having the old code loaded.
 
@kelunik What do you call a "worker"?
A new PHP process?
 
@MadaraUchiha Yup.
 
Aha
Yeah, that would work.
 
But that depends on the workers being always stateless.
If that's the guarantee, it would work beautifully.
 
12:43 PM
Well, any state you have needs to be stored outside the workers, otherwise you'll run into issues with clients connecting to different workers anyway.
 
are you there? @tereško
 
hi, my name is anna and im new here
 
@AnnaLA Hi Anna who is new here.
 
i am
 
:-)
 
12:47 PM
:)
 
I recommend ElasticSearch
 
42 secs ago, by Madara Uchiha
I recommend ElasticSearch
 
can you send me an exmaple pls? how to use it.
 
@AnnaLA It's a tool, you'll need to learn it.
Look up tutorials about it.
 
12:51 PM
Guys, it's 10 hours I'm trying to find a solution for a problem but still I stuck on it. the problem: I have a web service which returns a json (it acts like an API). Now I need to restrict it just for my own website. I mean, I want to return a correct response only to ajax calls which come from my own website, not anybody else. How can I handle this?
In other word, how can I identify my website's ajax requests?
 
@Shafizadeh The referer header
Although it's not secure (the client determines it)
 
it is usually empty
@MadaraUchiha yes.
 
@Shafizadeh A simple way is to make sure the user has a valid session with your server
Also, you should know that nothing you'll do will lock it down 100%
If I'm really determined, I'd start a headless browser on my server, actually visit your website, make the call from there, store the information, and do whatever I want with it.
 
shit!
@MadaraUchiha hmm, lemme think about it
 
@Shafizadeh Why do you care so much?
Is there private information there?
 
12:57 PM
@MadaraUchiha Because the API my website provides isn't free.
 
@Shafizadeh So the user pays, then accesses the infromation
In which case, you must be authenticated (and send a valid API token) to access the API call
Problem solved
 
You don't need OAuth for that.
 
@MadaraUchiha exactly ..! I need to get an access token per each request. all fine. But in this case, how can I authenticate my own website? I need to devote a token for my website which should be sent by every ajax request, right? ok, in this case that token should be written in the JS code which is visible for everybody. So eveybody can use the API as free (by copy/pasting the token belongs to my own website). any suggestion?
 
@Shafizadeh Why?
 
@Shafizadeh Why does your website have free access?
 
1:00 PM
What's wrong with the per-user tokens?
 
@MadaraUchiha it is good for authenticating other users, but it is not good for authenticating my own website.
 
@Shafizadeh Aren't the users implicitly on your website?
 
@kelunik well all I'm trying to do is changing this policy
@MadaraUchiha no, sometimes users connect to my website through an android application
 
@Shafizadeh OH
Wait
Why do you care if your paid users come from the website or the android app?
 
I don't care ..! actually I can control all paid users via that token. it's totally fine. My problem is I cannot detect my own website's requests...
 
1:04 PM
@Shafizadeh In that case, a very simple source=website would be sufficient.
It doesn't need to be secure, and you don't really care if a paid user is trying to cheat you
 
yes I don't care if a paid user is trying to cheat me. but look, I have to devote one token for my website requests, right? and it should be passed by each ajax request, which is written into JS codes. And as you know JS codes are visible to everybody, so everybody can use my website's token and get the result as a paid user!
this is the problem ^
 
@Shafizadeh you will never know for certain which client someone is actually using to connect to your api
 
@PaulCrovella too bad then!
 
@Shafizadeh No, you need both
Just saying "Hey! I'm from the website" isn't enough
You need to say: "Hey! I have this token XYZ, also, I'm from the website!"
 
it is enough, but is doing that possible?
 
1:08 PM
@Shafizadeh Why not?
 
how can I handle this? "also, I'm from the website!""
 
@Shafizadeh Add a source: website property to the requests coming from the website.
This is completely unrelated from the authnetication token the client must present for each API call
 
in the ajax request?
 
well yes, this is reasonable, I have to make such thing:
$paid_tokens = ['k3409k43', '3490ki34', '349ij0430'];
$token = $_GET['token'];
if ( in_arrray( $token, $paid_tokens) || <it is my own website> ) {
    // allowed
} else {
    // don't allowed
}
but still I don't know how should I handle this: <it is my own website>
 
1:12 PM
&&
 
@MadaraUchiha OR
I don't want to devote any token for my own website.
 
What do you mean by "your own website" the website doesn't send API calls, your client does.
 
5 mins ago, by Madara Uchiha
@Shafizadeh Add a source: website property to the requests coming from the website.
 
Are you saying that you have a normal server and an API server and you want the two servers communicating?
 
@MadaraUchiha no no! you are right, my client does
 
1:14 PM
@Shafizadeh So why OR?
 
but I need to know, this client is my own website
 
...
I give up.
 
@MadaraUchiha first condition is for paid users, second condition is for my website's requests
 
Someone please explain to them why what they're saying makes no sense.
I need to get back to work -_-
 
ok, have fun.
 
1:15 PM
1 min ago, by Saitama
5 mins ago, by Madara Uchiha
@Shafizadeh Add a source: website property to the requests coming from the website.
^ that would WORK!
 
@Shafizadeh Do people pay to use your website?
 
@NikiC yes, when they pay, I give them an access token
 
@Shafizadeh Okay. You include the access token in the JS on your website. You use that access token to access the API. You don't actually care that the request comes from "your website" in some way, you only care about the access token.
At least for authentication purposes, there is no need to identify that the request is made by JS served on your website, it doesn't matter
 
@NikiC in this case, everybody can see that token which is in my JS code.
 
@Shafizadeh no, only the logged in user who paid for the service can
 
1:20 PM
@NikiC no, look, here is the scenario: everybody can see the results on my own website, and paid user can also get the result as a json.
 
Ahhhh
 
I think I need a CRFS
 
So your website is free, public, without login, correct?
 
but it isn't secure either !
@NikiC yes
 
@Shafizadeh In that case you can't really prevent people accessing the API for free. The only thing you can do is making it harder
E.g. when the website is accessed generate a temporary and rate-limited token
Together with IP-based rate-limiting
 
1:24 PM
@Shafizadeh Your best bet is a tool like Incapsula that uses machine learning to determine whether users are trying to scrape information from you, and block them.
 
yes, this can be correct
 
If you provide your information for free, a determined user would always be able to get them in whatever format they want, after scraping your website.
 
@MadaraUchiha actually I've made a similar mechanism. I store all IPs and block suspect ones
 
@Shafizadeh I live in a place where IP is shared between ~1000 people
If you block me, you block all of them
Also, I happen to change IP addresses as I walk down the street with my phone.
 
:-)
anyway, that's all I can to do!
 
1:27 PM
@Shafizadeh What Github does (iirc) is allow unauthenticated api requests with a low rate limit, and authenticated with a high limit. Depending on what your service is that might be good enough.
 
you know, what google does isn't even secure.
it passes a fs.id which is a long dynamic number per each request, also it sets some headers. But all of them are visible into its JS codes!
 
@NikiC Yes, but any request with client ID + client secret is considered authenticated.
@Shafizadeh You just exposed your Google session cookies...
@MadaraUchiha Could you please delete those?
 
yes pelase @MadaraUchiha
 
@Shafizadeh You can do that yourself if you're quick enough.
 
time is over
 
1:36 PM
plol
 
thx!
I'm wonder, why this approach has earned 30 upvotes!
 
@Shafizadeh kinda, what's up?
 
nothing much ..! are you ok?
Also "nothing much" is a right answer as "what's up" question ?
 
it depends :D
and that answer has earned 30 upvotes, because it's close to 8 years old
 
ah :-)
anyway, I need to detect my own website's requests, do you have any idea for doing that?
 
1:48 PM
it's only partially possible
 
why do you want to do it though?
 
you can detect that the request was made by something, that has viewed your page before
 
good idea, but anyone else can simulate my page either ..!
 
you send a random string to the client, which the client then attaches to the next request
 
@user7594714 because I want to present my website API as paid (not free)
 
1:51 PM
use api keys then
 
@tereško also I have to store that token into the session, right?
 
@Shafizadeh in that case, you should look at how oauth does things
@Shafizadeh yes, but that is only CSRF protection
 
Evenings o/
 
look, I have one web service which returns a JSON string as result. Now there is three cases:
- paid users
- my own website
- anybody else
I can detect paid users via an access token
but I don't know how can I detect my own website's requests!
 
Limit your api requests to paid users and do your own website internally
 
1:56 PM
what do you mean "do your own website internally" ? how exactly?
 
Im guessing you have external endpoint for api requests and instead of using that call the functions internally
 
Sadly I don't understand what you mean!
 
Did you find a solution?
 
not really
 
is your api server and your website server the same?
if so you can call the functions that returns the value using php without using external endpoints, and if they arent then you can use curl.
 
2:14 PM
@Ocramius ohh, yeah, good point. closures are objects, but callables aren't necessarily
 
2:33 PM
puu.sh/uZ1Uv/a4103b1894.png results in two Undefined index errors for some reason
 
You should first check if they are set
like... if(isset($_POST['studentName']) && isset($_POST['studentEmail'])) { /* do stuff */ }
 
oh yea.. thanks!
 
user6845426
I have a query which grabs the last 3 entries from a table. And I have 3 <div> in which I want to place content inside. The problem is, the <div> I use have different ID's which have different styling properties. 1st div has 100% width whereas 2nd/3rd divs have 50% width. How would I go about looping through the results of my query and adding them to the appropriate divs? At the moment I just loop foreach $result and echo the html
 
user6845426
So basically, I want to echo 1 thing for the 1st returned query and echo something else for the other remaining results from the query
 
user6845426
2:53 PM
I've tried to grab the last 2 entries minus the last with this query SELECT * FROM projects WHERE id != (SELECT MAX(id)) ORDER BY id DESC LIMIT 2
 
00:00 - 15:0015:00 - 00:00

« first day (2353 days earlier)      last day (2588 days later) »