« first day (3775 days earlier)      last day (1159 days later) » 

7:10 AM
morns
 
user14716889
7:36 AM
Hi guys I have a question, is it possible to check or compare if a data is existing in another table? My problem is I need to check a data from other table if it is already been register and then compare to what I have been registered in another table. What I have accomplished is to check if the data should not be duplicate.
 
user14716889
Advance thanks for the help :)
 
9:32 AM
@any_something one way to do this is with unique indexes on the table: mysqltutorial.org/mysql-unique
Though trying to prevent duplicates in two different tables, makes me wonder if you have horribly designed tables. The same info shouldn't be in two placees.
 
10:29 AM
Morning, all.
 
10:47 AM
morning
 
 
2 hours later…
12:55 PM
Any laravel dev here?
 
> Don't ask to ask, just ask.
 
What is the future of laravel/ui, will it deprecate on newer version of laravel?
@Tiffany your ssl has expired
 
1:13 PM
@PeeHaa Are you on here anymore?
 
I was making sweet, sweet wordy love to him in here a day or two ago
 
Given a string, how would one double the spaces inside the string in O(n)? i.e if string=hello_world, result=hello__world
 
Homework?
 
yeh and also, what language?
doing it in C is very different from doing it in PHP
 
1:28 PM
in c
@MarkR Actually no. Ive had it in an interview...unfortunatly, i didnt knew the answer :)
so no job for me haha
 
Oh god, technical interview questions. Get them away from me.
 
using memcpy is easy but O(n^2)
 
@Eminem OK well in that case I answer your question with a question - do we know the length of the input string ahead of time?
 
We assume no extra space is required, so for example if the string is of "actual" length x, we can assume the string itself is atleast 2x
 
you have to allocate a buffer large enough to hold the result, which means you need to know how big the input is and how many spaces there are in it. However if you already know the length you can skip the counting step and simply allocate double the input buffer, which is the maximum possible size
but that will likely result in memory wastage
 
1:32 PM
No extra memory is allowed...
You cant create a new string
 
Then it's impossible.
 
OK well then you have to walk through the string and calc length + spaces, allocate that buffer, then walk the string again and copy it
note that this is still O(n)
 
Why? lets assume char arr[500] = "my_not_so_long_actual_string" will turn into "my__not__so__long__actual__string"
 
Because do you want buffer overflows? Because that's how you get buffer overflows :-D
 
arr[500] has a lot of wasted memory in it...
when it comes to stuff like this, the stupid solution is usually the right one
 
1:34 PM
You are right, but still, that was the question. The idea, i think, is to cound how many spaces are in the string, and then we know the "offset" of the shifted string
 
the clever solution is usually a bug waiting to happen
imho questions like that are not only testing whether you can solve that problem, but also whether you are capable of thinking about whether it makes sense to do this stuff in the first place
depends on the company, of course
 
@Eminem ......is str_replace not the right answer?
 
That would be O(n^2)
 
@Eminem You need to walk the string in reverse and do the replacements
 
i think
@NikiC yea that was the direction i tried
 
1:38 PM
Or rather, first walk through the string once to count how many spaces there are, then you know that the new string has length old_len+num_spaces
And then look for spaces in reverse, doing memcpy of the intermediate parts
That is O(n)
And in-place
 
2:16 PM
What is the purpose of PDO::PARAM_NULL?
 
2:46 PM
@DaveRandom lol - Yeah I saw him... he must be busy lately, not been on as much.
 
 
1 hour later…
3:54 PM
Well, I built my first zend_extension in Rust!
 
@LeviMorrison noice
 
Next step: make it do something actually useful.
Still have questions on Rust panics though.
 
@LeviMorrison replace phpize with phpoxidize
 
If I build two extensions in different versions of Rust (highly likely), then are the panic bits compatible as long as each module catches panics before crossing the plugin boundaries?
 
Aren't panics like die in PHP?
 
3:58 PM
It's important to me that I don't get in the same library dependency problems as C++ plugins, because they have to link to the same libstdc++ library.
@Dharman Panics can either be caught, or they can abort the program. Panics are not meant to be caught generally, only for specific cases like if you are going across an API boundary (you cannot panic across an FFI boundary).
 
 
1 hour later…
5:26 PM
@LeviMorrison uh no idea
 
I asked about it on Reddit: reddit.com/r/rust/comments/lkhmpj/…. Hopefully someone will know.
 
6:04 PM
Hi to all
 
6:25 PM
Is this room still alive? Looks like the js one is long dead.
What happened?
 
@NaftaliakaNeal Yes, though today is a US holiday that a decent number of people will not work on.
 
@LeviMorrison ehhhh idk -- my office is open /shrug
looks like its been dead a while
 
This room is alive, at least for php-src and php-doc contributors.
 
I meant the js one.
 
 
1 hour later…
7:43 PM
@Tiffany You can just commit typo fixes like github.com/php/doc-en/pull/449 directly
 
8:11 PM
@LeviMorrison No one told my company. Been here since 5:30am =P
 
8:23 PM
@Girgias I kinda like being forced to cast before passing a string to an int etc. It immediately makes it obvious where there could be an exception. Although I think the casting mechanism itself needs work (we need an exception throwing cast or a nullable).

Unit tests for everrrything would be nice, but it's often just not practical. If I use strict types, as soon as I pass a string to something expecting int I get a TypeError and can harden it immediately.

If I'm in lax mode then it's entirely possible, and probably likely, that all my 'valid' data will pass through without problem. Then
Especially as the Error branch is apparently meant to be "don't catch this, programmer screwed up"
 
@MarkR Huh? A poop emoji will throw a TypeError if you try to pass it to an int type in weak mode in PHP since... forever 3v4l.org/k9FKv
Like if you type cast it however you get 0
Which is like, the opposite of what you want
The issue was that a string like "12 hello" would pass it with a E_NOTICE, which also fails in PHP 8.0
 
But if I pass (int)"💩" I'm going to convert it to its closest accurate representation (0) rather than allow the (likely) user input to trigger a TypeError
 
8:38 PM
And I legit don't get why we need better casting mechanics, like for me it signals, I don't care how you do it, just give me an int
Well sure if that's your business logic, but if you only want valid numeric strings you need to parse it
Which most people do not do and will throw a cast just to comply with the type declaration
 
IMO the value is usually not as important, as chances are they could just put "0" in anyway.
 
Then use a type cast, but I don't see how that means we need better type casting
Liek the only one which might make sense to error on is forcing a scalar cast on an array (possibly object too if not stringable)
 
If we had something like (?int) the null coalescing operator could be used to add a default or throw an exception (now we have throw expressions in 8.0)
But a better parsing function would be equally as valid. But PHPStorm complains at you that the function call is something like 8x slower than (int)
 
@foo($input) ?? throw Exception
:)
(tying back the @ to suppress exceptions)
 
Would mask everything within the entire function yes?
 
8:45 PM
Or even better @<TypeError>foo($input) ?? throw new CustomExceptionLogic
 
So if that TypeError occured inside the call to foo you're still hiding it
 
If you're getting a TypeError within the call that's whack and your function needs work
Because the function will get a value of the type it requests
 
Well yeah, that's why I don't like relying on TypeError's for juggling from strings etc.
 
Which is a reasonable opinion, but I don't see why you want to use a "strict" or "nullable" type cast when what you basically want is to suppress a TypeError
 
@NikiC thanks. I was being lazy, I don't have the doc-en git repo set up yet and it was easier to update my GitHub repo. I'll close the PR and commit it directly after work.
 
8:52 PM
I don't want there to be a TypeError in the first place. And R11 would have me believe that Error branch exceptions shouldn't be handled at all except for a top level handler. There's the horribly verbose filter_var($foo, FILTER_VALIDATE_INT)
Which has to be strict compared to false because legit 0 is falsey and blah
 
Anything that generates a backtrace is going to be slow. Don't rely on that as part of your actual logic.
 
I do wonder if long term some smart person could come up with a mechanism to skip the backtrace if the handler that would catch it has the variable omitted
Personally I like the null on parse error for day to day use.
 
?? does make null returns somewhat less problematic. Converting them into something contextually meaningful in the caller rather than the callee is kind of nice.
This would be interesting, if we're establishing a pattern:

`tryInt($string) ?? "Not a numeric string"`
 
was thinking more alongt he lines of tryInt($string) ?? throw BadRequestException('Bad value for foo'); but yeah
Of course we're getting back into the confusion about 'tryX'
 
Yeah, the idea being you could put whatever you want on the right side.
Well, tryX is going to be a pattern in enums in about 2 days.
 
8:59 PM
and static analysis would be able to point out quite clearly that you have a null issue to deal with
 
And tryTYPE() functions could be made into language constructs so they're faster than functions.
 
It passing and it being confusing (at least initially) are two different things :P
 
Granted. :-)
 
But yeah I'd like to see a tryInt or tryFloat ... remind me who our resident number conversion expert is... looks around for blue avatar
 
But if we want a really compact "safe cast" syntax, "cast this var to this type conservatively or return null if it can't be" isn't a terrible option. The main reason not to is that null doesn't tell you WHY it didn't work, just that it didn't.
I don't know if tryX() or (?X) is better syntax.
 
9:02 PM
Yeah... a NumberParseException "Invalid character "b" at position 1" would offer a lot more feedback, at the cost of eating the CPU cycles to build the stack
But then we're back to either a 5 line statement for each one, or needing a try/catch shorthand
Then again I'd be willing to bet that in 99% of cases those exceptions are going to lead to the rest of the request bailing out with an error message and 400 error code.
 
"Cheaper exceptions" would be a very different creature with very complex implications.
And then I start talking about monads. :-)
 
a null-on-failure would seem to be the way to go initially, IMO. I'd sure like an exception throwing one too so I get something meaningful in the logs without having to go dumping params.
 
What if we had values that extend null? :-)
 
E_ANEURYSM
 
@MarkR I've been trapped, LET ME OUT
 
9:13 PM
I'll give you £20 and a packet of biscuits?
 
I suppose that will need to do
I need to do some webdesign stuff for uni websites
Reminds me why I hate CSS at times
 
Did they get you your server host yet?
 
We abandonned that and are going with Email because it's just to complicated
But I've basically redone one of the WP websites (which didn't use any of WPs functions) to a bare HTML/CSS combo but I need to make the menu mobile friendly now
 
Amazon is offering me a subscribe and save deal on bags of 1KG of chocolate :| Deliver every 2 months.. that seems optimistic
 
@MarkR I'm not accustomed to thinking of chocolate in kgs. How many regular or king sized Hersey's bars would that be?
 
9:24 PM
@LeviMorrison you're literally being the personification of the meme where Americans will use any mesuring system OTHER than SI for stuff xD
 
@LeviMorrison about 14
 
@MarkR That's not even 2 a week! You could totally do it! (although I do not recommend it)
 
@LeviMorrison I eat chocolate in O(1) not O(N)
 
9:40 PM
I eat chocolate in O(√n)
 
It's not a competition! ... but if I win I'm going to be able to go and buy more sooner
 
@MarkR Except the error message needs to include the parameter name that has the error, so github.com/Danack/Params - possibly too slow for people who really need a lot of speed....but for me, nice error messages are more important than parsing speed.
@crell btw you mentioned "null, the billion dollar mistake". You know that mistake isn't applicable to null in PHP, right?
 
@Danack I tend to use JSON schema for advanced cases (it can handle the GET /POST arrays too) but I'd say 90% of my usages go through a getInt() that's wrapping them and just returns 0 on invalid
 
It's less applicable in PHP than in C or Java, but that doesn't mean it's not applicable at all.
 
Although JSON schema doesn't really handle the casting in weak mode unless it's format number
 
9:50 PM
@MarkR you have lost the "is it a competition?" competition
 
@Crell the 'billion dollar mistake' was that null passes the type check for types, so this code:
public void foo(Bar bar) {
    System.out.println("What could possibly go wrong....");
    bar.someMethod(); // Null pointer exception.
}

foo(null);
Doesn't barf on the passing null, it fails when you try to call the method on null. But PHP doesn't have that behaviour.
 
Mercifully.
Are you planning on going after strict_types by any chance @Danack?
 
@MarkR No. After memory was jogged about Z being a twat about out parameters, was curious to see if anyone is using weak mode, as I'm reasonably certain that the vast majority of people who are making applications (rather than wordpress/drupal plugins/sites) use strict mode. And was wondering if there was enough evidence for that to be found.
 
@Danack Unrelated, but how can I bribe you to go ahead and make callable types happen? (With or without aliases.)
Enums are how I'm bribing Ilija to help with partials, so... :-)
 
@Danack We need an automated survey script
 
10:02 PM
@MarkR Nikita's "top 1000 packages" script would probably be a reasonable approximation.
 
I am thinking we need to have a package system, that allows people to declare that all code in a package uses strict mode or any other declare we want. Or various other diverse settings...
@Crell it's way beyond my skill level tbh. I was going to try to get @girgias interested in it...
 
@Crell Limited to those packages. I'm thinking more like something that could be ran from the command line to offer-up stats for code usage in private codebases and report it back to PHP.net (but without exposing the code itself)
 
Oh my. Like anonymized psalm results?
 
Yeah
 
@Danack If you want to explain the semantics and can try, as I still don't fully grasp all the issues with callable :)
 
10:04 PM
I'm sure with enough begging and pleading our dear friends in the PHPStorm IDE dept might even be willing to add something to run it directly in the IDE and copy-paste it into a form somewhere
 
@Girgias I'm happy to help on the design/PM side as I did with Ilija if it makes it easier. :-)
 
@Danack Reasonable path for that would be to bribe someone from getcomposer to do that in require key?
 
honest question: how do you deal with the ongoing irrational anger at the number of total fucking cunts in the world?
 
I would <3 typed callables but most of my use cases for them require would be generics :( Were you thinking about creating a CE for each of them and mapping __invoke?
 
like I can't just beat that crap out of people, it'd frowned upon
but seriously I really want to just punch a lot of people I meet day to day and I don't know how to continue not doing it
 
10:06 PM
@Crell I mean sure, no guarentees that I'll figure it out tho :p
 
so many people are just awful
 
user7659542
trololol
 
@DaveRandom It's easy - look at beautiful ones. yw
 
@MarkR I'm thinking something like: function foo (callable(int, string): string $c) {} // Which would then accept any callable that can be called that way. Function, method, closure, doesn't matter.
 
@Girgias There's too many to fix. If you really want the gory details they are here, but......fixing them isn't the right solution, as that doesn't actually get us to a useful place. Instead having a better callable type definition, along these lines, would be more useful. There was a previous RFC that has quite a bit of code, but not for the declaring types.
 
10:07 PM
@Tpojka E_ENGLISH
 
And the code for that previous RFC is linked in that 2nd link.
 
@DaveRandom :/
 
@Crell Gotta remember names now I think. Part of the API contract.
 
@DaveRandom I try and avoid watching/reading the news quite a few days....
 
@MarkR Kind of. The names are not enforced on interfaces. My thinking is we should support both, either without a name as above, or with a name and then only enforce the name if specified.
 
10:09 PM
They're not? o.O How the heck does that work.
 
ping @Machavity
(ongoing star wars)
 
The logic in the RFC was "other languages don't enforce it, and it would probably break a lot of people's existing code to enforce it, and it only matters if you're calling by name which no one is doing yet, so YOLO."
 
Hmm, thought the RFC decided against that, but my brain is foggy that far back.
 
user7659542
>:C
 
@Danack the bottling up has reached breaking point I think
like I am fully ready to walk into commons with a baseball bat
and like there are a few people who I would not stop until they are liquid
 
10:13 PM
Sooth yourself matey. I'm all for clearly hyperbolic statements of violence, but public forum and you don't want the police coming around.
 
true story
 
@Crell Yeah, the previous RFC failed at least in part due to the 'lack of named type'. Partly for people not being ready for the idea, and partly for the RFC authors being haughty....
 
but I am irrationally pissed off and don't know what to do with it
(I will not start beating people up, ftr :-P)
 
@Danack Lack of named type?
I think a type alias RFC would be good, but can also happen separately.
 
@DaveRandom it's to late for me tonight, but maybe have a beer/chat tomorrow? Also, pretty normal to be under a lot of stress (and strongly dislike the current state of affairs) so wouldn't call it irrational...
 
10:16 PM
s/irrational/uncontrollable/ perhaps
 
Interesting Q... would all function signatures be alike? i.e. would everything accepting an int, be acceptable for something accepting an int, or would it be named so ThingForThisInt = (int): foo; only accepted callbacks extending / implementing ThingForThisInt
 
I dunno I feel like I am psychologically nit awesome rn
 
@DaveRandom You've been working hard. Can you take some time off work?
 
not pencils up nose/pants on head but not miles away
 
@DaveRandom actually, lets discuss this tomorrow eve over virtual drink if you promise not to topple the government tomorrow?
 
10:17 PM
@Danack indeed planning on doing that tail end of next week hopefully
and yeh ftr I am not as fragile as this diatribe may appear :-P
maybe wouldn't mind a zoom tho @Danack on thurs/fri if you fancy a virtual beer
 
So,

https://i.imgur.com/ULQ4nkk.png
 
You're doing well, Danack would have deleted half my posts and kicked me for an hour at this point :P
 
yeh but
I mean
have you seen your posts
:-P <3
see I can still make myself laugh even if no-one else
 
@MarkR I would think if you type a parameter as callable(int): string, then any callable that takes and int and returns a string is acceptable. Aliases are just sugar to make typing easier.
As minimal a surface area as possible.
 
@Crell probably not. I'd vote against it probably. The conversation was quite shite last time, and there were people dead opposed to idea of naming the type....and so it seemed we'd be in a position where callable types were in, but there was no chance of getting types for them.
 
10:20 PM
tbf I have managed to go this crazy without dealing with it by taking a bunch of drugs, in a way that is progress
 
@Crell I'd naturally go that way too. Although I found it a bit of an oddity in TS recently, their interfaces don't care for the name, only the signature, so two completely unrelated interfaces that happen to match can pass
 
@DaveRandom well, Whereby, as Zoom makes be want to set fire to things....
 
@MarkR That's very Go-ish.
@Danack I do not recall this. But having union types and possibly callable types, which are all more verbose, could incentivize type aliases in the future.
 
@Danack you might be doing it wrong in that case, because it does generally "work"
in my experience
it's not hugely feature rich but the features it has are reliable, for me
 
@DaveRandom the video works. The audio quality is shite. And the UI moves shit around without me touching it, which is fucky.
 
10:23 PM
@Danack Which part would you vote against?
 
@DaveRandom I can't decide which of you is the bigger star. Sorry
 
@Danack the audio quality is perfect for live radio, according to my first-hand experience - flawless 256kbps constant bit-rate for 210 minutes
I did the set up for someone who broadcast weekly on 5live from a wardrode :-P
 
I like zoom. I still intend to trash it later this year when I get around to building a replacement using Twilio.
 
they do the whole thing over zoom, though I will concede it was a fucking arse to get it to always use high quality instead of constantly trying to detect connection speed
I have a reg hack if anyone is in the needful
 
@Crell not having named type definitions. aka only having inline types. I think one of the best things about PHP is that it makes you name stuff. Having it done as inline definitions, without separate type declarations (imo) decreases the chances of having type declarations happening, not increase it.
@DaveRandom perhaps it's the webinar mode that is shite....my user group uses it, and it's really kind of grating....
 
10:28 PM
@Danack How would they be named though? Specifically how would $foo = function(int $a, bool $b): float { ... } get that name?
 
@Danack I haven't ever fucked about with presentation stuff, and also tbf the BBC pay a crapload of money to zoom so they may get preferential treatment :-P
 
type alias callback: callable(int): float;
type alias scalar: int|string|float|bool;
(Or similar)
 
though also I have never had any issues talking to my misses, at least nothing that wasn't because of my stuff
 
@Danack That's when using it as a param right? How would a function say it was one of them, or would it just pick it up from the signature.
 
10:29 PM
function foo(scalar $val): int {}
 
@MarkR just match against signature: github.com/Danack/FunctionTypes/blob/master/…
 
btw the BBC is an impressive machine in terms of admin, I got id verified in about 7 mins or something, including being phoned by a human
 
OK, so the name is only really being used in one place, it wouldn't associate the callback with a specific type like, uh... $foo = function<Logger>(string $log) { ... }
 
At least part of the reason why I really want the named version is that I rely on the refactoring tools in PHPStorm quite a bit....and without a named type, changing function signature would be very annoying.
@MarkR declared in one place, and then whenever it is used as a parameter/return/property type.
as opposed to having to copy and paste callable(int): string everywhere that it is needed.
 
I think that makes sense for the param / return / property, perhaps less so for declaring the function itself. I know most are happy to just use the signature but that feels a bit ... meh
 
10:33 PM
named delegate type seem (to me) pretty uncomplicated, and the sort of thing that should be brought to minimum viable asap, then fight about the ambiguous bits later
 
If the dynamic function also had to use the name then refactoring tools would be able to lock onto it easier. ... although come to think of it the practicality ofthat would be limited
 
alias logFunc callable(string): void

function doStuff(string $a, logFunc $logger) {}
 
@DaveRandom on the other hand, you can't tell them you don't have TV, without also giving them personal info. And I tend to avoid giving people threatening to sue me any personal info.
 
I understand the principle but disagree with the application
it feels to me like refusing to tell your gram your pin number
 
(The part I really want is typed callables, which greatly help with FP stuff. The type aliasing is a convenience to make that easier.)
 
10:35 PM
like yeh sure you technically shouldn't but in reality why does it matter
(open to persuasion btw if there is something I missed)
if "personal info" is your name and address then I would argue that is not a thing which matters in the real world
 
@DaveRandom Meh. I react badly to the shitty lying letters that they send. Email address - almost every person who asks for it (instead of knowing where to find it) only seem to want it for shitty reasons.
 
I would argue that is an irrational point of principle that doesn't matter, a concept with which I am intimately familiar
lovehoney know all of that info about me
 
@Crell I want it mostly to be able to share expectations about callable types between libraries and application code.
 
as do argos, mcdonalds and probably several websites implicated in terrorism
 
<a-hem>
 
10:42 PM
Narrator: ...and that was how @MarkR revealed his terrorsim fetish
 
@DaveRandom But when the police turn up at the door... they'd refuse to handcuff me in case I enjoyed it
Honestly I've no idea where lovehoney and mcdonalds came into this :P
 
the police rig your house with C4 and make you negotiate to not blow it up
that is the worst taste joke I have ever made, and also something I wish Armando Ianucci would do
I mean, literally the worst taste ever, I'm really sorry, please don't flag it but it would be fair enough
still not deleting it tho :-P
 
@DaveRandom Well, that's why you shouldn't be seen
 
apologies for the over-zealous ping btw
the was some mild trolling happening but it was not modworthy
 
@DaveRandom Fun fact: we don't get tools for the starboard. If someone is star-happy we have the same remedy as ROs: de-starring
 
10:49 PM
@Machavity ah it's been too long
@Machavity just out of interest, do you have any more "bulk" tooling thank I do?
like in "star wars" people can star things as fast as I can unstar them
 
@DaveRandom No. There are some userscripts that can help with a mass de-star tho. SOCVR's move script, for instance, does a great job at fixing some usability
 
it's just not enough of an in issue in #11
thankfully
 
But yeah, chat is kinda neglected at present
 
s/kinda neglected/functional and not profitable for SE/
which again is kinda fair enough :-P
 
Well, the PHP chat room is still rated more helpful than Lounge C++ so there's that
 
10:57 PM
shouting IT questions at your cat is more useful than the lounge
see, normally I would move that message to the lounge and the bail, this is growth
 
11:16 PM
@DaveRandom for the record, I recently bought one of these at least in part to make myself feel better by making the world be a bit less shit, even if it's just the park near me having a bit less litter in it.
 

« first day (3775 days earlier)      last day (1159 days later) »