« first day (2224 days earlier)      last day (2724 days later) » 

8:01 PM
\o
 
8:17 PM
Freelancers, do you charge for inspection / analysis for existing builds?
I.e. trying to figure out how you're going to do something before moving actual dev
 
Depends
If it's large and/or potentially scary I will
 
Wes
@Sean yes. especially if it's people you don't know
unless it's just few hours job. in that case charging for a very little amount doesn't seem appropriate
 
Yeah, this seems a lot more than a few hours
:p
Think lots of business logic + WordPress
 
then you should..
 
Wes
wordpress will kill you, so charge, and a lot :B
 
8:25 PM
:P
 
:V I'm good on WordPress experience, spent at least 4 years of my life building on top of it heaven forbid. The unpredictable parts are the plugins
And just about everything else
and WordPress
 
@Sean s/spent/wasted
 
lol
 
I actually did what the closing keynote speaker did at PHPNW
My first open source commits were to wordpress, adding documentation
After they went through I started mentioning that I had committed work to WordPress core :P
 
lol
 
Wes
8:30 PM
lol :B
 
writing nested queries and using if else condition in query is good or bad?
 
Define nested queries
 
select * ( select * from table) where id=? like this.select inside select
ah subquery i mean
 
You probably want to do an actual join instead
 
Wes
8:34 PM
nested queries in mysql are the root of all performance evil
use joins!
 
ah ok :)
 
I am agree with wes here
Not in the last place because mysql is retarded
 
i have never faced such condition but when i see people writing and when i see that i feel i didn't learn mysql properly...
 
Wes
@bwoebi i don't fully get the big O notation so i'm asking, in an array (not a php array) is it correct to say that "the remove operation runs in O(n) where n is count($list) - $index"?
 
doesn't that depend on the implementation?
@Linus Nobody learned sql properly unless you are one of those dickhead dbas
 
Wes
8:39 PM
which implicitly means that is O(1) for the last element
 
@PeeHaa :P ahaha
 
Wes
(i can't even count) bah
 
@Wes What in specific are you asking here?
Are you trying to explain O(n)?
 
Wes
just if what i'm writing is correct :B
yes i'm defining "n"
 
@Wes Well that depends on the implementation
 
Wes
8:42 PM
aren't all vectors/arraylist whatever basically the same thing?
i think they work the same way in all languages
 
Dunno. I don't know all languages :)
 
Wes
except perhaps the way their capacity is increased
but other stuff works the same way everywhere, i think
 
Yeah everything I can think of is o(n)
I assume for php it's o(1)?
 
So I'm working on this drupal site I inherited and I'm trying to understand how webform templates work. It says you have to create a new file with the naming format webform-form-[nid].tpl.php where nid is the node id of the form. Well, we have a dev, test, and prod environment. Isn't the nid going to be different in each?
 
unless collisions :P
 
Wes
8:48 PM
i have no idea @PeeHaa as php's is a linked hash map. removing anywhere should be O(1), right?
 
ugh right
@Wes yeah
 
I think I deployed google recaptcha v2. fingers crossed
 
Wes
that is valid only for string keys though. integer keys are reindexed so it's linear time
 
No drupal people around, I guess? :(
 
We buried that last ones in a desert somewhere :P
 
Wes
8:52 PM
ie,
$a = [0,1,2,3,4,5,6,7,8,9];
array_splice($a, 3, 3, []);
needs to reindex 6 7 8 9. so not constant time
 
@Wes Not it php it doesn't
 
Wes
unless by remove you mean "set to null" :P
 
unset?
 
Wes
yeah that is O(1)
 
That's removing stuff
 
Wes
8:54 PM
leaves a hole in the index though. it's not how arrays usually work :B
 
It is how php works though :P
 
Wes
:B
 
I think I found a nice overview somewhere a while back. Let me try the browser history thing
Much better than chat search
 
Wes
that's useful. i kinda of get it, but not how it's (usually) used to define algorithms. ie most of the times they don't tell what n is
 
I wonder
does zend do resizes when it's deleting items?
 
8:58 PM
n is always the size of the array i think
 
for packed arrays, I mean, when it's getting too big, it resizes, which is O(n)
I wonder if it does the same when it's getting too small?
 
so basically you potentially have to traverse the entire array to do your operation
 
@Wes n is the size
 
@FlorianMargaine IIRC it doesn't
 
16 inches in my case
 
9:00 PM
@FlorianMargaine nope
 
Wes
niki :B
23 mins ago, by Wes
@bwoebi i don't fully get the big O notation so i'm asking, in an array (not a php array) is it correct to say that "the remove operation runs in O(n) where n is count($list) - $index"?
array = like vector/arraylist in java, ie that shifts elements to left when removing automatically
 
@Wes it's more like where n = count($list) - (count($list) - $index), no?
ah
depends where you remove the element from
 
@Wes That would be unusual
 
It should be O(1)
 
9:02 PM
You'd say "where n is count($list)"
You shouldn't parametrize the operation over the index
 
@Leigh it's too vague to know what he's talking about though...
 
If the array is ordered, even rearranging can be O(1)
 
Wes
the operation is: removing an element at an index by moving subsequent elements to their current index - 1
 
are the elements in order? :)
or is it a linked list?
 
[internals] ok, so, hopefully last question for a minute. How could I, from a zend_extension, after doing compile-time stuff with an op_array (handler), stop the script from executing? How do I just say, "We're done here" without forcefully terminating the program?
 
Wes
9:05 PM
@Leigh it's a splfixedarray (or a C array)
 
so memmove(pointer to n, pointer to element after n, sizeof(element) * remaining elements)
 
@Dereleased zend_bailout
 
Wes
@NikiC but with that "index", you would implicitly have O(1) (which is what it is) when $index + 1 == count()
moral of the story tl;dr: i don't get big O
 
@JoeWatkins perfekt
 
@Wes If you were to go over the whole array, and move each element individually, it would be O(n)
 
9:10 PM
One more, what's a better way of detecting when I've gotten to the global (last) scope than the following?

if ( !op_array->function_name ) {
zend_bailout();
}
 
or O(m - n)
 
override zend_compile_file possibly
 
@NikiC Basically, nearly all opcodes where we fill in a refcounted return variable are susceptible to leaking if one of the operands (if it's refcounted) in case freeing the operand can trigger an exception.
 
@JoeWatkins I've actually done that one previously, thanks
 
because when we do ZEND_VM_CONTINUE_CHECK_EXCEPTION(); we do not verify whether there was an exception and conditionally free the return value. Doing this would anyway have too much overhead. So we need to free the return value somehow in the ZEND_HANDLE_EXCEPTION opcode … but … when we do ZEND_VM_CONTINUE_CHECK_EXCEPTION() and the operand has a return value, the return value is actually always set. If we do HANDLE_EXCEPTION() in these opcodes, the return value usually is not yet set.
@NikiC ^ thus we need to set the return value (in order to avoid undefined behavior and possible segfaults) before
Like e.g. in this snippet try { new class { function __toString() { return "a"; } function __destruct() { throw new Error; } } . "foo"; } catch (Error $e) {}, looking at ZEND_CONCAT: the operation is done, then FREE_OP1(); FREE_OP2(); and ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); and nothing is freeing the return value…
 
9:18 PM
nn
 
@Wes What exactly do you want? A flat chunk of memory and memmove() everything back by one offset? Yeah, then yes.
 
Wes
just want to know if what i'm saying is correct :B
Also bob "The add operation runs in amortized constant time, that is, adding n elements requires O(n) time." add refers to insert here, which is shift to right all elements that have >= $index. how is that constant time? :\
 
@Wes adding is probably appending at the end
 
That's an ArrayList …
 
Wes
9:23 PM
add() is insert()
 
add(E e)
Appends the specified element to the end of this list.
@Wes ?
 
Wes
there's also add(at, elem)
 
@Wes That one shouldn't be amortized constant time … I'm pretty sure the first one is meant
 
Wes
it's O(n), but read that text
 
@bwoebi okay, I remember this problem
 
Wes
9:24 PM
The add operation runs in amortized constant time, that is, adding n elements requires O(n) time.
 
@Wes yes. … and that's adding n elements at the end in (amortized) O(n)
 
Wes
why the fuck didn't they say append()
:|
 
@Wes to fuck with you :-)
 
Wes
amortized i suppose it means because a resize could be involved, occasionally, right?
 
hey... yall wanna hear a programming joke?
 
9:25 PM
@Wes yes.
 
!false
 
@rabbitguy As long as it's not painting PHP bad, go ahead. Otherwise TELL IT IMMEDIATELY TO US!
 
it's funny bcz it's true!
 
Wes
ty bob and all. i've learned something!
 
user image
7
 
9:26 PM
@rabbitguy And what's funny about a truthy expression?
@tereško Meh, copying from reddits frontpage
 
@bwoebi I don't care who you are, my joke is funny
it's not !funny
 
@bwoebi I never visit that place
seriously, I use only custom subs
 
@rabbitguy I'm not sure if funny is defined to be true or false, thus I cannot tell you whether this expression is true or false.
@tereško I usually do too, but happens I misclick and see the frontpage…
 
! is just a negator
so !funny is implied to be the opposite of funny
so I guess I just said that it's not the opposite of funny
 
yes :-P
but you forgot the implicit cast to boolean PHP does when applying the negation operator
 
9:31 PM
@bwoebi Okay, I think doing this should be fine
Take care that CV retval ops are handled correctly
 
@NikiC you mean adding ZVAL_NULL()'s everywhere?
@NikiC yeah, should only apply to VAR and TMPVAR ops
 
@bwoebi By adding do you mean manually or as part of HANDLE_EXCEPTION?
 
@NikiC That's the question, I'm not sure
I think it's more sensible to choose the manual way
 
I think having it in HANDLE_EXCEPTION would be good
that should make this opcode semantics change pretty transparent
 
okay
@NikiC I'm in process of writing a bunch of tests for typed refs, will do that afterwards [so probably tomorrow and show you first]
 
9:35 PM
ok
 
Wes
10:06 PM
(you've seen minions, right?)
 
Yes, I do not understand how it applies here though @Wes
 
Yes, it was pretty shitty
 
Wes
that's "king bob" and he's dropping the mic after he did typed properties :B
 
 
10:08 PM
I wanna go put a fog machine in our server room so I can say "welcome to the cloud."
 
Wes
fuck you guys :B i liked minions, and i love both bobs
 
user image
5
 
awww
I wanna crush it.
 
:D
 
Hey guys anybody here uses twig ??
 
10:16 PM
How do you debug string encoding issues?
There's 2 strings that xdebug says are the same, but they aren't
 
@TomasZubiri what have you tried?
 
Ord($string1) and ord($string2) have different values.
 
Wes
@TomasZubiri ord() is for single byte characters only, not actual strings
what are you doing exactly?
 
the manual says it takes the first character of the string
mb_detect_encoding returns utf-8 for both
 
What are you actually trying to do @TomasZubiri?
 
Wes
10:22 PM
first byte. but that won't help you comparing the strings
also mb_detect_encoding is more like a guess
 
@Wes I am parsing a file whose encoding is always the same. Not sure what it is though. And I am comparing the string from said file with a string from a config file I created.
The config file is UTF-8
 
How are you comparing?
 
Yay, compiling with CPU throttling to 0.8 GHz <.<
 
preg_match with u flag
 
Can you share your code?
I want to see the repro case in 3v4l or something like that
@Wes fwiw I liked it too :)
 
10:27 PM
@bwoebi MacBook?
 
@tereško no, MacBookPro … but well, my Skype is already running at 300% CPU (active video call)
and then with a compile it goes all bad ^^
 
@bwoebi wat
 
next time buy a PC
 
@tereško I have an iMac and no issues, thanks.
 
you poor poor thing
@bwoebi also ... emm ... that's not how percents work on PC
 
10:31 PM
@NikiC dunno… Skype was never that CPU consuming, but I think there's a bit of regression.
@tereško You have a 100% per logical core?!
 
@bwoebi on linux yes. on windows it's 100% for all cores
 
@NikiC meh
 
I'm not sure which one is correct
I mean, in term of UX, windows way is certainly better
but in term of "correctness", I'm not sure what that would be
 
MVCE for my problem
 
@NikiC I mean, it's called CPU not CPUs, so 300% makes sense :p
 
10:44 PM
@Andrea It's called CPU, not core, so actually it doesn't
 
@bwoebi heh
 
@TomasZubiri wat. Why are you using preg_match?
 
I want to check if it is a substring.
 
stripos?
 
Wes
stripos doesn't work with utf-8, strpos only does. yeah it seems preg_match is what you should use
 
10:48 PM
wouldn't that be worst in terms of encoding support?
 
@Wes wat
 
tbh all I want to do is declare the encoding of both the files I am reading.
 
@PeeHaa probably lowercase of utf8 that doesn't always work?
 
It feels like php does encoding wrong.
 
Wes
@PeeHaa stripos normalizes case only on the ascii range
 
10:51 PM
@TomasZubiri You don't really declare that when reading.
 
Wes
well perhaps if you do setlocale it will work on utf-8 too, but who does that these days? :\
 
@Wes God such a shitty standard lib
 
My current hypothesis is that I should use a csv reading library that lets me declare the encoding of the file I am trying to read, like this one: csv.thephpleague.com
But I wonder what the php way is.
gonna try setlocale
 
Wes
no
 
no
 
Wes
10:52 PM
don't do that
kill setlocale with fire
 
ok, aborted?
 
The file is using a specific encoding. You don't set an encoding
My money is just one some extra linebreak
 
Wes
are you on windows @TomasZubiri ?
 
I am on windows
 
Wes
i missed what the problem is though
 
10:54 PM
setlocale('en-GB'); does that: codingstill.com/2011/08/if-php-were-british
 
Wes
you just need to be sure everything is utf-8 so that preg_match can do its job
 
@FlorianMargaine :P
 
@PeeHaa I understand this, I wish to do something like fopen("file.txt",'r','utf-8') not to set the encoding, but to tell fopen what the encoding is.
 
Wes
if you are getting weird results then you are not using utf-8
 
or a linebreak
or a bom
Just hexdump both strings
 
10:55 PM
@Wes I am opening a new file with notepad.exe, saving it as utf-8 encoded and that's it.
Did the assert work for you?
 
notepad? utf8?
 
Wes
strings don't have an encoding set in php @TomasZubiri so that won't make sense.
 
Since when does notepad utf8?
holy shit
is that new?
 
Wes
try mb_convert_encoding from windows-1252 to utf-8 on the string you get from that file
 
@Wes How are you supposed to read or manipulate a string without knowing how it is encoded?
 
Wes
10:56 PM
@PeeHaa it could be a scam
 
My money is even more on bom now
 
Wes
@TomasZubiri you can't guess the encoding, there are the BOM's for that
 
Who wants to bet against me?
 
Wes
i agree with you @PeeHaa
 
No that's not how betting works wes
 
10:57 PM
does anybody here work with RTMP streams
 
Wes
lol
 
Peehaa remember ord returned different values for both strings
 
:P
@TomasZubiri That's because it's a bom
 
Wes
you need to skip the first 3 bytes in that file @TomasZubiri, ie substr($str, 3)
 
10:58 PM
Or better remove only the bom
 
Wes
yeah
 
Prevents mistakes later when saving it using a sane editor
/me checks whether notepad also can do sane
lol nope ofc not
Do you have a text editor that doesn't suck @TomasZubiri?
 
It's a file for users. So it was either that, excel or word.
They must be able to edit it.
 
Wes
to be fair if you save txt files without bom you are a bastard
:B
 
@Wes BOM is only for retarded applications
 
11:00 PM
converting from windows-1252 didn't work
 
Can you send me the file?
 
Wes
@PeeHaa what. how else you would detect encoding?
 
magic
 
Wes
@TomasZubiri just skip the first 3 bytes as test
 
Correct you are.
There's a missing Bom
 
Wes
11:03 PM
missing? no, there's a bom you should get rid of :B
 
:P
27
Q: How to remove multiple UTF-8 BOM sequences before "<!DOCTYPE>"?

sheppardzwUsing PHP5 (cgi) to output template files from the filesystem and having issues spitting out raw HTML. private function fetch($name) { $path = $this->j->config['template_path'] . $name . '.html'; if (!file_exists($path)) { dbgerror('Could not find the template "' . $name . '" in ...

Just run that before parsing the thing
 
thanks
 
Fwiw you should not let users dick around with csv in notepad
That will only end bad
 
what would you use to allow users to add modify some config data?
 
Wes
11:06 PM
they won't help you detecting the encoding though, they are just for string comparison
 
on a non web app?
 
Ini file?
 
@TomasZubiri it depends
 
Anything but csv or yaml though
 
x means good
y means bad
z means good
that's my usecase
 
11:09 PM
so, "xz" is double good
sorry .. I have no fucking idea what you are talking about
 
that was dumb
sorry
Google;Company
apple;Company
John;Person
Mary;Person
something like that
csv seemed fine.
php didn't ducking think so.
 
you are allowed to swear here : youtube.com/watch?v=uFr6P2BtE3k
 
I'm out. nn all o/
 
@PeeHaa nite
 
Wes
gn \o
 
11:24 PM
1
Q: The "What does this symbol mean in PHP" reference is a mess

Mark AmeryThis reference question has been frustrating me for a while: Reference - What does this symbol mean in PHP? I'm not opposed, in general, to creating reference Q&As that are just link collections, especially about symbols. The What does this regex mean reference question is, in my opinion, the si...

 
digging through some older music albums:
 
@FélixGagnon-Grenier Hahaha Yes it was a little one sided but I was just tired and over thinking simple code.
 
11:41 PM
 
:D
 
hello people!
small issue with js... why this: $(document).ready(function() {
	$(function () {
		$(window).scroll(function () {
			if ($(this).scrollTop() >= ($(document).height() - $(window).height())*0.9){
				$('.ff-btn').click();
			}
		});
	});
});  creates duplicate?
 
ugh
too much jquery
 
wtf :(
 
Wes
totally php
 
11:53 PM
:) there's none there
 
Wes
asking jquery questions here because the js room is sleeping is like pooping in the kitchen because the toilet is occupied
 
it is like go in a different toilet at least :P
 
No you need to say <?php echo "your code"; ?> then its a php question right?
 
Wes
that sounded harsh. i should've added a smiley :B
 

« first day (2224 days earlier)      last day (2724 days later) »