Google Fonts in WordPress

So you’ve seen some of the new fonts that you can use for Free from Google’s Font library and now you want to drop them into your WordPress Blog. You could probably stumble through some of the WordPress configuration options within the admin areas to eventually find an ‘Editor’ tab which allows you to edit the PHP code files for the site. You could find a file that looks like it should accept the <link> code from Google and paste it in there… but if your template ever updates you’ll lose that setting. Below is an example of what the <link> code looks like.

Like most WordPress tasks, the easiest approach is to simply navigate into the plugins area and find a plugin. For Google Fonts there are quite a few plugins, but we’ll use one named ‘WP Google Fonts‘. This plugin has by far the most support and latest updates. To use the WP Google Fonts plugin, start by finding it, installing it, and activating it. Then you can click on the settings for the plugin to see it has several slots for finding the Google Font, specifying which parts of the HTML you want to override, H1, H2, etc. or even some custom elements with your own CSS.

wp fonts

Scroll Speed Parallels Mac OSx

mousescroll
The scroll speed on Parallels is a little off-par with the smooth scrolling on my new Mac OSx running Mavericks. When I slide into my Parallel’s, my mouse scroll slides half of the page at a time. To fix this simply navigate into Control Panel -> Mouse -> Wheel and change the scroll lines down to 1. This will reduce the scrolling per line and make it more inline with what you’re expecting the scroll speed to be.

Deploy to Windows Phone

To deploy to a Windows Phone you need to,

1) Register at https://dev.windows.com/en-us/join.

You don’t necessarily need to Register if you want to side-load apps on your own Windows Phone, but if you want to submit Free or Paid apps to the Windows Store you’ll need to register.

2) Unlock your Windows Phone

You’ll need to first start by unlocking your phone for side loading custom developed applications. You can unlock your windows phone, up to 3 phones per windows developer account, by opening the Windows Phone Developer Registration application and logging in. It will prompt you to plug-in your Windows Phone and it will link your phone to your windows account. After it syncs with Window’s servers it is effectively ‘unlocked’ and can side load your own custom developed .xap files. You can find the Windows Phone Developer Registration shortcut in the following path:

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Windows Phone SDK 8.0

**If you don’t find the Windows Phone Developer Registration shortcut (ultimately PhoneReg.exe), then you can download a zip containing the .exe in the attached zip PhoneReg.zip

3) Upload your .xap Package

Next you’ll have to build an epic App and then produce a Windows Phone App binary called a .xap file/package. The package contains everything the App needs to deploy as an App on the phone. You’ll upload the .xap to a phone by using a tool found in the exact same directory as the Registration Tool, but this one is aptly named Xap-Deploy.exe. The shortcut found in the Windows Phone SDK folder is Application Deployment.

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Windows Phone SDK 8.0

**If you don’t find the Application Deployment shortcut (ultimately XapDeploy.exe), then you can download a zip containing the .exe in the attached zip XAP-Deployment.zip

You can also download additional development tools here.

Python Web Server

Python comes with a built-in web server that can quickly host static content if you’re looking to browse a file that may require viewing that file from a ‘server’ rather than from a //file location on disk.

Depending on if you have Python version 3.4

If you have a younger version of Python, you might want to try the following older syntax

MAC OSx Terminals Alias (Bash Aliases)

To create an alias for Terminals, simply type the alias keyword followed by a string=”new command”. Here’s an example that turns allows the alias ‘cls’ (clear screen) to ‘clear’ the screen.

However, the above string makes this alias temporary for the current terminal window session and will disappear after you quit the terminal.

To make aliases permanent, you’ll need to edit the following file and place your alias commands in there. “~/.bash_profile”

Edit ~/.bash_profile

You can edit the bash_profile file by simply invoking “nano ~/.bash_profile” and then add your aliases. When you’re ready to save, simply Ctrl-O followed by enter. Then you can close the file by hitting Ctrl-X.

Other Common Aliases

Here is a few other commonly aliased commands for reference.

Web API Cross Domain Cors

Cross Origin Policy is a lingering security hole that was protected in Netscape Navigator by simply limiting web requests to requests made against the same origin, where the same origin was the same protocol scheme (http/https), host (example.com, www.example.com, abc.example.com), and port (:80, :8080). JSONP is one technique that sidesteps this issue by allowing data to be returned in a script tag and then ultimately re-interpreting that script as data. Well, now we can allow cross domain requests in ASP.NET WEB API by including the following Cors nuget package in your projects.

Install-Package Microsoft.AspNet.WebApi.Cors

After adding the nuget package, you’ll simply need to open your WebApiConfig and in the registration method, add the following code,

Next you’ll want to single out the controllers that you’ll want to expose to CORS by adding the following attribute. Note that this attribute takes a few parameters for supporting various requests (Origins, Headers, and Methods). If you want to support all origins, all headers, and all method verbs, simply use strings with a wildcard character “*”.

  • Origins includes a comma separated list of all of the protocol://host:port that will be accepted
  • Headers includes a comma separated list of all of the headers supported, such as ‘accept, content-type, etc.’
  • Methods includes a comma separated list of all the HTTP verbs that should be supported such as ‘get,post,put,etc’

The above code sample was used to make all actions within the DataController exposed, but it could easily be limited to just a few actions by decorating those actions with the attribute and removing it from the class. You can optionally choose to decorate an action or class with the [DisableCors] attribute.

To set all controllers to enable cross domain requests, simply set the following property in the WebApiConfig’s Register method.

In case you’re wondering what’s really happening by ‘enabling-cors’, well it’s simply setting a header on the Response that allows the web browser to accept and interpret the result in the response. Without it, the web browser will simply see the response and ignore any further evaluation of the body. Here’s what the Header looks like,

Markdown Basics

Markdown is simply a syntax that allows a writer to create a text file that can contain common textual elements (headers, lists, bold, italic, etc.) with a limited character set. Here is the basic syntax for the most common elements in a markdown (.md) file. Note that many development sites use a standard readme.md file to represent a repository or folder’s details.

Paragraphs
are simply lines of text followed by a blank line.

Headers
are specified by the number of hash signs (#), the more the higher the number the heading is
# h1 #
## h2 ##
### h3 ###
#### h4 ####
##### h5 #####
###### h6 ######

Bolding Text
is done by simply adding two ** on either side around the text you want bolded
** this is bolded text **

Italic Text
is done by simply adding one * on either side around the text you want italic
* this is italic text *

Lists
are created by adding a * or a dash before the elements in the list
* element 1
* element 2
* element 3
OR
– element 1
– element 2
– element 3

Links
are created by specifying the text in a block and the link directly following
[Visit my site!](http://davidemanske.com)

Block Quotes
are created by simply adding a single > in front of the sentence that you wish to have block quoted

Many different implementations have spun out of the simple markdown syntax, including MultiMarkdown which supports an even wider array of elements. Check it out here MultiMarkdown

Web Deploy 3.0 on IIS

So you’re setting up a new Windows IIS Web Server and you have heard about Web Deploy 3.5 to deploy applications to sites. It’s pretty sweet!

Installing Web Deploy 3.5

To install Web Deploy 3.5 on IIS 7.5 or IIS 8, I recommend using the Web Platform Installer. After adding Web Deploy 3.5, click Install and the platform installer will download and install the appropriate extensions for IIS.

webdeployadd

After you’ve installed Web Deploy 3.5, you’ll see a few more additional options under IIS’s home menu within the ‘Management’ section.

  1. Management Service – Go into the Management Service and Start the Service. You can optionally turn on IIS Manager Users or leave it by default to use only Windows Credentials.
  2. IS Manager Users – If you want to allow non-active directory users, you’ll need to create IIS manager users. Simply give a new user a name and a password.
  3. IIS Manager Permissions – Windows users can be granted all site access to deploy to any site, however IIS users are granted access on a per-site basis. So, if you have an IIS user you’ll need to go into each web site and grant permission.

iiswebdeploy3

HELP, the Management Service icon is not available!
If you find that the Management Service and associated icons are not appearing within IIS, it’s a potential for the web deploy not being installed correctly or the IIS management service was not installed when IIS was installed and configured. If the management service was not installed, simply open Server Manager and navigate to the IIS Role. Under the IIS features you’ll see a management service located toward the end of the list which needs to be installed. Check the box, install it, and then simply close and re-open IIS to see if the Management Service and associated icons appear.

Deploying with Web Deploy 3.5

To deploy to an IIS server that is configured with Web Deploy 3.5, you’ll need to start with a web application or site. Within Visual Studio, right-click on the Web Project and click ‘Publish’. Within the Publish Web dialog, create a new Profile and set the publish method to Web Deploy. Next, specify the service URL which is the IP or DNS name that you’ll use to point to your server. Set the Site/application to the name of your site within IIS. Lastly, specify the username and password and click Validate Credentials. If you’ve successfully validated your credentials, you can click Preview in Visual Studio 2013 to see the exact file changes that are going to occur, such as deleting, updating, or adding files. Clicking Publish will send your bits over the wire and deploy the site on IIS.

FastClick – Avoid Mobile Browser Tap Delays

because mobile web browsers don’t click fast enough…

Mobile web browsers have a short delay (300ms) when clicking on a link or activating an on-click event such that it allows the browser to successfully determine if the event was a double-click or a single-click. To mitigate this issue, you can drop in the following fastclick JavaScript script into your page and enable it to optimize the single-click events by removing the delay.

It’s important to note that the fastclick script will look at the user-agent and determine if the fastclick event listeners should be loaded or not, it will not change the behavior of desktop browsers.

AngularJS Built-in and Custom Filters

This post on AngularJS Filters continues on a series of posts on AngularJS. Click here view the complete list of posts on AngularJS.

Filters don’t just filter data in AngularJS

Filters in AngularJS allow you to format the value that is displayed in a data-binding expression. There are several built-in filters that provide textual transformations such as uppercase and lowercase which will simply capitalize or lowercase all the characters in the string. There are also filters for presenting dates and currencies. In the example below, I’ve illustrated a few of the common AngularJS filters as well as show an example for creating your own custom filter.

Custom Filters

To create your own custom filter in AngularJS, you simply create a module first and then create a filter very similiar to creating a controller. The first function allows you to inject any dependencies that you may need to access while performing the operation on the object. The filter function returns a function that is invoked on the bound value within the expression. This is then returned when the binding occurs. When the bound variable changes, the filter expression will be re-run.