« first day (524 days earlier)      last day (4413 days later) » 

user895378
12:16 AM
@LeviMorrison Awesome! New toys are so much fun.
 
user895378
@LeviMorrison OCD is a curse. I know these things.
 
lol
On the other hand, I have some really nice looking UI elements because of it.
 
user895378
True. If you can strike a balance between perfection and ever getting anything done at all it's a great trait for someone with our interests :)
 
user895378
I like to think I'm getting better at finding that sweet spot.
 
1px differences annoy me so much
like when an input/select menu/button is 1px higher than the one next to it OMG
then you fix it, and it does the opposite on chrome
then you open IE and cry
 
12:25 AM
This could easily be fixed.
Mozilla and Microsoft should just use webkit.
BAM, solved.
 
@Petah I'm having that problem with a project
Really aggravating
 
BAM all your activeX and COM is broken, and FF plugins
 
It is really, really, really awesome to see PHP source pull requests on github.
 
where?
 
user895378
12:49 AM
woot. watch.
 
Ahoy folks.
 
user895378
hola
 
Quick question for ye ole' gurus. I wrap an entire PHP CLI app in a function, say run(). Inside of run() I register a shutdown function, it checks error_get_last() and if !== null it dumps some debug, and calls run() again (recursively I suppose) as to prevent the script from terminating on a fatal.
Problem is, it only works for one iteration. The first fatal recurses, but subsequent ones just die out.
 
a recursive shutdown function
first i have herd of that
good luck
 
Haha, I know, it didn't sound right to say it that way, but really that's what it is in a way
It's sort of "recursive", in that the scope of the function from which the callback is called is the function it calls itself.
 
user895378
1:00 AM
I'm not sure ... PHP wants to terminate really badly when a FATAL error occurs ...
 
I know it does. But I keep trying to tell it "NO! PRESS ON DEAR PHP"
 
user895378
What I've done is implement an event mediator that dispatches a shutdown event and I can attach an infinite number of listeners
 
user895378
perhaps you could fork a new process for operations that have the potential for a fatal E_ERROR
 
Tip of the day: Fatal errors are not something that should ever happen in production code. They indicate that you, as a developer screwed up. Don't expect them. If they are thrown, figure out why and fix it. Don't retry the application
 
user895378
Sounds pretty definitive to me :)
 
user895378
1:02 AM
Especially if you're talking about a CLI app
 
@ircmaxell I agree. Problem is, my CLI app is just a pseudo terminal to access my framework's controller methods that have potential for automation, etc., but when I'm debugging the app libraries (they're stored as dictionaries of anonymous functions, so they can be "reloaded") and I reload one, if something happens, I don't want the session to die out altogether.
 
user895378
Sounds like you need the PCNTL functions to me ...
 
@rdlowrey Yea, I was thinking of forking... Process control has shoddy support on Win though doesn't it?
 
user895378
nope
 
user895378
unix style only
 
user895378
1:04 AM
I have no idea what you can do in those terms for windows
 
Shoddy support, no support, same difference :P
 
@rdlowrey nothing
Windows doesn't have a concept of forking. It uses threading to do the same (which isn't the same)
 
@ircmaxell & @rdlowrey I was afraid of that.
Yea
 
that's because forking is very cheap in *nix, but very expensive in Windows
 
user895378
Makes me feel good about my OS choices ... though I know sometimes you have an environment thrust upon you.
 
1:06 AM
@Bracketworks Load them in process isolation then. Plenty of people have tried what you're doing (hot-reloads), but in reality it almost never works
When I say process isolation, make a rest interface, or a CLI interface...
 
user895378
The old SOA back again
 
@ircmaxell Ah, so a process manager (server) that gets invoked as a whole new process for each command. The CLI app is just a thin client?
 
That, or just reload the application when reloading debugging extensions...
@Bracketworks yup...
or, I wouldn't even bother. Just reload the app, and have a sane bootstrap process...
 
Yea.. I wish I hadn't, as @rdlowrey said, had Win "thrust" upon me :)
Thanks guys, I'mma afk for a bit.
 
user895378
@Bracketworks Shakespeare might call it greatness :)
 
user895378
1:09 AM
But I wouldn't
 
user895378
-- Twelfth Night (II, v, 156-159)
 
I know this isn't the js chat, but no one is in there. Does any one know a Webkit hack to copy text to the clipboard (excluding the Flash hack)?
 
The flash hack
oh right. no.
it's the only reliable way I know of
 
when you create a bounty, and it deducts 50 points for example, if no one answers question in 7 days, do you get the points back?
 
1:22 AM
::@JohnMerlino fairly certain those points are gone forever
 
i thin you right
 
@MichaelRobinson Okay, thanks
 
2:12 AM
anyone here?
Apache mod-rewrites: multiple rewritecond - is it default AND or default OR?
nvm
 
2:46 AM
regarding isset() function on arrays, one stated "It is worth noting that in order to check for the existence of a key within an array, regardless of it's contents one should use array_key_exists() not isset().

isset() will (correctly) return false if the value of your array key is null, which may be a perfectly valid condition."

so what is the all-round solution ?
 
@ShivanRaptor use isset if you dont care about null values, or else use array_key_exists
 
nice !
 
Any mod_rewrite gods in here?
0
Q: htaccess rewrite to maintenance page if exists and not IP, else bootstrap

PetahHow would I rewrite all requests to maintenance.php, if it exists, except images, and except an IP white list. If maintenance.php does not exist it should rewrite to a bootstrap (index.php) if the requested file does not exist. If maintenance.php does exist and the IP is in the white list, then...

 
3:13 AM
@Petah: think about it in reverse. Bootstrap if maintenance doesn't exist, or IP. Then fallback on maintenance page...
 
3:41 AM
@ircmaxell thanks for the answer, I tried it but still can't seem it get it working
it sends the white list IPs to the maintenance page still
 
I have proven it doesn't
 
my exact code is:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{DOCUMENT_ROOT}/maintenance.php !-f [OR]
    RewriteCond %{HTTP_X_FORWARDED_FOR} ^x\.x\.x\.x$ [OR]
    RewriteCond %{HTTP_X_FORWARDED_FOR} ^y\.y\.y\.y$ [OR]
    RewriteCond %{HTTP_X_FORWARDED_FOR} ^z\.z\.z\.z$ [OR]
    RewriteCond %{HTTP_X_FORWARDED_FOR} ^a\.a\.a\.a$
    RewriteRule . siteignite.php [L]

    RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f
 
are you sure X_FORWARD_FOR is populated correctly?
 
yes, i did var_dump($_SERVER) on the maintenance page
["HTTP_X_FORWARDED_FOR"]=> string(14) "x.x.x.x"
 
Duh, you're calling it wrong:
RewriteCond %{HTTP:X_FORWARDED_FOR} ^x\.x\.x\.x$ [OR]
RewriteCond %{HTTP:X_FORWARDED_FOR} ^y\.y\.y\.y$ [OR]
RewriteCond %{HTTP:X_FORWARDED_FOR} ^z\.z\.z\.z$ [OR]
RewriteCond %{HTTP:X_FORWARDED_FOR} ^a\.a\.a\.a$
> %{HTTP:header}, where header can be any HTTP MIME-header name, can always be used to obtain the value of a header sent in the HTTP request. Example: %{HTTP:Proxy-Connection} is the value of the HTTP header ``Proxy-Connection:''.
 
3:52 AM
Trying now
(we work together)
 
And that's why you post real code. Not pseudo-code. Because REMOTE_ADDR is valid by itself, X_FORWARDED_FOR is not...
And coincidentally, this is where Apache sucks. Their config file is a big joke...
 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/maintenance.php !-f [OR]
RewriteCond %{HTTP:X_FORWARDED_FOR} ^x\.x\.x\.x$ [OR]
RewriteCond %{HTTP:X_FORWARDED_FOR} ^y\.y\.y\.y$ [OR]
RewriteCond %{HTTP:X_FORWARDED_FOR} ^z\.z\.z\.z$ [OR]
RewriteCond %{HTTP:X_FORWARDED_FOR} ^zz\.zz\.zz\.zz$
RewriteRule . siteignite.php [L]
@ircmaxell re:config agree
 
Did it work?
 
Check the case on X_Forwarded_For
 
3:55 AM
we tried REMOTE_ADDR so that was our real code, then we realized it was the proxy addr
 
camel case doesn't work either
HTTP:X_Forwarded_For
 
No, check in $_SERVER the case it was sent with
 
its all caps in $_SERVER?
 
["HTTP_X_FORWARDED_FOR"]=> string(14) "w.x.y.z"
 
3:58 AM
Ok, separate it out. Try doing a rewrite on just that header
RewriteCond %{HTTP:X_FORWARDED_FOR} ^zz\.zz\.zz\.zz$
RewriteRule . foo.php [L]
..?
 
RewriteCond %{HTTP:X_FORWARDED_FOR} ^w\.x\.y\.z$
RewriteRule . maintenance.php [L]

Goes to the home page, rather than the maintenance page
 
is that the first rule?
 
thats the only rule
 
Well, then you know that's the problem, don't you?
 
apart from

RewriteEngine On
RewriteBase /
no?
 
4:05 AM
since you should have been taken to maintenance.php, and weren't, that rule couldn't have matched
Try RewriteCond %{HTTP:X_FORWARDED_FOR} "w.x.y.z"
or perhaps RewriteCond %{HTTP:X_FORWARDED_FOR} w\.x\.y\.z (without the anchors, perhaps it's a white-space issue)
 
Still no love from the mod_rewrite
 
still the same :(
 
Duh... %{HTTP:X-Forwarded-For}
PHP converts the - to _
 
yay, RewriteCond %{HTTP:X-Forwarded-For} works
thanks heaps
you the man
 
BUT realize that X-Forwarded-For is spoofable, so don't depend upon it for security
 
4:10 AM
now to convert it back into the longer form
nah, its only for a transfer for 1 day
 
That sounds like it would be obvious, but certain chat applications were subject to a vulnerability that I discovered using that
 
Thanks @ircmaxell!
 
You got it...
 
@ircmaxell want to update your answer? For the rep! Rep!
 
@MichaelRobinson I don't need to, the given answer would have worked. The only reason it didn't is because the question wasn't correct
 
4:14 AM
Fair call
 
Ok, off to bed, later
 
later, thanks again
 
@ircmaxell wait
if you can please
i just noticed it doesn't work for multiple ip addresses
 
Solution: cram the ip addresses into the same regex i.e. ^(ip)|(ip)$
bleaagh
 
i knew that
 
4:25 AM
I think you might have been the one who told me
 
 
1 hour later…
5:28 AM
check this question stackoverflow.com/questions/9830104/… if you seems interesting,please reopen it.
 
6:04 AM
hey any one can help in cakephp
 
the cake is a lie
 
@MichaelRobinson i have problem in naming convention in cakephp ... can you help me ?
 
mornings
@DesaiAjay , the naming conventions would be the least of your problems in cakephp
 
6:20 AM
I am now on my new machine. Loving it already.
 
6:50 AM
Step 1: Get nVidia drivers.
Step 2: Get Google Chrome
Step 3: Get PHP 5.4

Done. Happy with my system.
 
nirbubg @Levi
ooops
that was supposed to be "morning"
 
lol
PHP 5.4 is actually taking a LONG time to compile.
I used a debian command so I couldn't thread it.
Running tests now.
Although I see a lot of FAIL. I think something didn't work.
 
 
1 hour later…
What is a "brogrammer"?
 
someone who respects the code :D
 
@MichaelRobinson one who does pair programming aka brogramming, although there is a couple of other variations on that pun: urbandictionary.com/define.php?term=brogrammer
 
@Gordon oh, so it's not a jock who codes
(reading the link) oh, wait...
I don't like them.
 
I never thought, I'd be asking for help with php after so many years of coding, but could someone please explain to me how is this possible:
atchable fatal error: Argument 1 passed to Db_session::__construct() must be an instance of Db_connection, instance of Db_connection given, called in ***/classes/session/Cache_db_http_session.php on line 207 and defined in ***/classes/session/Db_session.php on line 22
same class
yet type hint fails
 
9:26 AM
lol. i thought its a joke
 
OZ_
@JevgenijEvll it's names without namespaces?
 
yes, I do not use namespaces
if ( !($this->_db instanceof Db_connection) ) echo get_class($this->_db); also outputs "Db_connection"
it does not happen on every request, which is even more mistifying
 
OZ_
5.3.10?
maybe you should post it to bugs.php.net
 
5.3.10 - yes
 
do you use typehinting in construct declaration?
 
OZ_
9:33 AM
@ArtjomKurapov obviously yes
 
yes
I tend to think, that this is a bug as well
but unfortunately I cannot reproduce it on my development machine, only in production. and not on every page load
 
hi everyone
can someone help me with some eclipse configuration?
 
1
A: require lang file in MVC php

JonThe problem is that you are loading the lang file from inside a function, which means that $lang does not get placed into the global scope but rather the local function scope. Assuming you want $lang to be placed inside the global scope, one possible solution is: public function lang($file, $lan...

it is sad when this is what you get as answer from 50k+ user
 
OZ_
@sebastian try this: jetbrains.com/phpstorm
 
9:41 AM
@OZ are you stupid ? He asked help with configuration , not for a way to pay money
@sebastian , you will have to actually ask a specific question , before someone starts to take you seriously
 
Jon
hey all
@tereško, I thought it better to answer here
so, briefly:
 
OZ_
@tereško you are too nervous.
 
I have Eclipse indigo on Fedora, and i need 'Call Hierarcy' can't figure it out why it doesn't find anything. I have PDT installed.
Should call hierarcy work in eclipse with PHP?
 
@Jon , problem is that you are recommending that for a newbie
 
Jon
a) $GLOBALS['lang']['foo'] is the same thing as $GLOBALS['translator']->translate('foo') is the same thing Translator::translate('foo') as far as global state (not encapsulation) is concerned
 
9:45 AM
and .. so . .what
none of them should be used
 
Jon
b) encapsulation is a different issue entirely, which IMHO should be judged with practical criteria on any real-world project
what would you suggest instead?
 
to keep the data inside the object instance , or to return it
 
I'd suggest minimizing variables in global scope
 
Jon
re the newbie, you have a point there -- but also consider that suggesting engineering to a newbie who is perhaps not able to grasp the concept is also not very helpful
 
@Jon , a method should not have sideeffects
 
9:47 AM
so better to have one global singleton, than array
 
yours has
 
Jon
and how do you get at that object structure?
@tereško: fully agree on the side effects
@ArtjomKurapov: why?
if because of encapsulation then I agree
 
you dont need to know the object structure , if your method returns the fetched values
 
Jon
if because "singleton is not global state", I respectfully disagree
@tereško: so you are talking about encapsulation
 
then he ( the newbie ) can use it either inside , or outside that object
 
Jon
9:49 AM
which is not the same consideration as having global state or not
 
no, singleton is global, ofcourse. just so that you could change it in the future easier
 
Jon
which is what I 'm trying to say
k
 
OZ_
@tereško are you going to apologize for your insult?
 
Jon
so we all agree that global state is unavoidable but encapsulation is to be preferred
 
OZ_
@Jon lol
 
Jon
9:49 AM
and perhaps I should indeed have suggested something better to the newbie
 
the point was , that your method uses the worst possible way
 
OZ_
@Jon you are newbie self, be sure.
 
and you are a moderator-level member .. its kinda bad
 
Jon
@OZ_: by the way, judging from your own comments, it's funny you talk about insults
 
OZ_
@Jon well, "idiot" and "newbie" it's very different words
 
Jon
9:51 AM
also, I am a newbie who has shipped open source code used by millions of users worldwide -- but I 'm always eager to learn from your extensive experience
 
OZ_
@Jon and nothing wrong with newbie. I'm newbie in JS - nothing wrong for me with it.
 
Jon
@tereško: I won't disagree there, you have a valid point, but
consider that I was trying to explain why it does not work and propose the minimum required change
 
OZ_
@Jon don't worry, it's not so hard to write code which "millions will use".
 
Jon
so it was perhaps a wrong choice of goal on my part
@OZ: which is why you have also done so, I suppose
 
.. or a missing disclaimer
 
Jon
9:52 AM
yeah
 
OZ_
@Jon yes.
 
Jon
well, since you have worked on large open source you should have gotten over the epenis measurement by now
but I guess there's still time
@tereško: I 'm going to delete that answer as the accepted one is better anyway
thank you for your input
by the way... anyone here familiar with .NET expression trees?
 
it actually would be better if you left it , but explained why it is a possible-but-bad way to solve it
because there are a lot of people who learn from posts like this
 
Jon
so you think the already existing disclaimers are not enough?
hmm scrap that
 
OZ_
@tereško, will you answer? or you are coward?
 
Jon
9:58 AM
they are not enough
 
@OZ careful, he'll block you!
 
OZ_
@MichaelRobinson what??
 
@OZ answer to what ?
 
@OZ fairly sure he blocked me for not putting up with his ego
 
OZ_
10 mins ago, by OZ_
@tereško are you going to apologize for your insult?
 
9:59 AM
@OZ_ for you being an ass and pushing your favorite IDE on people who aren't even asking for IDE suggestions ?
 
@tereško no, for you calling him stupid - apologizing for that would be reasonable
 
OZ_
@tereško it was advice, because I want to help him. Is it means "be ass" in your mind?
 
you know, in christianity its much easier to code :)
 
OZ_
@ArtjomKurapov where? christianity?
 
exactly. my point is you focus too much on known personal (IDE?) things, otherwise its going to be religion wars
 
OZ_
10:05 AM
@ArtjomKurapov I'm not going to arguing, I just want to give hint
 
Jon
@tereško: edited and undeleted, check it out if you want
 
@ArtjomKurapov .. right .. have you been to Northern Ireland
 
Jon
accepting responsibility for your "children" is demanding dammit :)
 
=P
 
whats there? religion war?
 
10:07 AM
kinda
 
OZ_
@tereško so you are coward
 
between two Christian denominations
@OZ , wtf are you talking about ?!
 
so what now.. php with idea & zend vs php on eclipse, netbeans and stuff?
 
OZ_
@ArtjomKurapov there is no arguing about IDEs, read chat
 
well you do argue if including other denomination is a good idea :)
 
OZ_
10:09 AM
@ArtjomKurapov me? no
 
you said it yourself "hinting"
 
OZ_
@ArtjomKurapov You don't know the difference? I don't care which IDE he will choose, I just want him to know about alternative.
 
I mean for general knowledge its good to know that hinduism has karma.. but for a christian sinner its not helping much. Still i dont see a point of removing it. its just not that important info
 
@OZ pretty sure he's blocked you
 
OZ_
@MichaelRobinson I don't care I blocked him
 
10:17 AM
ahahahaa
you're missing out! his comments are often hilarious, such a massive ego
 
Hello
I wanna to make a query from external sql
for example:
 
Name calling, religious wars, ignoring ... what is this, IRC?
 
mysqli_query("SELECT * FROM friends", $file);
and $file = "test.sql"
 
actually I was wondering if there is xmpp fot this chat :D
 
and inside this file there all the queries
How can I do that?
 
10:22 AM
@user1123379 , what you have is just a file
 
but inside the file i have all the information, for example the INSERT
 
the .sql file usually just contain a lot of insert statements ( and few create table )
 
yes, it is right
 
thats not how databases work
 
but i want to make queries directly to this specific file
so how it works?
 
10:24 AM
if you want to a DB that you can keep in a file, try SQLite
 
ahh
Wait, I am checking information about SQL LITE
 
otherwise import sql file to existing server
 
@user1123379 , with one L
 
Ahh, ok
 
like mysql -uroot -ppass base < dump.sql
 
10:26 AM
^ that's a command you would run from terminal
 
^ as a developer who knows what he is doing
 
@user1123379 , oh .. and as a side-note .. stop using the ancient mysql_* functions for accessing DB. You should instead learn PDO or MySQLi .. if you use PDO, then you would be able to use SQLite with it too
 
I know mysqli
 
I thought he did.. see mysqli_query(
 
oh ...
 
10:30 AM
How do I connect to sqlite?
and what is the different between sqlite and sqlite3?
 
 $foo = sqlite_open( 'file/name.something', 0666, $sqliteerror );
 // OR
 $foo = new PDO( 'sqlite:file/name.something' );
 
Which one of those is more faster?
PDO or sqlite_open?
 
@user1123379 since pdo is an abstract layer on top of the other adapters, pdo is likely a fraction slower but I doubt that you'd notice the difference. profile your code if you want to know for sure.
 
OH: "Whats a 'competence leader' ?" - "It's a kind of human process bottleneck"
@user1123379 , yes, PDO will definitely be slower. You might even loose 5ms. The upside is that you would be able use the same connection API with mysql and postgre
 
Hi, here is some advice for everybody. If you don't want to be unable to login to stackexchange add a second login to your account (not a new account, just a second login). My openid provider was just down for the last half hour, it sucked.
 
So I'll use sqlite_open
 
@Paul OMG not being able to login to SO for 30 minutes is gonna kill me!!!111 ;)
 
@Paul make your own openid provider :) I did
 
i'm still alive, i hadn't even had a chance to look at the site for all of today, I had thoughts that I might lose my 89 day streak.
 
11:00 AM
@Paul im just kidding. i know that feeling.
 
@Gordon If they ever bring out the 1000 consecutive days badge it could be a life threatening thing for some people. :-)
 
Good morning
 
How do I enable sqlite on WAMP?
never mind, i success
 
@user1123379 note that you want sqlite3 not sqlite
 
what is sqlite3?
what is the different between sqlite and sqlite3?
 
11:09 AM
Dunno, the version?
 
@Donut obvious answer is obvious
 
12:00 PM
I can't believe it was up for 2 years, and I'm the first to even think of this:
0
A: one class instance

ircmaxellWithout changing object semantics, you could keep a static counter in the constructor. This is not a singleton, as it's not globally available, just only instantiatable once... class Foo { private static $counter = 0; final public function __construct() { if (self::$counter) { ...

 
you really aint
but i would say that this is a horrid way
 
Sure
 
12:23 PM
I love it. The singleton answer is upvoted, but mine - which avoids any shared global state - is downvoted...
 
12:38 PM
@tereško Why is ircmaxell's answer so horrible? It is basically what the OP was asking for:
` $user2 = new User(); // I want to catch another instance of the user class and throw an exception`
 
@ircmaxell the misconceptions about valid singleton use are terrifying
 
of course, it would still need private __clone, __wakeup
 
And it's the only answer that actually answers the question. A singleton is not the same as what he asked for...
 
> It's entirely appropriate for any class that is going to be instantiated only once to use the Singleton pattern, but if you know it's going to always be instantiated in a specific spot then it's not strictly necessary.
no, its not.
 
Not in the least
 
12:43 PM
why cant i post the other comment? Oo
> The question asked how to prevent a class from being initiated more than once. You are correct however, but instead of bloating out the answer, i have given the basis of a solution, in a hopefully easy method to understand. The poster can always use it as a base to learn more.
ah, there i go
bloating out = adding __clone and __serialize that are required to make the singleton a singleton in the first place
 
++
 
it's sad to see how people dont even get one of the simplest patterns in the GOF book
but misapply it all over the place
how are they supposed to get the other patterns then?
 
@Gordon They may not have been thinking in terms of patterns, but their request just happens to have similarities to the singleton pattern.
 
@Paul maybe but then i wonder why they all seem to know that ctor snippet
oh, nice. we have a SessionHandlerInterface now.
 
Yeah, I saw that. It's awesome
 
12:51 PM
Well, I'm yet to hear any argument against ircmaxell's answer, its a +1 from me, It seems the best to me.
 
@ircmaxell Im not that excited about it to call it awesome, but sure is handy :)
 
Well, finally we can use OOP paradigms directly with sessions
 
@Paul yup, uv'ed it too.
 

« first day (524 days earlier)      last day (4413 days later) »