Skip to content

Instantly share code, notes, and snippets.

@dshster
dshster / after_res_hooks.js
Created January 1, 2018 18:09 — forked from pasupulaphani/after_res_hooks.js
Mongoose connection best practices
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 October 7, 2017 13:48
Yandex Maps random polygones
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 June 12, 2016 10:52
Append download link to instagram photos (userscript)
// ==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 March 4, 2016 18:31
Angular e2e with http mock
(function(application, dependencies) {
angular.module(application, dependencies);
})('application', []);
(function(application) {
angular.module(application)
.controller('SampleController', SampleController);
SampleController.$inject = ['$http'];
@dshster
dshster / application.js
Created February 16, 2016 13:07
Angular bootstrap
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 February 16, 2016 08:57
Webpack PostCSS bootstrap
var css = require('./styles.postcss');

Install:

npm install

Run:

gulp

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

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 February 11, 2015 21:01
Drag and drop, resize and xhr post
<!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>