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
/**
* Strip HTML-tags from string
*
* @return {String}
*/
String.prototype.stripTags = function() {
return this.replace(/<(((.*?\n+?.*?)+?|.*?)?)>/gm, ' ')
}
@Piterden
Piterden / vue.es5.browser.eslint
Created November 22, 2016 01:10
[ESLINT3] Vue in browser
/*eslint no-new: 0*/
/*eslint no-undef: 1*/
/*eslint space-after-keywords: 0*/
/*eslint keyword-spacing: 0*/
/*eslint space-return-throw-case: 0*/
/*eslint semi: [1, "always"]*/
/**
* One to many relation
* @param {Array} parents
* @param {Array} children
* @param {String} field field to merge
* @param {String} pKey
* @param {String} cKey
* @return {Boolean}
*/
hasMany(parents = [], children = [], field = 'children', pKey = 'id', cKey = 'entry_id') {
@Piterden
Piterden / routes.php
Last active August 10, 2016 18:54
Laravel REST routes example
<?
Route::get('/authtest', array('before' => 'auth.basic', function()
{
return Response::json(array('result' => 'success', 'reason' => 'Logged In' ), 200);
}));
Route::get('/api', array('before' => 'auth.basic', function()
{
return Auth::getUser();
}));
Route::get('/prop', array('before' => 'auth.basic', function()
@Piterden
Piterden / Social.vue
Created July 31, 2016 05:14
Vue JS Social Comp
<template>
<div class="social-share">
<a @click.prevent="shareFacebook"><img :src="iconFacebook"></a>
<a @click.prevent="shareVkontakte"><img :src="iconVkontakte"></a>
<a @click.prevent="shareTwitter"><img :src="iconTwitter"></a>
</div>
</template>
<script>
export default {
@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)">
@Piterden
Piterden / Array.addBefore.js
Last active July 31, 2016 05:18
[ES6] Helper functions
/**
* Добавляет элемент в начало массива, сдвигая все индексы.
* Возвращает сам массив, а не новую длинну, как в unshift()
* @param {Mixed} val Значение нового элемента
* @return {Array}
*/
Array.prototype.addBefore = function(val) {
this.unshift(val);
return this;
@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 / .eslintrc.yaml
Created July 12, 2016 21:34
Eslint default config
parser: babel-eslint
rules:
indent:
- 2
- 2
quotes:
- 2
- single
linebreak-style:
- 2
root = true
[*]
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_size = 4