Skip to content

Instantly share code, notes, and snippets.

View oaleynik's full-sized avatar

Oleh Aleinyk oaleynik

  • CloudSpot
View GitHub Profile
@oaleynik
oaleynik / script.js
Last active December 15, 2015 17:59
Problem - defer function invokation till the full browser render and till the end of view-model synchronization cycle
var Ctrl = function ($scope, initAnchorScrolling) {
initAnchorScrolling($scope);
};
Ctrl.$inject = ['$scope', "initAnchorScrolling"];
applicationServices.factory("initAnchorScrolling",
['scroll', '$location', '$timeout', function(scrollUtils, $location, $timeout) {
return function(scope) {
var r = request.send(uri, options, function(e, res, body) {
if (e) {
// error in request
args.callback(e);
}
// What if 3xx status code? Correct: you will get response data wrapped into Error :))
else if (res.statusCode !== 200 && res.statusCode !== 201 && res.statusCode !== 202) {
// provide a default message when none is provided
body = body || 'server returned status code ' + res.statusCode;
@oaleynik
oaleynik / deepEqual_Mongoose.js
Created October 7, 2013 14:44
Deep Equality from Mongoose
exports.deepEqual = function deepEqual (a, b) {
if (a === b) return true;
if (a instanceof Date && b instanceof Date)
return a.getTime() === b.getTime();
if (a instanceof ObjectId && b instanceof ObjectId) {
return a.toString() === b.toString();
}
<?xml version = "1.0" encoding="Windows-1252" standalone="yes"?>
<VFPData>
<apisvar>
<nerrorno>1098</nerrorno>
<cerrmess>Ugyldig lisenskode i ProMed.</cerrmess>
<cprogline>Programmodul: settopppromedapi Linje: 3657</cprogline>
<cinfo>Programsti: c:\promed\ Datasti: c:\promed\ Tabell: DBFS Sortering: DBFS Filter: Reccount: 284 Recno: 78 EOF: .F.</cinfo>
</apisvar>
</VFPData>
<?xml version = "1.0" encoding="Windows-1252" standalone="yes"?>
<VFPData>
<apisvar>
<nuserid>101</nuserid>
<cname>Demo</cname>
<ctype/>
<cbrtype/>
<signatur>DEM</signatur>
</apisvar>
<apisvar>
angular.module('app', [])
.config(function($routeProvider) {
$routeProvider.when('/needsauth', {
// config for controller and view
resolve: {
'auth': function(AuthService) {
return AuthService.authenticate();
}
}
});
directivesModule
.directive('colorSource', [
function () {
var linkFn = function colorPickerLinkFn(scope, element, attrs, ctrl) {
element.colorpicker({
format: 'rgba'
}).on("changeColor", function cpChangeColorEventHandler(event) {
scope.$apply(function () {
var newColor = event.color.toRGB();
@oaleynik
oaleynik / directive.js
Created March 24, 2014 16:27
Passwords match directive
var myApp = angular.module('myApp', []).directive('uiValidateEquals', function() {
return {
restrict: 'A',
require: 'ngModel',
link: function(scope, elm, attrs, ctrl) {
function validateEqual(myValue, otherValue) {
if (myValue === otherValue) {
ctrl.$setValidity('equal', true);
@oaleynik
oaleynik / 0_reuse_code.js
Created July 4, 2014 11:00
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console