Skip to content

Instantly share code, notes, and snippets.

View rubentd's full-sized avatar

Ruben Torres rubentd

View GitHub Profile
// Exclude items with forbidden words
const filterItems = (items, forbiddenWords) => {
return items.filter((item) => {
return forbiddenWords.reduce((acceptable, term) => {
return (
(item.title + item.description + item.author).toLowerCase().indexOf(term) == -1 && acceptable
);
}, true);
});
}
describe('spider', function() {
describe('filterItems()', function() {
it('should remove the second item, cause it has a forbidden word', function() {
items = [
{
title: 'Redux rules',
description: 'Redux is the best, you might not need it tho',
author: 'Dan Abramov'
},
{
// Exclude items with forbidden words
const filterItems = (items) => {
items.forEach((item, i) => {
config.forbiddenTerms.forEach((term) => {
if((item.title + item.description + item.author).toLowerCase().indexOf(term) != -1){
// contains forbidden word
items.splice(i, 1);
}
})
})
//Static resources server
app.use(express.static(__dirname + '/www'));
var server = app.listen(8082, function () {
var port = server.address().port;
console.log('Server running at port %s', port);
});
var io = require('socket.io')(server);
setInterval(function(){
g.mainLoop();
}, INTERVAL);
mainLoop: function(){
if(this.localTank != undefined){
this.sendData(); //send data to server about local tank
}
if(this.localTank != undefined){
@rubentd
rubentd / client-server.js
Last active August 29, 2015 14:16
tanks-server-client
client.on('joinGame', function(tank){
console.log(tank.id + ' joined the game');
var initX = getRandomInt(40, 900);
var initY = getRandomInt(40, 500);
client.emit('addTank', { id: tank.id, type: tank.type, isLocal: true, x: initX, y: initY, hp: TANK_INIT_HP });
client.broadcast.emit('addTank', { id: tank.id, type: tank.type, isLocal: false, x: initX, y: initY, hp: TANK_INIT_HP} );
game.addTank({ id: tank.id, type: tank.type, hp: TANK_INIT_HP});
});
$("#form-id").dirrty("isDirty");
<script src="../js/jquery.dirrty.js"></script>
<script>
$("#my-form").dirrty({
onDirty: function(){
$("#status").html("dirty");
$("#save").removeAttr("disabled");
$("#status").removeClass("clean");
},
onClean: function(){
$("#status").html("clean");
/**
* Cubeman
*/
#cubeman{
margin-top:100px;
}
#spiderman{
margin-top:200px;
//BASE:
@head-width:50px;
@head-height:60px;
@head-depth:50px;
@body-width:25px;
@body-height:40px;
@body-depth:25px;