« first day (1870 days earlier)      last day (3072 days later) » 

Anonymous
8:01 PM
true.
 
@samayo The syntax is easy. You just need to fiddle around with pointers and memory stuff... That said, you could try hackerrank for fun
 
Anonymous
Yeah, I already know the syntax to some extent, but headers, memory, gc is till foreign to me.
 
Anonymous
At first I wanted to learn C, just to understand PHP more. Then I thought it would be a waste of time, but I've realized pretty much everthing is made with C. So, it would be nice to know the insides of linux, nginx some metasploit tools and php also.
 
Anonymous
it is actually a very important language to learn
 
Anonymous
I may put python3 aside for this.
 
8:05 PM
C is not more important than Python or PL/SQL
it's just a matter of specialization
the real question is: what you want to be good at?
 
Anonymous
Javascript :D
 
Anonymous
that language is going places
 
for better or worse, it really seems to be
@samayo you could start with this: youtube.com/playlist?list=PL7664379246A246CB
those are university style lectures .. including the first one being basically "history lesson, with no code"
 
Anonymous
Thanks, it looks good.
 
Anonymous
I am at that point where I actually have enough curiosity and enthusiasm to bing watch/read anything related to programming for more than 10 minutes.
 
Anonymous
8:16 PM
Last week, just when I was about to learn Angular, I realized they had switched the language to Atscript :/. Learn AtScript then Angular
 
Anonymous
/ain't nobody got time for dat
 
how do I create a namespace
 
Anonymous
namespace foo;
 
are they a good idea?
 
yes
 
8:26 PM
why?
 
because they bring order
 
... to CHAOS!!!
had to.
so if I created zyz\a namespace for object config I'd create a new one by... new zyz\a\config?
 
s/object/class
and people usually use aliasing for that
 
aliasing?
 
use My\Full\Classname as Another;
$foo = new Another;
please, for fuck sake, read the fucking manual: php.net/manual/en/language.namespaces.php
 
8:32 PM
lol... it's my first time using namespaces in php. I'm use to C# or VB.net
 
what is it with newbies and making shit up ?!
 
PS I am reading it.
@tereško I wouldn't consider myself a newbie. just not professionally schooled.
 
Anonymous
if you have been using C# VB.net, how do you not know the usefulness of namespaces? You must still be in the "hello world" level
 
@samayo lol, no I use them all the time, especially with 3rd party code. Just never in the real of PHP.
The question I should of asked, is "are their any issues with namespaces in PHP?"
 
simple function cannot be namespaced
constant namespacing is not really working
I think that's about it
 
8:50 PM
ok
why would you want a function outside of an object?
 
Sigh…
I loathe your training wherever you got it from.
 
@LeviMorrison self taught loath away. I suppose if you had a shared function that didn't have an object home.
 
There are many functions which can work on many different types of arguments.
For instance, consider this snippet:
 
how do I refer to a global object in a namespace... i'm getting this error: Fatal error: Interface 'xy\z\ArrayAccess' not found in
 
$buffer = [];
foreach ($xs as $x) {
    $buffer[] = some_function($x);
}
This snippet can be refactored into a stand-alone function map:
 
8:55 PM
function map ($iterable, callable $cb) {
    foreach ($iterable as $key => $value) {
        yield $key => $cb($value, $key);
    }
}
 
function map($input, callable $f) {
    $buffer = [];
    foreach ($input as $value) {
        $buffer[] = $f($value);
    }
    return $buffer;
}
 
:-P
 
The version ircmaxell wrote has particular advantages.
But anyway, this works on any sort of "iterable" input and something that can be called like a function.
It is not tied to any particular object or form.
It makes sense to live as a stand-alone function.
 
I've always just used a public shared function
 
@JustinKaz You need to "qualify" the namespace.
 
8:58 PM
or in php a function in global space
 
namespace Foo;

interface Bar extends ArrayAccess {} //this will fatal
 
@JustinKaz fuck sorry, I messed up
 
You need to "qualify" it:
 
13 mins ago, by tereško
simple function cannot be namespaced
this is BULLSHIT
simple function CAN be namespaced
 
namespace Foo;

interface Bar extends \ArrayAccess {} // this will not fatal
 
8:59 PM
class session implements \ArrayAccess
yeah had to add the qualifier.
 
... why the fuck I wrote something so dumb
 
thank you
 
@tereško 1) drunk 2) tired 3) both? 4)…?
3
 
@tereško that is def awesome
 
3) actually
but only slightly
 
9:00 PM
@tereško lol
 
the only issue with namespace functions is that they cannot be autoloaded
... which probably will change in some later PHP version
 
@tereško Well, functions cannot be autoloaded at all - has nothing to do with them being namespaced.
 
tru
 
By the way, unifying symbol tables would make autoloading easier.
 
@LeviMorrison btw, just checking, are names of php functions case-sensitive?
 
9:03 PM
In PHP function names are case-insensitive.
 
well .. at least there is that
 
autoloaded... what is this?
 
Autoloading is over-used in my opinion. It seems to be an unpopular one.
 
Anonymous
load class when object by the same name is called
 
Anonymous
Meh, 3 years of PHPying and I still have no tangible idea what PHP-FPM is/does.
 
9:08 PM
I was kind of hoping it would auto-include php files...
 
@samayo Really?
 
Anonymous
@LeviMorrison Yeah, I have been using it around the same time. I know the configs .. but still 0.01 knowledge
 
Can i consolidate these lines into 1? $obj = new \egt\auth\user_handler;
$rows = $obj->test();
 
If your version of PHP is new enough, yes.
 
5.6
 
9:12 PM
$rows = (new \egt\auth\user_handler)->test();
 
thank you
 
Bah
So focused on implementing a complex solution to a problem that I missed the simple one...
 
Anonymous
@JustinKaz for that to work, the constructor must be empty. No args
 
@samayo that makes sense.
 
function map($iterable, callable $cb) {
    $generator = function($iterable, $cb) {
        foreach ($iterable as $key => $cb) {
            yield $key => $cb;
        }
    };
    return iterator_to_array($generator($iterable, $cb));
}
:-P
 
9:15 PM
if anyone could answer this question

http://stackoverflow.com/questions/33983950/disable-time-picker-from-mysql

i'd give at least 50 rep to the accepted answer but cant now coz gotta wait 2 days, and will vote up all the answers as i always do, bye and thanks in advance, gotta go now
 
@ircmaxell ... why?
function map($iterable, callable $cb) {
    return iterator_to_array((function($iterable, $cb) {
        foreach ($iterable as $key => $value) {
            yield $key => $cb($value);
        }
    })($iterable, $cb));
}
:P
 
@NikiC PHP 7...
 
@ircmaxell what else ^^
@ircmaxell It's only PHP 7 compatible because there was no chance to use void in there :P
 
Thank you all kindly!!!
 
@NikiC Just have array_map supporting objects and iterators. :P
Any reason for using params instead of use(...)?
 
9:26 PM
@kelunik Nope, I only copied @ircmaxell's code ^^
 
function reduce(Traversable $filter, Callable $callback, $initial = null) {
$result = $initial;
foreach($filter as $value) {
$result = call_user_func($callback, $value, $result);
}
yield $result;
}
function map(Traversable $filter, Callable $callback) {
foreach ($filter as $value) {
yield $value => call_user_func($callback, $value);
}
}
I find I use those two functions a lot when working with Generators
 
@MarkBaker dat call_user_func
This code is so php 5.3
 
Well it was intended to work with min PHP 5.5 because I did it to emulate array_reduce and array_map with Generators
 
Also, why bother with Traversable?
until we have Algebraic types, Array | Traversable, just leave it off
 
@NikiC context?
 
9:35 PM
Are there benefits to simply using $callback($value); instead of call_user_func($callback, $value);? Or is it simply shorter syntax? I supposed it eliminates a function call overhead
 
@MarkBaker fcall overhead, yep. Or in case of PHP 7, with \call_user_func, they're equivalent, just shorter synatx.
 
@NikiC Don't say that. You'll attract hipsters!
PHP? Yeah, I preferred it when it didn't have classes bro.
 
Sometimes I wonder whether methods on objects were a good idea…
 
9:53 PM
huh?
 
@bwoebi Doesn't have Go what you want? I'm not sure, but I think it's separated there into structs and behavior.
 
@ircmaxell yep, only value objects and functions operating on them… I sometimes really am not sure about the polymorphic dispatching… It basically is an indirection of value->class->function
And I wonder whether it'd be better to be more C-like and directly dispatch via a function
sure, both is possible to do in PHP, I just wonder whether class methods are given too much importance…
 
How about internal state then (aka private)?
 
@kelunik internal state is a lie … it's just a language enforced hint of "this state is not to be used from others"
 
That doesn't make it a lie.
 
10:04 PM
The lie is "I have unique state nobody else should read and write" … the issue is that in reality others might be indeed interested in that state. If they can't access it, they usually reconstruct it (or rarely: just have direct Closure binding).
I rather would like to consider private like "do not call this unless you really know what you do and be aware that it may change without warning"
Because, sometimes you encounter this case where you'd need to reuse code of a private method, doing exactly what you need … but end up to just outright duplicate that code. … Or in case of properties, it holds the internal state accessible through various getters… Would be much easier to just use the state instead of proxying reassembling the results of the getters…
Leaky abstractions and yep.
You'll always inevitably run into these leaky abstractions … If just all state were always accessible, sometimes…
 
For the record, just because abstraction is leaky does not mean you should not abstract
 
Sure, private makes sense, in the way to mark a function/property as to not be modified or called from outside/relied upon, but sometimes I doubt whether language enforcement is necessary.
 
if it wasn't leaky, it wouldn't be useful
 
@ircmaxell hmm, why?
 
because no abstraction isn't leaky
if it wasn't leaky, it wouldn't be an abstraction, but instead "law"
 
10:18 PM
ah, yea. I'm not saying anything against abstractions…
 
look at how cars operate. When you press the gas pedal the car goes faster. When you press the brake pedal, it goes slower. That's an abstraction, because the physics under the hood are far more significant, and those abstractions break down often
 
Having a specific state to describe something is already an abstraction
I'm just saying that it's sometimes limiting to not be able to interact with the behind… The abstraction is fine for some cases, but in other cases, you'd like to tune your car to do something special.
 
bah
 
of course
 
an hour down the drain because i vs j
 
10:21 PM
lol
@NikiC welcome to programming
 
@NikiC That was why I always used i, ii, iii in past…
but then I had the same confusion with ii and iii…
@ircmaxell and this is where private being absolutely enforced by the language is annoying…
there always pop some cases up where you'd need to fiddle with the behind and end up recurring to hacks or code duplication just to get the desired result
And that goes down to: I'm not sure whether we really want to tie behavior to state…
We always strongly couple our state to a specific behavior…
Ideally, there maybe should be a value object of protected properties at the top of hierarchy and then we extend that class with specific behaviors…
 
@bwoebi can we move phpdbg result op to first instead of last?
It's really confusing...
 
@NikiC why?
op($a, $b) = $c ?
 
$c = op($a, $b)
 
oh, before the ZEND_*?
 
10:31 PM
I was thinking after, but before is probably even better
we can also cut down on the column size for that one I think. apart from recv it's pretty much always a temporary
 
yeah, we could… hm
I'd ask Dmitry for his opinion too though. He seems to be also actively using phpdbg -p
 
Is there any stackexchange community for asking "social questions" ?
Actually here is my question: "What is your opinion about using a lot of Emoji in text?"
 
^^
 
what is that mean?
@tereško well I don't ...
 
10:47 PM
Hell!!! I am running into very strange problem with php and mysql...
I am fetching data from the mysql with select statement but that does not work on the first attemt untill i run it twice..
$query="select Interest from registration_steps where UserId=?";
$stmt=$mysqli->stmt_init();
$stmt->prepare($query);
$stmt->bind_param('i', $userid);
$stmt->execute();
$stmt->bind_result($Interest);
$stmt->store_result();
$stmt->fetch();
if( $Interest>0)
{$stmt->close(); echo "interest true $Interest";return true;}
@NikiC @tereško
 
@whatever Sorry, I'm not familiar with mysqli. It looks horrible
 
the strange thing is that when I change the value in data base and run the code twice or thrice only then it say yes..
does the mysql cache anything..
I thought may be it because of some caching in place..
 
11:04 PM
morning
 
morning
 
11:15 PM
@whatever Two things - why do you think you need to call store_result? And why don't you just copy the working example from the manual of how to use fetch()?
 
@Danack copy working example?
 
scroll down to, or search to find "Example #1"
 
store_result was for counting the rows.. but wristling with the code made me forget to remove it..
I know how to do it.. this code was working perfectly fine... but it suddenly started to misbehave..
and i think there is nothing wrong with the fetch()..
 
if ($stmt->fetch()) {
    echo "interest true $Interest";return true;}
}
Would be the correct thing to test to see if a row was fetched, rather than the value of interest.
 

« first day (1870 days earlier)      last day (3072 days later) »