Skip to content

Instantly share code, notes, and snippets.

View azimidev's full-sized avatar
:octocat:
Pro

Eric Azimi azimidev

:octocat:
Pro
View GitHub Profile
import Vue from 'vue/dist/vue.esm'
import TurbolinksAdapter from 'vue-turbolinks'
import VueResource from 'vue-resource'
Vue.use(VueResource)
document.addEventListener('turbolinks:load', () => {
Vue.http.headers.common['X-CSRF-Token'] = document.querySelector('meta[name="csrf-token"]').getAttribute('content')
var Profiles = Vue.extend({
@azimidev
azimidev / .htaccess
Last active August 19, 2023 05:53
The Best .htaccess with browser caching and gzip
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
@azimidev
azimidev / postgresql_mac.md
Last active August 26, 2017 14:36
Run PostgreSQL on Mac Using Homebrew Install

Steps to install and run PostgreSQL using Homebrew (Mac OS X) (if you aren't using version 9.1.5, change line 6 with the correct version)

  1. launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
  2. brew update
  3. initdb /usr/local/var/postgres -E utf8
  4. pg_upgrade -b /usr/local/Cellar/postgresql/9.4.6/bin -B /usr/local/Cellar/postgresql/9.4.6/bin -d /usr/local/var/postgres -D /usr/local/var/postgres
  5. cp /usr/local/Cellar/postgresql/9.4.6/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
  6. pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
@azimidev
azimidev / Sluggable.php
Last active November 30, 2017 20:15
Laravel Sluggable Trait Version 2
<?php
/**
* PHP v7+
* Remember for this to work, in your controller you need to do:
* $model->slug = request('title')
* columns name are: title and slug
*/
namespace App\Traits;
@azimidev
azimidev / Sluggable.php
Last active November 30, 2017 20:14
Laravel Sluggable Trait Version 1
<?php
/**
* For this to work you don't need to do anything,
* just add this Sluggable Trait inside your Model
*/
namespace App\Traits;
@azimidev
azimidev / Sluggable.php
Created November 30, 2017 20:49
Laravel Slug Attribute Simple and Best
<?php
public function setSlugAttribute($value)
{
$slug = str_slug($value);
$original = $slug;
$count = 2;
while (static::whereSlug($slug)->exists()) {
$slug = "{$original}-" . $count++;
@azimidev
azimidev / chunk.js
Created December 8, 2017 01:05 — forked from jperler/chunk.js
Array chunking function for Underscore.js. Usage: _.chunks([1,2,3,4,5,6,7], 2) => [[1,2],[2,3],[4,5],[5,6],[7]]
_.mixin({
chunks: function(arr, size) {
var len = arr.length,
chunk_len = Math.ceil(len/size),
chunks = [];
for (var i = 0; i < chunk_len; i++) {
chunks.push(arr.slice(i*size, (i+1)*size));
}
return chunks;
}
@azimidev
azimidev / GIT-ALIAS.MD
Last active July 31, 2018 12:00
GIT ALIASES
  • g = git
  • ga = git add
  • gaa = git add --all
  • gap = git apply
  • gapa = git add --patch
  • gau = git add --update
  • gb = git branch
  • gba = git branch -a
  • gbd = git branch -d
  • gbl = git blame -b -w
@azimidev
azimidev / forge.sh
Created August 9, 2018 00:05
Laravel Forge Setup Script
#
# REQUIRES:
# - server (the forge server instance)
# - event (the forge event instance)
# - sudo_password (random password for sudo)
# - db_password (random password for database user)
# - callback (the callback URL)
#
@azimidev
azimidev / .vimrc
Last active September 24, 2019 16:27
Personal .vimrc file with ~/.vim/plugins.vim file and Vundle installed (https://github.com/VundleVim/Vundle.vim)
so ~/.vim/plugins.vim " Source from plugins
set nocompatible " Disable vi-compatibility
syntax on " Enable syntax highlighting
" Pathogen plugin specific
execute pathogen#infect()
filetype plugin indent on " Pathogen
set background=dark " Set bg to dark