Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Working from home

Stepan V styopdev

:octocat:
Working from home
  • Krakow, Poland
View GitHub Profile
@styopdev
styopdev / .htaccess
Created Mar 15, 2018
Angular .htaccess
View .htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) /index.html [NC,L]
@styopdev
styopdev / rotate-image.js
Created Nov 14, 2017
Image rotation by exif orientation using loadimage library.
View rotate-image.js
loadImage.parseMetaData(
file, (data) => {
if (!data.imageHead) {
return;
}
const orientation = data.exif ? data.exif[0x0112] : null;
if (orientation) {
loadImage(
@styopdev
styopdev / social-regexps.js
Created Oct 19, 2017
Social networks profiles validation regexps
View social-regexps.js
// Facebook
/((https?):\/\/)(www[.])?(mbasic.facebook|m\.facebook|facebook|fb)\.(com|me)\/(?:(?:\w\.)*#!\/)?(?:pages\/)?(?:[\w\-\.]*\/)*([\w\-\.]*)/ig,
// LinkedIn
/((https?):\/\/)(www[.])?linkedin\.com\/(in|company|groups)\/.?\/?.?\/?([0-9]*)/,
// Google+
/((https?):\/\/)(www[.])?plus\.google\.com\/u\/.?\/?.?\/?([0-9]*)/,
// Twitter
/((https?):\/\/)(?:www\.)?twitter\.com\/([a-zA-Z0-9_]+)/,
// IMDb
/(http:\/\/)(www[.])imdb\.com\/.?\/?.?\/?([0-9]*)/,
@styopdev
styopdev / loading.js
Created Jul 8, 2016
Node,js console loading
View loading.js
var startLoader = function () {
(function() {
process.stdout.write('Some text here...' + "\n");
var P = ["\\", "|", "/", "-"];
var x = 0;
return setInterval(function() {
process.stdout.write("\r" + P[x++]);
x &= 3;
}, 250).unref();
})();
@styopdev
styopdev / pick-schema.js
Last active Apr 24, 2020
Get mongoose schema fields, excluding specified values, for lodash.
View pick-schema.js
_.mixin({ pickSchema: function (model, excluded) {
var fields = [];
model.schema.eachPath(function (path) {
_.isArray(excluded) ? excluded.indexOf(path) < 0 ? fields.push(path) : false : path === excluded ? false : fields.push(path);
});
return fields;
}
});
// Example
View js-generate-random-color.txt
function getActivityColor(activityID) {
var color;
for (var key in activityColors) {
if (activityColors[key].activityID == activityID) {
color = activityColors[key].color;
break;
}
}
if (!color) {
var letters = '0123456789ABCDEF'.split('');
@styopdev
styopdev / isotope.txt
Created Jul 22, 2015
html/css/js Isotope grid example
View isotope.txt
<div class="grid">
<div class="grid-item grid-item--width2">1</div>
<div class="grid-item grid-item--height2">2</div>
<div class="grid-item">3</div>
<div class="grid-item">4</div>
<div class="grid-item grid-item--width2 grid-item--height2">5</div>
<div class="grid-item grid-item--width2">6</div>
<div class="grid-item grid-item--height2">7</div>
<div class="grid-item">8</div>
@styopdev
styopdev / background-fade.txt
Created Jul 21, 2015
Background image change with fade effect
View background-fade.txt
$(document).ready(function () {
var index = 1;
var coverIndex = 2;
var imagePath = "";
var coverImagePath = "";
var b = false;
setInterval(function () {
index = (index == 3 ? 1 : index + 1);