[PROJECT_NAME] and description
- Use Laravel Pint with the project's configuration (
pint.json) - Strict comparisons: Use
===and!==instead of==and!=
| function tinker() | |
| { | |
| if [ -z "$1" ] | |
| then | |
| php artisan tinker | |
| else | |
| php artisan tinker --execute="dd($1);" | |
| fi | |
| } |
| function StalinSort(array) { | |
| if (!Array.isArray(array)) throw new TypeError('Argument must be an Array!'); | |
| return array.reduce((prev, next) => | |
| !prev.length || | |
| next >= prev[prev.length - 1] ? | |
| [...prev, next] : | |
| prev | |
| , []); | |
| } |
| <?php | |
| // Register collection macros in the boot method of a app service provider | |
| // app/Providers/AppServiceProvider.php | |
| // usage: collect([...])->get()->data_get('key.someData.0.email','Default') | |
| Collection::macro('data_get', function ($key, $default = '') { | |
| return $this->map(function ($value) use ($key, $default) { | |
| return data_get($value, $key, $default); | |
| }); | |
| }); |
| <?php | |
| $customers = collect([]); // some nested Laravel collection | |
| // Instead of manually creating this monstrous nested loop... | |
| $customers->each(function ($customer) { | |
| $customer->orders->each(function ($order) { | |
| $order->payments->each(function ($payment) { | |
| //doWork($payment); | |
| }); |
| -- automatically fill Cisco AnyConnect credentials on mac | |
| set targetApp to "Cisco AnyConnect Secure Mobility Client" | |
| set vpnName to "yourVPNServer.com" | |
| set pass to "YOURPASSWORD" | |
| set loginWindowTitle to "Cisco AnyConnect | " & vpnName | |
| tell application targetApp | |
| activate | |
| end tell | |
| repeat until application targetApp is running |
| -- Weigh rows against eachother based on different conditions, | |
| -- ordering the results based on their given weights so that | |
| -- more precise matches will show higher up in the results. | |
| -- In this example, an exact match will show up at the top | |
| -- of the results, a match at the beginning of the string | |
| -- will show next, and a match anywhere will show last. | |
| set @query = 'Liam'; |
| #colorful prompt with git branch names | |
| parse_git_branch() { | |
| git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
| } | |
| PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ ' |
| # Ubuntu 15.04+ | |
| [Unit] | |
| Description=Setup a secure tunnel to server | |
| Wants=network-online.target | |
| After=network-online.target | |
| [Service] | |
| User=admin | |
| Environment="LOCAL_ADDR=localhost" |
| #! /usr/bin/env bash | |
| # Basic info | |
| IP=`hostname -I | awk '{print $1}'` | |
| HOSTNAME=`uname -n` | |
| #ROOT=`df -Ph | grep xvda1 | awk '{print $4}' | tr -d '\n'` | |
| ROOT=`df -Ph | grep vda1 | awk 'NR==1{print $4}' | tr -d '\n'` | |
| # System load | |
| MEMORY1=`free -t -m | grep Total | awk '{print $3" MB";}'` |