- https://speakerdeck.com/willroth/50-laravel-tricks-in-50-minutes
- https://www.reddit.com/r/laravel/comments/3to60i/50_laravel_tricks/
- 1. Automatic Model Validation
<?php | |
# http://jeffreysambells.com/2012/10/25/human-readable-filesize-php | |
function human_filesize($bytes, $decimals = 2) { | |
$size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB'); | |
$factor = floor((strlen($bytes) - 1) / 3); | |
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor]; | |
} | |
echo human_filesize(filesize('example.zip')); |
### Download setup Ubuntu 14.04 box | |
``` | |
// from local directory | |
vagrant init chef/ubuntu-14.04 | |
``` | |
### Setup Vagrantfile | |
``` | |
# -*- mode: ruby -*- | |
# vi: set ft=ruby : |
export ZSH=/Users/antoniwan/.oh-my-zsh | |
ZSH_THEME="robbyrussell" | |
ENABLE_CORRECTION="true" | |
COMPLETION_WAITING_DOTS="true" | |
plugins=(git) | |
# user configuration | |
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH" | |
export PATH="$PATH:~/.composer/vendor/bin" | |
export PATH="$PATH:/Users/antoniwan/.composer/vendor/bin" |
// A small SSH daemon providing bash sessions | |
// | |
// Server: | |
// cd my/new/dir/ | |
// #generate server keypair | |
// ssh-keygen -t rsa | |
// go get -v . | |
// go run sshd.go | |
// | |
// Client: |
alias gl="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" |
Sources: http://stackoverflow.com/questions/1753070/git-ignore-files-only-locally
The .git/info/exclude file has the same format as any .gitignore file. Another option is to set core.excludesFile to the name of a file containing global patterns.
Note, if you already have unstaged changes you must run the following after editing your ignore-patterns:
git update-index --assume-unchanged [<file>...]
Note on $GIT_DIR: This is a notation used all over the git manual simply to indicate the path to the git repository. If the environment variable is set, then it will override the location of whichever repo you're in, which probably isn't what you want.
In the case that you don't want development errors making their way to Sentry for error tracking, you can use the code below to ensure that Sentry will only record exceptions when in production.
First, instead of loading the SentryLaravelServiceProvider
in the config/app.php
providers
array, we will load it in our App/Providers/AppServiceProvider.php
. This allows us to check the environment before loading the appropriate service providers.
Seconly, in our App/Exceptions/Handler.php
we again check for the production
environment before trying to capture the exception using Sentry. This second step prevents Sentry from trying to catch an exception when it isn't bound in the container.
Recently when refactoring a Vue 1.0 application, I utilized ES6 arrow functions to clean up the code and make things a bit more consistent before updating to Vue 2.0. Along the way I made a few mistakes and wanted to share the lessons I learned as well as offer a few conventions that I will be using in my Vue applications moving forward.
The best way to explain this is with an example so lets start there. I'm going to throw a rather large block of code at you here, but stick with me and we will move through it a piece at a time.
<script>
// require vue-resource...
new Vue({