Skip to content

Instantly share code, notes, and snippets.

View volosgoto's full-sized avatar
😄
Fear is the path to the dark side.

Andrey volosgoto

😄
Fear is the path to the dark side.
View GitHub Profile
const mongoose = require('mongoose');
const validator = require('validator');
mongoose.connect('mongodb://127.0.0.1:27017/task-manager-api', {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
});
// const User = mongoose.model('User', {
const mongodb = require('mongodb');
const MongoClient = mongodb.MongoClient;
const connectionURL = 'mongodb://127.0.0.1:27017';
const databaseName = 'task-manager';
MongoClient.connect(
connectionURL,
{
useNewUrlParser: true,
let i = 0;
let intervalId = setInterval(() => {
if (i === 10) {
clearInterval(intervalId);
}
// or
// if (i === 10) {
// return;
// }
let max_of_array = Math.max.apply(Math, array);
@volosgoto
volosgoto / PHP default version on Apache
Created June 6, 2019 09:05
PHP default version on Apache
/etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/html
ServerName example.com
ServerAlias www.example.com
<Directory /var/www/html/wordpress/>
@volosgoto
volosgoto / Debug CSS
Last active May 30, 2019 07:25
Debug CSS
/*! debug.css | MIT License | https://gist.github.com/zaydek/6b2e55258734deabbd2b4a284321d6f6 */
// Declaration inside file
<style>
[debug], [debug] *:not(g):not(path) {
color: hsla(210, 100%, 100%, 0.9) !important;
background: hsla(210, 100%, 50%, 0.5) !important;
outline: solid 0.25rem hsla(210, 100%, 100%, 0.5) !important;
@volosgoto
volosgoto / async - await
Last active June 4, 2019 08:53
async / await
async function loadJson(url) {
let response = await fetch(url);
if (response.status == 200) {
let json = await response.json();
return json;
}
throw new Error(response.status);
}
https://marketplace.visualstudio.com/items?itemName=sdras.vue-vscode-extensionpack
Vetur
Vue 2 Snippets
vscode-material-ui-snippets
Vue Peek
Vue.js Extension Pack (https://marketplace.visualstudio.com/items?itemName=mubaidr.vuejs-extension-pack)
Install CLI
@volosgoto
volosgoto / RegExp functions
Last active June 4, 2019 08:54
RexExp functions
// let re = /hello/;
// let re = /hello/i;
// let re = /hello/g;
// i - 'case insensitive'
// g - 'search all matches'
// console.log(re);
// console.log(re.source);
@volosgoto
volosgoto / redux_store
Last active June 4, 2019 09:01
redux_store.js
import { createStore, applyMiddleware, compose } from "redux";
import thunk from "redux-thunk";
import rootReducer from "./reducers";
const initialState = {};
const middleware = [thunk];
const store = createStore(
rootReducer,