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 result = navigator.userAgent.match(/(opera|chrome|safari|firefox|msie|trident)\/?\s*(\.?\d+(\.\d+)*)/i); | |
//output: ["Chrome/41.0.2272.76", "Chrome", "41.0.2272.76", ".76"] |
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
def out = System.out.&println | |
out "Haaa!" //Haa |
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 myClosure(name) { | |
var x = 0; | |
//private method | |
function doCount() { | |
console.log("Count " + name + ", count: " + x++); | |
} | |
//public | |
return { |
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
return function(scope, element, attrs) { | |
attrs.$observe('key', function(value) { | |
console.log('key=', value); | |
}); | |
} |
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 fruits = [ | |
{name:'apple', color:'red'}, | |
{name:'orange', color:'orange'}, | |
{name:'grape', color:'purple'} | |
]; | |
var hasFruit = function(fruitToCheck) { | |
return fruits.some(function(fruit) { | |
return fruit.name === fruitToCheck; | |
}); |
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
def "Should return the number of events for each month of all events"() { | |
given: | |
controller.eventService = Mock(EventService) { | |
historyReport() >> [ | |
"2012": ["eventCount" : 6, "monthlyCount" : ["December" : 4, "November" : 1, "January" : 1]], | |
"2011": ["eventCount" : 3, "monthlyCount" : ["October" : 3]] | |
] | |
} | |
when: |
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
package com.ericsson.tv.saas.portal | |
import org.hibernate.transform.AliasToEntityMapResultTransformer | |
class EventService { | |
def sessionFactory | |
def historyReport(currentUser) { | |
def report = [:] |
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
public class Todo { | |
def name | |
def note | |
public static void main(String[] args) { | |
def todos = [ | |
new Todo([name:'1', note:'One']), | |
new Todo([name:'2', note:'Two']), | |
new Todo([name:'3', note:'Three']), |
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
HTMLElement.prototype.remove = function() { | |
this.parentNode.removeChild(this); | |
}; | |
document.querySelector("#a").remove(); |
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
document.addEventListener('invalid', (function(){ | |
return function(e) { | |
//prevent the browser from showing default error bubble / hint | |
e.preventDefault(); | |
// optionally fire off some custom validation handler | |
// myValidation(); | |
}; | |
})(), true); |