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
it('should save and find a tweet', async () => { | |
tweet.setFollowers(42); | |
tweet.setFriends(88); | |
const newTweet = await saveAndFind(tweet); | |
expect(newTweet.getFollowers()).to.eql(tweet.getFollowers()); | |
expect(newTweet.getFriends()).to.eql(tweet.getFriends()); | |
}); |
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
it('should save and find the followers', async () => { | |
tweet.setFollowers(42); | |
const newTweet = await saveAndFind(tweet); | |
expect(newTweet.getFollowers()).to.eql(tweet.getFollowers()); | |
}); | |
it('should save and find the friends', async () => { | |
tweet.setFriends(88); | |
const newTweet = await saveAndFind(tweet); | |
expect(newTweet.getFriends()).to.eql(tweet.getFriends()); | |
}); |
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
<script> | |
var source = new EventSource('/live'); | |
source.onmessage = function(event) { | |
console.log('Incoming date:' + event.data); | |
}; | |
</script> |
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
const http = require('http'); | |
const server = http.createServer(function (req, res) { | |
if (req.url === '/live') { | |
res.writeHead(200, { | |
'Content-Type': 'text/event-stream', | |
'Cache-Control': 'no-cache', | |
'Connection': 'keep-alive' | |
}); | |
res.write('retry: 5000\n'); |
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
<script src="/socket.io/socket.io.js"></script> | |
<script> | |
const socket = io('http://localhost:3000'); | |
socket.on('tic', (data) => { | |
console.log(data); | |
data.seconds++; | |
socket.emit('tac', data); | |
}); | |
</script> |
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
const http = require('http'); | |
const SocketIO = require('socket.io') | |
const server = http.createServer(function (req, res) { | |
... | |
}); | |
const io = SocketIO(server); | |
io.on('connection', (socket) => { | |
socket.emit('tic', { seconds: 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
# Turn a List<> into String[] | |
String[] strings = list.stream().toArray(String[]::new); | |
# Reduce by collecting over a field | |
list.stream().collect(Collectors.mapping( | |
Person::getName, | |
Collectors.toList())), | |
# Run several tasks asynchronously and wait for them | |
CompletableFuture<Map<String, List<String>>> campaignsByGeohashWithLocationsFuture = |
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
### Clone collection from remote host | |
mongo | |
use <database> | |
db.cloneCollection("remote.host:27017", "<collection>") |
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 groups =_.groupBy(categories, _.curry(_.has)(_, 'id')); |
NewerOlder