Skip to content

Instantly share code, notes, and snippets.

View asvae's full-sized avatar

Yauheni Prakopchyk asvae

View GitHub Profile
@asvae
asvae / Array to HTML converter
Last active August 29, 2015 14:17
Readable HTML from array and pattern (mergeWithPattern)
class sf
{
/**
* Make readable text|html from array
*
* Example:
* $data = [1,2,3];
* $pattern = ['(',', ',')'];
* sf::mergeWithPattern($data, $pattern)
* // '(1, 2, 3)'
@asvae
asvae / gist:0e7dc5ce2fcba996995e
Created April 3, 2015 14:58
Ngrok nginx bash alias
function ngroka() {
if [[ "$1" ]]
then
ngrok -authtoken YOUR_TOKEN -subdomain $1 80
else
echo "Error: missing required parameter."
echo "Usage: ngrok subdomain"
fi
}
<?php
$folders = [
// 'admin',
// 'boards',
'cgi-bin',
// 'cron',
// 'css',
// 'helpers',
@asvae
asvae / gist:524afebb9dc7aec6e38e
Created July 10, 2015 11:22
Laravel database backup migration
class BackupOldTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
@asvae
asvae / colspan_max
Created September 13, 2015 15:45
Maximized colspan
<table>
<tr>
<td>Varying</td>
<td>number</td>
<td>of</td>
<td>columns</td>
</tr>
<tr>
<td colspan="42">One row to rule them all</td>
</tr>
<template>
<select name="name" class="form-control" v-model="value">
<option :value="null" :selected="value === null">{{noProgrammer}}
</option>
<option v-for="(user_id, user_name) in apiProgrammers.data"
:value="user_id" :selected="value == user_id"
v-text="user_name"></option>
</select>
</template>
function registerComponents (Vue, components) {
for (var index in components) {
Vue.component(index, components[index]);
}
};
function registerPartials (Vue, partials) {
for (var index in partials) {
Vue.partial(index, partials[index]);
}
Here's the usage example:
<vm-recaptcha :value.bind="form.recaptcha"></vm-recaptcha>
And you have to include cdn as always. This gist doesn't cover serverside.
<template>
<div :id="id" value=""></div>
</template>
<script>
import _ from 'lodash'
module.exports = function (Vue){
// Глобальные миксины.
Vue.mixin({
props: {
id: {
default: function (){
var component_name = _.kebabCase(this.constructor.name);
@asvae
asvae / gist:29a3bc6616df2ede74b2
Created January 14, 2016 20:22
Select country vue component
<template>
<div class="flag-container col-sm-12">
<div class="flag-icon" @click="clean">
<i class="fa fa-globe fa-2x"></i>
</div>
<template v-for="(id, selected) in countries">
<div class="flag-icon"
:selected="selected"
@click="toggleCountry(id)">
<vm-country-icon :country="id"></vm-country-icon>