var str = ‘something — something_else’; var substr = str.split(‘ — ‘); // substr contains "something" // substr contains "something_else" Bookmark on Delicious Digg this post Recommend on Facebook share via Reddit Share with Stumblers Tweet about it Subscribe to the comments on this post
- Twisted Knickers – Change...
- The browser debate
- Website design – What...
- mind, body and spirit...
MongoDB handles unexpected shutdowns quite appallingly, one thing that I always forget is the general server language for speaking with the server and getting the info I need to get her back up and running. $ sudo status mongodb $ sudo stop mongodb $ sudo start mongodb $ sudo restart mongodb To see whats going on… If you see “Error: couldn’t connect to server 127.0.0.1} (anon):1137″ This condition is largely
Just had this delightful problem tonight, fix: First make sure port 80/443 is not used by any other service or application with netstat command: # netstat -tulpn| grep :80 If port 80 is bind to httpd, kill all process: # killall -9 httpd Now start the httpd: # /etc/init.d/httpd start Make sure it’s a user capable of sudo Bookmark on Delicious Digg this post Recommend on Facebook share via Reddit
Sometimes you want to link to a directory that isn’t necessarily within the web root for the particular site you are on. Simple enough solution for it though. ln -s /webroot/home/httpd/test.com/index.php /home/sbramley/index.php or ln -s /webroot/home/httpd/test /home/sbramley/ So you can link to a directory of file easyyyyy Bookmark on Delicious Digg this post Recommend on Facebook share via Reddit Share with Stumblers Tweet about it Subscribe to the comments on
Twisted knickers is a site I built when I first started building sites, unfortunately web standards were pretty shocking back then and my skill set wasn’t up to par. The entire site was built using a table (yes, before I knew how to float divs). So when I got the opportunity to fix it up this year I jumped at the opportunity, who likes having their name against something that
I just posted on splitting a string, might as well add my match as they can often come hand in hand. preg_match("your search item", "your_string") Boom, done Bookmark on Delicious Digg this post Recommend on Facebook share via Reddit Share with Stumblers Tweet about it Subscribe to the comments on this post
I’ve just spent 15 minutes looking for this darn function, never again! Here is how to split a string to get the information you require: Edit: A wise PHP guru just gave me an alternative option as well. $chars = explode(‘-’, "your-string-here"); Is the same as: $chars = preg_split(‘/-/’, "your-string-here", -1, PREG_SPLIT_NO_EMPTY); $your = $chars; $string = $chars; $here = $chars; Works just peachy Bookmark on Delicious Digg this post
True story, I always forget where each value should be positioned for a left join on an update statement. This is always useful for a reference guide for me: UPDATE t1 LEFT JOIN t2 ON t2.id = t1.id SET t1.col1 = newvalue WHERE t2.id IS NULL Bookmark on Delicious Digg this post Recommend on Facebook share via Reddit Share with Stumblers Tweet about it Subscribe to the comments on this
Easy to forget the correct syntax but darn it’s useful, a recap on shorthand php if statements. Basic True / False Declaration $is_admin = ($user['permissions'] == ‘admin’ ? true : false); Conditional Welcome Message echo ‘Welcome ‘.($user['is_logged_in'] ? $user['first_name'] : ‘Guest’).’!'; Conditional Items Message echo ‘Your cart contains ‘.$num_items.’ item’.($num_items != 1 ? ‘s’ : ”).’.'; Conditional Error Reporting Level error_reporting($WEBSITE_IS_LIVE ? 0 : E_STRICT); Conditional Basepath echo ‘<base href="http’.($PAGE_IS_SECURE
<a> tags are great for text and images, but what about divs? or list elements? not so much. With most of my images, I set them as background images of a div, when it comes to positioning divs on a page it’s just easier than having to mess with the images within them as well. Here’s a tidy way of making your div clickable. <div onclick="location.href=’http://sbramley.com/’;" style="cursor: pointer;"> </div> Bookmark