Posts

image - Can I add a poster to the audio player? -

i'd add poster audio player previews video mode of mediaelement.js player. i've checked shortcodes , there doesn't seem this. want static image above audio player visible before , during playing. the reason want 'all-in-one' player because wp theme allows me create posts in 'audio' format audio player appears @ top of category view of recent posts. it'd awesome add image each post , have part of audio player. kind of video less overhead. thanks in advance.

switch statement - How do I DRY up this Ruby code? -

here code: when 'jty' if j.type != "0" @color = allcolors.find { |c| c['type'] == j.type.to_s } clr << @color.color if @color else clr << @@default_map_marker_color end when 'jcat' if j.priority != "0" @color = allcolors.find { |c| c['type'] == j.priority.to_s } clr << @color.color if @color else clr << @@default_map_marker_color end i have 6 more when statements in case, , repeat part: clr << @color.color if @color over , over. hate it. here things need know: clr empty array initialize outside case statement, , case statement inside for loop that's going through lot of objects. it's looking color associated particular thing, , nosql-hack-ish way relational data. if like: def push_color clr << @color.color if @color end clr , @color aren't being passed around without params method. there's dislike passing para...

c++ - Nested class declaration: template vs non-template outer class -

i have c++ template class has nested class inside, like: template<int d> class outer_t { public: class inner; inner i; }; template<int d> class outer_t<d>::inner { public: float x; }; int main () { outer_t<3> o_t; // 3 or arbitrary int o_t.i.x = 1.0; return 0; } this compiles without problems. however, declare similar non-template class, this: class outer_1 { public: class inner; inner i; }; class outer_1::inner { public: float x; }; int main () { outer_1 o1; o1.i.x = 1.0; return 0; } i start getting following error (i'm using gcc 4.6.3): "error: field ‘i’ has incomplete type". know can remedy defining inner class inline, inside outer class: class outer_2 { public: class inner { public: float x; }; inner i; }; this compile, avoid defining nested class inline. have 2 questions: reason apparently odd discrepancy between template , non-template nested class de...

node.js - Using Express 4 how to redirect to my own route without losing req and response data? -

i have application structured 3 routes (api, admin, default). each lives in there own file , has it's own middleware , exports route. problem facing when want forward route lives on different router. want call same function not serving same view multiple locations. i don't want user res.redirect('/someplace') because want able pass req , res objects on method. |-app.js |-routes |---admin.js |---api.js |---default.js the routes required , used in app.js follows app.use('/api', require('./routes/api')(passport); app.use('/admin', require('./routes/admin')(passport); app.use('/', require('./routes/default')(passport); inside of admin if have situation need redirect login , pass data // authenticates routes admin router router.use(function(req, res, next){ if(req.isauthenticated()){ return next(); } res.flashmessage.push('session expired'); //is lost after redirect res.redi...

node.js - mongodb aggregation get the total number of matched document -

i have following sample docs saved in mongogb, like: { name: 'andy', age: 19, description: 'aaa aaa aaa' } { name: 'andy', age: 17, description: 'bbb bbb bbb' } { name: 'leo', age: 10, description: 'aaa aaa aaa' } { name: 'andy', age: 17, description: 'ccc ccc ccc' } what pipeline should total number of name in each of matched sets? can use sum number next pipe. pipeline have this: var pip = [ { $match: { name: 'andy' } } ] and want result like { name: 'andy', age: 19, description: 'aaa aaa aaa', total_andy: 3 } { name: 'andy', age: 17, description: 'bbb bbb bbb', total_andy: 3 } { name: 'andy', age: 17, description: 'ccc ccc ccc', total_andy: 3 } i not clear want. , don't have enough reputation ask in comment. let me have shot @ a...

hadoop - Flume - Tiering data flows using the Avro Source and Sink -

i'm attempting set simple tiered data flow using avro source/sink between 2 agents on different machines. the first agent on vm-host-01 node (called "agent") has netcat source, memory channel, , avro sink. the second agent on vm-host-02 node (called "collector" has avro source, memory channel, , hdfs sink. here config first agent "agent". agent.sources=s1 agent.channels=c1 agent.sinks=k1 agent.sources.s1.type=netcat agent.sources.s1.channels=c1 agent.sources.s1.bind=vm-host-01 agent.sources.s1.port=12345 agent.channels.c1.type=memory agent.sinks.k1.type=avro agent.sinks.k1.channel=c1 agent.sinks.k1.hostname=vm-host-02 agent.sinks.k1.port=42424 here config second agent "collector" on second machine: collector.sources=av1 collector.channels=c1 collector.sinks=k1 collector.sources.av1.type=avro collector.sources.av1.bind=vm-host-02 collector.sources.av1.port=42424 collector.sources.av1.channels=c1 collector.channels.c1....

javascript - backbone.js: Prevent listener event from firing when model changes -

i have following listener in view when model changed: this.listento(this.model, 'change', this.render); when change model : model.set('foo', bar); is possible make not trigger listener event specific function call? still want event trigger @ other calls. from fine manual : generally speaking, when calling function emits event ( model.set , collection.add , , on...), if you'd prevent event being triggered, may pass {silent: true} option. note rarely , perhaps never, idea. passing through specific flag in options event callback at, , choose ignore, work out better. so if don't want specific set call trigger change event then: model.set('foo', bar, { silent: true }); or tunnel information render using custom option: model.set('foot', bar, { ignore_this: true }); and adjust render : render: function(options) { if(options && options.ignore_this) return; // ... }