Posts

Showing posts from March, 2013

node.js - Waterline: query array using AND for elements -

i have model { title: 'title', tags: ['foo', 'bar'] } . how query documents containing tags foo , bar @ same time without going native? i tried contententry.find({tags: ['bar', 'foo'] }) but returns documents having either foo or bar in tags , while i'm interested in having both tags. there exact answer in similar topic https://stackoverflow.com/a/33145145/679052 rather workaround sails-mongo adapter allows use $and operator

security - Azure Storage, using BlobRequestOptions without CloudBlobClient -

the app i'm building downloads , uploads blockblobs on azure. i'm using v6.1 , works fine. cannot upgrade v7 because of following issue : i'm maybe totally wrong, decided not have cloudblobclient in application because don't want store connection string. instead, container upload / download initiated through sas uri provided web service actual (and shortened) download workflow following : //jsonstring contains sas uri provided web service var jsonstring = await response.response.content.readasstringasync(); cloudblobcontainer cloudcontainer = new cloudblobcontainer(new uri(jsonstring.replace('"', ' ').trim())); icloudblob blob = cloudcontainer.getblockblobreference(item.blobname); await blob.fetchattributesasync(); blob.serviceclient.paralleloperationthreadcount = 10; asyncresult = m_blob.begindownloadtostream(pstream, blobtransfercompletedcallback, new blobtransferasyncstate(m_blob, pstream)); this works well, blob.serviceclient.parall...

android - Cancel/Modify Intent Message -

i want send confirmation second activity main activity. if checkbox marked want set intent data , set result returned activity true . otherwise if checkbox unmarked want either: modify intent set false remove intent altogether if wasn't set confirmcheckbox.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { // view checked? boolean checked = ((checkbox) view).ischecked(); if (checked) { intent data = new intent(); data.putextra(extra_confirm, true); setresult(result_ok, data); } else { // remove or modify false. } } }); how can either of actions modify or cancel intent message? also, know what's best way handle it? you can use checkbox value value intent. there's no need have if/else construct. @override public void onclick(view view) { // view checked? boolean checked = ((checkbox) vie...

php - Magento Invalid - method Mage_Sales_Model_Order::assignCustomer -

Image
basically, im trying make finance section on magento, have looked how place order part of finance submission, everywhere uses code below (not exact): $order = mage::getmodel('sales/order'); $store = mage::app()->getstore(); $website_id = mage::app()->getwebsite()->getstoreid(); $quote = mage::getmodel('sales/order')->setstoreid($store->getid()); $customer = mage::getsingleton('customer/session')->getcustomer(); $quote->assigncustomer($customer); $quote->setsendcconfirmation(1); $product_ids = array(); $cart = mage::getmodel('checkout/cart')->getquote(); foreach($cart->getallvisibleitems() $item) { $quote->addproduct($item->getproduct() , $item->getqty()); } $shipping = $quote->getshippingaddress(); $shipping->setcollectshippingrates(true)->collectshippingrates()->setshippingmethod('flatrate_flatrate')->setpaymentmethod(array( 'method' => 'checkmo' )); try { ...

office365 - SharePoint 2013 Search Service to index Office 365 Shared Mailbox -

i have project requires sharepoint 2013 search service (on premise deployment) index 1 office 365 shared mailbox. based on research following not possible: exchange content source: works old on premise exchanges ediscovery: different feature. has exchange configuration can’t used in search scenarios. business connectivity services:i tried creating external content source in visual studio providing odata urls didn’t succeed hybrid federated search works in scenario sharepoint server 2013 sharepoint online, not in scenario third part solution not accessible client. this post close scenario old , doesn’t lead solution. i explored new “groups” in o365 not applicable. client needs single place searching sharepoint data , shared mailbox. what see possible approach use of outlook rest api real time searches against mailbox. tested , i’m able retrieve data in sharepoint hosted app. big problem don’t have refinements , total items count. can point me better solution? mi...

java - How to make sheetname tab in vaadin spreadsheet readonly -

Image
in vaadin-spreadsheet tab displays name of sheet editable. want make readonly. refer pic . suggestions? have tried spreadsheet.lockactivesheet() api not working disclaimer: more suited comment, surpasses maximum length... in excel protecting current sheet not prevent rename. protecting workbook it, please note that prevents addition, deletion, etc . since vaadin implementation relies on apache poi try passing in spreadsheet constructor xssfworkbook locked structure . nonetheless, looking @ sources , setworkbookprotected() method seems setting whole sheet read-only , i'm unable validate assumption since don't have licence commercial add-on (test key expired). public void setworkbookprotected(boolean workbookprotected) { sheettabsheet.setreadonly(workbookprotected); } all in don't think there's dedicated method of doing this, nor easy workaround.

How to use local json file in swagger-ui documentation -

Image
i trying use local swagger.json file displayed in swagger documentation. my swagger.json file under /home/user1/swagger-ui/dist/swagger.json , index.html resides under same directory. have modified index.html below. window.swaggerui = new swaggerui({ spec: ../swagger.json url: url, dom_id: "swagger-ui-container", after starting docker instance using docker run -p 80:8080 swagger-ui-builder , accessing http://192.168.xx.xx/ not display documentation. attaching screenshot reference. please me resolve this. here solution found here (pretty quick , painless if have node installed): with node, globally install package http-server npm install -g http-server change directories json located, , run command http-server --cors (cors has enabled work) open swagger ui (i.e. dist/index.html) type http://localhost:8080/my.json in input field , click "explore"

html - Clip path polygon css in not working in firefox and internet explorer -

i wan cut image right bottom , done not working in browser. there way this? note: hover effect necessary. here code. .clip>a>img{ -webkit-clip-path: polygon(0 100%, 0 0, 100% 0, 73% 100%); } .clip>a>img:hover{ -webkit-clip-path: polygon(0 100%, 0 0, 100% 0, 100% 100%); } <html> <head> <title></title> </head> <body> <div class="clip"> <a href="#"> <img src="https://farm4.staticflickr.com/3165/5733278274_2626612c70.jpg"> </a> </div> </body> </html> thank you. in short: doesn't work there because using css properties don't belong (firefox's , ie's) rendering engine. look @ question here see informative discussion it. gist is: webkit opera rendering engine, , works in chrome because chrome's rendering engine (gecko) based on webkit. from looking @ this css-tricks post seems b...

javascript - Simple D3.js line chart with data that are values collect every hours -

i'm newbie on d3.js , need produce simple line chart using values collected every hours i'm trying use d3.js sample ... http://bl.ocks.org/d3noob/b3ff6ae1c120eea654b5 ... , adapt data this 6/28/2016-10:2:0,24.3 6/28/2016-9:2:0,23.2 6/28/2016-8:2:0,22.2 6/28/2016-7:2:0,21.5 6/28/2016-6:2:0,21.2 6/28/2016-5:2:0,20.8 6/28/2016-4:2:0,21.6 6/28/2016-3:2:0,21.6 6/28/2016-2:2:0,22.0 6/28/2016-1:2:0,22.4 6/28/2016-0:2:0,23.3 6/27/2016-23:2:0,25.0 6/27/2016-22:2:0,25.4 6/27/2016-21:2:0,27.0 where 6/28/2016-10:2:0 time (mm/dd/yyyy-hh:mm:sec) , 24.3 value i'd plot (note can modify structure if needed ...) how may set time format in case, how i've modify following lines? // parse date / time var parsedate = d3.time.format("%d-%b-%y").parse; are these lines i've modify replicate sample code data? any samples / suggestion? sorry entry-level question, hope after move next steps in more independent way!!! cesare replacing data ...

solrj - Atomic Updates in Solr - multiple shards -

we working on atomic update feature in solr using solrj. solr update record correctly if distributed across shards? if record in shard2, updated or create new record in shard1? if you're handling sharding yourself, you'll have update exact shard in question (as you're 1 responsible distributing documents). if you're using solr in solrcloud mode, solr route document correct shard you, based on document routing strategy.

babeljs - Equivalent of Babel plugin for Typescript? -

using typescript compiler api, can code transformations in own scripts. seeing how typescript doesn't have plugin/extension architecture, can't find way integrate build pipeline. with babel, can integrate custom code transformation packaging code in plugin , loading plugin using .babelrc file. so i'm asking if typescript providing babel plugin system can write visitor-pattern-based transformations , plug straight default compiler?

javascript - nodejs + mqlight connection error -

i using nodejs mqlight run sample code provided https://www.npmjs.com/package/mqlight . i using nodejs 5.5.0 , npm version 3.3.12. i installed mqlight using npm install mqlight . var mqlight = require('mqlight'); var recvclient = mqlight.createclient({service: 'amqp://localhost'}); var topicpattern = 'public'; recvclient.on('started', function() { recvclient.subscribe(topicpattern); recvclient.on('message', function(data, delivery) { console.log('recv: %s', data); }); }); var sendclient = mqlight.createclient({service: 'amqp://localhost'}); var topic = 'public'; sendclient.on('started', function() { sendclient.send(topic, 'hello world!', function (err, data) { console.log('sent: %s', data); sendclient.stop(); }); }); while running above code got below error. e:\nodejs>node mqtest....

deployment - Error while Deploying WAR in WebSphere using ANT -

we trying checkout, build , deploy ear files ( ibm integration designer developed mediation modules.. similar java ear files ). while deploying nd getting below error... [wsadmin] wasx7017e: exception received while running file "c:\users\instal~2\appdata\local\temp\wsant1588202279705404612jacl"; exception information: com.ibm.ws.scripting.scriptingexception: wasx7132e: application install c:\ant_automation\esb\mmcheckout\ky_sf1520_cprservices_mmapplication\ky_sf1520_cprservices_mm.ear failed: see previous messages details. [wsadmin] wasx7341w: no "save" performed before interactive scripting session exited; configuration changes not saved. build failed c:\ant_automation\esb\build.xml:124: java returned: 105 total time: 1 minute 53 seconds i think have save configuration after deployment in nd deployment, not sure how can save using ant. dmgr system log [28-06-16 16:43:13:572 cest] 000003ef installschedu adma5016i: installation of ky_sf1520_cprser...

Ansible include task files based on conditional -

just getting ansible , want know if can include file in task main.yml based on variable passed in --extra-vars ? example; main.yml -- role/tasks # upload latest json s3 - include: upload-code.yml playbook.yml -- playbooks - name: launch cloudformation stack hosts: 127.0.0.1 connection: local roles: - launch.cloudformation as can see playbook.yml includes role , main.yml includes upload-code.yml how can include upload-code.yml based on conditional below ansible-playbook playbook.yml --extra-vars "include=upload" you can applying when condition include task. - include: upload-code.yml when: - include defined - include == "upload" or, if have multiple include files use include part of name. - include: "{{ include }}-code.yml" when: include defined

dom - Passing jQuery reference through Web Worker -

i'm working on offloading url polling requests web worker. this, need fetch attributes dom element of invokation, pass them url request, update original dom element results. since multiple dom elements use function fetch updates, need pass through $(this) or equivalent unique identifier ensure correct element updated. i understand questions such "passing objects web worker" , "can pass jquery object web worker" not possible, looking means emulate this. here rough outline of code: //main.js function update(){ var data = { 'id' : $(this).attr('itemid'), 'filter' : $(this).attr('filter')} updatepoller.postmessage(data); } //worker.js this.onmessage = function(e){ //format params e.data //make request url //when done... postmessage(req.responsetext); } //main.js (again) updatepoller.onmessage = function(message){ //process response //update child elements of $(this) }...

sql - How to restore differential mysql dump -

i have database named "testing". have restore data new dump file having old + new data "testing" database. want restore new data database (without duplicating old data ) . tried taking backup of portion of table , restoring ( how use mysqldump portion of table? ), did't work out because no column id in table (primary key row count ) my table structure , | b | c | d | e | +---------------+------------+---------+-------+---------+ | 1432550740000 | 111004 | 10000 | 2 | 9690001 | | 1432550790000 | 123001 | 10000 | 2 | 9690001 | | 1432550340000 | 44440215 | 10000 | 2 | 9690001 | | 1432550450000 | 125400054 | 10000 | 2 | 9690001 | | 1432551444000 | 43459067 | 10000 | 2 | 9690001 | +---------------+------------+---------+-------+---------+ can please guide me ? you can take little detour creating new table (same structure old one) , dump data of old , new data one. ...

winforms - How can i create combo boxes which i can choose my font with C#? -

Image
i have richtextbox text (for example: hello world). aim make 2 combo boxes can choose font , font size. richttextbox should change font whole text. for example: word. it nice when can tell me how can begin or must search in google. search whole day , find posts font dialog. i use visual studio windowsformsapplication question: how can make combo boxes in c# on picture? with friendly wishes sniffi it not hard. need find fonts installed on current machine, populate combo box them, , when user selects item combo box change font depending on selection. to find installed fonts: https://stackoverflow.com/a/8657854/4795214

Access - DLookup in a table field? -

for exercise have 2 tables. table a : employee record , table b : timesheet record . timesheet record tells me employee has entered how many hours job, other unimportant information. what need know how can bill client hours on entry? i have hourly rate set in employee record - however, i'm not entirely sure how pull information across. in perfect world, i'd dlookup cell (putting "hourly rate" alongside "hours" in single entry), final calculated cell multiply two. alternatively calculated cell "hours" in timesheet record , multiplied "hourly rate" in employee record , i'm not sure how limit result specific employee of record in timesheet record . any appreciated. ps: using access 2010. create select query join tablea.id on tableb.employeeid, group by tablea.id , tableb.projectid, , sum tableb.hours billinghours. this billinghours multiply hourlyrate billingamount.

issue with DecimalFormat in java -

this question has answer here: how round number n decimal places in java 28 answers i facing issue in below code - int precision = 3; string value1 = "2.0425"; string value2 = "2.1425"; decimalformat dfform = new decimalformat(); dfform.setminimumfractiondigits(precision); dfform.setmaximumfractiondigits(precision); system.out.println(dfform.format(value1)); system.out.println(dfform.format(value2)); output - 2.042 2.143 1st output expected 2.043. can me in this? from docs decimalformat : decimalformat provides rounding modes defined in roundingmode formatting. default, uses roundingmode.half_even . it sounds need: dfform.setroundingmode(roundingmode.half_up); that's after you've fixed code call format on actual numbers, mind you: bigdecimal value1 = new bigdecimal("2.0425"); big...

jquery - Slide Up on click -

i have several divs on page. on page load want first div visible 'show more' link. upon clicking 'show more', want load first three divs , on clicking second time want show all divs. so far working fine. after show all , when span tag clicked, should slide , hide except first div i.e should reset divs on page load gives show more/show less effect. here fiddle try this <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"> </script> <div class="offerscontainer"> <div class='pan-box'>a</div> <div class='pan-box'>b</div> <div class='pan-box'>c</div> <div class='pan-box'>d</div> <div class='pan-box'>e</div> <span>show more</span> </div> <script> $(".offerscontainer > div:gt(0)").hide(); var click = false; var = 1; $(".offersc...

c# - To open an EXE on a remote computer using ip address -

i want open program on remote computer ip 10.64.4.38 through c# windows based program. the file want open on . @"c:\program files\realvnc\vnc viewer\vncviewer.exe" i using following code it's not working. please me out connectionoptions options = new connectionoptions(); options.impersonation = impersonationlevel.impersonate; options.authentication = authenticationlevel.default; options.username = username; options.password = password; options.authority = null; options.enableprivileges = true; managementscope scope = new managementscope(path, options); scope.connect(); // create process using (managementclass process = new managementclass("win32_process")) { connectionoptions conn = new connectionoptions(); conn.username = "support"; conn.password = "password"; process.scope = scope; process.invokemethod("create", commandline); managementscope ms = new managementscope(@"\\10.64.4.3...

php - Add zeros at beginning of a number if it is small than 1000 -

i have sql query select count(*) tot_std `login` `login_account_type` = 'student' the output of query 9. what want add: three zeros if number small 10, 0009. two zeros if number small 99, 0099, one 0 if number smaller 999, 0999. if number equal or greater 1000, don't add zero. note using php codeigniter , mysql project. please help. try below code in query, can like select lpad(count(*),4,'0') tot_std login login_account_type = 'student' in php $your_value = 9; $your_value = str_pad($your_value,4,'0', str_pad_left); echo $your_value; str_pad() function add leading zeros. second parameter shows total number. need thousands, add 4. 3rd parameter represent character added @ beginning. fourth parameter side need add zero

python - Step with scipy integrator without going past final point -

the scipy integrators take 2 parameters when integrating: (1) step tells integrator take single step, , (2) relax tells integrator fine step past final time point. i want take steps (so can collect entire solution), not step past final time (because have discontinuity in real problem). however, step being true seems ignore relax being false . take 1 step on final time abandon. here simple example illustrating problem: from scipy.integrate import ode obj = ode(lambda t, y: -y) # simple exponential decay obj.set_initial_value(4.0) final_time = 2.0 ts_new = [] ys_new = [] # take 1 step @ time until final time reached while obj.t < final_time: y_new = obj.integrate(final_time, step=true, relax=false) ts_new.append(obj.t) ys_new.append(y_new) print(ts_new[-1]) # 2.073628416585726 i have expected last step partial step (is it's called?) , stop on final_time , such value given obj.integrate(final_time, step=false, relax=false) . other rerunning enti...

c# - passing value to handler -

i have code this: private void button1_click(object sender, eventargs e) { openfiledialog1.showdialog(); } private void openfiledialog1_fileok(object sender, canceleventargs e) { string ext = path.getextension(openfiledialog1.filename); if(string.compare(ext, ".fdb") == 0) { string filename = openfiledialog1.safefilename; string filedirectory = path.getdirectoryname(openfiledialog1.filename); string databasetxt = @"c:\users\arist\appdata\roaming\tdwork\"; string[] database = { filedirectory + filename }; if (directory.exists(databasetxt)) { system.io.file.writealllines(databasetxt + "databases.txt", database); } else { directoryinfo di = directory.createdirectory(databasetxt); system.io.file.writealllines(databasetxt + "databases.txt", database); } } else { messagebox.show("fajl koji s...

properties - How to prevent people from stealing my source code? -

i stuck searching of how people can source code , cab once access ? , how can protect ? ( called lisense ?) you can use third-party services uglifyjs online . those services replace identifiers - variable or function names - random, short names. way, thief of code given hard time understand how code works, rendering useless him. you keep readable code yourself, , keep developing it. once want publish new version, make copy of code, uglify , upload servers. your code still work in browser @ times.

sql - Need part of a date -

i using sql server 2008r2. trying part of date in output, , column in datetime datatype. eg, if current date , time 2016-06-28 17:34:12.060 , need output 17:00 hour :00 mins. i have tried until now, select datename(hh,substring('2016-06-28 17:34:12.060',12,5)) +':00' which gives me right output.but when pass column name of datetime datatype, gives error, select datename(hh,substring(timeinhour,12,5)) +':00' gives error, argument data type time invalid argument 1 of substring function. i know using substring() @ wrong place, don't know how achieve output. appreciable.i need output hh:00, hour 00 mins. why use substring() @ all? second argument datename() should date/time data type. so, do: select datename(hour, '2016-06-28 17:34:12.060') + ':00'

javascript - Resizing a kendo drop-down -

i have kendo dropdown have resize reason not work. shows icon not resize container. html : <select id="dropdownlist"> <option>1</option> <option>2</option> <option>3</option> javascript $("#dropdownlist").kendodropdownlist(); css .k-list-container { resize: both; overflow: auto; } it works other control besides dropdown. can point me in right direction please? http://jsfiddle.net/bws9j/389/ check out: $("#dropdownlist").kendodropdownlist().data("kendodropdownlist"); var dragging = false, currentx = null, currentw = null; $("body") .on("mousedown", ".k-dropdown-wrap", function(e) { dragging = true; currentx = e.clientx; currentw = $(this).width(); }) .on("mouseup", ".k-dropdown-wrap", function() { dragging = false; }) .on("mousemove", function(e) { ...

css - Centering components in a Layout -

Image
i'm trying center picture , label vertical layout here's code wrote: picture = new embedded(null, brandableresourcehelper.getinstance().newresource("image/icon.png")); lab = new label(); lab.setwidth(100, units_percentage); verticallayout col = new verticallayout(); col.addcomponent(picture); col.addcomponent(lab); col.setwidth(30, units_percentage); col.setcomponentalignment(picture, alignment.middle_center); col.setcomponentalignment(lab, alignment.middle_center); here's wanna get: here's i'm getting:

c - Issue if polled on listening socket instead of binding fd -

in tcp server/client, polling on binding fd (fd received during socket connection , binded ip). wondering impact if polling on listening socket (socket fd received during accept call)? polling on listening socket can anyway have issue related close_wait state socket issue? sample code below:- struct pollfd pfd; pfd.fd = sockfd; /*listening socket fd got during accept call*/ pfd.events = pollin; ret = poll(&pfd, 1, 60000); if (ret == 0 || errno == eintr) { *err = socket_err_read_timeout; *size = 0; return socket_failure; }else if (ret < 0) { close(sockfd); return socket_failure; } ret = recv(sockfd, content, *size , 0); if (ret == -1) { close(sockfd); *size = 0; return socket_failure; } else if (ret == 0) { close(sockfd); *size = 0; return socket_failure; } *size = ret; return socket_success;

android is not working -

greeting,i developing 1 app implementing load more on recyclerview view using interface. but problem work fine first time , after monloadmorelistener null,i dont know why monloadmorelistener null. so not load next element this code , listener follows onloadmorelistener.java public interface onloadmorelistener { void onloadmore(); } the main problem @ first time load data well. , when scroll list down , when reach @ last item load next data @ first time after doesnt work... i checked monloadmorelistener become null. so please give solution. getting irritated because of it. please me.solve problem because important me.i searched on internet didnt thanks in advance as see, first time create adapter = new dataadapter(); in oncreate() method , set adapter.setonloadmorelistener(new onloadmorelistener()) . later in getproducts() method recreate adapter (check jsonarrayrequest->onresponse) , lose onloadmorelistener . problem suppose.

powershell v2.0 - Not able to connect to a remote SQL Server instance -

i trying find solution problem online no luck yet. hence posting question: i running powershell script fetch backup details sql servers mentioned in notepad. script working fine sql servers till 2008r2 . getting error while connecting sql server 2012/2014 . script running on windows server 2008 having sql server 2008r2 installed on it. request me troubleshoot it. input file:e:\sachin\sql_servers2.txt servername,servername,1433 $servers = get-content 'e:\sachin\sql_servers2.txt' #create new excel object using com $excel = new-object -comobject excel.application $excel.visible = $true $excel = $excel.workbooks.add() $sheet = $excel.worksheets.item(1) #counter variable rows $global:introw = 1 foreach ($sv in $servers) { # separate server , instance names $srvr = $sv.split(",") $server = $srvr[0] $instance = $srvr[1] $port = $srvr[2] getsqlinfo $server $instance $port function getsqlinfo { param ( [string]$svr, [string]$inst, [string]$port...

javascript - how to avoid drag and drop for a specific list item in sap.m.list -

i have implemented drag n drop sap.m.list below. need avoid drag drop specific items of list. how stop drag n drop feature specific items jquery.sap.require('sap.ui.thirdparty.jqueryui.jquery-ui-core'); jquery.sap.require('sap.ui.thirdparty.jqueryui.jquery-ui-widget'); jquery.sap.require('sap.ui.thirdparty.jqueryui.jquery-ui-mouse'); jquery.sap.require('sap.ui.thirdparty.jqueryui.jquery-ui-draggable'); jquery.sap.require('sap.ui.thirdparty.jqueryui.jquery-ui-sortable'); my.clauserendering = function (ocontrol) { //inject control //debugger; test = this; test.ocontrol = ocontrol; }; my.clauserendering.prototype = { onafterrendering: function () { $("#clauselist-listul").addclass('ui-sortable'); $("#clauselist-listul").sortable({ //connectwith : ".ui-sor...

c# - Visual Studio Can't Update .NET -

Image
i have problem in updating .net framework of file.... use webclient, it's not available in .net 4.0:

performance - Truly vectorized routines in python? -

are there methods in python vectorize matrix data constructs/containers -operations? according data constructs used? (i observe , read pandas , numpy element-wise operations using vectorize or applymap (may case of apply/apply along axis rows/columns) not of speed progress compared loops. given when trying use them, have mess specificities of datatypes when little bit easier in loops, benefits? readability?) are there ways achieve gap of performance similar happens in matlab when comparing loops , vectorized operations? (note not bash numpy or pandas, these great, whole matrix operations ok, when have element-wise operations, becomes slow). edit explain context: wondering because received more once answers mentionning fact apply , on similar loops. that's why wondering if there similar functions implemented in such way perform better. actual problems varied. had element-wise, actually, not "doing sum, product, whatever of whole matrix". did lot of comparison...

java - How to mock Guava Maps.newConcurrentMap() -

how mock this? public class myclass { } use dependency injection : public class myclass { private map<string, myclassmodel> list; // don't initialize. public myclass(map<string, myclassmodel> list) { // inject ctor. this.list = list; } }

xamarin - Setting bit rate and sampling rate-Android -

i working on xamarin cross-platform app in have audio recording feature. have used mediarecorder native android api recording. here code: recorder = new mediarecorder(); recorder.setaudiosource(audiosource.mic); recorder.setoutputformat(outputformat.mpeg4); recorder.setaudioencoder(audioencoder.aac); recorder.setaudioencodingbitrate(8000); recorder.setaudiosamplingrate(44100); recorder.setoutputfile(path); recorder.prepare(); recorder.start(); the above code doesn't set bit rate , sampling rate audio. since media recorder not have pause , resume feature trying creating temp file , append file new(final) audio file. since sampling , bit rate of 2 files merging has same, merge function not work. any on setting bit rate , sampling rate?

sql - JOIN two tables but only return rows from Table 1 that match Table 2 -

good day have 2 tables need join , transfer excise tbl , value entry . transfer excise tbl: no must match item no in value entry table. did comparison items not in transfer excise in value entry , found few. transfer excise tbl: starting date no_ excise location location code unit rate excise type code unit of measure code litre conversion factor ----------------------- -------------------- --------------- ------------- --------------------------------------- ---------------- -------------------- --------------------------------------- 2013-02-28 00:00:00.000 600011263 nonbond ~duty paid 2.70000000000000000000 uwnepack litres 1.33333000000000000000 2014-02-27 00:00:00.000 600011263 nonbond ~duty paid 2.87000000000000000000 uwnepack litres 1.33333000000000000000 2015-02-26 00:00:00.000 60001126...

while importing csv to sqlite database android facing special character issue on view part -

i importing questions.csv sqlite database, imported successfully, in view part of questions i'm getting ? mark instead of proper special character. i tried import csv in utf-8 still got same result. my special characters : 1. alpha, 2. theta, 3. pie, 4. degree-celsius, 5. 1/2 , 6. square, 7. cube, 8. m-1 l-2 t-1 , -1 in upper square, 9. <= , 10. >= , 11. - for should csv file? should write in csv?

c# - Files and Directories inside Access Database -

Image
i'm working on program contains directory ( major directories , each directory contains sub directories , each sub directory contain sub2 directories , on ... till final directory contains .doc files objects.) example: how can design data base accept tree hierarchy can each directories , open .doc in c# program. i'm beginner in using tree-view , database. thanks edit: i have 7 main folders , each folder has number of sub-folders , may sub-folders1 have sub-folders2 contain files, other sub-folders1 have files too. ( files 10000 almost). question: how populate structure database can list them in treeview or listbox ? thanks you can go unlimited level infinite structure 1 table. using ms sql here. same logic apply ms access well. id unique identifier of row. parentid reference id row appear under. in other words, parent of current row. name field containing directory or file name. isfile (can omitted) determine if file or directory. can apply log...

javascript - Error when uploading images using Play! Framework on Google Chrome -

i'm using play! framework , i'm having troubles make upload of images, in google chrome: [error] play - exception caught in requestbodyhandler java.nio.channels.closedchannelexception: null @ org.jboss.netty.channel.socket.nio.abstractnioworker.cleanupwritebuffer(abstractnioworker.java:433) @ org.jboss.netty.channel.socket.nio.abstractnioworker.writefromusercode(abstractnioworker.java:128) @ org.jboss.netty.channel.socket.nio.nioserversocketpipelinesink.handleacceptedsocket(nioserversocketpipelinesink.java:99) @ org.jboss.netty.channel.socket.nio.nioserversocketpipelinesink.eventsunk(nioserversocketpipelinesink.java:36) @ org.jboss.netty.channel.defaultchannelpipeline$defaultchannelhandlercontext.senddownstream(defaultchannelpipeline.java:779 on client-side, request code: var formdata = new formdata(); (var = 0; < $scope.images.length; i++) { formdata.append('picture' + i, $scope.images[i]); } $http.post('/resource/ad/' + id + '/upload', ...

android - How do I pass data from sqlite database to another activity? -

i have database columns {id,eng,kurd,ar} , have populated listview shows {eng} databse. want pass {eng,kurd,ar} have same {id} when user clicks item in listview, when click item app crashes, else works fine there no error in non of other classes[adapter,sqliteopenhelper] mainactivity.class package com.rawa.rawadict; import android.content.intent; import android.database.cursor; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.view; import android.widget.adapterview; import android.widget.arrayadapter; import android.widget.listview; import android.widget.textview; import java.io.ioexception; import java.sql.sqlexception; import java.util.arraylist; public class mainactivity extends appcompatactivity { adapter adapter; arraylist<item> mylist = new arraylist<item>(); listview mylistview; databasehelper mydbhelper = new databasehelper(this); string engres,kurdres,arres; @override protected voi...

reactjs - Execute async task in componentWillUnmount in React Native? -

i trying disconnect bluetooth device before unmounting component in react native. disconnect done asynchronously. following approach not disconnecting device. how can make work? i guess has fact disconnect done async. componentwillunmount(){ bluetoothmanager.disconnect(device); // working in other contexts. }

php - where clause not working in codigniter -

Image
i showing products in page clause. selecting product table category vegetable, it's not working. new in codeigniter. checked many questions on internet, nothing working. if there in code wrong, please tell me. the controller part: <?php class products_list extends ci_controller { function __construct() { parent::__construct(); $this->load->helper('url'); //to load css base url $this->load->helper('form'); $this->load->library('form_validation'); $this->load->model("pagination_model"); $this->load->library("pagination"); $this->load->library('table'); } function vegetables(){ $this ->load->view('includes/header1'); $config['base_url']='http://localhost/mah/index.php/products_list/vegetables'; $vegetable="vegetable"; $config['total_rows']= $this->db->g...

asp.net mvc - Unit of Work SaveChanges Issue -

getting error: attaching entity of type 'axp.gcpt.gpat.model.wizardselectioncriteriastage' failed because entity of same type has same primary key value. can happen when using 'attach' method or setting state of entity 'unchanged' or 'modified' if entities in graph have conflicting key values. may because entities new , have not yet received database-generated key values. in case use 'add' method or 'added' entity state track graph , set state of non-new entities 'unchanged' or 'modified' appropriate. i using unit of work mvc in application. understand if inserting data in 3 tables have 1 savechanges() after third insert, dont need call savechanges 3 times after each insert. now problem deleting table , inserting in same table.after call savechanges(). problem once delete exectued , when going exceute insert line fails error of duplicate primary key. understanding once call savechanges delete , insert. code _...

text - How to cluster different strings using machine learning in python -

i have dataset consists of building names.e.g {hill view,hills view,hill apartment...}.i want cluster these strings using machine learning.for eg after clustering 1 cluster should contain strings similar or similar {hills,hill...}.i have tried various scikit algorithms k-means,affinity propagation etc did not succedd.kindly help. machine learning isn't magic! uses mathematical objects , functions. you need first steps - known data mining - kind of consists in: transforming input (string, pictures, videos, anything...) numbers (vectors, matrices or relevent structure). defining distance , similarity between vectors (= distance between numerical representation of input ~= distance between string, pictures, videos, anything). this not trivial , can done different ways depending on data/objectives. since don't know background in cs/ml/maths, give general approach is, in general case, quite good/easy. that general speach, in pratice problematic complex , th...

javascript - jquery Toggling between sidebars -

i want create simple sidebar. have 2 links, clicking on them expand sidebar different div>. clicking again collapse it. how can make, clicking on link2, expanded sidebar link1, change div , not collapse sidebar? panel in http://www.w3schools.com/ (click tutorials/references/examples) #wrapper { padding-left: 0; } #wrapper.toggled { padding-left: 220px; } #wrapper-link1 { display:none; } $('[data-toggle="link1"]').click(function () { $('#wrapper').toggleclass('toggled'); $('#wrapper-link2').hide(); $('#wrapper-link1').show(); }); what you're attempting known tabbed content. in specific instance presentation little different implementation same/similar. what want bind same click handler links show own content div. handler hide shown div , show selected content div. html <ul class="sidebar-toggler"> <li><a href="#" data-target="a">link a</a>...

ruby on rails - Does Postgres hav an equivalent of 'mysqldump --where'? -

i'm working on rails project uses multi-tenanting gem milia . milia uses row-based tenanting, meaning every row in database has column named tenant_id determines data belongs to. use heroku , postgresql. the database whole large, , while there times when want full production dump, more rather have data 1 tenant. so i'd dump whole db, rows where tenant_id=x . mysqldump has where condition, can't find equivalent postgresql. for example, if database this: table members tenant_id, id, name, sex 1, 1, joe, m 1, 2, sally, f 2, 3, bob, m table jobs tenant_id, id 1, 1 1, 2 2, 3 and want dump tables tenant_id 1 , expect dump containing following: table members tenant_id, id, name, sex 1, 1, joe, m 1, 2, sally, f table jobs tenant_id, id 1, 1 1, 2 i'm not sure if best practice, can: create view of table rows want create view tweets select * contents provider = 'twitter'; create new table view create table...

python - Floating Point Exception when using OpenFOAM and matplotlib.path.Path.contains_points -

in python code, using ctypes (later switched cython ) call functions c++ shared library wrote myself. library small wrapper on top of third-party library (openfoam specific, not important question). third-party library uses mpi (and petsc) , giving me issues when try call contains_points matplotlib.path.path . each time call contains_points before have called function c++ library works fine. when try call contains_points after have @ least called 1 function c++ library following error: [0]petsc error: ------------------------------------------------------------------------ [0]petsc error: caught signal number 8 fpe: floating point exception,probably divide 0 [0]petsc error: try option -start_in_debugger or -on_error_attach_debugger [0]petsc error: or see http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind[0]petsc error: or try http://valgrind.org on gnu/linux , apple mac os x find memory corruption errors [0]petsc error: configure using --with-debugging=yes, recomp...

python - Dictionary of directories -

i have paths (simplified): /rootfolder/subfolder_1/subsubfolder_1/ paths = { 'rootfolder':'rootfolder/' 'subfolder_1':paths[rootfolder]+'subfolder/' 'subsubfolder_1:paths[subfolder]+'subsubfolder/' } basically, want static dictionary of paths, want keep dependencies can make 1 change in future. unsure if that's doable, , if, how? have better ideas mine? in advance help. you can use functions values keys. because functions not called before dict constructed, there'll no nameerror . in [320]: paths = { 'root': lambda: '/', 'usr': lambda: os.path.join(paths['root'](), 'usr')} in [321]: paths['root']() out[321]: '/' in [322]: paths['usr']() out[322]: '/usr' in [323]: paths['root'] = lambda: '//' in [324]: paths['usr']() out[324]: '//usr' if don't want paths['root']() , subclass dict ....

vector - Android - VectorXML notification icon color, SAMSUNG bug? -

Image
i try use new vectorxml small icon notificationcompat.builder . on nexus devices works fine , android automatically tint icon required color, white. on samsung (s5 android 6.0.1) icon never tinted. see screenshots: any idea why? samsung's implementation bug? for all, the solution make base color white , "auto" tint works fine on samsung devices! ;) <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="101dp" android:height="101dp" android:viewportwidth="101dp" android:viewportheight="101dp" <path android:fillcolor="#fff" android:pathdata="@string/round"/> </vector>