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
defaultSource = '//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'; | |
// just uncomment the library that you need ( and keep the others commented ) | |
// scriptSource = '//cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.1/lodash.min.js'; | |
// scriptSource = '//cdnjs.cloudflare.com/ajax/libs/angular.js/1.0.3/angular.min.js'; | |
// scriptSource = '//cdn.jsdelivr.net/sugar/1.3.9/sugar.min.js'; | |
// scriptSource = '//cdnjs.cloudflare.com/ajax/libs/zepto/1.0rc1/zepto.min.js'; |
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
// http://stackoverflow.com/questions/6690752/insert-html-at-cursor-in-a-contenteditable-div | |
function pasteHtmlAtCaret(html) { | |
var sel, range; | |
if (window.getSelection) { | |
// IE9 and non-IE | |
sel = window.getSelection(); | |
if (sel.getRangeAt && sel.rangeCount) { | |
range = sel.getRangeAt(0); | |
range.deleteContents(); |
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
window.requestAnimationFrame ||= | |
window.webkitRequestAnimationFrame || | |
window.mozRequestAnimationFrame || | |
window.oRequestAnimationFrame || | |
window.msRequestAnimationFrame || | |
(callback, element) -> | |
window.setTimeout( -> | |
callback(+new Date()) | |
, 1000 / 60) |
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
# http://stackoverflow.com/questions/9206013/javascript-fuzzy-search#answer-15252131 | |
String.prototype.fuzzy = (search) -> | |
return true unless search | |
str = @toLowerCase() | |
search = search.toLowerCase() | |
i = 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
app = angular.module('app',[]) | |
app.controller 'myCtrl1' , ['$scope','$http','$location', ($scope, $http,$location)-> | |
$scope.data = {} | |
] | |
app.controller 'myCtrl2' , ['$scope','$http','$location'].push ($scope, $http,$location)-> | |
$scope.data = {} |
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
app.directive 'markdownLink' , ($timeout)-> | |
restrict: 'EAC' | |
replace: true | |
link: (scope, element , attrs)-> | |
$timeout -> | |
$links = $(element).find('li') | |
$links.each (index, Element)-> |
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 sortByDependencies(array $array){ | |
$solved_dependencies = array(); | |
while(!empty($array)) | |
{ | |
$tmp_list = array(); | |
foreach ($array as $key => $dependencies) { | |
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
detectLanguage = -> | |
lang = undefined | |
lang = lang[1] if navigator and navigator.userAgent and (lang = navigator.userAgent.match(/android.*\W(\w\w)-(\w\w)\W/i)) | |
if not lang and navigator | |
if navigator.language | |
lang = navigator.language | |
else if navigator.browserLanguage | |
lang = navigator.browserLanguage | |
else if navigator.systemLanguage | |
lang = navigator.systemLanguage |
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
# <a ui-sref="mystate" ui-sref-class="active">link</a> | |
# | |
# whenever the current state is 'mystate' a class of 'active' will be added to the same element. | |
angular.module('ui-sref-class',[]) | |
.directive "uiSrefClass", -> | |
link: (scope, elm , attrs)-> | |
scope.$on '$stateChangeSuccess' , (event, toState)-> | |
if toState.name == attrs.uiSref | |
elm.addClass(attrs.uiSrefClass) |
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
<?php | |
preg_match('/^SQLSTATE\[\w+\]:[^:]+:\s*(\d*)\s*(.*)/', $error->getMessage(), $matches) || | |
preg_match('/^SQLSTATE\[\w+\]\s*\[(\d+)\]\s*(.*)/', $error->getMessage(), $matches); | |
$code = $matches[1] ?: "0" ; | |
$message = $matches[2]; |
OlderNewer