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 / .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]
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 / _spacing-helpers.scss
Last active February 5, 2020 08:59 — forked from jacurtis/_spacing-helpers.scss
SASS Margin and Padding Helpers Loop.
/*
This .scss loop will create "margin helpers" and "padding helpers" for use in your web projects.
It will generate several classes such as:
.mr-10 which gives margin 10 pixels.
.pb-5 gives PADDING 5 pixels
The first letter is "m" or "p" for MARGIN or PADDING
Second letter is "t", "b", "l", or "r" for TOP, BOTTOM, LEFT, or RIGHT
Third letter is the number of spacing in pixels. Adjust the amounts generated by editing the $spaceamounts variable below.
@azimidev
azimidev / MaterialTheme.xccolortheme
Created June 2, 2017 14:07
Material Theme for Xcode
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0.319563 0.371489 0.414287 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>FiraCode-Regular - 12.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>0.319563 0.371489 0.414287 1</string>
@azimidev
azimidev / Form.js
Last active April 26, 2020 07:00
Axios Form Class for use with Vue.js
class Errors {
/**
* Create a new Errors instance.
*/
constructor() {
this.errors = {};
}
/**
* Determine if an errors exists for the given field.
<?php
/* PHP */ /* JavaScript */
mb_strpos($myEmail, '@'); myEmail.indexOf('@');
str_replace('@', '[at]', $myEmail); myEmail.replace('@', '[at]');
mb_substr($myEmail, 0, 5); myEmail.substr(0, 5);
mb_strlen($myEmail); myEmail.length;
(int) '10'; parseInt('10');
array_key_exists('name', $user); 'name' in user;
in_array('Book 1', $userBooks); userBooks.includes('Book 1');
time(); Date.now();
@azimidev
azimidev / Amir - Material.icls
Created May 18, 2017 12:50
PHPStorm Amir Theme
<scheme name="Amir - Material" version="142" parent_scheme="Default">
<option name="FONT_SCALE" value="1.0" />
<option name="LINE_SPACING" value="1.5" />
<option name="EDITOR_FONT_SIZE" value="12" />
<option name="EDITOR_LIGATURES" value="true" />
<option name="EDITOR_FONT_NAME" value="Fira Code" />
<colors>
<option name="ADDED_LINES_COLOR" value="212c32" />
<option name="ANNOTATIONS_COLOR" value="8b999f" />
<option name="BORDER_LINES_COLOR" value="" />
@azimidev
azimidev / sort_column_by.php
Last active August 8, 2017 19:01
Laravel most generic sorting tabulate data. It works for every column in database
<?php
/**
* Sorting tabulate data
*
* @param $column
* @param $body
* @return string
*/
function sort_column_by($column, $body)
{
@azimidev
azimidev / get_enum_values.php
Last active August 8, 2017 19:00
Return the possible enum values from the table and column from MySQL. The values returned can be implemented when using something like HTML comboboxes or checkboxes
<?php
/**
* Return the possible enum values from the table and column
*
* @param $table
* @param $field
* @return array
*/
function get_enum_values($table, $field)
{
@azimidev
azimidev / calculate_profile_percentage.php
Last active July 11, 2022 01:51
Calculates how much percentage of a profile is completed. It stripes off timestamps like created_at updated_at and primary keys like ids. Usually beneficial when using Laravel
<?php
/**
* Calculate how much a profile is completed
*
* @param $profile
* @return float|int
*/
function calculate_profile($profile)
{
if ( ! $profile) {