Skip to content

Instantly share code, notes, and snippets.

View Piterden's full-sized avatar
🇷🇺
Stand with Russia!

Denis Efremov Piterden

🇷🇺
Stand with Russia!
View GitHub Profile
@Piterden
Piterden / back_forward.js
Last active August 29, 2015 14:25 — forked from sstephenson/back_forward.js
How to detect whether a hash change came from the Back or Forward button
var detectBackOrForward = function(onBack, onForward) {
hashHistory = [window.location.hash];
historyLength = window.history.length;
return function() {
var hash = window.location.hash, length = window.history.length;
if (hashHistory.length && historyLength == length) {
if (hashHistory[hashHistory.length - 2] == hash) {
hashHistory = hashHistory.slice(0, -1);
onBack();
@Piterden
Piterden / .htaccess
Created April 26, 2016 20:36 — forked from splittingred/.htaccess
Example of how to use new REST server class in MODX 2.3+
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(.*)$ rest/index.php?_rest=$1 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ rest/index.php [QSA,NC,L]
</IfModule>
'use strict';
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var WriteFilePlugin = require('write-file-webpack-plugin');
var BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const devServer = {
@Piterden
Piterden / BladeSetServiceProvider.php
Created July 12, 2016 21:17
[Laravel 5] Blade @set extension
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class BladeSetServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
@Piterden
Piterden / GravatarMethod.php
Created July 12, 2016 21:23
[PHP] Get Gravatar Image from user email
<?php
/**
* Generate Gravatar image for user
* @param string
* @return string
*/
public function getImageAttribute($value)
{
$gravemail = md5(
strtolower(
@Piterden
Piterden / CreateCategoriesTable.php
Created July 12, 2016 21:32
[Laravel 5] Migrations example
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCategoriesTable extends Migration
{
/**
* Run the migrations.
*
root = true
[*]
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_size = 4
@Piterden
Piterden / .eslintrc.yaml
Created July 12, 2016 21:34
Eslint default config
parser: babel-eslint
rules:
indent:
- 2
- 2
quotes:
- 2
- single
linebreak-style:
- 2
@Piterden
Piterden / gulpfile.js
Last active July 12, 2016 21:39
[Laravel 5] Gulp + Webpack + VueJs
var elixir = require('laravel-elixir'),
assetsPath = elixir.config.assetsPath,
publicPath = elixir.config.publicPath;
require('laravel-elixir-webpack-advanced')
require('laravel-elixir-imagemin')
elixir(function (mix) {
mix.styles(
@Piterden
Piterden / Datepicker.vue
Last active July 31, 2016 05:10
Vue components
<template>
<div class="datetime-picker" :style="{ width: width }">
<input type="text" :style="styleObj"
:readonly="readonly" :value.sync="value">
<div class="picker-wrap" v-show="show">
<table class="date-picker">
<thead>
<tr class="date-head">
<th colspan="3">
<span class="btn-prev" @click="yearClick(-1)">