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 / 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 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,
};
}

Install:

npm install

Run:

gulp

@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');
@dshster
dshster / .bowerrc
Created February 9, 2015 19:55
gulp-bower-concat
{
"directory": "Scripts/Components"
}
@dshster
dshster / grid.svg
Created December 14, 2012 05:38 — forked from pepelsbey/grid.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dshster
dshster / grunt.js
Created November 21, 2012 18:43 — forked from vojtajina/grunt.js
Grunt script for inlining AngularJS templates
module.exports = function(grunt) {
grunt.initConfig({
inline: {
'index.html': ['tpl/*.html']
}
});
grunt.registerMultiTask('inline', 'Inline AngularJS templates into single file.', function() {
var SCRIPT = '<script type="text/ng-template" id="<%= id %>"><%= content %></script>\n';