Posts

Showing posts from February, 2010

Javascript loop when calling focus event -

i trying validate form, , testing event handlers new them. wondering why code loop, in sense moment click on input field messages keeps on showing. have thought of adding boolean stop it, there better way? $(document).ready(function(){ function test() { alert("this keeps showing up!"); } document.formulario_reserva.dni.addeventlistener("focus", test, false); });

Enforcing user quota in Firebase -

what best way enforce per-user quota on data stored in firebase? my users able create documents unique id on following path: /documents/id/contents the id uniquely generated using transaction. id reserved using verification rule ( contents.id == auth.id ) however how prevent user spamming db (by randomly allocating ids themselves)? can have rule counts number of ids allocated user , rejects them if count high? there's no way this. in cases enumerate children allowed exist (child1, child2, etc), , grant read / write each one. won't work large numbers though or ids don't know beforehand. we have plans built features restrict number of allowed children , provide other features enforce quotas on users.

doctrine2 - Doctrine - QueryBuilder, select query with where parameters: entities or ids? -

i have product entity , shop entity. a shop can have 0 n products , product can in 1 shop. the product entity table refering shop entity through shop_id table field. when querying products of given shop using doctrine query builder, can this: $products = $this->getdoctrine()->getrepository('mybundle:product') ->createquerybuilder('p') ->where('p.shop = :shop') ->setparameter('shop', $shop) // here pass shop object ->getquery()->getresult(); or this: $products = $this->getdoctrine()->getrepository('mybundle:product') ->createquerybuilder('p') ->where('p.shop = :shopid') ->setparameter('shopid', $shopid) // pass directly shop id ->getquery()->getresult(); and both seem work... i'm wondering: can pass directly entity ids instea

c# - EF - How to edit the below model using linq? -

i'm sending view model data client , update model. know how calling stored procedure, know how using linq queries. appreciated. thanks [httppost] public jsonresult editemployee(models.employee employee) { try { if (modelstate.isvalid) { using (emsctx) { var employeeresults = (from q in emsctx.employees q.id == employee.id //code update model. ); employeedata.employees = employeeresults; } return json(); } if want update data in db correspoding employee check below edited code: [httppost] public jsonresult editemployee(models.employee employee) {

mysql - How to make an exe or a setup to distribute my Java(+DB) project made in NetBeans -

hello made project using netbeans , netbeans database jdbc, tried make own exe file using "exe4j wizard" , successful project still using database computer, when try on computer throws error (cant find it). im wondering if can problem. im guessing, maybe if find way use relative path database can put inside folder exe, or that. ps: give details, im kinda new , first time this, thank you!

Mapping a stream of tokens to a stream of n-grams in Java 8 -

i think basic question concerning java 8 streams, have difficult time thinking of right search terms. asking here. getting java 8, bear me. i wondering how map stream of tokens stream of n-grams (represented arrays of tokens of size n). suppose n = 3, convert following stream {1, 2, 3, 4, 5, 6, 7} to {[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]} how accomplish java 8 streams? should possible compute concurrently, why interested in accomplishing streams (it doesn't matter in order n-arrays processed). sure, old-fashioned for-loops, prefer make use of stream api. such operation not suited stream api. in functional jargon, you're trying called sliding window of size n . scala has built-in sliding() method, there nothing built-in in java stream api. you have rely on using stream on indexes of input list make happen. public static void main(string[] args) { list<integer> list = arrays.aslist(1, 2, 3, 4, 5, 6, 7); list<list<

javascript - How work with $(target) inside directive? -

i build directive time selection 2 blocks. problem catch target event on blocks inside directive template. directive template: <div class='time-picker-container'> <div class='block1' ng-click='show()'>1</div> <div class='block2' ng-show='selectvisible'>2</div> </div> js: scope.selectvisible = false; scope.show = function() { scope.selectvisible = scope.selectvisible ? false : true; } $rootscope.$on('documentclicked', function(inner, target) { //try hide div.block2 if user make click outside block. }); basic idea: when user make click on document, outside div.block2, block disappear. when user click somewere inside div.block2 block stay visible. on run function: angular.element(document).on('click', function(e) { $rootscope.$broadcast('documentclicked', angular.element(e.target)); }); in template, add $event argument ng-click handler

db2 - PHP alternative to mysql_data_seek for ODBC -

i converting php-mysql application php-odbc application. ie getting database migrated mysql db2. while using mysql used mysql_data_seek function reset recordset pointer, not work odbc connection. tried , checked odbc_fetch_row($recordset,0) resetting recordset, not work. know how reset recordset via odbc connection? according the docs , need pass 1 second parameter instead of 0 . to step through result more once, can call odbc_fetch_row() row_number 1, , continue doing odbc_fetch_row() without row_number review result. however, note if driver doesn't support method, there may not way accomplish task: if driver doesn't support fetching rows number, row_number parameter ignored.

c# - Add Serialized List to jquery Datatables -

i'm trying add serialized list in .txt file , add jquery datatable using ajax call, got error in first line of ajax. can tell me i'm doing wrong? this path.txt (serialized list): ["ens frutas","rest","cenas","$26.50",0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,"$26.50"] this datatable-filling javascript: $(document).ready(function () { var table = $('#pftable_hdr').datatable({ "ajax": { "url": "/path.txt", "datasrc": "" }, "columns": [ { "data": "descripcion" }, { "data": "pdv" }, { "data": "rid" }, { "data": "pv" }, { "data": "1" }, { "data": "2" }, { "data": "3" }, { "data": &q

javascript - how to add row in the table dynamically -

how modify code add row in table dynamically using javascript? existing code having other functionality. need 1 button below table add row. don't need pop-up how many rows want add. every single hit add row. javascript var editing = false; function catchit(e) { if (editing) return; if (!document.getelementbyid || !document.createelement) return; if (!e) var obj = window.event.srcelement; else var obj = e.target; while (obj.nodetype != 1) { obj = obj.parentnode; } if (obj.tagname == 'input' || obj.tagname == 'a') return; while (obj.nodename != 'td' && obj.nodename != 'html') { obj = obj.parentnode; } if (obj.nodename == 'html') return; var x = obj.innerhtml; var y = document.createelement('input'); var z = obj.parentnode; z.insertbefore(y, obj); z.removechild(obj); y.value = x; y.classname = 'inp-edit'; y.onblur = saveedit;

r - Count the occurence of specific combinations of characters in a list -

my question simple..but cant manage work out... have run variable selection method in r on 2000 genes using 1000 iterations , in each iteration got combination of genes. count number of times each combination of genes occurs in r. example have # iteration 1 genes[1] "a" "b" "c" # iteration 2 genes[2] "a" "b" # iteration 3 genes[3] "a" "c" # iteration 4 genes [4] "a" "b" and give me "a" "b" "c" 1 "a" "b" 2 "a" "c" 1 i have unlisted list , got number each gene comes interested in combination. tried create table have unequal length each gene vector. in advance. the way think of paste them , use table follows: genes_p <- sapply(my_genes, paste, collapse=";") freq <- as.data.frame(table(genes_p)) # var1 freq # 1 a;b 2 # 2 a;b;c 1 # 3 c 1 the above solution assum

ios - NSMutableAttributedString strike-through with animation -

- (void)setstrokelabel:(bool)strokelabel { _strokelabel = strokelabel; if (_strokelabel) { _timer = [nstimer scheduledtimerwithtimeinterval:0.4 target:self selector:@selector(setstrokethrough) userinfo:nil repeats:no]; } else { [self cancelstrokethrough]; } } - (void)setstrokethrough { nsmutableattributedstring *attributedstring = [[nsmutableattributedstring alloc] initwithattributedstring:self.attributedtext]; (nsuinteger = 1; <= [attributedstring length]; i++) { [attributedstring addattribute:nsstrikethroughstyleattributename value:[nsnumber numberwithint:1] range:nsmakerange(0, i)]; self.attributedtext = attributedstring; } } - (void)cancelstrokethrough { nsmutableattributedstring *attributedstring = [[nsmutableattributedstring alloc] initwithattributedstring:self.attributedtext]; [attributedstring removeattribute:nsstrikethroughstyleattrib

Weird float number from sqlserver jdbc river in ElasticSearch -

i have sqlserver database , when import float type, it's import incorrect values: db value: 9.0 es value: 90.0 db value: 16.00 es value: 16000000000000004 i have setup mapping value float type , set scale:2 parameter in river config without success. my guess somewhere along line value parsed string , formatted in wrong culture. e.g. if decimal point comma, dot thousands separator (most of time) , ignored: ps> get-culture lcid name displayname ---- ---- ----------- 1031 de-de german (germany) ps> [double]::parse('9.0') 90 and 16 doesn't seem exact 16 why you'll ridiculously large number. the easiest fix change locale on server or machine. other option figure out whether that's bug in code or framework's. falls under common sense specify culture (e.g. invariant culture in .net or c locale in c) when formatting or parsing numbers intended machine consumption

How can I pass a php include call as a variable for javascript function? -

i have page use javascript innerhtml replace contents of element pseudo-static page. the following code current content of element: <?php $con = mysql_connect('***********', '******', '**********'); mysql_select_db(dbbmdmi); if ($con) { $sql = "select teamid, captain, countryid, arrdate, depdate teams"; $result = mysql_query($sql) or die(mysql_error()); $link = "<a id='" . $row["teamid"] . "' onclick='setteamid();replacecontentincontainer('content','replace_target6')'>edit</a>"; if ($result) { // output data of each row while($row = mysql_fetch_array($result, mysql_assoc)) { echo "captain: " . $row["captain"]. "<a id='" . $row["teamid"] . "' onclick=\"replacecontentincontainer2('content','<?php include 'scripts/editteam.php?teamid=" . $row

Problems with decoding bytes into string or ASCII in python 3 -

i'm having problem decoding received bytes python 3. i'm controlling arduino via serial connection , read following code: import serial arduino = serial.serial('/dev/ttyacm0', baudrate=9600, timeout=20) print(arduino.isopen()) mydata = arduino.readline() print(mydata) the outcome looks b'\xe1\x02\xc1\x032\x82\x83\x10\x83\xb2\x80\xb0\x92\x0b\xa0' or b'\xe1\x02"\xe1\x00\x83\x92\x810\x82\xb2\x82\x91\xb2\n' , tried decode usual way via mydata.decode('utf-8') , error unicodedecodeerror: 'utf-8' codec can't decode byte 0xb2 in position 1: invalid start byte . tried other decodings (ascii, cp437, hex, utf-16), face same error. do have suggestions, how can decode received bytes or decoding arduino requires? tried decode piece piece using loop, face same error message. and there general way avoid decoding problems or find out, decoding have use? thanks in advance. as @jsbueno said in comments not decoding problem

c++ - inheritance and polymorphism for class and its member at the same time (shared_ptr, C++11) -

i playing around following structure of classes use std::shared_ptr (c++11): #include <string> #include <iostream> #include <vector> #include <memory> //class member given 3rd party library, can't modify structure! class member {//no instance of class allowed public: member() {};//should never called virtual ~member() = 0;//pure virtual distructor; virtual void foo() { std::cout<<"member"<<std::endl; } }; member::~member() {} //need define destructor because of child classes class childmember : public member { public: childmember() {}; virtual void foo() { std::cout<<"child member"<<std::endl; } virtual void foo2() { std::cout<<"unique foo in child"<<std::endl; } }; class base { public: base() {}; virtual std::shared_ptr< member > get_var() {return var;} virtual void set_var ( s

localization - ios Localizing MPMoviePlayerController Done button -

i writing ios application italy. when launch mpmovieplayercontroller , there "done" button on top. change done button text italian. i changed cfbundledevelopmentregion it , changed language of simulator italian, still text of "done" button not changed. what should localize done button. thanks in advance

Paypal redirect : testing with sandbox account asks to login after redirection -

i have created sandbox account in developer.sandbox.com , in have buyer account , seller account associated it. i logged in sandbox account , when app(donation form) redirected paypal sandbox url, asks me signin sandbox account. the same worked week before after paypal developer site had upgrade beta version causing problem. please help. this has been answered here ( paypal sandbox testing - change of url endpoint? ) basically need clear cache , cookies , ensure test merchant account using has been imported new beta version. generate fresh token , should work (just worked me)

sql server - How to create a reference key from given details -

create table test1 ( id bigint not null, name varchar(10) not null constraint pk_test primary key(id,name) ) create table test2 ( mid bigint not null references test1(id) , msalary varchar(10) not null ) in test2 not able create reference test1 id please me.. in advance!!!! you need foreign key in order reference table. try this: create table test1 ( id bigint not null primary key, name varchat(10) not null ) create table test2 ( mid bigint not null, msalary varchar(10) not null, foreign key (mid) references test1(id) )

eclipse - Java Virtual Machine Launcher - could not find the main class -

this question has answer here: “could not find main class” error 2 answers i working on gui application in eclipse ide. when trying run it, following error message thrown: java virtual machine launcher - not find main class:org.cnstar.wiki.app.greatplaces.program exit. update: here how main method looks like: public static void main(string[] args) { nativeinterface.open(); swingutilities.invokelater(new runnable() { public void run() { try { // loading splash panel splashpanel panel = new splashpanel(); splashmanager manager = new splashmanager(panel); panel.setmessage("initializing..."); manager.repaint(); (int = 0; < 100; i++) { panel.setprogress(i);

javascript - Declaring array of objects -

i have variable array , want every element of array act object default. achieve this, can in code. var sample = new array(); sample[0] = new object(); sample[1] = new object(); this works fine, don't want mention index number. want elements of array object. how declare or initialize it? var sample = new array(); sample[] = new object(); i tried above code doesn't work. how initialize array of objects without using index number? use array.push() add item end of array. var sample = new array(); sample.push(new object()); to n times use for loop. var n = 100; var sample = new array(); (var = 0; < n; i++) sample.push(new object()); note can substitute new array() [] , new object() {} becomes: var n = 100; var sample = []; (var = 0; < n; i++) sample.push({});

webrtc - JsSIP Firefox - InvalidSessionDescriptionError: Answer tried to set recv when offer did not set send -

i working jssip. tried connect conference 1 way (incoming) audio stream, firefox not working. firefox error message: invalidsessiondescriptionerror: answer tried set recv when offer did not set send so our jssip configuration is: mediaconstraints: {'audio': false, 'video': false}, rtcofferconstraints: { offertoreceiveaudio: true, offertoreceivevideo: false }, sessiontimersexpires: 120, pcconfig: { iceservers: [{'url': 'stun:stun.services.mozilla.com'}, {'url': 'stun:stun.l.google.com:19302'}] } here offer body v=0 o=mozilla...this_is_sdparta-39.0 1234582256825317267 0 in ip4 0.0.0.0 s=- t=0 0 a=sendrecv a=fingerprint:sha-256 78:ff:54:2c:9a:b0:dc:2b:fc:31:83:89:17:aa:33:af:fc:ec:c5:9e:0c:8b:e4:aa:23:47:15:09:71:dd:4d:a0 a=group:bundle sdparta_0 a=ice-options:trickle a=msid-semantic:wms * m=audio 44686 rtp/savpf 109 9 0 8 c=in ip4 x.x.x.x a=candidate:0 1 udp 2122252543 x.x.x.x 44686 typ host a=candidate:0 2

Error calling Android activity from .aar library. -

i have project uses googles map api performs geofencing , other map related activities. transformed project library (.aar) can share other projects has similar use cases maps , geofnece. my problem when create new project , import .aar library cannot call activities inside .aar library. app crashers after click button call activity library , shows error in debugger. android.content.activitynotfoundexception: no activity found handle intent { act=com.package.name.mapsactivity } this how call activity public class mainactivity extends appcompatactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } //onclick button public void testsubmit(view view) { //com.package.name.mapactivity activity inside .aar intent intent = new intent("com.package.name.mapsactivity"); startactivity(intent); } } i add

sql - How can I sort A1,A2,A3,B1,B2,B3,...,AA1,AA2,AA3 in MySQL? -

i have data set looks this: +--------+ | square | +--------+ | a1 | | a10 | | a2 | | a3 | | a4 | | a5 | | a6 | | a7 | | a8 | | a9 | | b1 | | b10 | | b2 | | b3 | | b4 | | b5 | | b6 | | b7 | | b8 | | b9 | ... | aa1 | | aa10 | | aa2 | | aa3 | | aa4 | | aa5 | | aa6 | | aa7 | | aa8 | | aa9 | +--------+ the prefix runs a#-z#, goes aa#-zz# , continues, maximum of 2 letters (i.e. never go on zz). number suffix can length (i.e. a1,a10,a100,a1000,etc.). how can sort these , have result set come out follows: +--------+ | square | +--------+ | a1 | | a2 | | a3 | | a4 | | a5 | | a6 | | a7 | | a8 | | a9 | | a10 | | b1 | | b2 | | b3 | | b4 | | b5 | | b6 | | b7 | | b8 | | b9 | | b10 | ... | aa1 | | aa2 | | aa3 | | aa4 | | aa5 | | aa6 | | aa7 | | aa8 | | aa9 | | aa10 | +--

git - How to connect Visual Studio 2015 to an existing Gitlab project? -

Image
there on-premise instance of gitlab installed. there visual studio projects in instance. easiest way of connecting visual studio 2015 1 of projects? with github, can selecting "connect github" on following picture: and pasting repository url. there no gitlab option in drop down. easiest way of configuring visual studio 2015 work solution gitlab repository? work mean have usual source control bindings repository. note, question useful in more general context of connecting any git repository not github, , not have direct support built-in visual studio menu, not gitlab repository. first, clone using command line: git clone <repository url> then in visual studio, in team explorer pane, select connect button , local git repositories "tab": press add, indicated on picture, , select folder cloned repository too. when process finishes, can double-click added repo "connect" it, , select , open solution contains. after follow usu

ember.js - How to access another controller's action from another controller -

i have upgraded ember application newest version, while testing functionality, actions doesn't work. previous code working fine in older version below. export default ember.controller.extend({ needs: 'sales-order', actions: { showmodal: function(mode){ this.get('controllers.sales-order').send('showmodal', mode); } } }); looks " needs " depreciated. instead of needs should use ember.inject.controller . should this: export default ember.controller.extend({ salesorder: ember.inject.controller(), actions: { showmodal(mode) { this.get('salesorder').send('showmodal', mode); } } }); you can find more information in managing dependencies between controllers guide.

arrays - Copying subfolders with their own files to another folder with WebClient in VB.NET -

i'm copying array of subfolders , array of files of subfolders, process successful, files copied has no size. 60 mb file became 0 bytes after being copied directory, wrong? this code: dim withevents webcopy new webclient dim folderstocopy new arraylist() dim filesofsub new arraylist() private sub button6_click(byval sender system.object, byval e system.eventargs) handles button6.click folderstocopy.clear() filesofsub.clear() dim src string = form2.textbox1.text dim dest string = form2.textbox2.text dim di directoryinfo = new directoryinfo(src) dim dii directoryinfo = new directoryinfo(dest) ' subfolders , files. each sd in di.getdirectories each fi in sd.getfiles if not directory.exists(dest & "\" & sd.name) , not file.exists(dest & "\" & fi.name) folderstocopy.add(sd.name) filesofsub.add(fi.name) end if next next ' crea

sql server 2008 express - Compare rows in different table having same columns -

i have 2 tables tbl_a , tbl_a_temp. both table have same schema. primary key differ since identity columns. there way can compare 2 rows in these 2 table , know if differ.i inserting data tbl_a_temp tbl_a, need compare make sure not inserting duplicate data in main tables. regards, amit i think should work you. basically, since don't have primary key join on, you'll need perform left join on other fields. if different, null check true: select t.* tbl_a_temp t left join tbl_a on t.field1=a.field1 , t.field2=a.field2 , ... a.field1 null i've seen others use checksum , have run issues myself returning false positives.

jquery - Get only common objects from a list of arrays in javascript -

i have couple arrays in javascript code (i'm using knockout js too) , want single array contains common objects of arrays. my code this: array1 = [{a: 1, b: 'something'}, {a: 2, b: 'something1'},{a: 3, b: 'something3'}]; array2 = [{a: 3, b: 'something3'}, {a: 1, b: 'something'}, {a: 4, b: 'something4'}] array2 = [{a: 3, b: 'something3'}, {a: 1, b: 'something'}, {a: 5, b: 'something5'}] so, arrays want common of 1 single array, result this: array4 = [{a: 1, b: 'something'}, {a: 3, b: 'something3'}] i have mention array1, array2 , array3 inside array this: array0 = [array1, array2, array3]; i hope can me this, thank you! for example: array1 = [{a: 1, b: 'something'}, {a: 2, b: 'something1'},{a: 3, b: 'something3'}]; array2 = [{a: 3, b: 'something3'}, {a: 1, b: 'something'}, {a: 4, b: 'something4'}] array3 = [{a: 3, b: &

android - samsung galaxy tab 2 7.0 API level/SDK Version -

i wanted know api level or sdk version of samsung galaxy tab 2 7.0 ? hope can me :) if still on jellybean 4.1 sitting @ api level 16. don't know whether has been upgraded conclusion can come specs online if question. galaxy tab 2 7.0 update

Regex Get path name from full path -

can give me few examples of getting path full path..e.g c:\aaa\bbb\c cc\file.exe to c:\aaa\bbb\c cc\ more 1 example method cool must regex only, language called ici has similar regex perl , other such language why need few examples, atleast 1 work better other , can modify it. thanks! here basic example of inverse regex (finds filename). use substring before start path. [\w]*[.][\w]*$ and path only: .*[\\]

How to call the linux command "source FILE_NAME" from Java? -

actually have 2 commands : source file_name install abcd before executing second command, need execute first one. tied execute both command using runtime.getruntime().exec(cmd) methos, second command failed, since depends on first one. tried many combinations, not succeeded. can please me? you're executing 2 separate exec commands, spawning separate processes, , whatever in first process not visible second. resolve putting of commands script (bash, ksh, etc) , call once java program. paramterize script can pass arguments. here's on writing first shell script [edit] mentioned @rnj can @ using processbuilder pass in environment variables each of processes spawned. fine if can specify name of file being created ahead of time. example code taken api link above... processbuilder pb = new processbuilder("mycommand", "myarg1", "myarg2"); map<string, string> env = pb.environment(); env.put("var1", &quo

html - Keeping lists horizontal at all times -

i'm having trouble trying keep list horizontal, haven't been able find anywhere , white-space: nowrap doesn't work. don't mind 4 items being underneath text after screen size it's gotta horizontal still, in case goes vertical , can't figure out why, there's fiddle try out re-sizing , you'll mean! <div class="menu"> <h2> text </h2> <ul> <li><a>test1</a></li> <li><a>test2</a></li> <li><a>test3</a></li> <li><a>test4</a></li> </ul> </div> js fiddle please css or html fixes! thank you! h2 { display: inline; } ul { text-align: right; margin-right: 100px; white-space: nowrap; } li { display: inline-block; } { padding: 14px 16px; } <div class="menu"> <h2> text </h2>

asp.net mvc - Not able to POST ASP-NET form with WWW::Mechanize or LWP::UserAgent -

i need automate extraction of products catalog, authorized distributors. company ingram micro , they're huge, don't provide simple way (like web service) query catalog , stock, we've been extracting lwp::useragent far, daily, our online store database. recently, changed website, , there's can't detect preventing perl script doing succesful login. if try directly on browser, login succesfully, if try submiting form perl, login page again (like unsuccessful login). their site made on aspnet , full of hidden form fields generated asp. @ first, doing own 'spider' login page, read hidden field values , include them in post login request along username , password, now, after problem, started using www::mechanize requests , have task automated correctly. however, not www::mechanize or lwp::useragent able succesful login. i've tried looking @ exact http conversation between browser , server, , including same exact headers on automated request correct

mysql - Insert missing records from table -

i have 2 tables users (id, username, etc...) , user_contacts (id, userid, contactid, etc...) . given have user w/ id of 84, efficient query in order have missing records inserted user_contacts associate user 84 w/ other users? given recent comment, should work: insert user_contacts (userid, contactid) select u.id, 84 users u left join user_contacts uc on u.id = uc.userid , uc.contactid = 84 uc.id null this insert row user_contacts table each user don't have row contactid 84. sure specify columns correctly. alternatively, use not in or not exists . example, insert user_contacts (userid, contactid) select u.id, 84 users u u.id not in ( select userid user_contacts contactid = 84)

playframework - implicit json read and writes for lists -

i following following example https://github.com/leon/play-salat/tree/master/sample . in data model have lists , tried adopt model that. i following compilation errors: [error] /home/malte/workspace/bdt/app/models/ballot.scala:26: no json deserializer found type list[models.position]. try implement implicit writes or format type. [error] "positions" -> b.positions, [error] ^ [error] /home/malte/workspace/bdt/app/models/ballot.scala:33: no json deserializer found type list[models.position]. try implement implicit reads or format type. [error] (__ \ 'values).read[list[position]]).map { l => l.getorelse(nil) } ~ for type "position" have implicit reads , writes, how make list[position] ? implicit write , read: implicit val ballotjsonwrite = new writes[ballot] { def writes(b: ballot): jsvalue = { json.obj( "positions" -> b.positions, "title" -> b.title) } }

c - Parsing a text file - any reason why space / new line would be ignored? -

i have while loop... char count[3] = {0}; int = 0; while( c != ' ' || c != '\n' || c != '\t' ) { count[i] = c; c = fgetc(fp); i++; } and though see while debugging space , newline right ascii numbers, while loop not exit. know causing this? the logic in conditional not right. evaluate true time. while( c != ' ' || c != '\n' || c != '\t' ) if c equal ' ' not equal '\n' or '\t' . what need is: while( c != ' ' && c != '\n' && c != '\t' ) and measure, add c != eof . while( c != ' ' && c != '\n' && c != '\t' && c != eof ) it might simpler use: while( !isspace(c) && c != eof )

python - Can't scrape HTML table using BeautifulSoup -

i'm trying scrape data off table on web page using python, beautifulsoup, requests, selenium log site. here's table i'm looking data for... <div class="sastrupp-class"> <table> <tbody> <tr> <td class="key">thing dont want 1</td> <td class="value money">$1.23</td> <td class="key">thing dont want 2</td> <td class="value">99,999,999</td> <td class="key">target</td> <td class="money value">$1.23</td> <td class="key">thing dont want 3</td> <td class="money value">$1.23</td> <td class="key">thing dont want 4</td&g

Grails internationalization for the views -

in grails views, need change language labels, buttons, etc., depending on language user picked. how can achieved? i found soultion problem . a great thing of scaffolding internationalizing elements on screen breeze! default translations home , create have been provided dozen or languages in i18n folder. name of entity (“product”) , properties can defined following convention: [entity name].label , [entity name].[property name].label – see grails installation /src/grails/templates/scaffolding folder. take @ how translate few things dutch, adding few keys messages_nl.properties: product.label=product product.name.label=naam product.status.label=status here link ( http://tedvinke.wordpress.com/2012/08/22/grails-scaffolding-enums-and-i18n/ )

ruby on rails - No Method Error in show.html.erb, known good works fine, file copy/paste doesn't work -

i'm running rails 4./ruby 2.3 environment trying rails app , working , it's breaking somewhere down line following error: nomethoderror in invoices#show undefined method `company' nil:nilclass <p> <strong>company:</strong> <%= @invoice.company %> </p> <p> now, i've added alot of styling , edits app build functionality , appearance. may have broken , not sure where. did fix make app same "rails generate" commands , variables before, it's basic app. work. looking @ 2 app's side side, within invoicescontroller, same: # /invoices/1 # /invoices/1.json def show end when copy show.html.erb file known , tested app, following: nomethoderror in invoices#show undefined method `amount' nil:nilclass <p> <strong>amount:</strong> <%= @invoice.amount %> <%= @invoice.currency %> </p> i looked @ error terminal , got this: activerecord::schemami

regex - Need SED or AWK script to do strlen optimization -

i need little cause touch sed or awk. i'm trying replace string1.append("hello"); // regexp find is: \w*\.append\(".*"\) with string1.append("hello", 5); // note has figure out length of "hello" and need search , replace across hundreds of thousands of files. , "hello anything... including "\n\n\n" should 3 not 6. example: s.append("\n\n\n"); ---> s.append("\n\n\n", 3); thanks in advance help... i'm thinking need awk i'm reading tutorial basics of awk right now... since want run on files containing code, here's example of full functionality: $ cat file foo() { string1.append("hello"); if (bar) { s.append("\n\n\n"); } else { s.append("\n\\n\n\\\n"); } } $ $ cat tst.awk match($0,/[[:alnum:]_]+\.append\(".*"\)/) { split(substr($0,rstart,rlength), orig, /"/) head = substr($0,1,rstar

Drupal 6: How to create a view which displays all articles written by all members of a group -

Image
i want create view displays articles written members of group. how accomplish in drupal 6? add filters view. 1) user: roles / 1 of / select group of members 2) node: type (if need specify content type)

c - Seg Fault, malloc char pointers -

i keep getting segmentation fault , know char pointer. cant figure out why? whiskey* createwhiskey(int a, double p, char* n){ whiskey* whiskey = malloc(sizeof(whiskey)); whiskey->age = a; whiskey->proof = p; whiskey->name = malloc((strlen(n)+1) * sizeof(char)); strcpy(whiskey->name, n); return whiskey; } int main(){ whiskey* burbon; burbon = createwhiskey(12, 90.0, "makersmark"); free(burbon); return 0; } in comment alex (see below) following information added: typedef struct{ int age; double proof; char* name; }whiskey; as discussed in comments program shown fine. however, should add checks avoid problems. like: typedef struct{ int age; double proof; char* name; } whiskey; whiskey* createwhiskey(int a, double p, char* n){ whiskey* whiskey = malloc(sizeof(whiskey)); if (whiskey) { whiskey->age = a; whiskey->proof = p; if (strlen(n) > some_maximum)

architecture - Why are multiplication algorithms needed if hardware already does it? -

i learning karatsuba algorithm fast integer multiplication , wondered, since computers have dedicated hardware built cpus multiplication why algorithm necessary? is large numbers hard multiply, algorithm breaks down simpler steps easier hardware handle, because hardware @ multiplying smaller numbers? all cpu has fixed bit width alu/fpu. for example on i80x86 (pc) alu limited to: i8086+ 16 bit i80386+ 32 bit x64 arch 64 bit allowing compute 16/32/64 bit numbers operands. i80x87 fpu use 80 bit number representations converted from/to ieee float(32bit)/double(64bit) limiting precision. if need compute numbers bigger bit width hw limit then need break down chunks computable on alu/fpu (and handle them digits of number) , combine results final value. alu counting , why cpu's have carry flag , alu support adding , substracting carry. if doing simple +/- add/subs digits lowest (lsw) highest (msw) propagating carry. see: cant make value propagate thr

c# - In linq at a time how to join multiple tables -

Image
i know how join in linq, failed desired output plain join , need advanced idea. table structure bellow my input , out set bellow base on tables want write linq query gives me required table result. is possible in linq or need create list , manually update it?

resize - OCaml: Dynamic Arrays? -

i've been trying figure out how resize initialized array in ocaml. however, seems while can write function create brand new array elements of old 1 copied on (and slots), function's output cannot assigned existing array. how 1 this? there easy way in use references make happen if not without? here's tiny example: let rec function_that_adds_to_array storage args ... = (* let's function has set of if-else constructs controls does, , let's further 1 of cases leads to: *) let new_array = array.make (array.length storage) ("null", ("null", -2)) in array.blit collection 0 new_array 0 index; (* index controlled function's recursion *) array.set new_array index (obj_name, obj_expr); new_array) (* insert macro @ tail *) ... ;; ### main method ### let storage = array.make 10 ((x : string), (a, b)) in ... while true ... storage = function_that_adds_to_array storage args....; ... a print statement @ end of function_that_a

windows - Can't Configure Remote Access of Docker Host -

i did successful docker windows install on 2 windows machines (windows 10 , windows 7 x64 sp1). can perform administration duties of docker hosts through terminal services (rdp) or through powershell remoting. however, docker documentation indicates docker host offers own restful remote api administration. use api. problem in examples given in documentation, client invocations (via curl ) physically on same box docker host. in other words not remote and, unfortunately, steps adapt remote scenario not obvious. for example, consider command taken straight documentation: curl --insecure --cert ~/.docker/cert.pem --key ~/.docker/key.pem https://your_vm_ip:2376/images/json obviously need your_vm_ip proceed. on both of windows boxes type docker-machine ls . discover on both physical windows machines address docker host tcp://192.168.99.100:2376 . oops. can't both have same ip address. virtualbox nat address local vm in both cases. this primary issue. i

jquery - Changing text in a div -

my aim once click on each photo - not displaying now( can see broken image icon) text inside div "core-tab-sec" should change. see 3 paragraphs , each of them 1 of photo. 2 of them should hidden , 1 displayed. can me this? here of code https://jsfiddle.net/net1994/7zovyuow/ <div class="core-tab-sec"> <ul class="core-tabnav"> <li class="active"><a href="#tab1"><figure><img src="<?php bloginfo('template_url'); ?>/img/people-icon.png" alt="people"></figure><div>people</div></a></li> <li><a href="#tab2"><figure><img src="<?php bloginfo('template_url'); ?>/img/passion-icon.png" alt="passion"></figure><div>passion</div></a></li> <li><a href="#tab3"><figure><img src="<?php bloginfo('template_ur

javascript - Post redirect Get on same page PHP -

this old issue , have consulted many questions on before posting this how prevent form resubmission when page refreshed via php post/redirect/get on same page firefox preventing form resubmission and many other. i have small app , structure this index.php (acting controller) viewsfolder(contains html) models(contain db insertion etc) when user lands on index.php show him required view suppose require_once(views/signin.php) user submits form on index.php , signin.php posts data index.php?signin=true . call required function models , make redirect itself. avoid form re-submission. apparently in chrome , in firefox still able resubmit form , click on button of browser go previous page. destroys whole business logic. i assume redirection should here n't know can use ajax avoid of that, cant without ajax. don't think every mvc based cms using ajax on backend. is wrong me architecture ?

html - Partial support in IE9+ refers to the fonts only working when set to be "installable" - what's that mean? -

i trying implement .otf font website working on @font-face rule: @font-face { font-family: "neris"; src: url(../fonts/neris/neris-semibold.otf) format("opentype"); font-weight: 400; } however, doesn't work in ie, checked caniuse , said: partial support in ie9+ refers fonts working when set "installable". what's mean anyway? there can make "installable" or should give ie support in case? thanks!

html - Can't center animated div with Animate.CSS or other animation libraries -

i'm trying center div in page , animate it, but transform:translate(-50%, -50%) will not work @ relying on default top: 50%; left: 50% here html code: <html> <head> <link href="http://www.exaltedweb.com/refs/animate.css" rel="stylesheet" type="text/css"/> <link href="stylesheets/admin2.css" rel="stylesheet" type="text/css"/> </head> <body> <div id="container"> <div class="modal-wrapper" style="position: absolute; width: 100%; height: 100%; top: 0; left: 0; display:block;"> <div class="modal-background" style=""></div> <div class="modal-content animated bouncein"></div> </div> </div> </body> here css: #container{ width: 100%; height: 100%; } .modal-wrapper{ position: absolute; widt