« first day (432 days earlier)      last day (4742 days later) » 

03:02
@LeviMorrison This question (better answer): stackoverflow.com/a/8509074/367456
There was some discussion earlier, linked in comments to the answer.
I just wanted to review the code.
It's a stream wrapper that implements the functionality to select a sub-portion of the file.
For ID it's trivial, but xpath was requested as well.
It was criticized that the URL syntax would be close to HTTP therefore to mix HTTP and some inc://{FILE}?xpath=expression like syntax.
I'm not sure about if mixing is actually problematic.
But I'm open to other suggestions as well.
Assuming that it is meant to be transformed, it sounds fine to me :) Meaning, this won't happen for any given file, right?
Just certain ones?
The file itself is not changed, just the part that is returned from it.
Like a query.
Which is like a HTTP query sort-of.
So you are defining a function with a pseudo-protocol which will take any file and run an expression on it. Right?
Exactly.
Honestly, I like it.
03:10
The (pseudo) protocol is implemented within the stream wrapper (which is then registered to a sheme).
Okay, I think I'll stick with it.
I keep the code modular so it's easy to change later on.
Just in case some other URL design is preferable.
user1385191
Can anyone point me to a good article on autoloading?
Maybe it needs some docs, but I keep it the way it is for the moment.
user1385191
I'm still maddeningly confused about how it works
@MattMcDonald: About which part of it you're confused?
basically there is some classname.
And then there is a function that includes the file for that classname.
And that's how autoloading works.
user1385191
right, I'm referring to implementation
03:18
@MattMcDonald It's a simple idea, really. Your autoload function is given the name of the class (with namespace) being accessed. The function then uses some algorithm to find where the file would be and include it.
So how do you define or register the callback function for autoloading?
And into which problem do you run?
user1385191
well, the idea is to toss it into a class
user1385191
but I don't know what to do from there
So the function to autoload is a class method?
     class Autoloader
     {
         function load($classname)
         {
             # implementation
        }
     }
?
@MattMcDonald I have done that, putting autoload into a class. Here's what I did: github.com/cspray/SprayFire/blob/master/libs/sprayfire/core/…
03:22
I don't see ROOT_PATH and. DS defined anywhere.
Dbz
Dbz
I have a string, "abcbca", and I want to search the string to find all of the indicies for "a", eg the answer would be 0,5. I tried using preg_match_all with PREG_OFFSET_CAPTURE, but it didn't really work. Can someone help me?
user1385191
so where would one instantiate an autoloader class?
user1385191
that's where I get lost
Okay.
First of all, you're right, you need to instantiate it.
@MattMcDonald I use an apache prepender to prepend it to my scripts, lol.
03:23
@MattMcDonald As soon as possible. You want the autoloading to occur asap
As it's an autoloader, to that early.
E.g. at the very beginning
Like:
@LeviMorrison github.com/cspray/SprayFire/blob/master/web/index.php All requests are routed through this script
$loader = new Autloader();
So now you've got the autloader in $loader.
@CharlesSprayberry That's where you should manually load your autoloader :)
@Dbz Are you always finding single-letters?
Dbz
Dbz
YEs
03:24
@LeviMorrison $ClassLoader->setAutoloader() in the file is not manually setting it?
Then you register it with spl_autoload_register
@hakre He does that in setAutoloader()
user1385191
so if this autoloader is instantiated in, say, "index.php", then sub-directories would be using it as well?
$loader = new Autloader();
spl_autoload_register(array($loader, 'load'));
Dbz
Dbz
@LeviMorrison honestly, I don't know the language well enough to use function shortcuts, so I'm writing a lot of code myself, but yeah, I will be finding single-letters
03:26
@Dbz Always?
@MattMcDonald Actually, you need to register the callback of the autoloader function first. Unless it's not done, it won't work anywhere, not even in subdirectories.
Dbz
Dbz
@LeviMorrison, I will always be finding single letters. I only do it once though.
user1385191
right, with spl_autoload_register
user1385191
so you're saying it would propagate down if registered first?
@MattMcDonald As long as the autoloader function is registered, it will work everywhere.
user1385191
03:28
wow
It's just like ON or OFF.
you can de-register with spl_autoloader_unregister.
user1385191
it's really difficult getting a project off the ground when you don't understand how to link files together like that
user1385191
thanks a lot
If it helps, use absolute paths.
03:30
@Dbz That will be faster than a regular expression every time.
Dbz
Dbz
@LeviMorrison , thank you so much! Is that the most efficient way to do that for a string say of 10,000 letters?
By most efficient way- I mean fastest
@Dbz Probably. I'm not sure why you would need such a thing, though :)
Regular expressions would always be slower than what I gave you.
Dbz
Dbz
Thank you so much then =]
@Dbz That function will always return an array, but it might be empty.
@Dbz: Speed is relative. You could use explode as well and sum up not each character but the length of each fragment, which will give you more speed after some length. But if you're in that area, you need to get creative on your own as well.
03:33
@hakre He wants the indices, not the count.
Dbz
Dbz
@Hakre, what do you mean use explode?
If you some up the counts, you get the indecies.
@hakre . . . I don't think so.
strlen is quite fast in PHP as PHP stores the length of each string already.
$has = strpos($haystack, $needle );
if ($has !== FALSE)
{
foreach($explode($needle, $haystack)
}
@hakre That's probably going to be slower than what I wrote. Write a full solution and I'll do the speed tests :)
@ircmaxell Are you still here, amigo?
03:38
the chat ate my edit :/
I guess you get the idea
No idea when it pays off.
Dbz
Dbz
Well
That's kind of cool
Thanks for the two different examples
@hakre Theoretically yours will be slower. First you call strpos which will iterate part of the way through it, then it iterates through all of them to split, then you have to do math to get the indices. My way: loop through the string and keep track of where you hit the letter. lol
How would your way EVER be faster?
@Dbz: Stick to Levi's example until you need anything else. Otherwise, stick to strpos first which allows offsets, it's faster than explode.
@LeviMorrison explode runs in C. It's faster when it's faster than the loop. No idea when, but it will be if data chunks are faster than iteration in pure PHP.
Dbz
Dbz
Cool
This is interesting to learn
Unless these chunks are easily handable by copying memory, it will be faster. However, it still needs a comparison when that happens.
E.g. with large chunks, copying memory is slow.
Anyway I need to get away from the computer, it's late.
all the best and have fun coding.
Dbz
Dbz
03:47
Thanks!
04:01
@Dbz It turns out hakre is correct: viper-7.com/EesjHc
v2 uses explode, and it is faster. I think I have it populating the results correctly.
Dbz
Dbz
Interesting
It's because PHP has to do a lot of other things with variables. the c strings work quicker. Note that the string I gave is decently long.
Dbz
Dbz
Okay
Is v2 ALWAYS faster?
Or only for large strings
943 characters and its faster
Let me test small strings
Dbz
Dbz
Always?
Okay
I don't want to mess up the lest by doing it myself haha =/
This is my first day coding in php
04:07
viper-7.com/f0Dbu3 There are the results. It seems that v2 is ALWAYS faster.
Dbz
Dbz
Interesting. Well, thank you!
And I just verified that they do produce the same results.
Dbz
Dbz
Cool
However, I get a negative number for v2- v1
v1 - v2I mean
For the second test*
Are you sure? I've ALWAYS had v2 be faster.
Dbz
Dbz
I refreshed the page for another result, and I got a positive second test; however, the first refresh showed it negative
04:14
This version tests a longer string, but runs the tests less times.
Dbz
Dbz
looks like the longer the string, the faster it is
Keep refreshing the page over and over. Honestly, when things are short, both implementations are fast. So the only thing that matters is when the string is long. And it's clear that v2 is faster on long strings.
Dbz
Dbz
True, thanks for checking that out for me.
You might want to run the code I gave you on the machine you'll actually be running your code on. See how the results compare.
Dbz
Dbz
That's a good idea. I'll try that now and see what happens
Both positive; however, the second test's v1-v2 has a huge number (1.3)
Nevermind, I misread the notation, it's in exponential notation
04:21
:)
 
2 hours later…
06:11
hiii,Good morning all
I am zero in jquery,I want to learn jquery from starting
06:32
hi
06:44
Hi
is anyone there?
I have an issue with my HTML and want to upload it on live test so any one cam see my html and css also images
is there any link of this type ?
 
2 hours later…
08:33
@hakre Should all be there (maybe except 0x00 and 0x01 directly
09:20
Morning everyone!
09:43
morning :)
what is a fastest way to see if your site can handle 50 000 users at once. may be a way to ping 50 000 times simultaneously
ab or jmater
jmeter*
@kcrajput you can post your html code here
@Ivan you referring to me?
@user994144 The general term is "load testing". AB is "Apache Bench"
There are some more tools but I'd also recommend those two. "AB" gets you started really quickly
yes, apache bench or apache jmeter. Both supports threads so you can make 50 000 requests at once. Personally I prefer jmeter
okay great. just found some commands to send multiple requests on a server using linux.. any way to send requests using windows?
09:56
jmeter is writen in java and it works also on windows
morning
@ircmaxell @LeviMorrison @hakre Seems like I missed a good bit of discussion. Too lazy to read it though :P
Sometimes I wish DIRECTORY_SEPARATOR would return "/" on windows > XP too
why?
if that's what you want you really should be using / not DS
Because it works and it would make away some more "caring about the os" stuff in php
Let me rephrase: All the dir stuff should always use "/" if the os accepts it so that I can be a lazy bum
no
10:24
DS should always the the separator that a path returned by the OS would contain
But in your own code just use / if that's what you need.
or don't use windows :)
@Ivan That is not an option.
I "need" php to work the same on all plattform if at all possible. Windows supports / for pretty much everything now.
If you are creating your own paths, sure, use /.
It makes my tests look ugly :P .. I know that thats something php can't give and that I have to take are of it and test more multiplatform
10:27
You actually will circumvent problems you would normally have with DS
user336242
maybe just create your own DIR_SEP constant?
You should use DS only if the path is returned by the OS (in my opinion)
It's about non strictly compareable realpath(); stuff. And yes: returning what the OS returns if the last-wtf way
And $rasmus/$deity knows we don't need more of that
It's just really annyoing that pretty much every projects test suite just breaks on windows because they don't properly wrap the PHP file-io functions
Ah, so you are talking about comparing realpath output, not creating own paths?
wow, I am out of moderator flags (I have 50)
how to use apache bench to test site performance ? :s
10:30
(The current approach is the right one, I'm just rambling because I can't test phpunit on windows because every frigging project fails somewhere because no one cares enough to make the tests work on win)
@edorian Patch them :P
@NikiC Really annoying when that happens
I can't quite understand that. Most developers are on Win imho. So it would sound somewhat plausible to run the tests there too...
@NikiC Patching string comparsion to strtr("\\", "/", $input); was a lot easier for now :)
@edorian :D
maybe one needs an ->assertPathEquals :P
10:32
Well people say "our users are on windows but our developers are not"
lol
I'd say it's the other way around :D
user336242
I think alot of the core devs are OSX users...
The software is deployed on *nix but is devd on win
user336242
(judging by screencast)
@JamesButler of symfony or of php?
10:33
All the people I see at conferences ether run Linux or have a mac
@edorian uuuuh
@edorian uuuuuuuuuuh
And the few people with windows machines have virtual machines with linux because "nothing works on windows anyways"
user336242
I was thing of Zend mainly, but also some of the Zend core devs use OSX too
@edorian let me repeat that: uuuuuuuuuuuuuuuuh
user336242
yeah, virtual machines for the win
user336242
10:34
isolate your dev enviroment from your desktop
@edorian Yeah, that's my approach :P You just need a VM for PHP core development, you can't do that on Windows. But developing normal PHP on Win works great for me.
user336242
and make it identical to production and you get deployment happiness
@edorian , well , because running a php-stack webserver on a windows is mental
@JamesButler Vagrant to the rescure? :)
@edorian liar :)
user336242
10:36
@edorian indeed, couple it up with chef/puppet and you can keep an entire dev team happy
@Gordon :D
@JamesButler And it's way cheaper than cocaine
@NikiC although he's right. i run ubuntu on the netbook i usually take to confs
besides , webserver on windows has on big problem : you cannot keep it upt to date
there are no tools to automatically update shit which does not come with MS copyrights
@Gordon you should take a windows notebook there just to make a point.
10:38
@JamesButler Do you do lots of build automation (up to deployable builds from ci)? And if yes since when
user336242
@edorian Also as bonus, you can trash servers without fear, (or in my case as I like breaking stuff regardless, having sys-admin come hunt you down)
user336242
@edorian I have a mix of build automation
@NikiC yeah, and offer a talk about "How to code on Windows".
@Gordon would be great ^^
@Gordon "How to code on Zend Frameworking, using Zend Studio on Windows"
Something like "Broken setups master class"
10:39
@edorian and Zend Server
maybe someone should make a new startup .. producing tools for automatically updating 3rd party software on windows
user336242
@edorian my personal stuff has reached the Zen status of being auto build and deploy once i commit to trunk on git. Jenkins gets notified, pulls trunk, runs tests etc, pushes the end-product to an S3 bucket, and pokes Puppet to get the production servers to update
user336242
@edorian work stuff is getting that way, but you know how things are never as easy when your getting paid for it, and work don't quite see the point
@JamesButler Sweet :) I'll be setting up something similar (without cloudy stuff) at my next employer. Looking forward to that
i suspect that there will be no new updated/patches of PhpUnit till february
Bought Skyrim today and got access to the Diablo III Beta. Should help passing the time it takes to log into SW:TOR ...
10:43
@tereško Well @edorian is working on it too ...
@NikiC Steam sales
@edorian ^^
@edorian was already down the count
( if that was the correct expression )
I'd be pretty happy If we don't break projects for some month. I've fixed +20 bugs last month and 3.6 is looking quite stable / acceptable / adaptable now.
btw , @edorian , is it possible to use a different bootstrap file for each <testsuite> ?
10:47
Nope. The closest thing to this is: github.com/sebastianbergmann/phpunit/pull/441 or some other TestSuite stuff that isn't all that pretty.
Having a "integrationTestBaseClass" that does setup stuff for those is an option too
After that it's having multiple configs / bootstrapping everything
yeah , "not all that pretty"
a string that cannot be parsed by parse_url returns false. What would be the appropiate exception? DomainException?
how do i use ab to test my site performance?
@user994144 man ab
@Gordon Out of the SPL Exceptions?
10:54
@Gordon sorry?
Jon
Jon
My boss runs almost all data retrieved from and being put into a database through htmlentities() and then mysql_real_escape_string(). He read that it was a good idea in a book on PHP, I think it's ridiculous to use htmlentities before putting stuff in a database AND because he does it everywhere without consideration for context it adds loads of completely unnecessary code. Has anyone else come across this practice? When should I be using htmlentities()?
@Gordon windows
emm ... as i understand it , it is because strings format is invalid , @Gordon
@edorian yeah probably. i dont like inventing new ones.
so the exception should describe the cause of problem , not the effect
@Jon your boss is wrong
@Gordon Ether domain or invalid argument "is not a url"
@tereško so you'd invent an InvalidUrlFomatException?
@Jon Filter input, escape output
10:56
@Jon You should only MySQL escape when writing to the DB. You should HTML escape (using htmlspecialchars, not htmlentities!) only right before you print the string into an HTML document.
isnt there some "invalid format" exception already in SPL ?
html escaping should happen when outputing only
@tereško nope. and if there was it would probably extend domain exception, which is the range of possible inputs that can generate an output iirc
Tell him that you can never generate PDFs from that data if you run htmlentities when putting it in
Maybe that gives him the idea why it isn't going to work out
Jon
Jon
@NikiC @edorian Thanks. Damn PHP books!
10:58
the domain of a function is the set of "input" or argument values for which the function is defined
@Jon tell your boss that actually he should not even be using mysql_* functions at all (they are old and in the process of being deprecated) , nowadays you should be using either PDO or MySQLi with prepared statements
> Damn PHP books
QOTD ;)
For a longer a little tainted discussion on the subject
fou
fou
Hi all
Jon
Jon
@edorian cheers... the whole codebase is full of $mysql arrays containing escaped data, and $clean arrays containing htmlentitied data... its a nightmare!
Hi!
I have a couple of variables. Like avar, bvar, cvar, eq.
I want to print my equation. Like:
I input the vars:
avar = 1,2
bvar = 2,4
cvar = 2,3
eq = (a*b)-2(a-c)

I don't want to calculate the result, ONLY print the "math form".
Like: (1,2*2,4)-2(1,2-2,3)

How can I do this? :/
Jon
Jon
11:01
@tereško pretty sure PDO will scare him off
There was such a nice slideshow something about "only filter/escape at module bondaries"
Because only the modules know how to do the escaping right anyways
So passing when data to the DB layer that layer knows what to do :)
fou
fou
if I use the command curl should I configure something in easy php to run it
@fou Sorry I can't follow you. "command curl" / "easy php" ?
fou
fou
I use easy php to run php code. In my code I use curl_setopt($ch, CURLOPT_URL, "https://pushapi.eval.blackberry.com/mss/PD_pushRequest");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_USERAGENT, "Hallgren Networks BB Push Server/1.0");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $appid . ':' . $password);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
should I add something in easy php to configure curl
Anyone? :(
Maybe somehow I can "replace" the values in my equation?
Like I input my eq: a + b + c + a + b
Then the result would be: $a + $b + $c + $a + $b
How can I do this? :/
11:08
Ether use eval and hope nobody breaks your system (they will) or build/find an equation parser that works
@Gordon where do you enter those commands? completely lost
@user994144 on the command line
@user994144 On the command line
Ah no this would be a simple helper php file for myself. Nothing commercial or stuff.
@Jon there is nothing more scary then a boss who likes to pretend that he is a developer
11:09
@Gordon where is the command line?
7
Jon
Jon
@tereško yeah I've got a whole host of questions to ask in my next job interview to make sure I'm working for someone who understands/cares about development
hehe
so you basically are looking for a new job
@Jon They don't need to care about development. They need you to care about it and trust you that you ask only for things you really need
@user994144 no offense, but if you do not know where the command line is, then you are probably not ready to do what you are trying to do. hop over to google and do some research about how to use your operating system.
@edorian - Could you take a look, please? pastebin.com/SjWrgwdS
11:14
@Gordon dude I am not sure which command line you are talking about. I triedit on cmd but it does not work
fou
fou
@edorian did you check my post?
@user994144 dude. cant help u no mo'. go to google plz.
@Gordon thanks
@user994144 yw
Jon
Jon
@edorian @tereško he's actually pretty supportive, but I wouldn't hire him to develop for me and he's the only other developer in the office and I've yet to figure out how to ask him to get better at his job
11:17
well ... you can approach like something new you learned about , and ask him if he had heard of it too
Jon
Jon
patronization ftw
naah ... not that way
its "talking shop"
both PDO and MySQLi are "a new thing" for 99.9% of php developers
uuuhm.. anyone care to take a look at my link? Its a really noobish question, but the time is short. Quite short.
and same goes for even a concept of prepared statements
@user994144 , you should hire someone
user336242
@Jon I'm currently in your position.. It can prove testing
Jon
Jon
11:33
@Shiki have a look at this: pastebin.com/zjysfbpy
@Shiki needs some work but that'll get you going
Good afternoon
Jon
Jon
@Shiki the first foreach loop is where you'd do your data validation/input filtering etc, then second foreach loop prints out the final equation
Thanks!
Later! (but yeah, that code helps a lot!)
Jon
Jon
@JamesButler I fear for some of our clients for whom he's the only coder working on their site
@Shiki np
hi friends
11:47
where is "report user" button in profiles ?!
Why are you promoting ObjC blog in PHP room?
just fro followers yaar
@Donut , just flag it , it is a spam
@Sadumerry hi really annoying person
Probably, you won't find them here.
@tereško Oh, I've forgotten there's a flag option in chat room :P
11:51
there should be a way to flag spammers ( as in "report user" thing )
12:01
hmm, i cannot use throw in a ternary expression?
throw is a statement, not an expression
but you can do throw $a ? new AException : new BException;
will trigger_error then
@Gordon ^^
public function __get($property)
{
    return in_array($property, get_object_vars($this))
        ? $this->$property
        : trigger_error('Property does not exist', E_USER_NOTICE);
}
if (!in_array() throw new Exception; return $this->$property
12:08
if (isset($this->{$property})) {
return $this->{$property};
}
throw new Exception("Property does not exists");
yeah, that would work too
though i guess the notice is more appropriate
or?
@Gordon If you think like that then just do return $this->$property. It'll give you your notice.
@NikiC hmm.. true. im thinking too complicated again
(and will be more descriptive than your error message)
@NikiC thanks
12:11
btw, it looks like you are doing some very black magic there :P
@NikiC nah, just abusing magic methods for getters :)
and its just a value object
If I wouldn't know better I could think that you are trying to give someone access to private class members because you think that just declaring them public is "bad" but providing a magic getter is not ;)
@NikiC i am doing that. like i said its a value object.
@Gordon But why not making it public then?
@NikiC i dont want them to be writable
12:14
or do you have additional setting logic?
ah, you just answered my question ^^
:)
of course this wouldnt be necessary if php would only have readonly but it doesnt
const :)
@Ivan the values are not constant
class Url
{
    protected $scheme, $host, $user, $pass, $path, $query, $fragment;

    public function __construct($url)
    {
        if ($parts = parse_url($url)) {
            foreach ($parts as $part => $value) {
                $this->$part = $value;
            }
        }
        throw new SyntaxError('Url cannot be parsed');
    }

    public function __toString()
    {
        return http_build_url(get_object_vars($this));
    }

    public function __get($property)
    {
        return $this->$property;
@Ivan see what i mean? they are constant once set, but not in the const sense.
I see
12:30
can any one tell me when i use header('Location: ./something.php'); why is it that the page doesnt load? i see the something.php as a response in firebug but the index.php page stays as it is!
when i refresh the page the index.php goes away and then i can see something.php! why does this happen!
browser doesn't have idea about your filesystem and current path.
use full url
i think i need to supply the relative path
because i just checked and supplying the complete path returned an error
and additionally it shows up in the browser, but only after i press f5.
@Tanmay is it happening in all the browsers?
yes
 
1 hour later…
13:50
Never knew about # and ## in macros
looks very useful
Good Morning
@NikiC @edorian and I decided that you got nothing to do all day and therefor have to implement friend classes in php. can you do that please? :)
@Gordon const means it's writeable exactly once (definition time). So it should be the same thing...
0
Q: how to creat successful unique hash function?

Mor Selai'm looking how to create unique hash function or finding one that is not prebuilt already so there will not be bank of it , AKA : http://www.md5decrypter.co.uk/ any suggestion how to make one? thanks in advance , Mor.

Morning
13:56
@ircmaxell good morning
@ircmaxell definition of class !== initialization of instance
@Gordon you might be right about nothing to do, but ...
user336242
@MorSela Tried salting your variables
@Gordon Huh? I'm talking about variables...
@MorSela commented

« first day (432 days earlier)      last day (4742 days later) »