Skip to content

Instantly share code, notes, and snippets.

ScreenRouter = Backbone.Router.extend(
routes:
"" : "index"
":page": "page"
index: ->
@.navigate("#scores")
page: (page) ->
Session.set('currentPage', page)
# expose a list of players
Template.scores.players = ->
return Objects.find({type: 'player'}, sort: sortOrder()).fetch().slice(0,Session.get('page_size'))
# expose a user object
Template.profile.user = ->
return Objects.findOne({type: 'user'})
@tsgautier
tsgautier / run.js
Created October 26, 2012 17:44
Test runner for Mocha inside Meteor
proc.on('exit', function (code, signal) {
if (signal) {
log_to_clients({'exit': 'Exited from signal: ' + signal});
} else {
log_to_clients({'exit': 'Exited with code: ' + code});
if (code >= 40) process.exit(code - 40);
}
on_exit_callback();
});
@tsgautier
tsgautier / application.coffee
Created November 21, 2012 21:12
auto-refresh in an express/angular project
watcher.watch __dirname + '/../public'
watcher.watch __dirname + '/../views'
io.sockets.on 'connection', (socket) ->
watcher.on 'changed', -> socket.emit 'cmd:refresh'
@tsgautier
tsgautier / jquery.spin.js
Created November 22, 2012 17:56 — forked from innotekservices/jquery.spin.js
jQuery Plugin for Spin.js
/*
You can now create a spinner using any of the variants below:
$("#el").spin(); // Produces default Spinner using the text color of #el.
$("#el").spin("small"); // Produces a 'small' Spinner using the text color of #el.
$("#el").spin("large", "white"); // Produces a 'large' Spinner in white (or any valid CSS color).
$("#el").spin({ ... }); // Produces a Spinner using your custom settings.
$("#el").spin(false); // Kills the spinner.
series = _.map instances, (name) => (done) =>
return done "no node defined with name #{name}" unless configuration.config.nodes[name]
configuration.config.nodes[name].name = name;
parallel = _.map [0..env.instances[name].qty-1], (i) => (done) =>
if env.state == "disabled"
logger.info "environment disabled, skipping node #{name}"
return done()
if env.instances[name].state == "disabled"
@ContextConfiguration
@SpringBootTest(webEnvironment=SpringBootTest.WebEnvironment.RANDOM_PORT)
@ExtendWith(SpringExtension.class)
public class WebClientTest {
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(WebClient.class);
private static final String BODY = "this is the body";
private static final String ENDPOINT = "endpoint";
@LocalServerPort
@ContextConfiguration
@SpringBootTest(webEnvironment=SpringBootTest.WebEnvironment.RANDOM_PORT)
@ExtendWith(SpringExtension.class)
public class WebClientTest {
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(WebClientTest.class);
private static final String BODY = "this is the body";
private static final String ENDPOINT = "endpoint";
private static final StringDecoder stringDecoder = StringDecoder.textPlainOnly(false);
@RestController
@SpringBootApplication
public class Application {
private static final int B_TO_KIB = 1024;
private static final int KIB_TO_MIB = 1024;
private final String chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
private final Random r = new Random();
private final Map<Long, Mono<String>> cached = new ConcurrentHashMap<>();