Skip to content

Instantly share code, notes, and snippets.

View VanDalkvist's full-sized avatar

Ivan VanDalkvist

  • Yandex
View GitHub Profile
@VanDalkvist
VanDalkvist / route.event.log.js
Created June 27, 2014 06:19
ui router: state events logging
$rootScope.$on('$stateChangeStart',function(event, toState, toParams, fromState, fromParams){
console.log('$stateChangeStart to '+toState.to+'- fired when the transition begins. toState,toParams : \n',toState, toParams);
});
$rootScope.$on('$stateChangeError',function(event, toState, toParams, fromState, fromParams){
console.log('$stateChangeError - fired when an error occurs during transition.');
console.log(arguments);
});
$rootScope.$on('$stateChangeSuccess',function(event, toState, toParams, fromState, fromParams){
console.log('$stateChangeSuccess to '+toState.name+'- fired once the state transition is complete.');
});
cd Packages/
git clone https://github.com/wbond/sublime_package_control.git "Package Control"
cd "Package Control"
git checkout python3
@VanDalkvist
VanDalkvist / Angular-experiments.txt
Last active August 29, 2015 14:03
Angular-experiments
http://andreev-artem.github.io/angular_experiments/index.html
ng-if
tb-tooltip - require jQuery, Bootstrap Tooltips component
ui-alerts
ui-checkbox
@VanDalkvist
VanDalkvist / tbTooltip.js
Last active August 29, 2015 14:03
Директива-обертка для Tooltip-а из Twitter Bootstrap (source - http://habrahabr.ru/post/164493/)
angular.module("ExperimentsModule", [])
.directive("tbTooltip", function(){
return function(scope, element, iAttrs) {
iAttrs.$observe('title', function(value) {
element.removeData('tooltip');
element.tooltip();
});
}
});
@VanDalkvist
VanDalkvist / uiSource.js
Last active August 29, 2015 14:03
Директива для подсветки кода (source - http://habrahabr.ru/post/164493/)
.directive('uiSource', function () {
return {
restrict: 'EA',
compile: function (elem) {
var escape = function(content) {
return content
.replace(/\&/g, '&')
.replace(/\</g, '<')
.replace(/\>/g, '>')
.replace(/"/g, '"');
@VanDalkvist
VanDalkvist / orderObjectBy.js
Last active August 29, 2015 14:04
OrderBy angular filter for objects
filter('orderObjectBy', function () {
return function (items, field, reverse) {
var filtered = [];
angular.forEach(items, function (item) {
filtered.push(item);
});
filtered.sort(function (a, b) {
return (a[field] > b[field] ? 1 : -1);
});
if (reverse) filtered.reverse();
@VanDalkvist
VanDalkvist / Utils.js
Last active August 29, 2015 14:04
some utils
.constant('Utils', (function () {
return {
addRange: function (dest, source, mapFunction) {
_.forEach(source, function (elem) {
dest.push(mapFunction ? mapFunction(elem) : elem);
});
},
resetMomentTime: function (moment) {
return moment.hour(0).minute(0).second(0).millisecond(0);
}
@VanDalkvist
VanDalkvist / iso8601.js
Last active August 29, 2015 14:05
iso8601 date regexp
var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
// 1 2 3 4 5 6 7 8 9 10 11
@VanDalkvist
VanDalkvist / map.js
Created August 30, 2014 11:52
map and merge arrays
function map(collection, callback) {
var index = -1,
length = collection ? collection.length : 0,
result = [];
if (angular.isArray(collection)) {
while (++index < length) {
var part = callback(collection[index], index, collection);
pushAll(result, part);
}
var underscore = require('underscore');
var underscoreStr = require('underscore.string');
var concat = require('gulp-concat');
var gulp = require('gulp');
var exclude = ['lib1', 'lib2'];
gulp.task('bundle-libraries-auto', ['bower'], function(){
var bowerFile = require('./bower.json');
var bowerPackages = bowerFile.dependencies;