LESS to SASS

Less to SASS

 

Auf wiedersehen LESS, Hallo SASS! In this post I am going to cover:

  1. Why LESS to SASS?
  2. How to migrate from LESS to SASS, and a couple of things to note.
  3. Using grunt-contrib-sass to compile SASS.
  4. Switching to bootrap-sass (until Bootrap 4 is stable).
  5. Adding the postcss autoprefixer task to your Grunt tasks to add necessary vendor prefixes to your CSS.
  6. And, switching from LESS Hat to the Bourbon SASS mixin library.

Read more

CSS3 Content Property

CSS3 Pseudo Elements

The CSS3 content property is extremely value for inserting content into the ::before and ::after pseudo elements. As the Mozilla Developer Network states:

“The content CSS property is used with the ::before and ::after pseudo-elements to generate content in an element.”

The content property enables us to insert generated content. The content can include:

  • String value.
  • URI for showing an image.
  • The value of an attribute for the element.
  • Quotes (open-quote and close-quote).

Further, the content property is widely supported by all major browsers.

I think the most valuable of these is being able to insert a string value. Let’s look at some examples of using the content property along with the ::before and ::after pseudo elements.

Read more

Bootstrap via RequireJS

Bootstap and Requirejs

I have been learning and using RequireJS for the past couple of weeks, and I have to say, I love it. Here are some of the benefits of using RequireJS for a web application:

  1. Only load the JavaScript code/modules you need.
  2. Each JavaScript module defines it’s own dependencies.
  3. Load your JavaScript via XHR without rolling your own JavaScript loader.
  4. Still works well with libraries that do not support AMD (Asynchronous Module Definition).

I want to quickly show how to load libraries, such as Bootstrap, that do not support AMD.

Read more

Web font in IIS: ERR_CONNECTION_RESET

ERR_CONNECTION_CLOSED

If you are using a web font, including popular font icon fonts like Font Awesome, then you may notice an error when loading your web font from an IIS server. I received the error: “ERR_CONNECTION_RESET”, and when inspecting the network request I see that the server responded with header “Connection: close”.

The reason for this is that the .woff and .woff2 file extensions do not have a defined MIME type in IIS.

Read more

Multiple Batches in a single Transaction

Goal: Create a migration script that uses a transaction to roll back the changes in case one of the sql statements fail.

Problem: If you alter a table and add a column, and then attempt to use the new column in SQL statements that follow, you will discover that you get an error that indicates that the column does not exist. This is because the statements are in the same batch.

Sample problem code: Here is a little snippet showing TSQL that contains the problem. This is a classic example of adding a bit field to an existing table, setting the values all to true (1), and then updating the bit field to not allow NULLs.

BEGIN TRANSACTION

ALTER TABLE Employees ADD Active bit;

UPDATE Employees SET Active = 1;

ALTER TABLE Employees ALTER COLUMN Active bit NOT NULL;

COMMIT TRANSACTION;

 

So, what are we left to do? Well, we need to create a single transaction with multiple batches, separated by the GO keyword.

Read more

Migrating Databases in Amazon RDS

Amazon RDS

Amazon’s Relational Database Service (RDS) enables developers to launch database instances in the cloud that are “fully” managed by Amazon. What this means is that developers can focus more on development and less on minor upgrades to the database, replication, fault tolerance and backups. This all sounds great, but there is one minor issue: no file system access. While this is generally not an issue, it does become an issue if you are attempting to create/restore a SQL Server backup (.bak) file.

Read more

Learning Nginx on OS X

Nginx

 

I have long been a big fan of Apache’s web server. It’s powerful, versatile, and free. For the most part, the website that I have worked on are not mega websites, so I have never run into performance issues using Apache (or IIS for that matter). However, I still wanted to play with nginx. What is it? It’s a web server, and much more:

Nginx (pronounced engine-x) is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server.

So, let’s dive in…

Read more

chmod directories (and not files)

Here is a quick snippet that I used today, and that I might end up needing in the future. I needed to give all directories the execute permission for Apache to be able to traverse the directories.

Here is the error in my Apache error log:

[Thu Mar 26 12:37:24.857559 2015] [core:crit] [pid 14413] (13)Permission denied: [client 127.0.0.1:59372] AH00529: /www/local.brianflove.com/www/scripts/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that ‘/www/local.brianflove.com/www/scripts/’ is executable

 

chmod all directories recursively

So, I used the find command in terminal to update the permission on the files.

$ sudo find /www/local.brianflove.com/www -type d -exec chmod chmod 775 {} +

Now all directories have the following permissions:

  • User: 7 – read/write/execute
  • Group: 7 – read/write/execute
  • World: 5 – read/execute

 

Mac Permissions Table

Just in case it is helpful, here is a permissions table for Mac (from freebsd.org).

Value Permission Directory Listing
0 No read, no write, no execute ---
1 No read, no write, execute --x
2 No read, write, no execute -w-
3 No read, write, execute -wx
4 Read, no write, no execute r--
5 Read, no write, execute r-x
6 Read, write, no execute rw-
7 Read, write, execute rwx