PHP Find Variable in String

Anyone code in PHP out there. Well if so, here is a helpful hint. Ever need to find a string in an another string? Uh, or maybe find a variable in a string? If you don’t, someone sure does, well take me for instance, I do this often. Its quite simple. You use the strstr() function like so:

$string_to_find = “Patrick”;
$string_to_look_in = “Hello Patrick, what is your name?”;

if(strstr($string_to_look_in,$string_to_find)) {

echo “AHA, found it.”;

} else {

echo “hmmm… yeah, just doesn’t seem to be here right now.”;

}

Hope this was helpful to someone.

Comments (0)



Move Files from One Server to Another

So I had about 20 GBs in a folder on one server and I wanted to move that folder to another server. So I decided the best way to do this (and maybe the only way) would be to do it through the shell. Both of my servers are linux, and both allow login via ssh. I logged in to the server that I’m going to copy the files to and then I used rsync and here is the command I used:

rsync -av -e ssh username@oldserverhost:/home/old_folder/ /home/new_folder/

This was done on Dreamhost servers so the folders might be different on other servers. This was very helpful for me and I hope it will be for you too. One last thing. the v in the command stands for verbose. If you don’t want to view what is taking place in the transfer, leave the v out.

Technorati Tags: , ,

Comments (0)



Start Xampp with Automator when Mac Boots

AutomatorI’m not sure if anyone else knew this, but I couldn’t find anywhere on how to do this. I use xampp as my local web server and to start apache and mysql you have to go into terminal, login as the super user an then type the command to start it. Well this started to get tedious and I wanted to run 1 command to start xampp. This is how I did it.
I used automator to accomplish my task. Open automator, on the left click automator under applications an then in the list that shows up to the right, drag Run Applescript in the pane to the right. Once you have your applescript box up, type this in there:

do shell script “/Applications/xampp/xamppfiles/mampp start” password “password” with administrator privileges

Make sure you tupe it all on one line, if it word wraps for you, that is ok, just don’t manually hit return. Once you have this in the input box, change “password” to whatever your super user password is. After you do this click compile. Now you can click the run button above and this should start up apache and mysql. I then went ahead and saved this as an application in my Applications folder and whenever I need to start it up, I just do it using Quicksilver.
This is a simple process but now I just have to do 1 step instead of 3 or 4. A simple time saver. You could also have this application run at boot so you don’t even have to do anything.

Technorati Tags: , , , ,

Comments (0)



Code Monkey Video

For all you code monkeys out there (including myself) here is a funny video for you to enjoy. It covers a lot of what I go through everyday, it may for you too.

Let me know what you think in the comments.

Technorati Tags:

Comments (0)