Posts

Showing posts from March, 2011

java - Spring RestController custom view resolver -

i've started implementing application using spring, , particularly making use of @restcontroller annotations. i've defined custom view resolver before normal controllers, i'm wondering how similar rest controller. i'm trying capture json before gets returned can pretty print it. i guess since it's not routing "view" view resolver wrong approach. should using? can use handlerinterceptor perhaps? how target @restcontroller annotated classes? your controller (most likely) ends returning object gets serialized json appropriate httpmessageconverter -- this one . as message converter writes json representation of returned object directly response output stream, need subclass mappingjackson2httpmessageconverter , overwrite writeinternal method chance apply custom logic around serialization. you'll need register custom converter instead of default 1 (or @ least before it). if post-processing can replaced customized serialization can h

actionscript 3 - Will Flash Builder let me build framework-less application? -

i want create pure as3 (without mxml) web application using flash builder. the problem don't want use flex framework nor airsdk - because rely on playerglobal.swc, , uicomponents exported fla swc. unfortunately, seems ide forces pick flex framework or airsdk. there way around this? look this: http://help.adobe.com/en_us/flashbuilder/using/wsc5cd04c102ae3e972ff2927b12e1411968f-7fff.html#wsc5cd04c102ae3e972ff2927b12e1411968f-7ff7 create actionscript projects create actionscript application web or desktop following these steps: select file > new > actionscript project. enter project name , location. default location current workspace. select either web or desktop application type. project uses air sdk 3.4 default. click check updates check , download updated version of air sdk if available. click next. specify build paths. more information, see build paths, native extensions, , other project configuration options. click finish. f

regex - How to get text of URL from notepad plus? -

i have text: 1135/how-are-you-86789/pp 1125/example-fran%c3%a7aise-86749/pp 1125/episode-6-movie-86749/pp can give me regex can text "something", please ?. so, ouput be: how-are-you example-fran%c3%a7aise episode-6-movie how like /[a-za-z]+(?:-[a-za-z]+)+/g regex demo edit 1 to replace contents, small change in regex ^(?:[^\/]+\/)?([a-za-z]+(?:-[a-za-z]+)+).*$/gm replaced \1 , capture group content regex demo edit 2 ^[^\/]+\/([^-\/\n]+(?:-[^-\/\n]+(?=-))+).*$ replace \1 regex demo

asp.net - Linq to SQL: select additional count -

i want select table add additional column holding count() of other rows in table. how can that? groupby not i'm looking think. want in sql: select *,(select count(*) tablename2 y=1) count tablename x = 1 i found solution: context.tablename.where(y>y.column.equals(1)) .select(x=>new{object=x,count = context.tablename2.count()}) will generate this: select *, (select count(*) tablename2) tablename tablename.y = 1

python - To use OpenCV/cv2 to compare and mark the difference between 2 images (with pictures) -

Image
i want use python , cv2 compare 2 images, below. (python 2.7 + windows) c:\original.jpg c:\edited.jpg pretty straight forward can below , save picture showing difference: import cv2 original = cv2.imread("c:\\original.jpg") edited = cv2.imread("c:\\edited.jpg") diff = cv2.subtract(original, edited) cv2.imwrite("c:\\diff.jpg", diff) the result like: c:\diff.jpg further, want difference shown in picture, based on files compared. in word, want have picture circle or mark difference, based on “edited.jpg”. possible? (thinking 1 of ways be, identify visible area in "diff.jpg", draw circle area in "edited.jpg"?) thanks micka's above. below added, , works. im = cv2.imread('c:\\diff.jpg') im1 = cv2.imread('c:\\edited.jpg') imgray = cv2.cvtcolor(im,cv2.color_bgr2gray) ret,thresh = cv2.threshold(imgray,127,255,0) contours, hierarchy = cv2.findcontours(thresh,cv2.retr_tree,cv2.chain_

internet explorer - SVG text element with whitespace not preserved in IE -

i want preserve white space in single svg < text> element. this works fine xml:space="preserve" attribute in text element in ie browser. <text x="0" y="15" fill="red" xml:space="preserve">i love svg!</text> here jsfiddle, try open fiddle in chrome/firefox , in latest ie, notice whitespace in text element text not preserved in ie. jsfiddle any workaround works in ie well? i guess replace each space &#160; (that's unicode non-breaking space character). in javascript written \u00a0 though.

java - Spring security does not work on server (google appengine) -

i have simple spring project works locally. urls intercepted spring security when upload same google appengine server, security fails work , assciated method instead executed. public class springsecutiryinitializer extends abstractsecuritywebapplicationinitializer { // nothing. initializes security chain. } public class springmvcinitializer extends abstractannotationconfigdispatcherservletinitializer { @override protected class<?>[] getrootconfigclasses() { return new class[] { appconfig.class, securityconfig.class }; } @override protected class<?>[] getservletconfigclasses() { return null; } @override protected string[] getservletmappings() { return new string[] { "/" }; } } @configuration @enablewebsecurity public class securityconfig extends websecurityconfigureradapter { @autowired environment env; @autowired datasource datasource; @autowired public void configure

How to check if Javascript is enabled or not in browser using PHP? -

this question has answer here: check if javascript enabled php 24 answers i need check server side if client machine javascript enabled or not. possible in php? if is, how? try using ajax client, if works javascript enabled with jquery can simply: $.ajax({ url: "/checkjavascript.php" }); if php receives call client javascript enabled in client

Java Casting in Method Overloading -

i have methods overloading such as: public int sum1(int a, int b) { int c= a+b; system.out.println("the method1"); return c; } public float sum1(int a, float b) { float c= a+b; system.out.println("the method2"); return c; } public double sum1(float a, float b) { double c= (double) a+b; system.out.println("the method3"); return c; } from main method, suppose have double x=10.10f; double y=10.20f; the apparent type x , y double, actual type float. when call system.out.println(" output :"+cc.sum1(x,y)); the error in compile-time. the method sum1(int, int) in type class not applicable arguments double, double). where should go sum1 (i.e. method3) casting double float tl;dr version of answer: variables of primitive types never have different type @ execution-time compile-time. (a double double , never float , etc.) overload resolution (picking method signature used) perf

javascript - Countdown don't stay run if close tabs -

i'm learning make countdown, , find guide on internet. when page closed countdown stops , if open page again countdown runs again, want make countdown continues run if page closed http://jsfiddle.net/fnsy4/ function setcookie(cname,cvalue,exdays) { var d = new date(); d.settime(d.gettime()+(exdays*24*60*60*1000)); var expires = "expires="+d.togmtstring(); document.cookie = cname + "=" + cvalue + "; " + expires; } function getcookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for(var i=0; i<ca.length; i++) { var c = ca[i].trim(); if (c.indexof(name)==0) return c.substring(name.length,c.length); } return ""; } //check existing cookie cook=getcookie("my_cookie"); if(cook==""){ //cookie not found, set seconds=60 var seconds = 60; }else{ seconds = cook; console.log(cook); } function secondpassed() { var minut

storyboard - Can you enter a constraint value with decimal in IB? -

Image
here hoping simple setting. i cannot enter constraint value decimals in ib. whenever enter value decimals , press enter, system rounds it! i don't have problem when creating constraints in code. in ib. is there way? yes, can. enter value "f" postfix this: click priority. notice how effective constraint value changes 0.5: hit esc

mongodb - Java server stopped working -

i have java server, know little java. develop company in html, css, js , js libraries, today unable start server again. each file has error, example, first 1 on 5 line, code import org.jongo.mongocollection; and says error `the import org.jongo cannot resolved` and dont know now. worked yesterday , lot of time before, have no need know more java , on. little company, works home, developer, created java server have no time till afternoon, try ask here, if similiar happens else. simply application not getting required classes, reason either lib files not present in class path. check class path. clean application.

Genie Effect Animation in Android -

Image
i have requirement of implementing genie effect animation shown below. reference: https://github.com/ciechan/bcgenieeffect i not understand start. can suggest me ideas? i tried code basic animation translation , scaling not succeed. i have implemented code game library andengine kindly find attached code below u move further.. can use code fragment ur android code or make instance of code , again extend activity reusing code. this zip file contain 2 project : code implementation above effect , andengine library u need add project . click here download code

css - applying css3 translate property -

i applied translate property link. translate-y(-50px); on hover , works fine. when hover mouse on image reverse animation when first time hover on it translate y -50px problem when mouse off it again translate y -50px; here code .nav{ background-color:red; padding:10px; font-size:20px; transition:0.5s all; margin-top:80px; } .nav:hover{ transform:translatey(-50px); } <html> <head></head> <body> <a href="#" class=nav>home</a> </body> </html> add parent fix issue , apply translate style when hover on parent .parent { border: 1px solid green; display: inline-block; } .nav { background-color: red; padding: 10px; font-size: 20px; transition: 0.5s all; display:block; } .parent:hover .nav { transform: translatey(-50px); } <div class="parent"> <a href="#" class=nav>home</a> </div>

python - 401 when trying to authenticate user in Eve flask framework -

i'm using awesome eve rest-framework creating crud api jwt authentication. i've looked @ tutorials posted here i'm receiving 401 error when doing post request endpoints require token auth. i've read question: issue python eve tokenauth feature i'm pretty sure token base64 encoded. this response i'm getting server when doing curl request: curl -h "authorization: <mytoken>" -i http://my_ip/users/548f6ecd64e6d12236c9576b ---- response ---- http/1.1 401 unauthorized server: nginx/1.4.6 (ubuntu) date: tue, 16 dec 2014 10:49:25 gmt content-type: application/json content-length: 91 connection: keep-alive www-authenticate: basic realm:"eve" {"_status": "err", "_error": {"message": "please provide proper credentials", "code": 401}} below code: app.py from eve import eve eve.auth import tokenauth import jwt class rolesauth(tokenauth): def check_auth(self, to

unity3d - What is the Object parameter in UnityEngine.Debug.Log(string, Object) for? -

Image
i've checked unityengine.debug.log method documentation cannot find use of second parameter object . have tried 1 of gameobjects , nothing particular happens, passing anything. still unuseful line unityengine.debug.log(object) wonder 1 use for? since haven't noticed merit find annoying. line unityengine.debug.log(object) space wasted in console. have twice number of rows in it. what parameter for? edit adam know!. object might become handy still think waste of space in console window. the documentation says 'context' debug message applies, perhaps isn't useful, hint @ use. connection makes between object , debug message can used locate object you're debugging, try double clicking on message in debug log see this.

python - scrapy crawl spider ajax pagination -

i trying scrap link has ajax call pagination. trying crawl http://www.demo.com link. , in .py file provided code restrict xpath , coding is: # -*- coding: utf-8 -*- import scrapy scrapy.contrib.linkextractors import linkextractor scrapy.contrib.spiders import sumspider, rule scrapy.selector import htmlxpathselector sum.items import sumitem class sumspider1(sumspider): name = 'sumdetailsurls' allowed_domains = ['sum.com'] start_urls = ['http://www.demo.com'] rules = ( rule(linkextractor(restrict_xpaths='.//ul[@id="pager"]/li[8]/a'), callback='parse_start_url', follow=true), ) #use parse_start_url if spider wants crawl first page , overriding def parse_start_url(self, response): print '********************************************1**********************************************' #//div[@class="showmorecars hide"]/a #.//ul[@id="pager"]/li[8]/a

javascript - Populate jqxDropDownList using ajax call (JSON) -

i populating "jqxdropdownlist" json data database, @ run time nothing displays in drop down. please me resolve this. the link refer, http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxdropdownlist/index.htm?(arctic)#demos/jqxdropdownlist/bindingtojson.htm using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; using system.web.services; using system.data; using system.collections; using system.web.ui.htmlcontrols; using system.io; using system.data.sqlclient; namespace jqwidgets { public partial class fromdb : system.web.ui.page { public class teaminfo { public int teamid { get; set; } public string teamname { get; set; } } public list<teaminfo> teaminformation { get; set; } [system.web.services.webmethod] public static list<teaminfo> loadteam() {

sql - using Transaction query in jsp page -

i use below query in jsp page. i'm not sure true use query in jsp page. int = st.executeupdate("'begin transaction declare @id [int] select @id = scope_identity() insert viewer(reserve_id, f_name, l_name, competition_id, city, phone, [e-mail]) values (@id, '" + fname + "','" + lname + "','" + 30 + "','" + city + "','" + phone + "','" + email + "' ) insert reservation_inf(reservation_date, competition_id, numberofticket, position_id) values ('" + dnow + "','" + 30 + "','" + 1 + "','" + 8 + "' ) commit transaction '" ); if (i > 0) { response.sendredirect("success.jsp"); } else { response.sendredirect("fail.jsp"); } it gives error : incorrect syntax near 'begin transaction declare @id [int] select @id = scope_identity() insert viewer(reserve_i

html - Changing the img src through javascript whilst src is stored in an array -

i'm trying change source of image on page load yet instead of image loading, string of it's location being displayed. simple solution cannot see it. <form id="form1"><h1 id="dude">question?</h1><br> <h2> <label ="answer1" id="label1"><img src="imgs//img.png" id="img1" width="150" height = "150"></label> <input type="radio" name="answer" id="answer1"> </h2><br> <h2> <label ="answer2" id="label2"><img src="imgs//img.png" id="img2" width="150" height = "150"></label> <input type="radio" name="answer" id="answer2">

javascript - Document.getElementById('Button').click(); not triggering Code-Behind -

i'm new coding javascript/vb.net , i'm having trouble making button2 onclick event fire. code-behind click event button1 in page.aspx.vb protected sub _lnbcomments_click(byval sender object, byval e system.eventargs) //some code needs run before opening modal page dim script string = "javascriptcode();" scriptmanager.registerstartupscript(me.upntoolbar, me.upntoolbar.gettype(), "commentsclick", script, true) end sub js file function showmodal(page,name,style){ var r = window.showmodaldialog(page,window,style); } function javascriptcode(){ var jsbutton = document.getelementbyid('ct100_sitecontent__hiddenbtncomments'); //i made sure clientid correct jsbutton.click() //this should trigger onclick event , open modalpage } page onload of page.aspx me._hiddenbtncomments.attributes.add("onclick","showmodal('somepage.aspx','somepage','somestyle')") the

d3.js - How to generate graphs and charts on the fly using web2py -

i getting data after firing databases. want generate basic graphs using data interpret results. read posts protovis helpful in achieving can't find content it. in ideal scenario use d3js generated data driven documents. here example of how use d3.js in web2py. works me using this d3.js sample book, interactive data visualizations web . add controller, controllers/d3js.py import random def histogram(): dataset = [(random.randint(1,6) + random.randint(1,6)) in range(100)] return dict(dataset=dataset, title='d3.js histogram') add view view/d3js/histogram.html contains d3.js code utilising dynamic features passed controller. <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>{{=title}}</title> <script type="text/javascript" src="https://d3js.org/d3.v3.min.js" ></script> </head> <body>

android - Facebook friendliest is not retrieving -

i using scrumptious documentation show friends using application. have followed tutorials here https://developers.facebook.com/docs/android/scrumptious/show-friends?locale=en_gb i have tried every combination not retrieving friends using application i have used 3 class scrumptious.java public class scrumptiousapplication extends application { private list<graphuser> selectedusers; public list<graphuser> getselectedusers() { return selectedusers; } public void setselectedusers(list<graphuser> selectedusers) { this.selectedusers = selectedusers; } } selectionfragment.java package com.example.facebooknew; import java.io.bytearrayinputstream; import java.io.bytearrayoutputstream; import java.io.ioexception; import java.io.objectinputstream; import java.io.objectoutputstream; import java.util.arraylist; import java.util.arrays; import java.util.list; import org.json.jsonarray; import org.json.jsonexception

c - Can't spot the error in Mergesort -

l & h corresponds indices of 1st & last elements in array a:- individual partition , merging functions working well. please explain error occurring in linking of 2 functions. #include <stdio.h> void mergesort(int a[], int l, int h); void merge (int a[], int l, int m, int h); int main () { int a[] = {5,4,9,0,8,6,1,3,2,7}, i; mergesort (a, 0, 5); (i = 0; < 10; i++) printf ("%d ", a[i]); return 0; } void mergesort(int a[], int l, int h) { if (l == h) return; int m = (l + h) / 2; mergesort (a, l, m); mergesort (a, m + 1, h); merge(a, l, m, h); } void merge (int a[], int l, int m, int h) { int t[h - l + 1], = l, j = m + 1, k = 0; while (i <= m && j <= h) { if (a[i] < a[j]){ t[k] = a[i]; k++; i++; } if (a[j] < a[i]) { t[k] = a[j]; j++; k++; } } if (i != m) { while

Bash doesn't end the loop despite pipeline is broken -

the simple script: while [ 1 ]; cat pattern_file done | socat - /dev/ttys0 it makes stream, looped pattern included in file , sends serial port via socat. script allows read data serial port. unfortunately when socat ends (eg. killed) loop hangs forever without error message. want avoid: pts more scripts one reopening serial port every pattern_file the problem running that, under bash (other may shells differ), pipeline terminates after all commands in pipeline finished. one solution use: while [ 1 ]; cat pattern_file || break done | socat - /dev/ttys0 if socat terminates, cat command fail when runs. however, mere failure of command in loop not cause loop terminate. adding break command, can assure that, if cat fails, loop terminate. another solution avoid pipelines altogether , use process substitution : socat - /dev/ttys0 < <(while true; cat pattern_file; done) documentation the problematic pipeline behavior documented in ma

Silex Routing to Controllers -

building app silex using mvc pattern. i'm having bit of issue in regards should doing after have route collection. here bootstrap app: <?php namespace app; use igorw\silex\configserviceprovider; use silex\application silex; use symfony\component\routing\route; use symfony\component\routing\routecollection; class bootstrap extends silex { public function __construct() { $this['debug'] = true; $this->registerdefaultparameters(); $this->registerdefaultservices(); $this->registerroutes(); } protected function registerdefaultparameters() { $paths = isset($this['base_path']) ? $this['base_path'] : array(); if (!isset($paths['base'])) { $paths['base'] = realpath(__dir__ . '/../'); } $defaults = array( 'config' => $paths['base'] . '/app/config', 'twig.path' =

Writing updates to xml file with XQuery and BaseX -

i have file.xml storing protocols structure following: <?xml version="1.0" encoding="utf-8" standalone="no"?> <economato> <protocollo> <numero>1</numero> <data>2014-12-15</data> <oggetto>trasmissione prospetti di rendiconto chiusura esercizio 2012 - beni mobili proprietà dello stato</oggetto> <destinatario>ragioneria provinciale como</destinatario> <operatore>maestri</operatore> <valido>true</valido> </protocollo> ... </economato> and need change/update value of tag "valido", example 'true' 'false' of protocollo number 1 , update written file. using basex, following documentation have tried write query: xquery let $update := doc('c:\users\lorenzo enzino vinci\desktop\economato\databases\2014.xml')//economato/protocollo[numero = 1] return replace value of node $update/valido 'fa

java - Easy way to print arabic numbers -

i want print numbers 1...10000 latin , arabic numbers. there fast , easy way print arabic numbers 1...10000 in loop? many in advance! you can use below code convert in arabic. int arabic_unicode = 1632; int num = 786; string str_en = num+""; stringbuilder builder_ar = new stringbuilder(); (int = 0; < str_en.length(); ++i) { builder_ar.append((char) ((int) str_en.charat(i) - 48 + arabic_unicode)); } system.out.println("arabic : " + builder_ar.tostring()); above code convert int arabic number. print 1------10000 can use loop accordingly. please try yourself.

caching - Laravel sending no-cache header -

Image
i'm having trouble laravel 4. somehow header cache-control: no-cache is being sent in response on pages within site. can't find or how change it. since affecting controllers i'm presenting view view::make way change globally. if want use cache, can change behavior in "response" object (returned controller method in example) : public function mycontrollermethod() { $response = response::make('something'); $response->setlastmodified(new datetime("now")); $response->setexpires(new datetime("tomorrow")); return $response; } it works in environnement, hope help. edit: if want set globally, can try (in app/start/ directory): app::after(function($request, $response) { $response->setlastmodified(new datetime("now")); $response->setexpires(new datetime("tomorrow")); });

ggplot2 - climatograph with R and ggplot -

Image
i climatographe or climat chart using ggplot. my data > data.df mese temperatura.media pioggia 1 jan -0.3 46.6 2 feb 2.6 40.9 3 mar 7.1 68.5 4 apr 11.5 72.5 5 may 15.6 92.0 6 jun 19.1 79.6 7 jul 21.4 79.2 8 aug 20.6 81.2 9 sep 17.2 85.4 10 oct 11.3 98.9 11 nov 4.9 93.7 12 dec 0.8 52.1 i have data.df$mese<-month(data.df$mese, label = t) climagg<-ggplot(data=data.df)+ geom_bar(aes(x=mese, y=pioggia),stat = "identity") climagg that give me but need have 2 axes 1 left , 1 right different range (e.g. climatographe )... it seem not easy ggplot. so climat chart may easyer ... non axes , using multiplot fonction ggplot ggtheme<-theme(strip.text.x = element_text(size=14), strip.text.y = element_text(size=14),

python - test initialization of object and use it -

i have class , want test built in unittest module. in particular want test if can create intances without throwing errors , if can use them. the problem creation of objects quite slow, can create object in setupclass method , reuse them. @classmethod def setupclass(cls): cls.obj = myclass(argument) def testconstruction(self): obj = myclass(argument) def test1(self): self.assertequal(self.obj.metohd1(), 1) the point is i creating 2 times expensive object setup calles before testconstruction, cannot check failure inside testconstruction i happy example if there way set testconstruction executed before other tests. why not test both initialization , functionality in same test? class mytestcase(testcase): def test_complicated_object(self): obj = myclass(argument) self.assertequal(obj.method(), 1) alternatively, can have 1 test case object initialization, , 1 test case other tests. mean have create object twice, might accepta

windows - Python behavior -

i did simple test, tried take square of numbers till 50.000.using python 3.4. first tried; num=range(1,50000) sq=lambda x:x**2 print (list(map(sq,num))) i got error python stop working . then tried; sqlist=[] x in range(1,50000): sq=x**2 sqlist.append(sq) print (sqlist) i got same error again,stop working. then tried while loop; sqlist=[] t=1 while t<50001: t+=1 sq=t**2 sqlist.append(sq) print (sqlist) again same error, while loop survived more for loop. last test is; sqlist=[] sqlist1=[] sqlist2=[] sqlist3=[] sqlist4=[] t=1 while t<50001: t+=1 sq=t**2 if t<10000: sqlist.append(sq) elif t<20000: sqlist1.append(sq) elif t<30000: sqlist2.append(sq) elif t<40000: sqlist3.append(sq) elif t<50000: sqlist4.append(sq) print (sqlist,sqlist1,sqlist2,sqlist3,sqlist4) and got want, no error,shows me squares of numbers till 50,000. did for loop too, , while

python - Django REST serializer not working with files -

for example have following in models.py : def upload_attachments(filename): return '/logos/%y/%m_%d/{}'.format(filename) # well, not exactly, close class client(models.model): name = models.charfield(unique=true, max_length=255) logo = models.imagefield(upload_to=upload_attachments) serializer model way: class clientserializer(serializers.modelserializer): class meta: model = client fields = ( 'name', 'logo' ) the view, working model: @renderer_classes((jsonrenderer,)) @parser_classes((formparser, multipartparser)) class clientview(apiview): def post(self, request, domain=none): data = request.data.get('data', none) serializer = clientserializer(data=data, files=request.files.get('file', none)) if serializer.is_valid(): serializer.save() return response(utils.ok, status=status.http_201_created) return response({'error': serializer.er

ruby - Printing ssh output to screen -

i've been working on script remotely run ruby script on server using net/ssh , print output screen can see what's going on , i'm there has answered questions here. thanks! right prints output prints commands, /opt/scripts/test_run.rb , exit, several times screen first , output of script. see commands run once , output of script screen. doing wrong? in advance! #!/usr/bin/ruby require 'net/ssh' require 'pty' puts "running test" net::ssh.start(server, user) |ssh| ssh.open_channel |channel| channel.on_request "exit-status" |channel, data| $exit_status = data.read_long end channel.request_pty |channel, data| channel.exec("sudo -s") channel.on_data |channel, data| puts data channel.send_data("/opt/scripts/test_run.rb\n") channel.send_data("exit\n") end end end end puts "done" puts `sleep 5` puts " " puts "end of test"

javascript - WinJS ListView placed into the Flyout or ContentDialog breaks after window resize -

i have winjs listview placed winjs flyout. being displayed fine until change window size after showing flyout @ least once. if flyout shown , change window size - listview breaks , doesn't display items correctly, background. there solution that? html: <div id="addrabbitflyout" data-win-control="winjs.ui.flyout" aria-label="{select rabbit add}"> <div id='addrabbitlistview' data-win-control="winjs.ui.listview" data-win-options="{ itemtemplate: select('.rabbittemplate'), layout: {type: winjs.ui.listlayout} }"> </div> </div> css: .win-container { width: 200px; } .win-surface { width: 100%; } .win-item { height: auto; margin-bottom: 5px; } .win-itembox { min-height: 40px; } .rabbitname { font-size: 12px; font-weight: 400; }

jquery - Display viewable <div> as counter -

i have carousel of divs , need display 'counter' of sorts - can display number of visible divs enough, want display visible as: 1-4 of 12 using jquery cycle, html is: <div id="wrapper"> <div id="carousel1"> <div class=""></div> <div class=""></div> <div class=""></div> <div class=""></div> </div> <div id="carousel2"> <div class=""></div> <div class=""></div> <div class=""></div> <div class=""></div> </div> <div id="carousel3"> <div class=""></div> <div class=""></div> <div class=""></div> <div class=""></div> </div> </div> <div id="counter"></div> as can see, have 3 carousel panels... how use j

loopbackjs - How to use jsonschema for Loopback remoteMethod? -

in app want define json schemas custom api. for example from: http://docs.strongloop.com/display/public/lb/remote+methods#remotemethods-example module.exports = function(person){ person.greet = function(msg, cb) { cb(null, 'greetings... ' + msg); } person.remotemethod( 'greet', { accepts: <generate definitions jsonschema>, returns: <generate definitions jsonschema> } ); }; how that? this right way? my solution - validation decorator + remote method params object type var validate = require('jsonschema').validate; byschema = function (schema) { return function (func) { return function () { var data = arguments[0], callback = arguments[1]; var result = validate(data, schema); if (result.errors.length > 0) { // errors in request body callback(null, { success: false, error: 'schema validation