« first day (3442 days earlier)      last day (1499 days later) » 

6:00 PM
if (array_keys($set1)[0] === array_keys($set2)[0]) { ... }
 
Tay
Well, I thought that too
until I realised that the original JSON will have multiple first keys
Thats whats tripping me up rn
so now instead of comparing two keys... im comparing several versus 1
{
 "key1" = {}
 "key2" = {}
}

vs

{
 "key3" = {}
}
and if its different, merge the arrays and create
 
uhhhh sorry I meant
 
Tay
{
 "key1" = {}
 "key2" = {}
 "key3" = {}
}
 
if ($set1[array_keys($set1)[0]] === $set2[array_keys($set2)[0]]) { ... }
However, in JSON, tyhe key order is undefined
 
Tay
PHP if statements are a bit different, Can you show me what this does? Just a summary or something

`$set1[array_keys($set1)[0]] `
I do want to understand how it works so Im not just copy pasta-ing
 
6:06 PM
array_keys() finds the keys, the [0] selects the first key... and putting that inside $setx[...] gets the value of the first key
 
Tay
is it possible to use a similar method with something like for_each to see if it matches?
or.. I just realised, what if I selected the entire original statement and use ["nameImComparingFor"] and if it returns undefined, Ill continue the operation
Thanks for the if statement help, Ill use this and see what I can come up with
 
@PeeHaa ?
 
@DaveRandom I am playing a bit with writing a dns server :P
 
Tay
could something like this work?
if (!array_keys((array) json_decode($originalData))[$userName])
 
ah yeh I have considered doing that a few times
 
Tay
6:14 PM
like, if it cant find an array key with that value, cancel operations
 
bind isn't nealry pluggable enough
 
It should be pretty simple (the thing itself)
But there is a lot I simply do not know about it
 
I'd also like a DHCP server module for it, if we are going to do that
because again, dhcpd isn't nearly pluggable enough
and the config for it is absolute garbage
 
Sounds awesome
And again pretty simple?
:P
 
oh yeh dhcp is stupid simple
 
6:16 PM
\o/
 
I never actually implemented it but I think you can pretty accurately describe the whole protocol on 2 sides of A4
inb4 yes in readable size font :-P
 
:D
 
I am 100mph until (I'm guessing) ~3 days into lockdown, whenever that happens, then I am hoping to get some of the stuff done that hasn't been getting done for years
there will be a bit of dribbly idiot mouth wiping for a few days
 
Business as usual
got it
 
and we have now had >£600K of hardware through this office since last monday
so that's been fun :-P
 
6:20 PM
:-)
 
@DaveRandom Time to write DCHP in PHP?
 
@Trowski That's what's going to happen :)
Right after dns :P
 
If someone is quarantined with nothing to do, SMTP is on my wishlist.
 
@Trowski Way ahead of you :P
Yes I have issues ok
I know
@Trowski You already seen mailgrab I assume right?
 
@PeeHaa Heh, we all do (know)
 
6:26 PM
<3
 
@PeeHaa Yes, though I haven't looked in some time.
 
@Trowski Currently writing a full server
 
Tay
I did a bit of research, and I came up with this: however, somehow, its still writing to my json file.

Even though its supposed to return "not True" or !true
  $fp = fopen("./CDN/Private/Users.json", 'r+');
  $originalData = fread($fp, filesize("./CDN/Private/Users.json"));
  if (!array_keys((array) json_decode($originalData))->$userName) {
    $userDataStreamMerged = (object) array_merge((array) json_decode($originalData), (array) $userDataStream);
    fwrite($fp, json_encode($userDataStreamMerged, JSON_PRETTY_PRINT));
  }
 
and client
 
Awesome :-D
 
6:27 PM
@Trowski I have started it 3 times, and lost the will to live 3 times
that is a protocol that essentially mandates terrible code :-P
 
@DaveRandom I can't really think of a reason for it anyway. Nevermind, I thought you replied to the DCHP question.
 
@DaveRandom I concur
I have something OK right now
 
EHLO fuck.no
 
Not good / sane but ok
 
Tay
could someone atleast attempt to help? please? I legitimately dont know what else to do
 
6:28 PM
@Tay what is it you are actually trying to do?
 
Tay
Compare the first keys of both JSONS
 
I massively prefer + for assoc arrays btw
 
Tay
and if they are the same, cancel operation
See the JSON file, I want it to NOT post duplicates if they have the same name (sirCode)
{
    "sirCode": {
        "pass": "examplePass",
        "role": "admin",
        "name": "Sir Code",
        "uuid": "cwsUser-admin-5e73b921b7d2b"
    }
}{
    "sirCode": {
        "pass": "examplePass",
        "role": "admin",
        "name": "Sir Code",
        "uuid": "cwsUser-admin-5e73b92300531"
    }
}
it shouldnt post the second one
 
Dear God, it takes 18 functions and 400+ LOC to determine the winning poker hand in a game of Texas Holdem.
Who knew poker was this complicated?
 
Tay
poker is complicated. Its not a "oh he made that move, he wins"
ive never personally played, but Ive watched
 
6:31 PM
@Tay is that because all the keys are identical? or just one of them?
 
@Sherif is that a challange?
 
Tay
Im going to put other peoples accounts here.

So yes, im just making sure the name isnt already in the JSON file
its basically an account generator
 
oh god
@Tay no
 
@JBis No, I just didn't expect it to be that complicated. The problem seems deceptively simple at first. It's just a sorting problem. But then you realize all the edge cases.
 
@Tay what are you doing with the data? inserting it into a database?
 
6:33 PM
@Sherif like what? (besides your aces issue)
 
Tay
I dont know how to use any DB languages, and this is a tiny project, I just wanted to play with JSON for now
think of JSON as my database
temporarily atleast
 
detecting a hand is probably more difficult than checking which one beats
 
@JBis No those are the same problem
Detecting a hand is as simple as going down the list of taxonomies in the sorting algorithm
 
@Tay ok well it sounds like you should be keying it by username and doing if (isset($collection[$userDataStream['name']])) // bail
 
@Tay you should not store passwords in plain text
 
Tay
6:35 PM
Its fake
Temporary
 
temporary is never temporary, ftr :-P
 
Tay
This is all just a test code, once its setup, all that will be serversided, hidden, locked away, whatever
infact, I might remove passwords all together
 
@Tay I highly advise you to not try auth until you have more experience and learn what hashes are, how they work, and other secruity concerns. I'd suggest looking at owasp/
 
Tay
I just wanted to see how I could store data
Im not doing auth... Im writing account names to json -.-
 
Hey @DaveRandom o/ remember me from like 2 years ago?
@Sherif fair enough
well i'm going to go try and make one
 
Tay
6:37 PM
@DaveRandom also whats that if statement, whats isset and $collection?
 
Well, that was a rather fun 2 hours
Never wrote a poker game before
 
Tay
@Sherif Ive seen some lazy devs, when it comes to stuff like board games on pc, everything is just draggable.

and it relies on the people ingame actually following the rules to win the game. **or even start it**
 
@Sherif is it playable?
 
@JBis Well, only as an interface. It's not a complete implementation.
But it passes all tests :)
 
6:42 PM
Nice. When ever you are having a bad day, just open this project and see all your tests succeeed.
 
Tay
@DaveRandom but, it looks like its just reformatting it.

Im a bit confused, is that for each detecting for dupes?
foreach (json_decode($new, true) as $name => $user) {
    if (!isset($db['users'][$name])) {
        $db['users'][$name] = $user;
    }
}
now I see the isset thing, it must mean "is Set"
 
you think? :-P
yeh
 
Tay
i just thought ya mispelled asset or something lol
 
it's only adding an element to the array if it doesn't already exist
 
Tay
I work with java programs, I see asset pretty much half my time.
ok
that makes sense
Ima look over it some more, because I need to understand what exactly is going on
 
6:45 PM
in reality you would have a SQL table with a unique constraint on the username column
i.e. the database would enforce the deduplication
 
Tay
Well, id LOVE to setup SQLite, or something similar, but Im dumb-f and I dont get it
I miss ios development... property lists ;-;
so easy to write to
 
configuring it is a pita. using it is actually pretty simple
 
Tay
well, ive gone this far with the JSON writer, and I want a JSON writer for an online api that Im going to start working on soon. so I might as well finish this one first
 
isset() is a language construct that basically does !== null, but doesn't throw an error if it's undefined
 
Tay
makes sense
its literally asking if its set or not
 
6:47 PM
indeed
there's also empty() which is basically == false but again, suppresses the undefined error
you rarely want that though, imo
 
Tay
Also... whats that really wierd JSON wrapper thing?

the
<<<'JSON'

JSON;
thing
 
it's called a nowdoc
similar to heredoc
which is also a thing php has, but comes from *nix shell
it's basically a way of writing string literals without needing to worry about escaping
 
Tay
is it like a inline file, it interprets the content as a specific mimetype and uses that variable as file content.
 
@Tay have you ever used C#?
 
Tay
yes, a bit infact
 
6:50 PM
you know the @"" string literal syntax?
it's like that, but you also don't need to escape quotes
 
Tay
yeah, usually used as file references
oh
Well thats simple
 
yeh :-)
 
Tay
learn somethin new everyday i guess
 
if you do $foo = <<<LABEL (without the single quotes) the variables are interpollated, that's a heredoc
$foo = <<<'LABEL' (nowdoc) doesn't interpolate anything
 
Tay
And whats the difference? like do they function in a different way
 
6:52 PM
just interpolation
one sec
 
Tay
only reason Im so late to start php (html/css/js at about 11, others 13, and php at 15 now) is because I was never able to use it before.
now I got things like repl.it 3v4l, etc
And my dad as strict as he is, would probably never let me turn my pc into a php apache server
 
that's the difference
 
Tay
oh I see, its like a string vs an escaped string literal
one escapes, one doesnt
 
here is @$"" and now is @""
in c# terms
 
wonders when we'll get a <<thendoc
 
Tay
6:54 PM
ah, thanks
 
or is it $@"", I can never remember the sigil order of that
I really wish both worked there
in fact I might open an issue for C#.next (8? 9?)
there's really no reason for it not to work like that
 
Tay
No idea lol
I havent used NET or C# in over half a year
I got on a little bit again with Unity Gamedev, but im just too unskilled for that atm
and traded C# with Blender Courses
 
@MarkR I prefer proper await over then
 
Tay
so I could atleast create good quality game assets
 
@PeeHaa I have been toying with the idea of trying to make a yieldable generator derivative that inherits from promise with ffi
for me that would solve 90% of the problems we have now
 
6:59 PM
I understood the word "that"
\o/
Would the ultimate goal be to get it into the language itself?
 
@PeeHaa in essence, using the stuff behind github.com/lisachenko/z-engine to make class Coroutine extends Generator implements Promise {}
(automagically cast by virtue of return type)
not sure if actually possible
but I think might be
 
Well I would not be using that if it uses that library :P
> It is not a freeware license. This license requires that you open-source all of your own source code for any project which uses this library!
 
no it would be super stripped down pure ffi
 
k
good
 
like I say, not sure if even feasible
 
7:02 PM
make it so
 
have yet to play with it properly
@PeeHaa funny you should say that ^ :-P
 
:D
 
lol
@JoeWatkins happy belated birthday and I enjoyed the canonish in G :-) you've got some strings in the background there, working with a DAW now?
 
no, I'm playing that on the piano
 
huh, cool stuff
 
Tay
7:06 PM
@DaveRandom I tried implementing your solution into the project, and Im getting a wierd error about using a string offset as an array? repl.it/@skylerspark/CWS-CDN
 
yeah, fancy piano and finger trickery makes it sound like more than one instrument ...
the thing can also sing like a choir ...
 
@Tay $originalData is a string, you didn't json_decode() is (I assume is what you meant)
that error is, I concede, a little cryptic if you are unfamiliar with PHP
 
Tay
its wierd
because it works
like, if you clear the JSON file, it works
 
ah yeh, that's another weird foible of PHP
false can be used as an array with no error and will be transparently cast to one
 
Tay
I decoded it
 
7:10 PM
we are trying fix weird ass shit like that, ftr :-P
 
Tay
still same error
 
Isn't that b eing killed in 8.0?
 
I seriously hope so
 
Tay
maybe its because I dont include that "users" subpath normally
 
I can't remember if falsey array generation was in that one or another one
 
Tay
7:11 PM
Ill try that
 
@Tay should I be able to see the change on that link?
because I can't
replace this:
 $fp = fopen("./CDN/Private/Users.json", 'r+');
 $originalData = fread($fp, filesize("./CDN/Private/Users.json"));
with:
 
Ah, afraid not, objects only. Probably to deal with sodding nulls.
 
Tay
why doesnt original data show the decode...
 
$originalData = json_decode(file_get_contents("./CDN/Private/Users.json"), true);
 
Tay
ohhh
ok
 
7:13 PM
see also file_get_contents() :-P
 
Tay
its working now
 
btw @Tay it gets easier when you stop thinking as low level as Java/C#
 
Tay
Whats the difference with file_get_contents, what im guessing is that it cant open 2 file streams at once?
 
@DaveRandom you have a spare minute to clone and test something for me?
 
PHP has a lot of stuff to help you out with things like that, a lot of the time there is a kitchen sink function that does 50 line of java in one fcall
sometimes you don't want that, sometimes you do
@PeeHaa I will in ~30mins
 
7:15 PM
awesome
will push and share a link
 
I really need to go do some work btw @Tay but bbiab
 
Tay
I guess with so much javascript and C#, (nearly 3 years of it, and I started when I was only 11), Ive sorta grown into my own style
 
@PeeHaa kk
 
Tay
cya, and thanks a ton
 
did you change your mob num btw @PeeHaa?
I whatsapped you a few days ago and permanently undelivered
 
7:15 PM
Nope. I don't use it here it dead.
Want booty call?
 
always
 
Can reach on twitter dm if you want private sexy time
 
kk cool
 
<3
 
ttyl
 
Tay
7:16 PM
o-o
 
x
:-P
 
Tay
o_O
 
@Tay file_get_contents() does what it says on the tin... opens a file, reads it into a string and closes it. You don't get an fd to work with, but if all you want to do is read the data from a file it saves you a lot of code. There's also file_put_contents() which writes a string to a file "atomically" (from PHP's perspective), in general they make for much more readable code unless you really actually need a handle to work with in several steps
really going now
inhabit
 
Tay
Cool
thanks, and cya
 
@DaveRandom git clone https://github.com/PeeHaa/async-dns-server.git && cd async-dns-server && composer install && php ./bin/server.php
nslookup example.com 127.0.0.1 this works
When I bind to ipv6 interface github.com/PeeHaa/async-dns-server/blob/master/bin/… and run nslookup example.com localhost it fails with:
> PHP Fatal error: Uncaught Amp\Socket\SocketException: Could not send packet on endpoint: stream_socket_sendto(): The requested address is not valid in its context.

in D:\Web\async-dns-server\vendor\amphp\socket\src\DatagramSocket.php:160
Stack trace:
#0 D:\Web\async-dns-server\src\Server.php(67): Amp\Socket\DatagramSocket->send()
#1 [internal function]: PeeHaa\AsyncDnsServer\Server->PeeHaa\AsyncDnsServer\{closure}()
#2 D:\Web\async-dns-server\vendor\amphp\amp\lib\Coroutine.php(105): Generator->send()
Socketaddress in that case seems fine to me:
object(Amp\Socket\SocketAddress)#7 (2) {
  ["host":"Amp\Socket\SocketAddress":private]=>
  string(3) "::1"
  ["port":"Amp\Socket\SocketAddress":private]=>
  int(56391)
}
Whenever you have time / want @DaveRandom ^
 
Tay
7:23 PM
it probably doesnt recognize the shorthand localhost url.
 
@PeeHaa sounds like you are trying to sendto and IPv4 dest on an IPv6 src, at a no-think guess
or vice versa
> The requested address is not valid in its context
 
@DaveRandom Socket address tells me it is ipv6 loopback address though
 
k I will look properly when I've finished this AD bullshit I am doing
 
No stress
 
really triple sanity check that you are dumping out the right things though, and not accidentally dereferencing false instead of 1 from an array, for example
(which is a thing I did yesterday so it's fresh in my mind :-P)
 
Tay
7:31 PM
man this is the most active Ive ever seen this room
that moment when github gets blocked FFUUUUUUUUUUUUUUUCK
 
8:32 PM
@PeeHaa I have to go do data centre duty :-/ might have to be tomorrow
Got 9 servers that need to be in by 10am, realistically that ain't happening unless we go now
 
8:42 PM
@DaveRandom have fun.....and try to get some sleep at some point...and ask for a raise/bonus...
 
Tay
@DaveRandom Sorry to bug ya, I tried moving that merge forEach into a seperate function for multiple uses (Im going to be using several different JSON files)

And after a ton of bullcrap, I thought I had fixed all the errors. And I did, however, now its setting the json file to NULL https://repl.it/@skylerspark/CWS-CDN
 
@Tay you should learn to debug your code...
 
Tay
sorry I was gone, had to do some chores
Oh, I wasnt askin- nevermind, I was just seeing if he wanted to look at it if there was any obvious issues
Im blind irl
it causes many issues
sometimes I just dont see stuff
yup, it was something stupid
I wasnt returning $json1
So it was returning NULL
Oh, now theres more issues
 
9:00 PM
@Tay I suspect the person who just said they're about to work for 15 hours after just finishing their normal days work, isn't likely going to take a look at random stuff that needs debugging.
 
Tay
this is something I dont think I can solve though... If I clear the JSON file, and click run, it works perfectly, but if I run it again, it deletes the inputs 1by1
@Danack He was the one who gave me the snippet, Im still a little confused on how it works
 
8 mins ago, by Danack
@Tay you should learn to debug your code...
 
Tay
I know how to log and var_dump things to see outputs
thats how I solved the NULL issue
 
head desk
 
Tay
but this JSON issue? I dont know how to go about debugging something that I didnt write
 
9:02 PM
please.....watch that video.
 
Tay
I will in a bit, Im on a school pc, stuffs a little blocked and limited
Ill get on my home pc
 
9:32 PM
@DaveRandom No worries
Good luck
 
Afternoon... how are things in your cities right now?
 
Hey @StatikStasis
 
... why does microtime give such a weird string format?
I've never noticed this until now.
 
probably something bad related to 32bit versions of php.
 
10:04 PM
I forgot 32 bit PHP was even a thing
 
10:21 PM
 
10:42 PM
For 20 points: find the bug 3v4l.org/WhiSn
 
I reckon it's somewhere where you're using an array instead of an object.
 
@Danack you nailed it
But more seriously, there is a bug somewhere in the DetermineWinnerByTie() function that I'm having a total brain fart in finding.
 
sent an email to internals with a disruptive idea, apologies in advance: news-web.php.net/php.internals/109157
unfortunately, while I changed the name of the email so it's not a “reply”, it still shows up as a reply in my newsreader :p
 
@Andrea I've vaguely read it, but one idea I have is that since now all RFCs need a 2/3 threshold to pass. We maybe could change the "cool off" period for RFCs which is currently 6 months
 
@Girgias not a bad idea…
 
10:50 PM
As in if an RFC has between 1/3 and 2/3 it's considered "contentious" and needs more work so that the author can work on it again and throw it back into a vote/discussion period quicker
 
@Girgias you're incidentally making me wonder if, in my rough proposal, the first vote shouldn't require 2/3, only the second
 
Maybe? Not sure honnestly but haven't thought about it that much yet
 
@Andrea the second vote could be restricted to people with vcs access...
 
@Danack or release managers ;)
(joking)
 
> The typical life of an RFC — from draft to final merged patch — might be as little as a few weeks

It's a minimum of 4
 
10:53 PM
@Danack which VCS access, php-src?
 
@Girgias yarp.
 
I don't mind anymore because I have it /s
 
@MarkR are you agreeing or disagreeing?
 
A few is typically considered to be 3, but an RFC requires a minimum 2 week discussion and 2 week voting period.
 
that's not my understanding of “a few”
 
10:56 PM
@Sherif - What is/isn't happening with DetermineWinnerByTie that should be? I'm not seeing much obvious there that could be an issue.
 
@MidnightlyCoder Nevermind, I found the bug. I was using value instead of sort so for things like 10, J, Q, K, it was considering it a tie when it wasn't.
 
Ah - glad you caught it.
 
I'm just having a brain fart of a day today
 
Well technically it means more than 2, but in common parlance it's generally considered to be 3. Just thought I'd point out the ambiguity :-)
 
@MarkR who said it means three specifically? what is the point of the word “few” if it means a specific number?
xkcd 1070 has one person's interpretation of “few” for example: xkcd.com/1070
 
10:59 PM
Can an RFC pass and be implemented in 2 weeks?
 
@Sherif It's acceptable during this time period lol
 

« first day (3442 days earlier)      last day (1499 days later) »