Skip to content

Instantly share code, notes, and snippets.

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

Azimi azimidev

:octocat:
Pro
View GitHub Profile
@azimidev
azimidev / regex.md
Created May 13, 2019 14:38 — forked from jacurtis/regex.md
Most Useful Regex's

Useful Regular Expressions

These are the most useful Regular Expressions that I find myself using on a regular basis


URLs

Test to see if a string is a valid website address or not.

All URLs
@azimidev
azimidev / no-right-click-on-images.js
Created May 13, 2019 14:35 — forked from jacurtis/no-right-click-on-images.js
Removes right-click on images
/*
* This script will look for all images on a page and prevent right clicking on an image.
*/
const images = document.getElementsByTagName('img');
for(var i = 0; i < images.length; i++) {
images[i].addEventListener('contextmenu', event => event.preventDefault());
}
// Note: I threw this script together as requested by a subscriber. I personally don't recommend doing
@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
@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 / 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 / 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 / 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 / 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
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 / 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