Posts

Showing posts from March, 2011

jpa - how to call oracle stored procedure in jpa2.0 which returns integer as out variable -

i have written 1 stored procedure return integer value. not able count in jpa. can 1 suggest me way call stored procedure , return out value variable in java using jpa. int count = 0; string id = "m123" count = getem().createnativequery("call sample_procedure(?,?)") .setparameter(1, id) .setparameter(2, count) .executeupdate(); stored procedure: have logic in procedure , inside loop incrementing count. create or replace procedure sample_procedure( id in varchar, count out number) ........ begin ..... loop --------- count := count + 1; looks similar answer options tried: tried curly braces before call statement. query q = entitymanager.createnativequery("{call sample_procedure(?,?)}").setparameter(1, inparam).setparameter(2, outparam); q.executeupdate(); it did not work. did not return output java class. tried this: query q = entitymanager.create...

Android Universal Image Loader store downloaded progress listview -

i using universal image loader in listview. problem following usecase: when scroll on listview,it works perfectly, , load images. lets suppose, have 2 items on screen in listview, in download progress. can see it's progress imageloadingprogresslistener() , scroll anywhere , come same images, progress starts again, downloaded data lost!! there way store downloaded progress can resume process later when come image in listview. edit: can cache images once downloaded, , able use cached image, problem time when thay being downloaded , scroll , come back. my displayimageoptions : options = new displayimageoptions.builder() .displayer(new roundedbitmapdisplayer(100)) .cacheinmemory(true) .cacheondisk(true) .considerexifparams(true) .bitmapconfig(bitmap.config.rgb_565) .build(); my imageloaderconfiguration : new imageloaderconfiguration.builder(context)...

what causes android emulator work slow -

this question has answer here: why android emulator slow? how can speed android emulator? 85 answers what causes android emulator work slow ? is because of: 1. downloading libraries available in sdk 2. using latest version of sdk 3. device specification screen size, memory option (ram), internal storage, or sd card. 4. or else other above mentioned. i have no idea, please share knowledge. thanks in advance try using oracle virtual andro virtual machine. faster native emulators comes sdk. dis-advantage oracle vm is, doesn't have gpu (requires game development etc). [see link install vm][1] http://wcrosstechnologies2.blogspot.com/2013/06/androvm-how-to-install-and-run.html

How do I iterate through a Clojure ISeq in Java? -

i'm calling clojure library java program , getting iseq. how can iterate through in java? seems ought straightforward, looking @ library can't figure out how java iterator out of iseq. check out clojure.lang.seqiterator , implements java.util.iterator .

Work out the location of X given distance from 10 other map locations (in PHP) -

i have variable number of locations (lat/long coordinates) on map , approximate distance in miles x each. how can accurate lat/long location of x information? i'm coding in php answer in language immensely helpful. thank you!

javascript - Regular Expression for checking at least one alphabet or number -

i want regular expression checks if string contains allowed characters. allowed characters alphanumeric , special characters (),#\/\- . used expression, , working fine. /^([a-za-z0-9 .(),#\/\-]*)+$/ now don't want string start space or disallowed characters, can have space in middle. also, string may not consist of special characters; should have @ least 1 alphanumeric character. can me understand how adapt regex using check these additional constraints? ^(?=[a-za-z0-9])([a-za-z0-9 .(),#\/-]*)+$ this should it.

c++ - How to make gcc/g++ accept expressions like LOBYTE(v15) = someExpression? -

i have decompiled function , want compile source. problem lobyte statements: "error: lvalue required left operand of assignment" on every line that: lobyte(v9) = ((_byte)v12 + (v7 ^ v13)) & 0x1f; tip workaround, please. assuming v9 object of arithmetic type (the question not explicit declarations of different identifiers / macros involved) , system little-endian: #define lobyte(x) (*(unsigned char *) &(x)) would allow lobyte on left hand side of = operator.

java - Android how to stop recursive function when I got one result -

i new android. writing simple app user solve sudoku. user asked input numbers program provide 1 solution puzzle. my recursive function find results works dont know how stop function when got first solution. therefore, app keep running , crash. here code public class solver extends actionbaractivity implements onclicklistener{ private final string tag = "solver"; public final int[][] = new int[9][9]; private solverview solverview; public static final int[][] temp = { {1,1,1,2,2,2,3,3,3}, {1,1,1,2,2,2,3,3,3}, {1,1,1,2,2,2,3,3,3}, {4,4,4,5,5,5,6,6,6}, {4,4,4,5,5,5,6,6,6}, {4,4,4,5,5,5,6,6,6}, {7,7,7,8,8,8,9,9,9}, {7,7,7,8,8,8,9,9,9}, {7,7,7,8,8,8,9,9,9} }; @override protected void oncreate(bundle savedinstancestate){ super.oncreate(savedinstancestate); solverview = new solverview(this); setcontentview(r.layout.activity_solver); solverview.requestfocus(); solverview.bringtofront(); setcontentview(solverview);...

javascript - How to open a Dialogue Box On Page Load -

i trying open dialogue box on page load of jquery mobile screen .right able open dialogue box on button click .i want dialogue box pop automatically on page load not able it. here html.. <body onload="onload()"> <p style="display: none>you have entered: <span id="dialogoutput"></span></p> <a href="#" id="dialoglink" data-role="button" style="display: none>open dialog</a> <!-- contacts list page --> <div data-role="page" id="cont_list_page" data-theme="a"> <div data-role="header" data-position="fixed" data-tap-toggle="false"> </div> </div> </body> and here jquery .. function onload() { document.addeventlistener("deviceready", ondeviceready, false); $("#searchby_chooser_ok_button").bind ("click", searchbycriteria); if (typeof conta...

asp.net - Blocking invalid URL and redirect to homepage in IIS -

currently using web hosting service provided company. uses iis 7/iis 8 , allows customers modify web.config according needs. suppose have set 2 valid url: http://www.example.com http://dev.example.com now, when try access http://abc.example.com , http error 403.14 - forbidden returned; , if try access http://www.example.com/abc , http error 404.0 - not found returned. how can configure web.config such users redirected http://www.example.com when trying access invalid url? i have tried use snippet provided company without success: <?xml version="1.0" encoding="utf-8"?> <configuration> <system.webserver> <rewrite> <rules> <rule name="canonical host name" stopprocessing="true"> <match url="(.*)" /> <conditions> <add input="{http_host}" pattern="^example\.co...

php - MySQL datatype with many options -

i'm creating mysql table store user information. if 1 info user's graduation year, 1970~2014, best datatype this? want values give users options choose graduation year when sign up. going use enum this. grdyr enum('70','71','72', ... '14') , myaql maual recommends not use numbers enum values. adding character grdyr enum('s70','s71','s72', ... 's14') solve problem? also, if add more values later on, year 15, 16, , on students graduate each year, altering table each time way done? knowledge, seems way altering table sounds shouldn't do. help please! firstly, should use multiple tables , foreign keys insead of enum . should store year in 4 digit format, instead of 2 digits. because... if need add year 2070? secondly, use datetime or date type of columns dates. or, use varchar , int , tinyint numbers yours (i still still prefer date types). not make table (or single column enum) containing...

javascript - Why I'm not able to dynamically add the HTML to the page using jQuery? -

i've following html code of bootstrap modal dialog box: <div class="modal fade" id="rebatemodal" tabindex="-1" role="dialog" aria-labelledby="mymodallabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <h4 class="modal-title">submit form</h4> </div> <div class="modal-body"> <p style="text-align: justify;"><span style="font-weight: 700;"></p> <br/> <!-- here want dynamically add html ajax response --> <form id="request_form" method="post" class="form-horizontal" acti...

javascript - On click event only fires once, why? -

i've been having problem past week skipped time. so jquery code: jquery(function ($) { $(function () { $('.mpicture').on('click', function (e) { e.preventdefault(); $(this).find('div').bpopup(); }); }); }); i have seen people needed use .live getting work multiple times doesn't code. code connected div isn't visible until image clicked. question is: why doesn't work , need change? html: <div id="product_tabs_new_contents" class="product-tabs-content" style="display: none;"> <div class="merk"> <table id="tblogo"> <tr> <td> <div id="as" class="mpicture"> <img src="logo's/as.png" id="mpicid" class="mpicmaat"/> <div class="logopopup" style="wid...

file upload - storing each and every chunk of data php -

hello trying upload data server, requirement if uploaded content large file , if connection disconnected need upload same file stopped , not start again. can upload file server unable resume upload.. there other way can this?? following code. resume.php <?php $host = "localhost"; $db_uname = "root"; $db_pass=""; $db_name = "upload"; $cont=mysql_pconnect($host,$db_uname,$db_pass) or die("too many connection, please try later "); mysql_select_db($db_name); ob_clean(); if($_post['submit']) { define('chunk_size', 1024*1024); // size (in bytes) of tiles chunk // read file , display content chunk chunk function readfile_chunked($filename, $retbytes = true) { mysql_query("insert uploads(chunk) values('')") or die('insert query: ' . mysql_error()); $last = mysql_insert_id(); $file = '/tmp/'.$_files...

java - Custom method in spring data couchbase -

i need write custom method spring data couchbase repository . here code. cbsamplerepositorycustom.java public interface cbsamplerepositorycustom { public void addindex() ; } cbsamplerepositoryimpl.java public class cbsamplerepositoryimpl implements cbsamplerepositorycustom { @override public void addindex() { system.out.println("cbsamplerepositorycustomimpl createindex"); } } cbsamplerepository.java @repository public interface cbsamplerepository extends couchbaserepository<content,string> , cbsamplerepositorycustom{ } couchbasebeansconfiguration.java @configuration public class couchbasebeansconfiguration { @bean public couchbaseclient couchbaseclient() throws ioexception { return new couchbaseclient(arrays.aslist(uri .create("http://localhost:8091/pools")), "test", ""); } @bean public couchbasetemplate couchbasetemplate() throws ioexception { return new couchbasetemplate(couchbaseclient(...

java - What are the JRE version requirements of JWrapper? -

i'm trying online jwrapper installers use system jre, end downloading jre resulting in tens of gb day of download traffic. in log see following log messages: +161 [extractor] checking jre version requirements: 0 vs required 6 +0 [jresearch] jre not exist or not have unpack200 +0 [jredownload] failed pick existing system jre, download so, 6 jre version requirements , possible supply unpack200 implementation installer use?

java - Saving the Edited Data from Datatable in mysql -

i making jsf web page, show data of table, , edit, update, delete data database. i using datatable, update method in loginbean class is @managedbean(name = "loginbean" , eager=true) @viewscoped public class loginbean implements serializable { private static final long serialversionuid = 1l; private string emailid; private string password; boolean disabled = true; @ejb loginmanagerremote loginmanager; entitymanager em; list<login> list=null; @postconstruct public void init() {system.out.println(">>>> in list method <<<<"); list = new arraylist<login>(); list = loginmanager.findall(); } public list<login> getlist() { return list; } public void setlist(list<login> list) { this.list = list; } public string updateaction(login list) { system.out.println(">>>> started in list loop <...

javascript - node.js Buffer not empty -

when create lots of buffer s aren't empty: for (var = 0; < 100; i++) { console.log((new buffer(30)).tostring('hex')); } (partial) output: 782668013a0000003b00000035000000b0c17900391100003c0000003d00 e4216801ffffffff000000000100000000000000000000003e0000003f00 40c27900100000000100000000000000000000000000000018c379000000 000000000000000000000000000000000000000000000000000000000000 --> empty 000000000000000000000000000000000000000000000000000000000000 --> empty 0000000000000000108269014000000041000000c86f79000cf679000000 6611000080c27900c0c27900040000000100000000000000d0c279000000 00000000000000005c2468014200000043000000cc6f7900002668014400 (partial) output (without .tostring('hex') , new buffer(10) ): <buffer 01 00 00 00 58 db 62 00 b4 86> <buffer 90 b9 65 00 08 00 00 00 03 00> <buffer 10 ba 65 00 04 00 00 00 00 00> <buffer 04 00 00 00 00 00 00 00 00 00> <buffer 10 00 00 00 00 00 00 00 70 ba> <buffer 00 00 0...

c# - WPF Change View from a User Control MVVM -

i'm trying navigate 1 view model without side panel. for example, have main window view , load user control . i have tried access static instance mainviewmodel change views, it's not working. mainwindow.xaml <window.resources> <datatemplate datatype="{x:type vm:firstviewmodel}"> <v:firstview/> </datatemplate> <datatemplate datatype="{x:type vm:secondviewmodel}"> <v:secondview/> </datatemplate> </window.resources> <contentcontrol content="{binding currentviewmodel}"/> mainviewmodel.cs class mainviewmodel : observableobject { private observableobject _currentviewmodel = new firstviewmodel(); public observableobject currentviewmodel { { return _currentviewmodel; } set { _currentviewmodel = value; raisepropertychangedevent("currentviewmodel"); } } private static...

sql - Extract Data into Reload Scripts -

i have set of legacy test data on several sql server databases want extract in form can replay onto empty database (with same schema). want can manage test data sql scripts (or other script format) in source code control system - test data created on many years exists sql server backups. i dont think sql server can extract data in format allow replay in referential integrity compliant order - or can ? alternatively there technical method doing not require dropping referential integrity on destination database while doing data load ? this not quite straightforward 1 wish, possible - use exact setup describe @ workplace. in order generate insert scripts data, follow these steps: open connection database engine in sql server management studio right-click database, , choose "tasks"->"generate scripts...". wizard opens. click "next" couple of times, until @ "set scripting options" step. there, click "advanced" button...

c# - Changing Html.DisplayFor bool? text -

i have situations when trying display bool? value. in case if bool doesn't exist: @html.displayfor(m => m.hastype) shows text "not set". fine, need show text. how can replace "not set", example "empty"? i like: @if (!model.hastype.hasvalue) { ... } else { ... } but want know, there possibility change "not set" itself. p.s sorry bad english.

java - Jersey/JAX-RS clients that use Jackson to pass POJOs as entities -

i trying implement restful web service client using jersey /jax-rs: public class myclient implements closeable { private client client; private fizzresource fizzresource; // several other resources omitted brevity. // ctor, getters , setters, etc. @override public void close() throws exception { client.destroy(); client.getexecutorservice().shutdown(); } } public class fizzresource { private client client; public fizz savefizz(fizz fizz) { webresource webresource = client.resource("whatever"); clientresponse response = webresource.accept(???).post(???); if(response.getstatus() != 200) { // something... } else { // else... } } } my problem not want work json; instead want work directly entities (e.g. fizz ). use jackson automagically serialization between json , entities (without me having explicitly conversion inside each method), i'm not se...

c# - using distinct in DataTable.Select function -

i have data table , want populate 2 datatables using datatable,here simple form of table my data table columns [name][family][id][propertyid][propertyenergy] john smith 1 12 gas john smith 1 13 gas john smith 1 14 null john smith 1 15 gas hannah smith 2 16 gas hannah smith 2 17 gas hannah smith 2 18 gas i want use query in datatable select distinct [name][family][id] table results john smith 1 hannah smith 2 and again use query in datatable select [id][propertyid][propertyenergy] table results 1 12 gas 1 13 gas 1 14 null 1 15 gas 2 16 gas 2 17 gas 2 18 gas i searched , found can datatable.select examples have seen shows can add sentense datatable.select , have no idea how perform things distinct in it, can please me or give me hints how it? thank much i'd use linq-to-datatable instead: var distinctnames = table.asenumerable() .select(row => new { name = row.field<string>("name"), family = row.field<str...

wcf - OperationContext in State Machine Workflows (WF 4.5) -

so i'm struggling following scenario. i'm trying integrate di (autofac) in xamlx workflow service. since such service merely wcf hosted service, thought @ autofac's wcf integration implementation , adapt can used workflowservicehost(factory). , while managed (adding instancecontextinitializer puts iextension on current operationcontext start new lifetimescope wcf request) , tested simple sequential workflow, doesn't work state machine workflow! well, work in first state of workflow, after transitioning following state, operationcontext gone. questing is, out there doing similar? have lifetime scope per wcf request xamlx state machine workflow service? guess i'm going have go lifetime scope per activity have kind of control on resovled objects container..

java - Get all classnames that extend a specific class -

in java project, need variable each class extends class. problem here don't know name of these classes. let's classtree looks this: package - myproject - baseclass - class 1 extends baseclass - class 2 extends baseclass - class 3 extends baseclass - class 4 - class 5 now each class extends baseclass has variable basevariable , , need value in myproject . there way list of classes extend baseclass, can access basevariable value? thanks in advance you use reflections : set<class<? extends baseclass>> subclasses = reflections.getsubtypesof(baseclass.class);

multithreading - My program hangs on pthread_rwlock_wrlock -

i have 9-threaded program hangs after sometime on pthread_rwlock_wrlock pthread_rwlock_wrlock(p_lock) write(file_handler, buff, len); pthread_rwlock_unlock(p_lock); after sometimes, program hangs , threads found blocked lock. however, same program seems working fine when replaced rwlock mutex.

x86 - How do I optimize this assembly code? -

can here me optimize assembly code? i'm trying make execute faster now, can't find other way it. code: mov eax, x mov a, eax again : mov ecx, shr ecx, 1 cmp ecx, 2 jb skip mov ebx, 2 inc ecx sub ecx, ebx mov count, 0 repeat : mov eax, sub edx,edx div ebx sub dx,0 jnz finish inc count finish : inc ebx loop repeat mov ecx,count cmp ecx,max jbe done mov max, ecx mov eax,a mov num,eax done : skip : mov ecx, y inc ecx sub ecx, inc loop again there several redundant lines in code, example: mov ebx, 2 inc ecx sub ecx, ebx is identical to: mov ebx...

javascript - Adding existing canvas to a div dynamically -

i have problem adding existing canvas div dynamically via jquery. try numerous options append 1 works. here code: <div class="a"> <div id="b"></div> <div id="c" class="c"> </div> </div> jquery: $(document).ready(function() { if($('.mydivifload').text().length >= 0) { //$('canvas[class="canvasclass"]').appendto($('.c')); // doesn't work //$('canvas[class="canvasclass"]').append($('.c')); // doesn't work //var canv= $('canvas[class="canvasclass"]'); //doesn't work //document.getelementbyid('c').appendchild(canv) // doesn't work $('canvas.canvasclass').appendto('.c') $(function() { $(".a").hover(function() { $(".a").stop(true, false).ani...

python - django print only one value in for loop in template -

i want display 1 value loop in template. let's have this: {% category in categories %} {{category.name}} <a href="{% url "my_url" category.id %}">see all</a> {% endfor %} if have 5 category see in being printed 5 times. how can print once.. thanx in adnvance.. you have limit object , send object template tempalte_var['content'] = categories.objects.all()[:5]

python - Adding CSS item to Django menu -

i need add css classes menu items. can not figure out how that... i using django cms, not want client alter menu. have far: from menus.base import menu, navigationnode menus.menu_pool import menu_pool django.utils.translation import ugettext_lazy _ class mymenu(menu): def get_nodes(self, request): nodes = [] n1 = navigationnode(_('start'), "/", 1) n2 = navigationnode(_('item 1'), "item1/", 2) n3 = navigationnode(_('item 2'), "item2/", 3) nodes.append(n1) nodes.append(n2) nodes.append(n3) return nodes menu_pool.register_menu(mymenu) my menu looks this: <ul> <li class="child selected"><a href="/">start</a></li> <li class="child sibling"><a href="item1/">item 1</a></li> <li class="child sibling"><a href="item2/">item 2</a>...

(ORACLE SQL) about subquery and operators like ALL,ANY etc -

i have 3 tables create table airships( idas number primary key, nameas varchar2(20), range number ); create table certificate( idem number not null, idas number not null, foreign key (idem) references employees(idem), foreign key (idas) references airships(idas) ); create table employees( idem number primary key, nameem varchar2(20), paycheck number ); i have find idem employees certified biggest number of airships using subquery , oparatos exists,in,all,any i've managed find 1 employee, whithout usig of oparatos. select * (select idem,count(idas) airshipname certificate group idem order count(idas) desc) rownum=1 i'm not sure how using specific operators list. here's how having the all operator explained here . can use query: select "idem" certificate group "idem" having count(*) >= ( select count(*) certificate group "idem") demo ...

ocr - Best method to train Tesseract 3.02 -

i'm wondering best method train tesseract (kind of text/tiff , on) particular kind of documents, these particularities: the structure , main text of documents same the things change 5 alphanumeric codes (this real important thing detect!) some of thes codes bold at moment used standard trained datas, detect entire text , extrapolate codes regular expressions. it's okay, i've got errors sometimes, example: 0 / o l / / 1 please knowns "tricks" improve precision? thanks! during training part of tesseract, have make file manually give engine in order specify ambiguous characters. for more information @ "unicharambigs" part of tesseract documentation . best regards.

python - Django Rest Framework - Unicode error -

i using django rest framework django-oauth-toolkit, have used earlier , never have face issue. i have followed per documentation of django-oauth-toolkit on trying request access token: curl -h post -d "grant_type=password&username=k@k.com&password=k&client_id=abc&client_secret=abc" http://127.0.0.1:8000/o/token/ i following stack trace: [27/nov/2014 06:11:41] error [django.request:226] internal server error: /o/token/ traceback (most recent call last): file "/users/k/documents/personaldata/rock_env/lib/python2.7/site-packages/django/core/handlers/base.py", line 114, in get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) file "/users/k/documents/personaldata/rock_env/lib/python2.7/site-packages/django/views/generic/base.py", line 69, in view return self.dispatch(request, *args, **kwargs) file "/users/k/documents/personaldata/rock_env/lib/python2.7/site-packages/django/utils/de...

A fast way to merge named vectors of different length into a data frame (preserving name information as column name) in R -

i have list l of named vectors. example, 1st element: > l[[1]] $event [1] "eventa" $time [1] "1416355303" $city [1] "los angeles" $region [1] "california" $locale [1] "en-gb" when unlist each element of list resulting vectors looks (for 1st 3 elements): > unlist(l[[1]]) event time city region locale "eventa" "1416355303" "los angeles" "california" "en-gb" > unlist(l[[2]]) event time locale "eventb" "1416417567" "en-gb" > unlist(l[[3]]) event properties.time "eventm" "1416417569" i have on 0.5 million elements in list , each 1 has 42 of these feaures/names. have merge them dataframe taken account names , not of them have same number of feaures or names (in example above, v2 has no information region , city ). @ moment, loop throu...

java - How to get Integer of BigDecimal without separator -

i got following bigdecimal money-object: bigdecimal 49.99 , need integer 4999, ask getting rid of separator. i bigdecimal string , remove separator , parse integer, not think pretty. bigdecimal bigprice = moneyprice.getvalue(); integer price = bigprice.intvalue(); using responses 49. try code: bigdecimal db = new bigdecimal("49.99"); // multiply 10^scale ( in case 2) db = db.multiply(new bigdecimal(10).pow( db.scale())); system.out.println(db.intvalue());

ios - How do I unable the "Space" Key on the keyboard in Swift? -

i'm creating login system , don't want spaces allowed in username field. instead of check , validating field, want prevent spaces being added. so, every time user presses spacebar, nothing should happen. how can that? i've seen instagram this. this code far: import uikit class viewcontroller: uiviewcontroller, uitextfielddelegate { @iboutlet weak var signup: uibarbuttonitem! @iboutlet weak var navbar: uinavigationbar! @iboutlet weak var usernametext: uitextfield! override func viewdidload() { super.viewdidload() self.navigationcontroller?.navigationbar.clipstobounds = true usernametext.attributedplaceholder = nsattributedstring(string:"typeyourusername", attributes:[nsforegroundcolorattributename: uicolor.whitecolor()]) func textfield(usernametext: uitextfield, shouldchangecharactersinrange range: nsrange, replacementstring string: string) -> bool { if (string == ...

android - What ways are there to execute a SQLiteDatabase join function -

i need use join function in use of android 'game'. know how write inner- , outerjoin. need know ways there execute sqlitedatabase join function? you got basic rawquery can use join, wonder if there other way select(query), insert, update , delete methodes implemented in sqlitedatabase class. want confirmation if i'm not missing @ point. there no function exclusively 'join' 2 tables. either run rawquery or query achieve same. check documentation. i suggest go rawquery.

c# - Why doesn't AsQueryable<T> imply a filter on the _t discriminator -

assuming model of [bsondiscriminator(rootclass = true)] [bsonknowntypes(typeof (dog), typeof (cat))] class animal { public objectid id {get;set;} public string name {get;set;} } class dog : animal { public int barkvolume {get;set;} } class cat : animal { public int purrvolume {get;set;} } i can following: var collection = new mongoclient().getserver().getdatabase("test").getcollection<animal("animals"); collection.save( new dog { name="spot", barkvolume=7 } ); collection.save( new cat { name="kitty", purrvolume=2 } ); however if try , query cats with var cats = collection.asqueryable<cat>(); foreach(var c in cats) { console.writeline("{0} purrs @ {1}", c.name, c.purrvolume); } i'll exception "element barkvolume not match field or property of class cat". of course, if change query to: var cats = collection.asqueryable<cat>().where(x=>x cat); then no problem, there warning sta...

javascript closure - how come I refer to an undeclared variable -

this question has answer here: javascript closures vs. anonymous functions 11 answers try head around javascript closures new me. have tutorial indicates use: function warningmaker( obstacle ){ function doalert (obs) { alert("beware! there have been "+obs+" sightings in cove today!"); }; return doalert; } but confused "obs". parameter 'obstacle' automatically passed obs ? a better example perhaps might be: function warningmaker( obstacle ){ return function (number,location) { alert("beware! there have been " + obstacle + " sightings in cove today!\n" + number + " " + obstacle + "(s) spotted @ " + location + "!" ); }; } either example you've got missing lines or isn't proper ex...

scala - What API for optional case class creation matches common developer expectations -

what api best use point of view of obviousness optional case class creation? suppose have case class case class position(position: int) and position should never outside range [0, 18]. additionally want fp friendly argument cannot rejected exception when constraint have been violated. is there better approach uses factory method result in option, object position { def apply(position: int): option[position] = if (in range) some(position(position)) else none } when called not clear option returned val p = position(99) would better? object position { def maybe(position: int): option[position] = if(in range) some(position(position)) else none } then usage becomes, val p = position.maybe(99) but maybe boilerplate clarify result type. this solution went based on linked duplicate answer, case class port private(portnumber: int) object port { private val validrange = range(0, 65535+1) def opt(portnumber: int): option[port] = if (val...

reference json numeric key with variable in javascript -

how loop through data: (i have no control on format) {"rowcount":3,"1":{"k":"2009","v":"some data"},"2":{"k":"2010","v":"more data"}} above console.log(results) , results string var r = json.parse(results); var t; for(var i=1;i<=r.rowcount;i++) { t=r[i].v; tabledata.push( {title:t, year:'2009', haschild:true, color: '#000'} ); } error: typeerror: 'undefined' not object (evaluating 'r[i].v') i cannot evaluate variable i. doing wrong? thanks update the incoming data had bad rowcount causing error. accepted answer correct... user error on part not catching bad incoming data. had put console.log inside loop have realized error happening after 2 successful loops. oops i assume r.rowcount should j.rowcount . ideally should initialise i v...

sql - Creating a stored procedure with many-to-many relationship giving proper response -

i'm trying create stored procedure school project uses model first. wanted make sp returning av list of games orders, 'top list' speak, can't figure out after searching similiar threads. parameter @antal should return range of distinct results give back. let's send in 5 should return 5 products, , 3 should return 3 products , forth... since new this, i'm stuck. code far is: use spelaffarendatabas go create procedure [dbo].[gettoplistgames] ( @antal int ) select distinct top (6) p.id, p.name, p.orders, k.name, g.name produktset p left join consoleproduct kp on p.id = kp.product_id left join consoleset k on kp.console_id = k.id left join productgenre pg on p.id = pg.product_id left join genreset g on pg.genre_id = g.id group p.id, p.name, p.orders, k.name, g.name so how go getting proper response gives me proper response, whic guess of distinct entities? select distinct top (@antal) p.id, p.name, p.orders, k.name, g.name produktset p left join c...

.htaccess - https htaccess exclude only one folder from redirecting to https -

i activated https on site , added .htaccess rewriteengine on rewritecond %{https} off rewritecond %{http_host} !^www\.(.*)$ [nc] rewriterule (.*) https://%{http_host}%{request_uri} [r=302,l] rewritecond %{https} on rewritecond %{http_host} !^www\.(.*)$ [nc] rewriterule (.*) https://www.%{http_host}%{request_uri} [r=302,l] rewritecond %{https} off rewriterule (.*) https://%{http_host}%{request_uri} [r=302,l] it's ok, want add exception single folder not redirected https. folder "public_html/files"

c# - Logging SQL exceptions from database using log4net -

i have wcf service calls stored procedure in sql database. use log4net logging purpose. if sql exception thrown database, can sql exception properties procedure name, error line, severity etc., exception object in service. but there way directly log properties in file using log4net?. follow these steps: add reference log4net dll import following namespaces using log4net; using log4net.config; add following code global declaring private static readonly ilog log = logmanager.getlogger(system.reflection.methodbase.getcurrentmethod().declaringtype); add code constructor xmlconfigurator.configure(new fileinfo(appdomain.currentdomain.basedirectory + @"\config\log4net.config")); copy following config file under configuration tag <configsections> section name="log4net" type="log4net.config.log4netconfigurationsectionhandler, log4net" /> </configsections> <log4net debug="true...

vb.net - What the Green band in code editor Visual Studio 2013 means? -

Image
i'm reading vb.net code file has green band beside line code. see snapshot: i add method asynchronous method (its signature shown in snapshot). is warning suppression? thanks in advance help! p.s.: important point returnvalue y synchronous sub . the bands tell information current session in visual studio. when edit lines, you'll yellow band shown next them. when save file, band turns green. the bands not retained if close , re-open file. so screenshot, can tell you've edited line 329 (maybe added it) during current session , that change has been saved disk.

php - PHPMD - include a whole ruleset and configure the properties -

i using phpmd ( http://phpmd.org/ ) , quite new this. md works, writing ruleset configure metrics should used. instead of including each rule individually, load whole rulesets. have problem don't know how configure properties of single rules if include whole set. for example, want use rule check cyclomatic complexity. can use <?xml version="1.0"?> <ruleset name="demo phpmd rule set" xmlns="http://pmd.sf.net/ruleset/1.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:nonamespaceschemalocation="http://pmd.sf.net/ruleset_xml_schema.xsd"> <description> custom ruleset checks code </description> <rule ref="rulesets/codesize.xml/cyclomaticcomplexity"> <properties> <property name="reportlevel" va...

android - Crash on ListView adapter after obfuscating -

after obfuscating app stops working. use gradle. it`s part of build.gradle. buildtypes { release { debuggable false minifyenabled true proguardfile 'other-proguard-rules.pro' proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' signingconfig signingconfigs.releasesigning } } here mt other-proguard-rules.pro -keepattributes *annotation* -keep class com.polites.android.** { *; } -keep interface com.polites.android.** { *; } -keep class com.handmark.pulltorefresh.library.** { *; } -keep interface com.handmark.pulltorefresh.library.** { *; } -keep class android.support.v7.internal.** { *; } -keep interface android.support.v7.internal.** { *; } -keep class android.support.v7.** { *; } -keep interface android.support.v7.** { *; } -keep class com.google.** { *;} -keep interface com.google.** { *;} -dontwarn com.google.** trouble listview adapter. mtriggerlist.clear(); mtrigg...

c# - Format currency with symbol before instead of after -

i use converter textbox currency. works great, except €-sign after value instead of before. here code: public object convert(object value, type targettype, object parameter, cultureinfo culture) { var dvalue = value decimal?; return string.format(cultureinfo.getcultureinfo("de-de"), "{0:c}", dvalue ?? 0); } i know can put before instead of after so: public object convert(object value, type targettype, object parameter, cultureinfo culture) { var dvalue = value decimal?; return "€ " + string.format(cultureinfo.getcultureinfo("de-de"), "{0:c}", dvalue ?? 0).replace("€", "").trim(); } but i'm assuming here there should standard in formatter this. so, know how put currency before value instead of behind using formatter itself? for example: decimal 12345678.90 , don't want display [see first method] 12.345.678,90 € , want display [see second method] € 12.345.678,90 instead. ...

r - Output of parApply different from my input -

i still quite new r (used program in matlab) , trying use parallel package speed calculations. below example trying calculate rolling standard deviation of matrix (by column) use of zoo package, , without parallelising codes. however, shape of outputs came out different. # load library library('zoo') library('parallel') library('snow') # data z <- matrix(runif(1000000,0,1),100,1000) #this want calculate timing system.time(zz <- rollapply(z,10,sd,by.column=t, fill=na)) # trying achieve same output parallel computing cl<-makesockcluster(4) clusterevalq(cl, library(zoo)) system.time(yy <-parcapply(cl,z,function(x) rollapplyr(x,10,sd,fill=na))) stopcluster(cl) my first output zz has same dimensions input z, whereas output yy vector rather matrix. understand can matrix(yy,nrow(z),ncol(z)) know if have done wrong or if there better way of coding improve this. thank you. from documentation: parrapply , parcapply return vector....

ios - is it possible to implement iCarousel with SKScene array? -

Image
i'm working on project , want create icarousel contains different scenes details. clear, app save arenas contents in xml files skscene, , want have previews of arenas before load them. , thought icarousel solution, don' know if possible. what is: 1-i created project storyboard contains tab bar view. 2- 1 tab used skscene , saving elements (the scene working , there switch second tab). 3- second used present icarousel, should preview arenas (maps). can , suggest solution problem? , if icarousel choice. please tell me how it. it's little expensive in term of storage capacity, works perfectly. here's you'll get: when click load arena, you'll following view select arena: you have select arena , click on green button return calling view chosen arena loaded. and here's way achieve it: -(void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { //uitableviewcell *cell=[tableview cellforrowatindexpath:...