This file contains hidden or 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
String.prototype.manualLowercase = function(s) { | |
return (typeof s === 'string') ? s.replace(/[A-Z]/g, function (ch) { | |
return String.fromCharCode(ch.charCodeAt(0) | 32) | |
}) : s; | |
}; | |
String.prototype.manualUppercase = function (s) { | |
return (typeof s === 'string') ? s.replace(/[a-z]/g, function (ch) { | |
return String.fromCharCode(ch.charCodeAt(0) & ~32) | |
}) : s; |
This file contains hidden or 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('myApp') | |
.directive('capitalize', function () { | |
return { | |
require: 'ngModel', | |
link: function(scope, element, attrs, modelCtrl) { | |
var capitalize = function(inputValue) { | |
if(angular.isDefined(inputValue)) { | |
var capitalized = inputValue.toUpperCase(); | |
if(capitalized !== inputValue) { | |
modelCtrl.$setViewValue(capitalized); |
This file contains hidden or 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
.filter('bold', function() { | |
return function(str, object) { | |
return String(str).replace(new RegExp('(^|\\s)(' + object.value + ')(\\s|$)', 'ig'), '$1<b>$2</b>$3'); | |
}; | |
}) |
This file contains hidden or 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.properApply = function(callback) { | |
var phase = this.$root.$$phase; | |
if(phase !== '$apply' && phase !== '$digest') { | |
$scope.$apply(callback); | |
} | |
}; |
This file contains hidden or 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 bin2hex (s) { | |
// From: http://phpjs.org/functions | |
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) | |
// + bugfixed by: Onno Marsman | |
// + bugfixed by: Linuxworld | |
// + improved by: ntoniazzi (http://phpjs.org/functions/bin2hex:361#comment_177616) | |
// * example 1: bin2hex('Kev'); | |
// * returns 1: '4b6576' | |
// * example 2: bin2hex(String.fromCharCode(0x00)); | |
// * returns 2: '00' |
This file contains hidden or 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
// start |
This file contains hidden or 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
var originalTarget = event.target || event.srcElement || event.originalTarget; |
This file contains hidden or 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
<?php | |
public function getStandardOffsetUTC($timezone) | |
{ | |
if($timezone == 'UTC') { | |
return ''; | |
} else { | |
$timezone = new DateTimeZone($timezone); | |
$transitions = array_slice($timezone->getTransitions(), -3, null, true); |
This file contains hidden or 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
var screenshotUrl = 'http://example.com/' | |
var casper = require("casper").create({ | |
viewportSize: { | |
width: 1024, | |
height: 768 | |
} | |
}); | |
if (casper.cli.args.length < 1) { |
This file contains hidden or 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 countCSSRules() { | |
var results = '', | |
log = ''; | |
if (!document.styleSheets) { | |
return; | |
} | |
for (var i = 0; i < document.styleSheets.length; i++) { | |
countSheet(document.styleSheets[i]); | |
} | |
function countSheet(sheet) { |