regex – Internet Strategy Guide https://phpprotip.com Together we can defeat the internet Tue, 07 Mar 2017 02:01:20 +0000 en-US hourly 1 https://wordpress.org/?v=4.7.31 55205001 Copyright © Internet Strategy Guide 2013 chance@chancegarcia.com (Internet Strategy Guide) chance@chancegarcia.com (Internet Strategy Guide) http://phpprotip.com/wp-content/plugins/podpress/images/powered_by_podpress.jpg Internet Strategy Guide https://phpprotip.com 144 144 Together we can defeat the internet Internet Strategy Guide Internet Strategy Guide chance@chancegarcia.com no no Using MySQL Workbench with MAMP https://phpprotip.com/2011/10/using-mysql-workbench-with-mamp/ https://phpprotip.com/2011/10/using-mysql-workbench-with-mamp/#comments Fri, 07 Oct 2011 06:07:52 +0000 http://phpprotip.com/?p=527 Recently I’ve started working locally due to the PHPStorm IDE. In order to work locally, I invested in MAMP Pro to make use of their GUI interface for configuring vhosts. I also like to use MySQL Workbench for my database work, unfortunately these 2 items never seemed to work together for me before. After a brief google search I was able to find out how to connect to MAMP’s MySQL install to do SQL Development, which is by done by choosing the local socket connection method and using the value /Applications/MAMP/tmp/mysql/mysql.sock for the connection.

MySQL Workbench MAMP Socket Connection Settings
MySQL Workbench MAMP Connection Settings

After setting that up, I got to thinking, “I’m already using an IDE for code convenience and a GUI for vhost convenience, I should set up Server Administration with MySQL Workbench too!” So after some googling, I found an article to help me set up Server Administration with MAMP. Unfortunately the article only got things partially working and has no way to comment on it to have it corrected. So I’m going to outline the steps. Also I just noticed that the images with the article are updated correctly but it’s hard to cut and paste an image of something someone has done so I’ll just give you the value pairs

  • Configuration File: /Applications/MAMP/tmp/mysql/my.cnf
  • Start: /Applications/MAMP/bin/startMysql.sh –
  • Stop: /Applications/MAMP/bin/stopMysql.sh –
  • Check MySQL Status: ps -xa | grep “/Applications/MAMP/Library/bin/[m]ysqld”
If the check status doesn’t work, just do a
ps -xa | grep MAMP
and find the correct path to mysqld
And that’s all you need to know.
MySQL Workbench MAMP System Profile Settings Tab
Enhanced by Zemanta
]]>
https://phpprotip.com/2011/10/using-mysql-workbench-with-mamp/feed/ 3 527
Use regex to find the source of an image https://phpprotip.com/2008/03/use-regex-to-find-the-source-of-an-image/ https://phpprotip.com/2008/03/use-regex-to-find-the-source-of-an-image/#respond Tue, 18 Mar 2008 17:47:54 +0000 http://magic.garciawebapps.com/?p=3 Recently, I needed to find the source of an image in a blob of text. Since the text was out of my control, the exact location of the tag was unknown. So to solve this problem, I buckled down and finally learned some regex. Regex has been my nemesis for years up until this point. Below is the result.

/src=[\"](.*?)[\"]/i

Looking at it now, I think it could be improved upon to be

/\<img.*?src\=[\"|\']?(.*?)[\"|\']?/i

[Edit: I’m dumb. the first one works. can’t figure out how to make quotes optional. They really shouldn’t be because your shit should be well-formed.]

Basically, my original expression looks for the first src property it finds and returns the text within. Looking back on it, this makes a few assumptions.

1) the first src property is within an image tag

2) the property is surrounded in double quotes

The second one (redone just now and therefore untested), should be better. Namely because It doesn’t make any assumptions.

Point is that I’m now learning regex and am excited. Plus wanted to put this somewhere on the web in case there’s someone like me who needs this and doesn’t understand regex quite yet. Maybe one day I’ll come back and break it down into how and why it does what it does but as of now, I don’t think I can put my understanding of regex into a form someone who isn’t me would understand.

]]>
https://phpprotip.com/2008/03/use-regex-to-find-the-source-of-an-image/feed/ 0 3