Archived Posts from this Category
Archived Posts from this Category
So you want to hide or style the page numbers in wordpress pagination. The numbers have class .page-numbers but so do the previous and next buttons. paginate_links() doesn’t have any properties that will add a class to the numbers. So how do you do it?
Turns out you can use multiple .not() selectors to select them:
If you boot into recovery mode on an old laptop and see the message, “An Error occurred while preparing the installation. Try running this application again,” chances are that Apple is rejecting the request from your computer because the battery has died and the time is reset. Open up terminal from the utilities menu and type date and hit enter. If it says 2001, you need to set the date to the current date. You can set it with
date HHMMmmddYYYY, such as 130107092014 for 1:01 PM, July 9 2014. After that, quit terminal and try reinstalling again.
As a web developer, the easiest thing for me to develop on my mac was to work from /Library/WebServer/Documents, which is the default directory for OS X’s apache. There are two problems with this: First, the permissions are all root. I found it easiest to change Documents’ owner to my user, but then running a permissions repair would automatically change these back. Second, Backblaze automatically excludes your /Library directory, so none of my web work was getting automatically backed up. I contacted backblaze about including only this directory and got this response:
I am sorry but there is not a way to back up this data.
Backblaze does not back up the system files or the system library. The /Library and all subdirectories are excluded.
My solution was to create a new directory, webdocs, in my home folder, and to move everything that was in /Library/WebServer/Documents into it. Then, I edited /etc/apache2/httpd.conf with root privileges (in terminal: sudo nano /etc/apache2/httpd.conf or sudo edit /etc/apache2/httpd.conf or sudo subl /etc/apache2/httpd.conf depending on your text editor of choice), and replaced all instances of /Library/WebServer/Documents with /Users/jordan/webdocs. Then I ran sudo apachectl restart to restart apache. Now all of my web work will get backed up automatically by backblaze.
I’m experimenting with Ratchet, a websocket server written in PHP. I wanted to install lib-event for PHP because according to this thread it works better than PHP’s choose_stream function. It ended up being a pain:
port install libevent worked but when I ran
pecl install channel://pecl.php.net/libevent-0.0.5 it could not find the libevent headers even when I pointed it to /opt/local/lib/, which is where
port contents libevent said it was installed.
I ended up following this tutorial on compiling it from source and then pointing the pecl installer to that library and it worked. Mostly. Compiling it from source put it in /usr/local/lib, which the pecl installer liked better. Then it was a question of enabling it in PHP.
OS X’s php.ini installed here:
MacPort’s PHP is installed here:
Unless you change your default setup, apache will serve pages with OS X’s PHP, while the command line will serve pages with MacPort’s PHP.
Most of my OS X PHP extensions are installed here:
Most of my Mac Port PHP extensions are installed here:
I had to copy libevent.so from my mac’s extension directory to the macports extension directory, and add extension=libevent.so to both php.ini files.
My ReFit was hanging on the windows logo on my macbook pro when I would boot into windows.
I was having problems with windows explorer crashing every 5 seconds anyway so I plugged in my boot thumbdrive and reset (reformatted) windows.
However, refit would STILL hang on the windows logo even after a clean install. If I held down option when booting I could use Apple’s menu to get to Windows, but not via Refit.
Finally, I tried unplugging everything from my macbook, including the external mouse, SD card, and external monitor.
Now it boots fine! Hopefully this saves someone from reformatting like I did when it was just a hardware conflict. I have read other reports of USB hubs and other peripherals also causing refit to hang.
I have created a Photoshop action to automatically generate a shadow for a given png. I recommend extending the canvas right 10 or so pixels first. It expects the file to have a single layer with transparency. It duplicates the layer, adds a black color overlay, rasterizes the layer effect, squishes the layer with free transform, skews it to the right, puts the layer below the first one, sets the opacity to 57%, and hides the first layer.
This is useful for generating custom pin shadows for leaflet, google maps or bing.
On mac you can place this in: ~/Library/Application Support/Adobe/Adobe Photoshop CS6/Presets/Actions/
I wanted to copy everything from my git repo to production except images and media. This tutorial helped me out. This command will copy all js, php, html, and css files and directory structure without copying images or other media:
rsync -av --include='*/' --include='*.php' --include='*.html' --include='*.js' --include='*.css' --exclude='*' source/ destination/
This will work in linux, unix, or os x.
What a Vista-like message. Apple warns you every time you open almost any kind of file that was downloaded from the internet, which is MOST files these days. There doesn’t seem to be any way to turn it off. It happens with applications, php files, even HTML and jpg files. As a PHP programmer, I can’t stand seeing this message every time I open files that I coded MYSELF. It severely interrupts my workflow.
The commonly suggested method of using terminal to write to defaults does NOT work for me:
defaults write com.apple.LaunchServices LSQuarantine -bool NO
There is another method of manually removing the quarantine flag of the files that you download each time you download them, but this would take more time than just clicking ok in the stupid dialog.
What did work for me was downloading the latest version of Onyx and unchecking the internet warning checkbox. Thank you, Titanium Software!
Note that this does make your computer more susceptible to viruses and trojans if you visit risky sites or blindly open unknown applications. For users like me, this is preferable to the condescending, interrupting workflow Apple has been increasingly favoring lately.
Cancel or Allow?
I’ve recently been experiencing never-ending beachballs (crashes) when trying to load instruments in EXS 24 in Logic Pro 9.1.6 in both 32-bit and 64-bit.
I recently installed a Blu-Ray player. As soon as I ejected the disc, Logic stopped beachballing and loaded the sample fine. It must have been trying to search the Blu-Ray drive for the audio files and gotten stuck somehow.
I’ve also read that turning off the spotlight index for any Windows partitions helps. I would suggest unmounting any network drives as well if you’re experiencing this issue.
Several of PHP’s DomDocument functions halt rendering the page on any kind of error, and are finicky to test. I was parsing an RSS feed and wanted to display a scaled down version of the image in the feed. This code worked if the code contained an image:
$rss = @file_get_contents('http://problemstosolve.com/?feed=rss2', false);
if($rss === false)
$feed = false;
$feed = mb_convert_encoding($rss, "HTML-ENTITIES", "UTF-8");
$result = new SimpleXMLElement($feed);
foreach($result->channel->item as $item)
$content = $item->children('http://purl.org/rss/1.0/modules/content/');
$dom = new DOMDocument();
$images = $dom->getElementsByTagName('img');
echo "<img src=\"" . $images->item(0)->getAttribute('src') . "\" width=\"100\" /><br/>";
However, if the post didn’t contain an image, the whole page would blow up with no PHP error. To make things worse, if the problem was in one of several codeigniter views, it would make codeigniter display the views out of order. None of these tests for images worked:
if($images->length() == 0)
What finally worked was:
if($images->length == 0)
getElementsByTagName always returns a DOMNodeList and it’s hard to check to see if it actually contains anything. I haven’t figured out a way for PHP to handle errors better with DOMDocument.