Posts

typescript - Header files for Mongoose' 'plugin' method (extending via .methods and .statics) -

i'm trying create typescript header files script extends mongoose-model using .plugin method. current signature mongoose header-files : export class schema { // ... plugin(plugin: (schema: schema, options?: object) => void, options?: object): schema; // ... } some actual code mongoose-lib : /** * registers plugin schema. * * @param {function} plugin callback * @param {object} [opts] * @see plugins * @api public */ schema.prototype.plugin = function (fn, opts) { fn(this, opts); return this; }; then own model, extending plugin ; import passportlocalmongoose = require('passport-local-mongoose') // ... var userschema = new mongoose.schema({ email: string, password: string, }); // ... userschema.plugin(passportlocalmongoose, { usernamefield: "email", usernamelowercase: true }); snippet passport-local-mongoose source: module.exports = function(schema, options) { // ... schema.method...

javascript - Custom HTML tags and CSS -

Image
i using custom html tag <spin-loader> encapsulates css styles , few div s form windows 8 loading spinner: it uses shadowdom (as seen in image) hide div s client , allow them use 1 tag complex element (no additional js, css or html). happen able use css on element change styles/features in controlled manner; background-color , example, change background of circles ( div s), , increasing width increase size of circles too. possible? edit: forgot mention css styles (such background shown in picture) don't work anyway. here's link spinner: http://cryptolight.cf/curve.html explanation your spin-loader tag has 0 sizing due root div child having no children give size. remember, gave div s position: absolute property. therefore, looking @ flying div s outside of spin-loader tag. try, <spin-loader style="display:inline-block; overflow:hidden; position:relative;"> and you'll see mean. solution here's how style them, ...

javascript - Kendo MVVM Grid export all pages in pdf -

i found kendo grid exporting pages javascript code $("#grid").kendogrid({ toolbar: ["pdf"], pdf: { allpages: true, filename: "kendo ui grid export.pdf", //optional proxyurl: "http://demos.telerik.com/kendo-ui/service/export" //optional }, ..... it exports pages of grid how use allpages setting in mvvm grid like <div data-role="grid" data-editable="false" data-columns="[ .... ]" data-selectable="false" data-bind="source: datasource" data-row-template="row-template" data-alt-row-template="alt-row-template" data-pageable="{ refresh: true, pagesizes: [50, 100] }" ...

vector - Convert worldcoordinates to screen coordinates -

how can convert 3d vector 2d vector can drawn on screen? have camera position, positon of 3d point, vertical , horizontal rotation of camera, screen resolution , field of view. heard world screen function not know how use it. there way using maths? thx. in advance. mate. question not of simple answer. explain maths if remembered. it's been time since don't study linear algebra. first, methods call uses math looking for, , optimized! but, regarding questions maths behind it, here link: https://en.wikipedia.org/wiki/3d_projection this "3d vector 2d vector screen point" called projection, , referring perspective projection. explained in link. if interested in learning it, should first study linear algebra, , start studying computer graphics. (one book: http://www.amazon.com/gp/product/0321399528/ref=as_li_qf_sp_asin_tl?ie=utf8&camp=1789&creative=9325&creativeasin=0321399528&linkcode=as2&tag=casueffe06-20 )

url rewriting - How to do URL Rewrite in Zuul Proxy? -

one of request comes zuul filter of uri /hello/world want redirect /myapp/test . /myapp/test service registered in eureka. zuul: routes: xyz: path: /hello/world url: http://localhost:1234/myapp/test stripprefix: true when try above configuration, incoming uri suffixed configured url http://localhost:1234/myapp/test/world . few of links came across seem stating url rewrite feature not yet available in zuul. is there other way can done @ zuul layer ? note : @ point of time, cannot reverse proxying in webserver or other layer since, zuul filter 1 receiving request directly. have tried creating pre filter or route filter ? that way can intercept request, , change routing. see zuul filters

Webm HTML5 doesn't seem to be compatable with IOS safari -

i'm struggling understand why wouldn't supported. snippet follows: <video autobuffer="autobuffer" autoplay="autoplay" class="maskfill" loop="loop" src="/videos/maskfill.webm" type="video/webm; codecs=vp8,vorbis"></video> is there official reason this? or there recommended alternative? i've considered moving them on mp4 i'm doubtful of lack of compression. the answer simple: it not supported . reason ios can hardware decoding of few codecs (typically h.264 profiles). so, recommended alternative use h.264 .

java - Using Mockito to mock a class method inside another class -

i'm trying write unit tests mockito / junit function this: class1 { method { object1 = class2.method // method want fake return value // code still want run } } is there way in mockito stub result of class2.method? i'm trying improve code coverage class1 need call real production methods. i looked mockito api @ spy method overwrite whole method , not part want. i think understanding question. let me re-phrase, have function trying test , want mock results of function called within function, in different class. have handled in following way. public myunittest { private static final myclass2 class2 = mock(myclass2.class); @begin public void setuptests() { when(class2.get(1000)).thenreturn(new user(1000, "john")); when(class2.validateobject(anyobj()).thenreturn(true); } @test public void testfunctioncall() { string out = myclass.functioncall(); assertthat(out).isequalto("output...