Posts

Can ActiveAdmin serve individual javascript files in development via Rails asset pipeline? -

i've configured activeadmin include own javascript, following these instructions active admin: including javascript . in initializers/active_admin.rb : config.register_javascript 'application.js.coffee' but 1 massive precompiled application.js served me (application.js.coffee require s many small files); in development mode when visit active admin pages. still want individual javascript files served individually easier debugging. there way this? put in development.rb : config.assets.debug = false

x11 - What Mechanism does compiz use when copying from a xclient's frontbuffer to the backbuffer of root window? -

what mechanism compiz use when copying xclient's frontbuffer backbuffer of root window? i can't seem find procedure in compiz source. there function calls whenever xclient's window' frontbuffer updated update root backbuffer? copiz uses x composite extension redirect windows offscreen pixmap. uses glx_ext_texture_from_pixmap extension glx/opengl transfer offscreen pixmaps opengl textures. for composition composite enabled x server provides special composite window layer, placed between root window (and windows of root window parent) , screen saver layer. compiz creates window in composite layer, creates opengl context window , performs composition using opengl drawing commands. there compositors don't use opengl. either use server side composition (which rather useless, except testing composite protocol itself) or use xrender drawing methods. technically x core drawing methods work, too, don't support transformations , scaling; things you...

c++ - Whats wrong with the following code -

i have written down code in c++ make words appear in array string input. doesn't works due overflow or something. compiler doesn't show error though. #include <iostream> #include <stdio.h> #include <string.h> using namespace std; int main() { char a[100]; gets(a); char b[100][100]; int i=0; for(int j=0;j<strlen(a);j++) //runs loop words { int k=0; { b[i][k]=a[j]; k++; } while(a[j]!=' '); i++; } cout<<b[0][0]; return 0; } if you're going use c strings, need add null terminator @ end of each string do { b[i][k]=a[j]; k++; } while(j+k<strlen(a) && a[j+k]!=' '); b[i][k] = '\0'; as ppeterka noted, need change loop exit condition avoid infinite loop. note repeated calls strlen here , in code wasteful. should consider calculating once before for loop instead. ...

javascript - Call variable number of functions in parallel? -

using async.parallel or custom control flow, arr = [1, 2, 3, 4, 5, 3, 2, 3, 4, 5] //arr length get_something = function(num, cb){ async_io(num, function (err, results){ cb() }); } i want run get_something() on each member of array in "parallel". when they're finished i'd callback called results. without async : var n = arr.length, results = new array(n), oneisdone = function(index, result){ results[index] = result; if (--n===0) callback(results); } arr.foreach(function(val i){ get_something(val, function(result){ oneisdone(i, result); }); }); with async : using async supposes asynchronous function accepts callback returning error first argument , result second, final callback : async.parallel(arr, get_something, callback); if functions don't follow norm, you'll have make ugly wrappings.

objective c - NSDate. Creating new date with same time -

i have existing nsdate object represents date , time of event. task make copying function of existing event other date attributes except day , month(but saving of hours , minutes). see nsdate documentation here no direct method this. can add few days standard methods or nsdatecomponents new date set calendar, not adding or substracting quantity days. is right way extract "hh:mm" string previous date, set formatted string , convert new nsdate? converting , string not best way. suggestion make nsdatecomponents date. can set month , day directly, , convert date.

html - Bootstrap 3 Overlap -

i using bootstrap 3 , these 2 grids i'm using in js fiddle demo below stack on top of each other instead of overlapping. <div class="col-xs-12 col-md-8"> overlaps on <div class="col-xs-6 col-md-4"> i need them stack on each other ""nav nav-pills nav-stacked" isn't hidden. js fiddle example demo here html code <div class="container"> <div class="row"> <div class="col-xs-6 col-md-4"> <ul class="nav nav-pills nav-stacked" style="max-width: 300px; background-color: #fff;"> <li class="active"> <a href="#">link1</a> </li> <li> <a href="#">link2</a> </li> <li> <a href="#">link3</a> </li> <li>...

ruby - Alternative to "rescue Exception" -

i unexpected errors on occasion such timeout errors, 503 errors, etc. there errors don't know may receive. can't account of them doing like: rescue timeout::error => e it's terrible idea rescue exception . what alternative use? want code rescue of them when there error; if there no error, need avoided. want able kill script not skip on syntax errors, etc. you can rescue standarderror , or rescue, same: rescue standarderror => e # or rescue => e you can see in following table exceptions rescued standarderror - note subset exception , , conceitually should errors ok catch. of course can have gems defines exception in wrong place, should not happen in well-developed gems. ruby exceptions http://rubylearning.com/images/exception.jpg i rescue exceptions know how handle, except when add in log/backtrace system consult errors later. if case, rescue standarderror