Skip to content

Instantly share code, notes, and snippets.

Dmitry Shvalyov dshster

View GitHub Profile
@dshster
dshster / after_res_hooks.js
Created Jan 1, 2018 — forked from pasupulaphani/after_res_hooks.js
Mongoose connection best practices
View after_res_hooks.js
var db = mongoose.connect('mongodb://localhost:27017/DB');
// In middleware
app.use(function (req, res, next) {
// action after response
var afterResponse = function() {
logger.info({req: req}, "End request");
// any other clean ups
@dshster
dshster / application.js
Created Oct 7, 2017
Yandex Maps random polygones
View application.js
const margin = 200;
const theta = 0.2;
function getRandomCoords({ width, height }) {
return {
top: Math.random() * (width - margin) + margin / 2,
left: Math.random() * (height - margin) + margin / 2,
};
}
@dshster
dshster / InstagramImgDownload.js
Created Jun 12, 2016
Append download link to instagram photos (userscript)
View InstagramImgDownload.js
// ==UserScript==
// @name Instagram image in a new tab
// @namespace http://shvalyov.ru
// @version 0.1
// @description append download link to photos
// @author dshster
// @match https://www.instagram.com/*
// @grant none
// ==/UserScript==
@dshster
dshster / application.js
Created Mar 4, 2016
Angular e2e with http mock
View application.js
(function(application, dependencies) {
angular.module(application, dependencies);
})('application', []);
(function(application) {
angular.module(application)
.controller('SampleController', SampleController);
SampleController.$inject = ['$http'];
@dshster
dshster / application.js
Created Feb 16, 2016
Angular bootstrap
View application.js
var application = 'application';
angular.module(application, ['ngMockE2E']);
angular.module(application)
.controller('SampleController', function(SampleServices) {
var Sample = this;
SampleServices.getServerData().then(function(result) {
Sample.serverData = result;
@dshster
dshster / entry.js
Last active Feb 16, 2016
Webpack PostCSS bootstrap
View entry.js
var css = require('./styles.postcss');
View README.md

Install:

npm install

Run:

gulp

@dshster
dshster / application.js
Last active Aug 29, 2015
AngularJS backend-less development
View application.js
'use strict';
var application = 'application';
var dependences = ['ngMockE2E'];
angular.module(application, dependences)
.config(['$compileProvider', function($compileProvider) {
$compileProvider.debugInfoEnabled(false);
}])
View pseudo-elements.md

Styling native elements

Native HTML controls are a challenge to style. You can style any element in the web platform that uses Shadow DOM with a pseudo element ::pseudo-element or the /deep/ path selector.

video::webkit-media-controls-timeline {
  background-color: lime;
}

video /deep/ input[type=range] {
@dshster
dshster / index.html
Created Feb 11, 2015
Drag and drop, resize and xhr post
View index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="styles.css">
<title>Filereader</title>
</head>
<body>
<div id="dragarea" class="drag-area"></div>
You can’t perform that action at this time.