Skip to content

Instantly share code, notes, and snippets.

View codev0's full-sized avatar
💪
Harder, Better, Faster, Stronger

Airat Zhanshuakov codev0

💪
Harder, Better, Faster, Stronger
View GitHub Profile
@codev0
codev0 / gist:79a2a49666f1534d8bba
Created March 15, 2016 19:50 — forked from belsrc/gist:672b75d1f89a9a5c192c
Simple Vue.js filters that I usually need
/**
* Changes value to past tense.
* Simple filter does not support irregular verbs such as eat-ate, fly-flew, etc.
* http://jsfiddle.net/bryan_k/0xczme2r/
*
* @param {String} value The value string.
*/
Vue.filter('past-tense', function(value) {
// Slightly follows http://www.oxforddictionaries.com/us/words/verb-tenses-adding-ed-and-ing
var vowels = ['a', 'e', 'i', 'o', 'u'];
@codev0
codev0 / default-csrf.js
Created September 7, 2017 19:30 — forked from nathanharper/default-csrf.js
axios default CSRF Token
let csrfToken = 'lololololol';
let axiosDefaults = require('axios/lib/defaults');
axiosDefaults.headers.common['X-CSRF-Token'] = csrfToken;
@codev0
codev0 / node.twig.html
Created December 11, 2017 19:43 — forked from leahtard/node.twig.html
Get file url in node for Drupal 8 twig template
{# Get URL of single file field #}
{{ node.field_file.entity.uri.value }}
{# Get URL of multi file field #}
{{ node.field_file['#items'].entity.uri.value }}
{# Trun into link #}
{{ file_url(node.field_file.entity.uri.value) }}
{# Check if there is at least one value #}
@codev0
codev0 / steps.md
Created January 18, 2018 18:28 — forked from travisvalentine/steps.md
Setup Facebook app to test authentication locally (aka, setting up App Domain)

Note: I had issues with setting up my Facebook app so authentication would work. I'd receive the error at the bottom, and it took me a while to figure out what was wrong

Here are the steps I took:

  • Go to http://developers.facebook.com/, create, and setup your app
  • When inside the dashboard, click "Settings"
  • Click "Add Platform"
  • Choose website (for authentication via the web app)
  • Add http://localhost:3000/ as "Site URL" (and "Mobile URL" if necessary)
  • Add localhost to "App Domains" above
@codev0
codev0 / restful.js
Created February 5, 2018 04:18 — forked from BinaryMuse/restful.js
Express API with Async/Await
import express from "express";
/**
* Takes a route handling function and returns a function
* that wraps it after first checking that the strings in
* `reserved` are not part of `req.body`. Used for ensuring
* create and update requests do not overwrite server-generated
* values.
*/
function checkReservedParams(routeHandler, ...reserved) {
@codev0
codev0 / node-folder-structure-options.md
Created March 27, 2018 20:27 — forked from lancejpollard/node-folder-structure-options.md
What is your folder-structure preference for a large-scale Node.js project?

What is your folder-structure preference for a large-scale Node.js project?

0: Starting from Rails

This is the reference point. All the other options are based off this.

|-- app
|   |-- controllers
|   |   |-- admin
@codev0
codev0 / Event-Module.markdown
Created June 3, 2018 15:05 — forked from zakirt/Event-Module.markdown
Event - JavaScript module handling addition/removal of multiple events

JavaScript Event Handling Module

A JavaScript module allowing addition and removal of multiple events and callback handlers. Its most useful feature is the ability to keep track of attached event handlers. Multiple event handlers can be attached and removed to/from a specific event. The module allows removal of all event listeners at the same time for a specific event, or all listeners for all events, if the user so desires.

  • Can be used with collections, or with a single DOM object.
  • Works on older browsers.

This module was inspired by this answer at Stack Overflow: http://stackoverflow.com/a/4386514

A simple example using Event module can be seen here: http://codepen.io/zakirt/pen/tjkEg

@codev0
codev0 / RestController.php
Created November 1, 2018 13:54 — forked from cherifGsoul/RestController.php
Yii simple rest controller exemple
<?php
/**
* Controller is the customized base controller class.
* All controller classes for this application should extend from this base class.
*/
class RestController extends CController
{
/**
* @var string the default layout for the controller view. Defaults to '//layouts/column1',
* meaning using a single column layout. See 'protected/views/layouts/column1.php'.

Install Mongo with WSL for Windows.

Home

This doc will guide you through installing Mongo DB using WSL through the Command Line.

Most of the steps are listed out here, but this guide will trim them down and make it more straight forward for our needs. There is also 1 step that is not in the link above as well, which will be noted when we come across it.

Install MongoDB Community Edition.

  1. Follow the directions listed on the mongodb official website for your distro of choice.