« first day (424 days earlier)      last day (4510 days later) » 

12:04 AM
@LeviMorrison @LeviMorrison It is quick and dirty but what do you think of my attempt at an answer? pastebin.com/uLg8UkHn
 
@CharlesSprayberry C14N I've never actually used that. Could you give me teh quicky of what it is?
Also, you could possibly just use [0] at the end of your query to get the first item
 
@LeviMorrison To be brutally honest I have never used DomDocument before. That is what I whipped up after looking at docs for a few minutes. I'm not sure that it is the correct method for what I want to do
 
But, according to the docs it simply returns the node as a string
 
$dom->saveHtml($domNode); <-- that's the traditional way to do it.
 
12:07 AM
I mean, I'm pretty sure it is the correct method
 
Oh, I'm not saying it's wrong.
I've just never used it.
 
But the element in DomNodeList is a DomElement which does not have a saveHtml method?
Let me take a look at the docs again
Ahh, nevermind
I see now
I guess when I read saveHtml I just assumed it would effect the document instead of creating a new one
@LeviMorrison pastebin.com/cbHVsYxq Here's one using saveHtml
 
I like it. Also, try using body/p[0] in as your query and dont' try to get an item. I think it will return the first p node.
I think.
 
ok one second
body/p[0] actually winds up returning the entire document
 
Hmm
I know there's some xQuery syntax
xPath *
doh,
[position() = 0]
 
12:18 AM
Well, I submitted my answer. I'll figure we can optimize later :)
 
try that
@CharlesSprayberry Good idea.
actually
(body/p)[position() = 0]
parens MIGHT be important.
 
Nope, my tests continue to return the entire document for those
including a parens around (body/p)
in addition to still needing to access it through $nodeList->item()
Bah, just saw the edit to his question
Now I just look like a noob that didn't read the question :P
 
 
1 hour later…
1:47 AM
mornings guys, gals and everyone else
 
2:12 AM
@tereško Good evening :)
 
2:43 AM
@tereško You call 3.47am a morning?
 
morning is the time between when i wake up and when i eat lunch
 
All right.
 
3:16 AM
so i have an object $date which is equal to 2011-12-13 18:54:27
but when i do $date = date("m/d/Y", $date); i get the generic 12/31/1969
 
3:32 AM
@JMRboosties , did you read the manual ? php.net/manual/en/function.date.php
look at the type of second parameter
 
 
2 hours later…
5:20 AM
Found out that I can send POST data using file_get_contents without using cURL by building the appropriate http context: php.net/manual/en/context.http.php - is using this a good practice? or should I use cURL instead?
 
@rickchristie I don't know. I've always seen cURL. I'll look into it myself. Seems interesting.
 
@LeviMorrison - I'm asking to be sure, since some PHP features can be unsafe :) - Just found out too. Would be great if it's safe to use!
 
5:54 AM
I want to modify a DateTime object, where my modification units are integers, representing seconds, how do I do it?
 
6:05 AM
never mind, have to use DateTime::add(new DateInterval("PT{$duration}S");
 
@tereško i did but thought since the object in my db is a timestamp it would work
 
@JMRboosties , mysql fucks with TIMESTAMP column type
you have to use UNIX_TIMESTAMP() to create integer type representation of time
 
@tereško yea, i found the strtotime method and it works fine now
 
Hello need a small help ;)
 
6:28 AM
@Ants , if you are not going to follow that up with actual question , then you can just leave
 
6:55 AM
@tereško I need to know the scheduling website that offers.....these features .... the websites allows a project manager to plan his schedule, to plan a holiday, supervision of employees, create a schedule, check users holiday status.. and so on...
 
you mean something like Basecamp , @Ants ?
 
7:31 AM
@tereško: I have found that already. Since there is no free sign up.. I haven't tried it.. Are they support what I asked for? More specifically it has feature like: "On this current date the user X is on holiday so look for another user Y to assign a task" kind of stuff? i.e It has holiday planning?
 
@Ants , first of all , there is actually free plan
and if you want to specific thing , then you have to create it your own
besides , this is PHP channel , not "find software for me" channel
 
 
1 hour later…
8:45 AM
Morning
 
yay
 
Yay?
 
I have a two step process, check and subscribe. Whenever I am going to subscribe I must check. Should I call check() from within subscribe() ?
 
Well in the first look it seems like it
 
9:02 AM
@all hi...
does anybody know how to send mail with mail() function and postfix server
 
@edorian : hmm, so my DocBlock should mention it with a <b>NOTE</b> . Thanks. I was somehow not comfortable doing it. Somehow, it just doesnt feel right. Though I can't point out exactly what
 
That is not what i said at all
If you need to describe in with order to call methods on a class chances are your API is flawed
If you need to make sure something is "checked" before you can authorize a "subscribe" then do that in the subscribe method and error out in case it's not allowed
 
0
Q: PHP json_encode a debug_backtrace() with resource types

Christian SciberrasCurrently, I have a logger which logs errors together with a backtrace. The logger serializes the backtrace to JSON via json_encode(). Let's look at some hypothetical code... <?php error_reporting(-1); // show all errors function test($b){ echo json_e...

@edorian Help, please? :P
 
@edorian so my Subscribe() should throw a RuntimeException , saying that the user is already subscribed . Or I can return false, but thats not very intuitive. Or I can cheat by returning previous subscription identifier.
I am confused. Something doesnt feel right in this flow of logic
 
@ChristianSciberras Hmm.. My take on it would be that it doesn't make much sense to serialize the real objects so I'd just store the debug_print_backtrace(); and not the objects but then you can't print really pretty backtraces anymore
If thats not good enough (I had one case where I wanted to store the backtraces nicer) and I used to transform it to the desired output format while logging.
Nope, I can't "solve" this nicely atm it seems
 
9:29 AM
@edorian Watch the new msg marker, it's cute :D
Regarding my little issue, I'm thinking about replacing objects. Something like:

if(is_object($value)) $trace[$i] = processObject($object);
 
0
A: PHP json_encode a debug_backtrace() with resource types

edorianSo you are trying to store the backtrace as a data structure that can be used to pretty-print the results later on? If that isn't needed I'd just store $result = print_r(debug_backtrace(), true) and be done with it. If not my first shot would be something like: <?php error_reporting(-1); fu...

 
processObject would return a new object (or maybe just an array?) with object info: {ctor:"whatever", oid:"12345"}
 
10:07 AM
hey :)
 
ho :)
 
how are you?
 
Fine thanks, you?
 
hi,
any who know cakphp?
 
good
 
10:17 AM
cakephp
 
a little @Manan
 
how to use observeField with radio button in cakephp?
 
idk, did ou make some search ? Google gives plenty results on this topic
you*
 
yes
but only questions are available
 
hmmm ok what's your code?
the case is on checkboxes but it should the same with radios
 
10:33 AM
echo $this->Form->input('category_id', array('label'=>'','type' => 'select','id'=>'categories1','multiple'=>'checkbox'));
echo $ajax->observeField('categories',
array(
'update' => 'skill',
'indicator'=>'ajaxloading',
'url' =>array('action' => 'skill')));
first line generate multiple checkbox so how can i track its id in objerve field
function
 
you're generating checkboxes in a select type form ?
 
gods below .. that look horrifying
 
first cake generate multiple categories with different id after that i need to put on this id in observeField function
so, how can i know what will be the generated id and how to point in observefield function
 
i hope you realize that this code sucks for several reasons:
    echo '<input id="showtasks2" type="radio" onClick="new Ajax.Updater(
   \'divname\',\'actionname\' , {asynchronous:true, evalScripts:true});')"';
 
hi folk
 
10:48 AM
Hi @MiPnamic
 
yes , its not useful @teresko
 
just stumbled upon another php framework: Laravel
lets hope it will make for a good laugh
 
@tereško Neat flavor text and immediately ruined by the first example. Thats how it should be isn't it?
 
oh .. i didnt scroll so far <_<
then again , it was nowhere said that it is an OOP framework
 
I'm a little befuddled by the decision of having a static DIC but it seems tacked on afterwards so that would explain that
 
11:02 AM
well .. honestly , if you ignore the "everything static" part , it doesnt look so bad .. though i'm still looking
 
Yeah me too
 
( i spamed link as soon as i landed in home page )
 
If you accept the class based programming aspect it does to a lot less wrong than other monolithic pieces
 
i wonder , what does IoC class do
 
Don't get me wrong: It's completely unusable for any code base that needs to maintain any sort of value over more than 2 month or any project that has any major business impact .. but so are a lot of "current generation frameworks" like the C-Words.
closure factory container
Which is a nice way to go if resolve takes more than one argument
 
11:07 AM
right now the verdict is : you should not use it , but if you are studying/exploring frameworks in php , then this is a must-see framework
and it is refactored till someone was sick of doing it , and then a bit more
at least compared to others that i have seen
 
even the bootstrap isn't all that broken (given it's all static)
 
if someone explained to this guy why static is not "beautiful" , it might morph in a pretty good framework
 
Cyclomatic Complexity / Lines of Code:           0.08
Cyclomatic Complexity / Number of Methods:       1.95
 
Not too bad on the defines. All the path defines could/should be thrown out and then the pollution it introduces it quite slim
 
11:16 AM
of course static methods are everywhere :
Static: 231 (43.10%)
 
2 isn't all that good but it's not so far off
 
wanna do LoC for Yii ? ..
 
Hi, I am wondering how to implement an php-proxy page.
 
All the relevant frameworks have comparable numbers on the regards of avg. cc / method (all under 2)
@ijse Could you explain what you mean by that
 
a php page that only modify http-header, but user download an file from another server
 
11:24 AM
i think function with highest CC would be a good indicator for code complexity
 
xxx.com/proxy.php?url=http://abc.com/aaa.mp3 and user will download aaa.mp3 from abc.com but http header was modified by proxy.php
 
and you want to proxy the download through your server or just redirect the user? So the second one.. i see.. strange to call it proxy then but ok
 
header('Location: urlhere') ?
 
Yeah you can pretty much only redirect him or make him fetch the content via javascript where you have a little more control but not all that much ether
 
@edorian but this won't be able to modify http headers
I want user download a file from another server by giving the direct link, and I also need to modify the http header to change the default file name when user saving it to his computer
 
11:30 AM
@edorian , btw , did you notice that in the first page there was nothing said about MVC or lightweight/micro/flexible/fast
 
Yeah. Except for "beautiful" there is nothing to complain about
 
and I can't control the another server....
 
.. too bad the code sucked , tweeted anyway
 
@Robik but...when user download urlhere, I can't modify file saving name
All what I want is just change file saving name when user click download link.
 
Then rename it when you fire click event oO
 
11:51 AM
@Robik this won't help
 
@ijse , why not just create a script , through which the download happens ?
said script would be responsible for translating the "pretty names" to the ones actually stored on the server, retrieving the files and slapping on the pretty name again
 
exacly
 
is there any way to remove , " tags from string
 
@Sibu plenty, try str_replace
 
@Gordon but i want to remove multiple op like ' " etc. i cannot specify what all to remove
 
12:05 PM
@Sibu sounds like you need a framework
 
if the string contains any single commas or double commas everything should be removed
 
Feb 14 at 11:59, by Gordon
$framework = new WonderFramework('unicorn');
$doms = $framework->doWhatIWant(
    $framework->readMyMind()
);
print $doms->getElementsByTagName(42);
3
 
@Gordon is there any other way?? like preg_replace
i dunno how to use preg_replace
 
@Sibu so if the string is "lalalala,foobarbar" you want everything removed?
so the result of my_replace("lalalala,foobarbar") is an empty string?
 
yeah, everytthing it show string w/o them
 
12:09 PM
what is: " tag ?
 
@Sibu everything without them? you are chaning requirements in each sentence
give examples please
 
@tereško html tags <p style=>
 
hod does one from " to html
 
ok, now it makes no sense at all anymore
impossible without wonderframework
 
@Gordon sorry if i am ambiguous the output string should contain only characters
nothing else
 
12:12 PM
i think , what he wants is strip_tags() , but he/she is physically incapable of expressing his thoughts into words
 
@Sibu which characters? im sorry, i cannot help you. i dont understand what you are asking.
 
classic "india asking pattern"
 
@tereško will strip_tags remove char like " ',
 
@Sibu no
 
@Gordon i will gve an ex
 
12:14 PM
no , we are not interested in your ex .. she might be ugly
 
$string=sdsd"dsd'sdsd,sdsdsd;
$output=sdsd sdsds sdsdsd
 
thats not valid php
 
how did you get sdsds in the middle?
anyways, have a look at php.net/manual/en/ref.strings.php
 
12:30 PM
I think he's just looking for a [a-zA-Z0-9] regex
 
i think he has the wrong hobby
 
@JohnP there is spaces in the result string, so no :)
 
@Gordon heh, yeah. Apart from the first four characters the string doesn't seem to match at all. Ah well, guess he'll need to be more descriptive
 
@JohnP yup
 
1:02 PM
Hi, I have ClassA::methodFoo(IfaceB $b) { $b->IfaceMethodBar() } , where do I catch RuntimeException thrown by IfaceB::IfaceMethodBar() ?
 
hoi
 
well , you shouldn't
 
@tereško : nowhere ? you mean not inside ClassA::methodFoo() ??
 
At the place where you can meaningful handle the error or cross module boundaries and need to adhere to the modules way of communication failure
 
consider a bridge implementation, where the bridged component is going to handle Database Interface, (I call it DBH, DataBaseHandler) . The DBH is (loosely) speaking a wrapper around PDO. Now DbhProduct::__construct(Dbh $dbh) { $this->_dbh = $dbh } and when I want to do some CRUD I will do $this->_dbh->updateFoo(), where do I catch the PDOExceptions (or rather DbhExceptions) ?
these are RuntimeExceptions , I am not so worried about LogicExceptions as I believe they will be rare (confidence comes from UnitTesting).
@edorian its bit difficult when you are the one who have to decide those boundaries and places for meaningful handles. Sometimes I wish I dont have to define an Interface, but just code against it. Feels much easier
 
1:33 PM
anyone using Netbeans here?
 
For a short while a couple of years ago
 
@MiPnamic From time to time
@Sudhi You catch all the PDO exceptions in your wrapper and when you need to throw stuff outside you throw your own DBH exceptions
 
@edorian exactly! I am doing that only, but what do I do of those DbhExceptions ?
consider Product::Subscribe() { $this->_dbh->insertInto($tableName, $data) } , and this throws a DbhException (assume FK constraint error) , what do I do with this DbhException ?
 
ok, solved thank you anyway
I posted a bug on the netbeans site :)
 
If you have a way of saying "this should happen when the insert fails" then you catch the exception and handle it.
If all you know is that "if that fails everything is lost, abandon ship" you don't catch it and your global exception handler will show the 500 page or something
 
1:49 PM
i have this nagging question : why do you bother with wrapping it into a class ?
 
@edorian Hmm, okay. This gives a good idea about the case handling. I think I should read up @ircmaxell 's PHP error handling post again
@tereško because I wanted to try out. One might not have any problems writing a .php file with 2K LOC filled with SELECT * FROM . But I just can't do it
 
I find the PDO API very cumbersome and unnecessarily complex. The DB API i like most for php purposes is ->fetch[One|Row|Col|All|Assoc]($sql, $param[s] ....);
 
Simply put this is sort of an exercise. To get an idea what a good design and code feels like
 
I don't want to deal with all the binding stuff my self. For me there is no additional value in doing the bind statements my self
 
@edorian wrap it.
 
1:54 PM
@edorian which DB API is this ? I sort of mimiced what you just said
@NikiC its not that easy
 
well .. you can avoid the binding , but then all the values will be bound as strings
 
@NikiC I was somewhat answering @tereško why wrapping PDO could make sense ;)
 
I say because I have tried (and I am using it) but the support is very limited. You only support things that you need. Making a full fledged wrapper is just too short of ORM.
 
what support , where
 
@tereško Yeah. Ether use the vars data type or bind everything as string. It's mysql, it doesn't matter. If I was talking to a DB that wouldn't handle that that might change my way of working :)
 
1:57 PM
@edorian , then i would suggest for you , as an educational experience , to install config and use postgresql for an experiment
it might change your view on how DB should actually work , and what should be the features
 
@tereško Like i was trying to say. When working with a REAL database that doesn't work
 
heh
 
@edorian ah, okay, I didn't read anything apart from your post ^^
 
MySql started off as glorified sql interface to text files and thats fine with me for the use cases where it makes sense
@Sudhi Something like framework.zend.com/manual/en/zend.db.adapter.html without all the clutter
 

« first day (424 days earlier)      last day (4510 days later) »