Skip to content

Instantly share code, notes, and snippets.

View MNBuyskih's full-sized avatar

Mihail Buyskih MNBuyskih

View GitHub Profile
@MNBuyskih
MNBuyskih / movie.styl
Created September 15, 2015 19:38
Example Stylus code
.video
background url('images/background.png') top center no-repeat
background-size cover
min-height 100%
padding-top 25px
.video-player
width 980px
max-width 100%
margin 0 auto
@MNBuyskih
MNBuyskih / movie.jade
Created September 15, 2015 19:30
Example Jade code
.video
.video-player
.player#player
.info
.info-info
span.info-item.info-quality(ng-if="movie.quality") {{movie.quality}}
span.info-item.info-duration {{movie.runtime}} min
span.info-item.info-lang Languages: {{movie.language}}
span.info-item.info-subtitles(ng-if="movie.subtitles") Subtitles: {{movie.subtitles}}
.info-tools
@MNBuyskih
MNBuyskih / siteAnalytics.js
Created September 15, 2015 19:24
Example JS code
/**
* Класс для аналитики вебмастера
* @param {{
* filterContainer: HTMLElement|String|jQuery
* tabsContainer: HTMLElement|String|jQuery
* dataUrl: String
* filtersUrl: String
* }} options Список параметров См. {@link AnalyticsAbstract.options}.
* @class
*/
[
{"name": "Afghanistan", "code": "AF"},
{"name": "Åland Islands", "code": "AX"},
{"name": "Albania", "code": "AL"},
{"name": "Algeria", "code": "DZ"},
{"name": "American Samoa", "code": "AS"},
{"name": "Andorra", "code": "AD"},
{"name": "Angola", "code": "AO"},
{"name": "Anguilla", "code": "AI"},
{"name": "Antarctica", "code": "AQ"},
@MNBuyskih
MNBuyskih / clone.coffee
Created September 1, 2015 11:43
Coffeescript deep object clone
clone = (obj) ->
return obj if not obj? or typeof obj isnt 'object'
return new Date(obj.getTime()) if obj instanceof Date
if obj instanceof RegExp
flags = ''
flags += 'g' if obj.global?
flags += 'i' if obj.ignoreCase?
flags += 'm' if obj.multiline?
@MNBuyskih
MNBuyskih / index.jade
Last active August 29, 2015 14:26
Basic Jade HTML5 template
doctype html
html(lang="en")
head
meta(charset="utf-8")
meta(http-equiv="X-UA-Compatible" content="IE=edge")
meta(name="viewport" content="width=device-width, initial-scale=1")
title Base Jade template
link(href="css/index.css" rel="stylesheet")
body
include _/head
@MNBuyskih
MNBuyskih / ucfirst.js
Created July 3, 2015 05:50
Capitalize first letter in string
/**
* Capitalize first letter in string
* Src is http://stackoverflow.com/a/1026087/1383927
*/
function ucfirst(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
@MNBuyskih
MNBuyskih / fail.js
Created June 1, 2015 11:11
Quick error handling function
function fail(errorCb, successCb, context) {
return function () {
var args = Array.prototype.slice.call(arguments),
isError = !!args[0];
((isError ? errorCb : successCb) || function () {
return arguments;
}).apply(context || null, isError ? args : args.splice(1));
};
}
@MNBuyskih
MNBuyskih / string-md5.js
Last active August 29, 2015 14:22
node js quick md5 string
// crypto = require('crypto')
crypto.createHash('md5').update('string').digest('hex');
function deepClone (obj, depth) {
var clone;
if (!obj || (typeof obj !== 'object')) {
clone = obj; // by value
} else if (_.isString(obj)) {
clone = String.prototype.slice.call(obj);
} else if (_.isDate(obj)) {
clone = new Date(obj.valueOf());
} else if (_.isFunction(obj.clone)) {