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
var items = mori.vector(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); | |
var acc = 0; | |
var changedItems = mori.map(function (item) { | |
acc += item; | |
return item + acc; | |
}, items); | |
console.log(mori.toJs(mori.take(3, changedItems))); |
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 retryIter(f, promise, n) { | |
return promise.then( | |
function (res) { | |
return res; | |
}, | |
function (err) { | |
if (n === 0) { | |
return $q.reject(err); | |
} else { | |
return retryIter(f, f(), n - 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
// Example of behaviour of CGLIB spring wrapped Grails services. | |
// The default behaviour of a plain class is `static transactional = true`, a backwards compatible | |
// default that creates a CGLIB spring wrapped bean. | |
// When generating services with "grails create-service", it will be annotated with | |
// @grails.transaction.Transactional and have different behaviour. | |
class MyAService() { |
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
var fayeClient = new Faye.Client("/cometd"); | |
fayeClient.publish("/client_info", {username: APP_CONFIG.currentUserUsername, userAgent: navigator.userAgent}); | |
fayeClient.subscribe("/active_statuses", function (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
def init = { ServletContext servletContext -> | |
String cometdUrlMapping = "/cometd/*" | |
// This is the only way to let CometDServlet know about our bayeux instance | |
servletContext.setAttribute(BayeuxServer.ATTRIBUTE, bayeux) | |
bayeux.setOption("javax.servlet.ServletContext", servletContext) | |
bayeux.setOption("ws.cometdURLMapping", cometdUrlMapping) | |
CometDServlet cometDServlet = new CometDServlet() | |
ServletRegistration cometDServletRegistration = servletContext.addServlet("cometd", cometDServlet) | |
cometDServletRegistration.setLoadOnStartup(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
function isDesktop(msg) { | |
return /^[a-z]/.test(msg) | |
} | |
function isMobile(msg) { | |
return /^[A-Z]/.test(msg) | |
} |
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
var stopSlices = mori.pipeline(appState | |
function (it) { return mori.getIn(it, measureCursor.concat(["selectedStops"]))}, | |
mori.keys, | |
mori.sort, | |
function (it) { return mori.interleave(it, it); }, | |
function (it) { return mori.take((mori.count(it) * 2) - 1, it); }, | |
function (it) { return mori.into(mori.vector(0), it); }, | |
function (it) { return mori.partition(2, it); }); |
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
import javax.servlet.annotation.WebListener | |
import javax.servlet.ServletContextListener | |
import javax.servlet.ServletContextEvent | |
import org.springframework.web.context.support.GenericWebApplicationContext | |
import org.springframework.web.servlet.DispatcherServlet | |
@WebListener | |
class BootstrapWebApp implements ServletContextListener { | |
// This is the "programmatic web.xml" of the servlet 3.0 spec. This is annotation driven and |
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
CREATE TABLE STRETCH_STOP ( | |
id number(19, 0), | |
jbv_id varchar2(15 char), | |
parent_stop_id number(19, 0), | |
duration number(10, 0), | |
note varchar2(4000 char) | |
); | |
CREATE TABLE PLAN ( |
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
class MyService { | |
private final ThreadPoolExecutor myExecutor = new ThreadPoolExecutor( | |
1, 1, | |
0L, TimeUnit.MILLISECONDS, | |
new LinkedBlockingQueue<Runnable>()) | |
Map valueCache = [:] | |
def getCachedValue() { | |
myExecutor.submit({ |