What they never tell you about GitHub

GitHub is brilliant…. There are loads of tutorials, video and articles out there, recently I’ve spent time filling gaps in my Git version control knowledge and something struck me as odd. Every tutorial should make it clear right from the start and reminders throughout their presentations that you

DO NOT STORE PASSWORDS, KEYS, USERNAMES, CREDENTIALS, ETC. ON GIT HUB

Why?

Because there are bastards out there who are scanning git repositories for anything that could help access secured areas or consume resources they should not.

Git does scan your repo’s and will warn you but its not in real time so be warned. Still not convinced? The image is of a free Amazon Web Service account that was set up as a learning exercise the keys where saved in a Git Repo and over the course of 3 days a free account had racked up nearly $10,000US .

What can you do, if you accidentally commit a password, key, etc? Delete the branch? Roll back?

No!

The best advice and this is also given by Git themselves is to consider your data compromised and your accounts that use the data hacked. Once again, rolling back and deleting does not work.

So reset your passwords/key etc and don’t just add a 1 at the end or swap out vowels for 12345.

How do you manage password and environment values?

Have a Google for git .gitignore or visit dotIgnore on GitHub

Laravel Pagination

Pagination with Laravel (5.4 at the time of writing) is very easy.

Say you want a table of users

In your controller:

$user = User::all()->paginate(10);

In the view loop through your users as normal and then add

$user->links() where ever you feel like it and more than one place if you are feeling dandy.

There is more..

But say you want more than one paginate-able list/table on the same page? This is the paginators signature

paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)

Easy, extending the original query lets get all the threads/comments for a user. Assuming your User model can dish out Threads and Comments

$user = User::find(1);
$threads = $user->threads()->paginate(4, ['*'], 'threads');
$comments = $user->comments()->paginate(4, ['*'], 'comments');

Then in your view loop through your comments and add

$comments->links();

Loop through your threads and add

$threads->links();

 

 

 

Laravel Real-Time Facades (Bastards!)

Come on Taylor Ortwell whats the deal? I spend time learning about Facades and their round-a-bout method of getting them registered and running. Now with Laravel 5.4 I can get the same outcome by typing a single line of code.

WTF?

What is a  Laravel Facade?

A Facade is a “static” interface for classes that are available in the application’s service container. Think functions on steroids!

Creating them WAS simple but there where a few loops you had to jump through. But now just declare them using the Facades namespace

use Facades/{location}/{of}/DoSomething;

and use them with

DoSomething::amazing()

No need to register your Facades. Just like before DI is taken care of.

 

Laravel Lovelyness

 

In case you don’t get it I think this new method of declaring Facades is a good thing.