# Blog

## Laravel 5.5 permissions based on user id

For a Laravel 5.5 project I solved a permission problem that i’d like to share in case someone else can benefit.

## Problem:

The structure of our urls look like this:

users/5/companies

Which will show all the companies for user 5. I however wanted to limit it so that only user 5 may see user/5 company listings. User/4 or another use should see access denied when viewing /users/5/compaines.

My current route was defined this way in routes/web.php:

## Solution:

Use middleware attached to a route group with prefix to do the check. Although you can accomplish this in a controller, you are better off using middleware. Middleware intercepts the request before it even its your controllers. So you can stop it at an earlier stage. (more…)

## Partition a Linked List by Value X (part 2)

To expand on the problem here Partition Linked List Based on value x

Partition a Linked List by a value x, so that values less than x come first, values equal to x come next, and values greater than x come last. Note: Retain relative order.

Unlike the previous question, this one has no shortcuts that were obvious to me.

To solve this problem, I need the concept of 3 lists. LessThanList (LTList), EqualToList (EqList), and GreaterThanList (GTList).

Because we are doing this in place and are working with linked list, it’s sufficient to just move around pointers without actually creating new lists.

So the pointers will track the beginning and end of their respective list.

startOfLTList, endOfLTList,

startOfEqList, endOfEqList,

startOfGTList, endOfGtList

So for an input of 4, 3, 6, 5, 2

We get an output of 3, 2, 4, 6 ,5

Where the partitions are 3, 2,| 4, | 6 ,5

## Partition Linked List Based on value x

During my algorithm review I came across this problem.

Write an algorithm to partition a linked list around a value, x, so that all nodes less than x comes before all all nodes greater than or equal to x.

I really like this problem, because it is being very generous and allows you to be very efficient. Here are some tips that will help you with getting  a full solution.

Tip 1 – A complete sort is not necessary. (smile) (more…)

## Most Useful Linux Commands

This is a lit of commands that I find found very useful on linux and related technologies.

Command 1

This command can prevent you from having a crisis.

## Site blocked from McAfee Web Gateway

Have you seen this before?

You may be trying to access a site from inside of a firewall and you get a scary message like this. What’s even worse is if it’s your own site and makes you wonder what in the world is going on. The message you may see is: (more…)

Recently, I was working on a sass project and then started to get strange errors about a file not being found. The error referenced a non existent file in the sass cache folder. I wasn’t sure why the file was not being generated, I had never seen this before.

The error came in two forms:

## Fixing Website Blocked. Category None

Seen this before?

You may have received an error that says content blocked with category “none” when you try to access a certain website from within a firewall. I have seen this happen with BlueCoat firewall which is often used by very large companies to limit the sites that their computers can visit. (more…)

## Better Organization with Sass Media Queries

Using media queries can get confusing and overlapping especially when structure is lacking. With sass css compiler and mixins we can structure our media queries and use them far more elegantly.

## Getting Selected Option From PHP Select List

Let’s say you have a php select box that is dynamically generated through your php loop. You want to make sure that the selected option is always displayed even after reload.

Here is an example of a basic dynamic list:

However when the page loads, you cannot tell which color was selected and aren’t sure where to put the html ‘selected’ value because the code simply ran through the colors loop.

Solution: (more…)

## Deploying WordPress via Bash Script

Deploying your site should be easy. There are many ways to accomplish this, and I decided to take a bash script approach for one project. This will appeal to the more hands-on developers, but don’t worry everything has been explained here.