Displaying A Local Image File In The UI on Android (React Native)

<Image style={{ width: image_width, height: image_height } source={{ uri: `file://${local_file_uri}` }} />
Code language: HTML, XML (xml)

The width and the height values appear to be required. Also, some tutorials will say to use file:/// (three slashes). That worked for me in IOS, but not on Android.

Displaying A Local Image File In The UI on Android (React Native)

Fixing Apache 2.4 – No Errors In Log – Connection Refused

I recently upgraded my Macbook to OS X El Capitan (10.11). As expected, Apache did not immediately work upon upgrade. In this case, it was because upgrading from Yosemite to El Capitan also upgraded Apache from 2.2 to 2.4.

Unfortunately, unlike in times past, this time Apache did not give me any feedback as to why it was not working. When I ran curl localhost from the command line I simply got:

curl: (7) Failed to connect to localhost port 80: Connection refused

While my web browser gave a standard “This site can’t be reached” error.

Not helpful. I found nothing in the Apache error log (/var/log/apache2/error_log) either.

I tried restarting apache (sudo apachectl restart). Still nothing.

However, this little command helped me tremendously:

apachectl configtest

This revealed a syntax error in my apache configs. In my case, I was attempting to use the SSL module (specifically, calling SSLEngine in my passenger config) without actually loading it. If you aren’t seeing anything in the apache logs, despite the fact that running sudo apachectl start returns a message saying apache is already running, then you may also have a syntax error somewhere in your configs. Try out apachectl configtest and see what you find.

In my situation, uncommenting “LoadModule ssl_module libexec/apache2/mod_ssl.so” in httpd.conf did the trick and I got apache up and running.

Hopefully this will help a fellow developer whose sysadmin skills, like mine, could use some work.

Fixing Apache 2.4 – No Errors In Log – Connection Refused

How To Hide Old Posts Without Deleting Them

You may occasionally want to curate the content that appears at the forefront of your blog. You may want it to be visible to search engines or via clicking on categories or tags, but not on your homepage.

Unfortunately, there are not a lot of good methods in WordPress of hiding certain posts without making them entirely private. I tried several WordPress hide plugins (like WP Hide Post) that appear to be abandoned and broke my page or didn’t work at all.

I finally settled on a solution that works well enough for my purposes. It requires the creation of an “Archived” category (you can call this whatever you want) and either a bit of custom code or some plugins. The post may still show up in things like “recent posts”, its tags will still show up in the tag cloud and it will be visible in any categories it is listed under. But importantly it will NOT be visible on your posts page. It is also important to note, the “Archived” category will show up in your list of categories. If this is something that is unfavorable to you, you could potentially use a plugin to exclude certain categories from the categories list.

To start, you will need to create your Archived category. You can call it whatever you want.

Now, you can use a plugin like Ultimate Category Excluder to choose what to exclude this category from. If this is the option you choose, you’re done!

A slightly more difficult option (but less dependent on plugins) is to just include some of your own code in the ‘functions.php’ file. I would not recommend doing this unless you are familiar with coding and feel comfortable editing your theme’s underlying files. If you are comfortable doing this, then I would at least recommend that you back up your site prior to messing around with your theme files directly. With all of that said, this is a relatively safe addition to your theme’s functions.php file if you are familiar with coding wp sites.

To make this change, you first need to determine your new category’s ID. Click on “Posts” inside your wp-admin page. Then click “Categories”. Click on the link to go to your newly created category and take a look at the URL. As of the time of this writing, you can ascertain the ID of the category (called the tag_id) from the url:

In my case, it is 54. Then head on over to Appearance > Theme Editor. You will see a menu for “Theme Files” (on the right in my case). Here you will find all of the files for your theme. Navigate to your functions.php file (called Theme Functions in my case) and click on it. Then you will want to add the following to the end of this file:

function exclude_category($query) { if ( $query->is_home() ) { $query->set( 'cat', '-ARCHIVE_CATEGORY_ID' ); } return $query; } add_filter( 'pre_get_posts', 'exclude_category' );
Code language: PHP (php)

Make sure to replace “ARCHIVE_CATEGORY_ID” with the ID you found earlier. It is important to leave the preceding dash (-) however.

Now, voila! Check your posts page and any posts that you have put into that category should be excluded from your posts page.

How To Hide Old Posts Without Deleting Them