When I am working on a project that unnecessarily has .svn folders strew about from Subversion I get a little annoyed. Luckily Linux has a solution (or is the solution!), the find command. find is a tool that can be very simple or very complex depending on how it is used. In this instance I simply want to find all directories names '.svn' and delete them.
Here it is, short, sweet, and removes all .svn folder in the sub-tree
find . -name ".svn" -type d -exec rm -rf {} \;
Enjoy!
I am currently working on a site where the client has a rich text box to enter content for his articles. This is not unusual in itself, however he wants the ability to do some wikiish syntax in the text box and have the system magically produce the output for him. For instance, \[\[ThisIsSomePage\]\] could create an internal link to some other page on the site. I had not done this before, however I immediately thought of using a regular expression(regex, regexp). A little bit of research confirmed that this would be a good approach, but how was I to get the data between the characters that I chose as delimiters so that I could manipulate it? Turns out that this is a fairly simple and straight forward process.
/**
* Converts all internal links into html links through the use
* of a wikiish syntax
*
* Syntax for internal links:
* \[\[LinkToSomewhere\]\]
*
* Converted to:
* <a href="LinkToSomewhere.html">LinkToSomewhere</a>
*
* @param String $text - Text to parse
* @return String - Parsed text
*/
function convert_internal_links($text)
{
$text = preg_replace_callback(
"/\[\[([^\]]+)\]\]/",
create_function(
'$matches',
'return "<a href="http://ben.lobaugh.net/blog/wp-admin/%5C%22%22.urlencode%28$matches%5B1%5D%29.%22.html%5C%22">$matches[1]</a>";'
),
$text
);
return $text;
}
It works great, and it seems to be pretty quick too.
My tech posts have been a bit lacking of late, and though this one isn't really much of a techy post it is a pretty geeky game. Instead of using a fancy visual interface this game is played through using sql statements.
mysqlgame
I am always forgetting what numbers have what permissions, so I made myself a text file with the answer. I use it so much I figure I may as well share it with all of you. I hope you find it useful. These numbers will work on any Unix based operating system. This includes Linux and Mac OS X.
1 = execute
2 = write
3 = execute write
4 = read
5 = read execute 4 + 1
6 = read write 4 + 2
7 = read write execute 4 + 2 + 1