This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('Scope.safeApply', []) | |
.run(['$rootScope', function ($rootScope) { | |
$rootScope.$safeApply = function () { | |
var fn, phase = this.$root.$$phase; | |
if (arguments.length == 1) { | |
fn = arguments[0]; | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myApp.directive('capitalizeFirst', function($parse) { | |
return { | |
require: 'ngModel', | |
link: function(scope, element, attrs, modelCtrl) { | |
var capitalize = function(inputValue) { | |
if (inputValue === undefined) { inputValue = ''; } | |
var capitalized = inputValue.charAt(0).toUpperCase() + | |
inputValue.substring(1); | |
if(capitalized !== inputValue) { | |
modelCtrl.$setViewValue(capitalized); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(global){ | |
var testFunc = function testFunc(func){ | |
var start = new Date(); | |
func(); | |
return new Date() - start; | |
}, | |
speedTest = function speedTest(name, func){ | |
var numOfTimes = 1000, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.loadDependencies = function(arr){ | |
var deferred = $q.defer(); | |
var arrLen = arr.length,i = -1; | |
(function loadNext(){ | |
i++; | |
(i < arrLen) ? arr[i](loadNext) : deferred.resolve(); | |
})(); | |
return deferred.promise; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RussianPeasant { | |
public Static int product(int a, int b){ | |
int x = a; | |
int y = b; | |
int z = 0; | |
while(x > 0){ | |
if(x%2 == 1) z += y; | |
x = x >> 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* LinkedList.c | |
* | |
* Created on: 4 Nov 2015 | |
* Author: Alex | |
*/ | |
#include <stdlib.h> | |
#include <stdio.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Tree.c | |
* | |
* Created on: 5 Nov 2015 | |
* Author: Alex | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <unistd.h> | |
#include <stdlib.h> | |
int main(void) | |
{ | |
int fd = open("/dev/sdd", O_WRONLY); | |
if (fd < 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @name pushToTemplate | |
* @param template | |
* @param object | |
* @returns {object} | |
* @description will push the object onto the template | |
*/ | |
var pushToTemplate = function pushToTemplate(template, object){ | |
var result = angular.copy(template); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @name orderedInsert | |
* @param {Array} collection | |
* @param {String} key | |
* @param {Object | array} items - array of objects to insert | |
* @returns {promise} | |
* @description will insert an object into a sorted collection using a modified | |
* form of binary searching. it will also insert an array of objects if that is provided | |
* instead. | |
* @example |
OlderNewer