Category Archives: Developer

Install OpenCV 3.x with Python 2.7 on Ubuntu

Updated: 10/11/2016

How to Install OpenCV 3.x and Python 2.7+ on Ubuntu

Step 1:

Open a terminal window and update the apt package manager lists and upgrade any currently installed packages:

Step 2:

Install developer tools:

Step 3:

Install packages to open image formats including JPEG, PNG, TIFF, and others:

Step 4:

Install the GIMP toolkit (GTK+) which OpenCV uses to build GUIs:

Step 5:

Install packages to open video formats:

Step 6:

Install libraries that optimize various routines in OpenCV:

Step 7:

Install pip, a package manager for Python:

https://pip.pypa.io/ is the official pip website

Step 8:

Install Python 2.7 development tools:

Step 9:

Install numpy because OpenCV stores images as NumPy arrays

This post follows, updates and adds to the instructions from Py Image Search here: http://www.pyimagesearch.com/2015/06/22/install-opencv-3-0-and-python-2-7-on-ubuntu/

Capitalized Case JavaScript code

 

Code adapted from stackoverflow.com ‘Convert string to title case with javascript‘ users Greg DeanBill the Lizard  licensed under cc by-sa 3.0

Delimiters

A delimiter is a sequence of one or more characters used to specify the boundary between separate, independent regions in plain text or other data streams. An example of a delimiter is the comma character, which acts as a field delimiter in a sequence of comma-separated values.

Common delimiters:

  • Tab
  • Colon
  • Semicolon
  • Comma
  • Space
  • Pipe
  • Hyphen

Delimiters in Excel

Excel uses delimiters in the Text to Columns function.  The options are tab (    ),  semicolon (;), comma (,), space ( ), or other which is an input field for a single custom character.

Intro paragraph from Wikipedia https://en.wikipedia.org/wiki/Delimiter

 

TensorFlow on Windows

TensorFlow is an open source (Apache 2.0) software library for Machine Intelligence created by Google

Windows 7

The two options are:

  • Run in Docker
  • Run in a Linux Virtual Machine (VM)

Windows 10

With the introduction of the Windows Subsystem for Linux (WSL) Windows 10 users have an additional option:

  • Run on Win 10
  • Run in Docker
  • Run in a Linux VM

 

Can you turn advanced custom fields into a standalone plugin?

The short answer is no, not completely standalone.

You can make a plugin from the output of the Advanced Custom Fields’ export to PHP option, but it still requires that the site have the full Advanced Custom Fields plugin installed.

There is a way to hide the ACF plugin’s user interface by defining define( ‘ACF_LITE’, true ); before including the acf.php file.

For simple custom fields, you might be better off defining them through native WordPress code https://codex.wordpress.org/Custom_Fields

Use the Advanced Custom Fields plugin for stashing code

Anyone working with code in the WordPress TinyMCE WYSIWYG editor will have had their code blown away when switching between “Text” (HTML) and Visual editing modes.

One of the many uses of Advanced Custom Fields plugin is to create a text area to stash code associated with a page or post that the editor can’t touch.

Using: https://www.advancedcustomfields.com/

It’s a similar idea to using the plugin to add custom JavaScript or CSS to a page/post, except the field isn’t exposed in the theme.

This serves to only store the code alongside the post/page in the database.

This will not prevent the editor from modifying the code again in the future if it is pasted back into the editor, but it is a convenient place to copy the code from again.

If you want a more permanent solution you could disable the visual editor, remove the filtering, or other options.

20160811-sot-acf-code-stash

WordPress’ .htaccess rules Decoded

If your WordPress’ .htaccess file has not been modified it should look like this:

# BEGIN WordPress / # END WordPress Tags

WordPress may modify anything within these two tags and anything you add should be outside of these tags.  Source: WordPress Codex

<IfModule mod_rewrite.c> / </IfModule> Tags

If your server doesn’t have the rewrite module or it isn’t properly enabled, the rewrite rules with the If tags will not be executed. Sources: WordPress Codex Using_Permalinks, Glossary

RewriteEngine On

The RewriteEngine directive enables or disables the runtime rewriting engine. Source: Apache documentation

RewriteBase /

The RewriteBase directive allows you to define a root directory for your website.  Source: RationalSpace RewriteBase Explained

RewriteRule ^index\.php$ – [L]

Prevents requests for index.php from being rewritten, to avoid infinite loops. If the request is for index.php the directive does nothing – and stops processing rules [L]. Source: StackOverflow

[L] flag

The [L] flag causes mod_rewrite to stop processing the rule set. In most contexts, this means that if the rule matches, no further rules will be processed. Source: Apache documentation

-f and -d flags

These Rewrite Condition flags allow you to perform various file attribute tests

-f
Is regular file.
Treats the TestString as a pathname and tests whether or not it exists, and is a regular file.

-d
Is directory.
Treats the TestString as a pathname and tests whether or not it exists, and is a directory.

Source: Apache documentation

The remaining code:

Are rules that are processed in order.  First it checks for a filename, then it checks for a directory, and if both of those fail the request is redirected to index.php. Source: SitePoint

How To Check If Your Site is Blacklisted by Google

Occasionally, you should verify that your site is still appearing as it should in search engine results (especially if you don’t use managed hosting or another site scanning service).

Getting de-listed from Google or any other search engine could be devastating.

In the Google.com search bar type in site:yourdomain.com where you replace yourdomain.com with your domain name.  Example: site:scottontechnology.com

Your main domain should be in the top search results along with other popular or top-level pages.

Going directly to your website ie http://yourdomain.com might still appear normally as some malware redirects only affect search engine referral traffic.

Signs that your sight might be hacked, serving SPAM, or de-indexed

What to watch for:

  1. Significant drops in traffic per analytics reports
  2. A warning in search engine results stating that “This site might be hacked”
  3. Long connection times in FTP access
  4. Large backups or backups that fail to complete
  5. Security alerts from Google Search Console (formerly Webmaster Tools)

Other blacklist sites to check:

  1. https://sitecheck.sucuri.net/
  2. http://mxtoolbox.com/BrandReputation.aspx
  3. http://www.bannedcheck.com/

Other search engines to check:

  1. Bing/MSN: http://www.bing.com/
  2. DuckDuckGo: https://duckduckgo.com/
  3. Yahoo: https://search.yahoo.com/
  4. AOL: http://search.aol.com/

Inspired by: https://woorkup.com/how-to-check-if-a-domain-is-blacklisted-by-google/

Review of “5 Simple .htaccess Tips to Tighten Your Site’s Security”

The article published on June 26, 2014 provides 5 Tips for upping a WordPress site’s security.  Original article: https://premium.wpmudev.org/blog/5-simple-htaccess-tips-to-tighten-your-sites-security/

The tips are:

  1. Protecting wp-config.php
  2. Prevent Directory Browsing
  3. Prevent Image Hot Linking
  4. Restrict Access to Your Admin Area
  5. Protect Your .htaccess File

Of these recommendations, you can test quickly whether you are already protected against some of these.  You should get a blank page or a 403 Forbidden page.  Quick test:

  1. http://yourdomain.com/wp-config.php
  2. http://yourdomain.com/wp-content/uploads/
  3. See the section below (coming soon)
  4. See the section below (coming soon)
  5. http://yourdomain.com/.htaccess

1.  Protecting wp-config.php

The Protecting wp-config.php advice comes directly from WordPress.org http://codex.wordpress.org/Hardening_WordPress#Securing_wp-config.php

Test it: http://yourdomain.com/wp-config.php

Gravity Forms Notifications/Confirmations Shortcodes

If this actually exists elsewhere, I haven’t been able to find it.

Helpful shortcodes (Merge Tags as Gravity Forms calls them) for confirmations and notifications in the Gravity Forms WordPress plugin.

General
Your site admin email {admin-email]
The form’s name {form_title}
All fields {all_fields}
Advanced Fields (where # is the Field ID)
Name – Prefix {Name (Prefix):#.2}
Name – First {Name (First):#.3}
Name – Middle {Name (Middle):#.4}
Name – Last {Name (Last):#.6}
Name – Suffix {Name (Suffix):#.8}
Time {Time:#}
Address (Street Address) {Address (Street Address):#.1}
Address (Address Line 2) {Address (Address Line 2):#.2}
Address (City) {Address (City):#.3}
Address (State / Province) {Address (State / Province):#.4}
Address (ZIP / Postal Code) {Address (ZIP / Postal Code):#.5}
Address (Country) {Address (Country):#.6}

 

Other
User IP Address {ip}
Date (mm/dd/yyyy) {date_mdy}
Date (dd/mm/yyyy) {date_dmy}
Embed Post/Page Id {embed_post:ID}
Embed Post/Page Title {embed_post:post_title}
Embed URL {embed_url}
Entry Id {entry_id}
Entry URL {entry_url}
Form Id  {form_id}
Form Title  {form_title}
HTTP User Agent  {user_agent}
HTTP Referer URL  {referer}
User Display Name  {user:display_name}
User Email  {user:user_email}
User Login  {user:user_login}

 

Note:

  • Page was not included
  • Section (break) was not included