My (R):
-
// safety switch
-
exit;
I was administering a Call of Duty 1 server a while back and wanted a rename command for use through the remote console in AWE 2.12 mod. So I dug into the code of the admin tools. And wrote the following function:
Nothing special really, but it is an interesting look into how scripting works for Call of Duty 1.
Quick tip. How to change keyboard layout in CentOS in console?
and change the KEYTABLE key. All available options can be found in subdirectories under /lib/kbd/keymaps/i386.
After that, just restart the machine.
So you have a Symfony2 project under construction. Login works. Now you want to execute some code right after the user successfully logs in.
The solution: Make a custom event listener.
An event listener is actually a service with a proper tag associated with it. So first step is to register the listener. The configuration file shown corresponds to the listener in file Acme/UserBundle/Listener/LoginListener.php. You can read more about services here.
In services.yml:
Let’s go through the configuration.
class defines the listener class.
With arguments we inject services that this listener depends on. In this case the security.context service for retrieving the User object and doctrine service for EntityManager.
tags is important. Every listener must be tagged with kernel.event_listener and must specify it’s event. For successful login that event is security.interactive_login. You can also specify the optional method tag.
Ok, our listener is registered. Let’s create it.
The above code should be pretty self-explanatory. The only required method is onSecurityInteractiveLogin(Event $event). You do not need the other stuff, but you probably will if you want to modify the User object, or something else in the DB.
When you run into this error, a few solutions apply.
First one is to check where mysql.sock or mysqld.sock actually resides and change values in php.ini appropriately.
You can also make a symbolic link to the correct location.
For me, the above solution did not work. All I got was the change in error from (2) to (13). Turns out the solution is quite interesting. Instead of using ‘localhost’ as host for DB, use 127.0.0.1 – it magically begins to work again.
I began toying around with KDE desktop since I got tired of Gnome. I wanted to try something new and shiny. Everything went great, it is highly customizable etc. Only one thing did not work. When ssh-ing to a server it did not ask me for keychain password anymore. So how to fix that?
First, if you don’t already have it installed, install ssh-askpass:
Ok, now that that is installed, we must ensure that it asks us for password everytime we log on. For KDE we have to create a script inside ~/.kde/Autostart/ directory.
askpass.sh
You can also specify the name of the key file:
The startup script has to be correctly chmod-ed:
Now log out and log in again and it should ask you for password. Happy ssh-ing.
I did something like this today:
The loop never came to the final element of the array, therefore not checking all of them. What was the problem?
Since sizeof($arr) is calculated every time the loop comes around, it was returning less and less with every unset instead of returning the same value.
Solution:
That way you ensure that size is always the correct integer. And it will run faster.
Today I got frustrated because when trying to parse a json string with jQuery, apparently it was causing a Missing } in XML expression error. But doing a bit more research I found the true problem. Boy was I wrong.
What was the problem?
And since Firefox and Firebug showed me purified and corrected HTML, I had no way of knowing that. So when you get this error next time, check for this situation.
That was the question I asked myself when a running cron job on a shared hosting went horribly wrong. Turns out the solution is ‘pretty’ easy. You just have to know when the cron job started. In my case it was a PHP script. So i grep-ed for php also.
You get the list of processes matching your criteria. Then you have to look for the time the script should have started. In the second column there is it’s PID. You can use that to kill it.
Recently I checked to see if my new project worked in IE6 and IE7. Well, actually I checked how it behaved. Obviously it did not work as expected.
The IE’s kept on bugging me with JS errors. IE6 said “Invalid property value”, while IE7 said “Unknown runtime error”. The code snippet was the following:
And it worked in all browsers except in IE6 and IE7. As I learned later on, IE < 8 does not support the inherit value. So when changing the inherit to an actual color value, the errors were gone. So the next time you are bugged by this kind of errors in IE < 8, check for inherit values in your CSS, JS.