Posts

Showing posts from 2011

Basic C programming.. logical error while converting Celsius to kelvin -

this question has answer here: c: converting farenheit celsius 3 answers #include <stdio.h> #include <stdlib.h> int main(void) { int celsius = 0, kelvin = 0; float farenheit; printf("enter boiling of water in celcius \n"); scanf("%d", &celsius); kelvin = 273 + celsius; farenheit = celsius * (9 / 5) + 32; printf("the boiling point of water in kelvin %d \n , in farenheit %f \n \n", kelvin, farenheit); printf("enter freezing point of water in celcius \n"); scanf("%d", &celsius); kelvin = 273 + celsius; farenheit = celsius * (9 / 5) + 32; printf("the freezing point of water in kelvin %d \n , in farenheit %f \n \n", kelvin, farenheit); return 0; } in eclipse, type code , i'm expecting ask me on console "enter boiling of water i...

javascript - How to concatenate (or union) the results of find() from two mongodb collections in Meteor JS? -

how can concatenate (or merge or union) results of find() 2 mongodb collections in meteor js? preferably want join them single cursor object, fetching , converting array acceptable. should use instead of union in following code? note: don't need remove repeated elements. concatenation enough. alllocations: function(){ location_set_1 = tablea.find({'loc':{$exists:1}},{loc:1,limit:300}); location_set_2 = tableb.find({'loc':{$exists:1}},{loc:1,limit:300}); combined_location_set = ??union??(location_set_1,location_set_2) return combined_location_set; } a (n incomplete) solution may following return array. instead need return cursor object "helper" in meteor: a=tablea.find() b=tableb.find() c=_.extend({},a.fetch(),b.fetch()) // c=[].concat(a.fetch()).concat(b.fetch()); return c; something ? alllocations: function(){ var location_set_1 = tablea.find({'loc':{$exists:1}},{loc:1,limit:300}).fetch(); var location_set_...

html - jquery-ui, draggable item : does'nt work when position is absolute -

i'm trying make draggable items contained in position:absolute div. works when dragged on div declared earlier in code, item never appear on [position:absolute] div declared later in code, when setting lower z-index div... here's example $(function(){ $(".myclass").draggable({stack:".bg"}); }(jquery)); <script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script> <script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script> <div style="position:absolute;background-color:#3ff;width:200px;height:200px;border:1px solid #000;left:0px;top:0px;z-index:10;"> <div class="myclass" style="position:absolute;left:10px;top:10px;width:70px;height:70px;background-color:#0f6;border:1px solid #000;z-index:100;">draggable</div> </div> <div style="position:absolute;backgrou...

d3.js - Shiny R : D3HeatMap triggered after click button - ReactiveEvent or ObserveEvent -

i'd trigger heatmap display after has clicked button. initially, heapmap generated each time interacting wigdet. example, if changed color, heapmap regenerated directly. want first select color , click button generate heapmap picture. don't succeed make works reactiveevent or observeevent. server.r library(shiny) library(d3heatmap) library(shinythemes) require(rcolorbrewer) library(dplyr) shinyserver( function(input, output,session) { output$heatmap<- renderd3heatmap({ loading_effect() infile <-input$file1 if (is.null(input$file1)) return(null) nba_players <- read.csv(infile$datapath, sep=";",row.names=1,na.strings = c("undef")) rownamesfiltered <- grep(paste0("^",input$gene,"-.*$", collapse = null),rownames(nba_players),ignore.case = true,value = true) data_filtered = filter(nba_players, grepl(paste0("^",input$gene, collapse = null),rownames(nba_players) )) row.names(...

java - Error in initialization - Expected ":" at line -

i'm doing item. got error: expected ':' @ line 7 column 11 i'm looking mistake , can't find it. log: [14:05:31] [client thread/error] [fml]: exception loading model utm:item/uraniumingot loader instance, skipping com.google.gson.jsonsyntaxexception: com.google.gson.stream.malformedjsonexception: expected ':' @ line 7 column 11 @ com.google.gson.internal.streams.parse(streams.java:56) ~[streams.class:?] @ com.google.gson.treetypeadapter.read(treetypeadapter.java:54) ~[treetypeadapter.class:?] @ com.google.gson.gson.fromjson(gson.java:803) ~[gson.class:?] @ com.google.gson.gson.fromjson(gson.java:741) ~[gson.class:?] @ net.minecraft.client.renderer.block.model.modelblock.deserialize(modelblock.java:47) ~[modelblock.class:?] @ net.minecraft.client.resources.model.modelbakery.loadmodel(modelbakery.java:269) ~[modelbakery.class:?] @ net.minecraftforge.client.model.modelloader.access$800(modelloader.java:73) ~[modelloader.class:?] @ net.minecraftf...

java - refresh apache camel routes -

i using spring camel standalone application builds many routes depending on returned psql database : private void addendpoint(string urlname, string type, string host, string port, string username, string password) { string endpointurl = string.format("https://%s:%s?username=%s&password=%s", host, port, username, password); from("direct:endpoint_" + urlname) .throttle(1).timeperiodmillis(60000) .to(endpointurl); } and route created in loop depends on returned database this: @override public void configure() throws exception { final list<url> url= dburldao.geturl(); (url urlinfo : urls) { addendpoint(urlinfo.getname(), urlinfo.gettype(), urlinfo.getip(), urlinfo.getport(),urlinfo.getusername(), urlinfo.getpassword()); } what acheive able add route without restarting application (route builder being initialized camel-context.xml). is there anyway fo...

javascript - Performance of jQuery script which dynamically shows/removes images -

i'm thinking best way attach image button each row of list. want every row have button. after click, script should append div image (and run lightbox). do think optimal way of doing is: onclick -> append , hide them run lightbox onexit -> .remove() images i'm worried performance of that. slow browser or rather not? fast written code: function test(){ $.post(url, {id:'1'}, function(data){ $("#cache").append(data).children("a").first().trigger("click"); //returns sth <a href="" rel="lightbox"></a> }); } and in lightbox.js @ function closing down script: $("#cache").empty();

PUT HTTP Request in HTTP API Wordpress -

i'm unable use put http requests in wordpress. https://codex.wordpress.org/http_api this link says can through wp_remote_request() ? specify ? can me this? need code. like this $response = wp_remote_request( 'http://test.com/test', [ 'method' => 'put' ] );

javascript - Error callback in Ajax call -

i using jquery method trigger ajax call. function fetchquestion(questionid,index){ $.ajax({ url: '${createlink(action: 'fetchquestion')}', data: {id:questionid,grantassessmentid:${grantassessmentid}}, cache: false, success: function(html) { $('div[id="questioncontent"]').html(html); }, error: function(e,status){ console.log("inside error..") } }); } in controller's action, throw exception(throw new exception("some message")) returns 500 response ajax call. in error callback not able catch it. try using third argument, thrown error there http://api.jquery.com/jquery.ajax/ error type: function( jqxhr jqxhr, string textstatus, string errorthrown )

c# - Add link to image in specific area of image -

Image
i'm creating image signature outlook, im creating template co-workers can edit own personal information. but want company site, personal linkedin, , company facebook in document links. when click on it sends site (a link ) this image looks when convert image: as can see in image have couple of thinks should filled in person using application. image panel converted code: private void converttoimagebutton_click(object sender, eventargs e) { bitmap bmp = new bitmap(backgroundpanel.width, backgroundpanel.height); backgroundpanel.drawtobitmap(bmp, backgroundpanel.bounds); bmp.save(@"c:\users\collin-k\repo\test.png", imageformat.png); } **question: ** how can add links image on specific place, lets place of website label. is possible or have idea signature looks this. image easy way because can edit it.

internet explorer 11 - font awesome icon is not appearing in IE 11, but showing in other browsers -

Image
i new font-awesome icons. have 1 page in there filter user can search data. have added font awesome icon before search link (as per below screenshot), can see icon in browsers except ie 11. funny thing have icon in other pages , can see in ie 11, cannot see icon on (as per below screenshot) page only. here screenshot ie 11: here screenshot chrome: can me out on this? i had same issue, solved adding meta tag first tag in <head> : <meta http-equiv="x-ua-compatible" content="ie=edge"> also, according official documentation , check following: for internet explorer : don't serve files no-store option in cache-control header (ref: #6454); for internet explorer , https : don't serve files no-cache option in pragma header.

java - How to make screen turn on when motion sensor detects something? -

is there way turn screen on when motion sensor detects phone moved? in advance. consider this //implement sensoreventlistener public class sensoractivity extends activity, implements sensoreventlistener { ...... sensormanager sensorman = (sensormanager)getsystemservice(sensor_service); sensor sensor = sensorman.getdefaultsensor(sensor.type_accelerometer); sensorman.registerlistener(context, sensor, sensormanager.sensor_delay_ui); @override public void onsensorchanged(sensorevent event) { if (event.sensor.gettype() == sensor.type_accelerometer){ } //or other sensor. } there's more info in docs here

c# - Change ToolStripButtomItem Attributes Using EventHandler -

this first question on stackoverflow, therefore errors in asking-style aren't on purpose. i'm both, new c# concept of event-handling, know, if there possibility have value of toolstripbuttonitem-attribute changed eventhandler. the context following: the code starts initializing ui contains windows.forms- elements. toolstripbuttomitem of interest me, has it's enabled-attribute set false default-value. functionality of button switch comparision-view reference file exists. allready can case when programm-start, otherwise reference file might created during runtime. of course, perform button.enabled=system.io.file.exists(reference-file) with initilization , createfile(referencefile){ ... button.enabled = true; } but seems rather crude me. instead like: button.enabled = new system.eventhandler(this.enablebutton); with private void enablebutton(object sender, eventargs e){ if(system.io.fileexists(referencefile) button.enabled = true; } ...

java - Action class value passing one method to another method -

the value not passing method 1 method 2 shows null pointer exception please me this. in struts2 action class contains 2 methods. 1 method produce value used method. in jsp page have 2 buttons. 1 calls first method populate value. button calls second method in same class , use populated value first method , display values in jsp. every button click action class object destroyed , create new object every button click. first method values lost , can not referred second method. please tell me solution this. struts2 action class : public class crudaction{ private list<string> list; public list<string> getlist() { return list; } //method 1 public string one(){ list=new arraylist<string>(); list.add("one"); list.add("two"); return "success"; } //method 2 public string two(){ list.add("three"); return "success"; } ...

javascript - jQuery blur event not working -

why blur event in below code not working , alert box pop-ups document ready , not wait blur event. give me suggestion fix it... thanks... <!doctype html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script> $(document).ready(function(){ $("[type=text]").blur(cc("[type=text]")); $("[type=email]").blur(cc("[type=email]")); function cc(s){ alert("value: " + $(s).val()); } }); </script> </head> <body> <input type="text" id="test" value="rev"><br> <input type="email" id="test" value="mail@example.org"> </body> </html> blur() function take function parameter. in code pas result of cc function execution. you should use anonymous functions: $(document).ready(fun...

Flink CSV file reader fails to cast a LongType into a PojoType -

part of code trying execute in flink: val pages = env.readcsvfile[(long)]("/home/ppi.csv", fielddelimiter = "\t", includedfields = array(1)) i want use pages other purpose when compile, flink throws me error message exception in thread "main" java.lang.classcastexception: org.apache.flink.api.common.typeinfo.integertypeinfo cannot cast to org.apache.flink.api.java.typeutils.pojotypeinfo by way using 0.9 snapshot version of flink. in right direction highly appreciated. if read csv file, return type scala tuple read fields. in example, reading single field give tuple1. try specify parentheses surrounding "long": readcsvfile[(long)] in scala can specify tuples 2 or more fields using parentheses. need write instead readcsvfile[tuple1[long]] the exception thrown because, flink's csvinputformat tries interpret non-tuple types pojo types.

c# - schedule for update date in asp.net -

i want make schedule run after every 24 hours in asp.net (global.asax). want check current date , date store database 1 one. if date less current date add 7 days it. i trying without close reader update not possible. kind of error shows me every time. private static void task() { string cs = configurationmanager.connectionstrings["dbcs"].connectionstring; using (sqlconnection con = new sqlconnection(cs)) { con.open(); datetime newdate; string ct = datetime.now.tostring("dd/mm/yyyy"); datetime ct = datetime.parseexact(ct, "dd/mm/yyyy", cultureinfo.invariantculture); sqlcommand cmd1 = new sqlcommand("select date tblinsertdate", con); cmd1.executenonquery(); sqldatareader rdr = cmd1.executereader(); while (rdr.read()) { datetime dt = datetime.parseexact(rdr["date"].tostring(), "dd/mm/yyyy", cultureinfo.invariantculture); ...

php - Zend_Form array of inputs -

using zend_form, how create form elements this: <input type="file" name="file[]" value="" /> <input type="file" name="file[]" value="" /> if don't know how many files user want upload. settings input type="file" form.elements.file.type = "file" form.elements.file.options.required = true form.elements.file.options.label = "file" form.elements.file.options.validators.extension.validator = "extension" form.elements.file.options.validators.extension.options.extension = "gif,jpg,jpeg,png,swf" please try this $image = new zend_form_element_file("image"); $image->setattrib('multiple', true) ->setisarray(true) ->addvalidator('extension', false, 'gif,jpg,jpeg,png,swf');

asp.net - Under what circumstances will .NET processes and AppDomains share loaded assemblies in memory? -

i'm looking more details around when , how .net applications share loaded assemblies. i'm interested in sharing between os processes, between appdomains within same process. sharing assemblies reduces system memory usage avoiding having multiple copies of same assembly in memory, presume main benefit interested know if there other benefits and/or implications. a summary of i've learned far... sysinternals process explorer can used list .net process's appdomains , assemblies loaded each appdomain. a .net process appears load 'core' assemblies appdomain called 'shareddomain' (it's reasonable assume shared between appdomains within current process). task manager , process explorer report not insignificant memory usage numbers 'working set shared' , 'working set shareable', it's not clear being shared. (is 'core' assemblies within shared appdomain? other [non-core] assemblies shared too? in simple test launched 2 ...

junit - Mockito -mocking implementation class -

hi trying mock dao layer application has class hire achy application->parser->dao(interface)->dao implementation class my problem when mocking dao interface or daoimp class using mockito in test case not working test case going db how make our test case use these mocked objects @runwith(mockitojunitrunner.class) public class csvdataloadserviceimpltest { @mock private meteringdatadao meteringdatadao; list<object> persistedlist; object meteringdata; list<object> s=new arraylist<object>(); @suppresswarnings({ "rawtypes", "unchecked" }) @before public void setup(){ mockito.doanswer(new answer<list<object>>() { @override public list<object> answer(invocationonmock invocation) throws throwable { object[] args = invocation.getarguments(); system.out.println("persist all"); if(persistedlist == ...

hadoop - storing pig output into Hive table in a single instance -

i insert pig output hive tables(tables in hive created exact schema).just need insert output values table. dont want usual method, wherein first store file, read file hive , insert tables. need reduce hop done. is possible. if please tell me how can done ? thanks ok. create external hive table schema layout somewhere in hdfs directory. lets create external table emp_records(id int, name string, city string) row formatted delimited fields terminated '|' location '/user/cloudera/outputfiles/usecase1'; just create table above , no need load file directory. now write pig script read data input directory , when store output of pig script use below a = load 'inputfile.txt' using pigstorage(',') as(id:int,name:chararray,city:chararray); b = filter id > = 678933; c...

c# - Is it possible to use index in wpf control's name (e.g. TextBox(i)) to lessen code duplication? -

Image
my application interface shown below: (ignore control names first) when button1 clicked, outputbox1 display string in inputbox , same button2 , when button2 clicked, outputbox2 display string in inputbox . my question possible this: when button(i) clicked, outputbox(i).text = inputbox.text , there less code duplication..? by way, simple illustration. real problem not simple (involve data binding listview). want know whether possible or not. thanks suggestion , ideas. you can create own list of controls in code behind , use indexer of it. public partial class someview : usercontrol { private list<button> buttoncollection; private list<textbox> targetcollection; public someview() { initializecomponent(); buttoncollection = new list<button> { button1, button2, button3 }; targetcollection = new list<textbox> { outputtextbox1, outputtextbox2, outputtextbox3 ...

php - c# http post data with parameters and save it to mysql -

i use code in c# app post data: void postdata() { webclient wc = new webclient(); var uri = new uri("http://my-real-address.com/test.php"); string myparameter = "?parameter=test"; wc.headers["content-type"] = "application/x-www-form-urlencoded"; wc.uploadstringcompleted += new uploadstringcompletedeventhandler(wc__uploadstringcompleted); wc.uploadstringasync(uri, myparameter); } void wc__uploadstringcompleted(object sender, uploadstringcompletedeventargs e) { try { messagebox.show(e.result); } catch (exception exc) { messagebox.show(exc.tostring()); } } and content of test.php: <?php $save = $_get['parameter']; //db auth settings $dbhost = 'localhost'; $dbuser = 'user'; $dbpass = 'password'; if ($save != "") { $conn = mysql_connect($dbhost, $db...

mysql - Magento Error: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'DATABASENAMEHERE.mage_index_process' doesn't exist -

i getting error - magento error: sqlstate[42s02]: base table or view not found: 1146 table 'databasenamehere.mage_index_process' doesn't exist below stack trace of same. trace: #0 c:\program files (x86)\easyphp-devserver-14.1vc9\data\localweb\skinbp\lib\varien\db\statement\pdo\mysql.php(110): zend_db_statement_pdo->_execute(array) #1 c:\program files (x86)\easyphp-devserver-14.1vc9\data\localweb\skinbp\app\code\core\zend\db\statement.php(291): varien_db_statement_pdo_mysql->_execute(array) #2 c:\program files (x86)\easyphp-devserver-14.1vc9\data\localweb\skinbp\lib\zend\db\adapter\abstract.php(479): zend_db_statement->execute(array) #3 c:\program files (x86)\easyphp-devserver-14.1vc9\data\localweb\skinbp\lib\zend\db\adapter\pdo\abstract.php(238): zend_db_adapter_abstract->query('select `mage_in...', array) #4 c:\program files (x86)\easyphp-devserver-14.1vc9\data\localweb\skinbp\lib\varien\db\adapter\pdo\mysql.php(428): zend_db_adapter_pdo...

Getting rtf field from domino with java for JSON -

i trying make json save domino document. works fine, except when handling rich text format field. problem this: html editor puts newline , tabs after every html beginning tag, when try rtf in html saved, contains newlines, tabs etc. tried replacing them, nothing happened. this how rtf looks (and can not changed): <p> sample text</p> this how i'm trying data rtf: somestring = viewdata.getdocument().getmimeentity("myfield").getcontentastext(); how tried replacing newline: somestring.replaceall("\n", ""); somestring.replaceall("\\n", ""); somestring.replaceall("\\\n", ""); i like <p>some sample text</p> i tryed approach jsongenerator hadle me. returns json full of /t , /n chars. , had other problems jsongenerator because json has more 1 level in depth. returning string without newline , tab simpliest solution. does have idea how solve problem? i can imagin...

ios - Navigation bar is hiding on swipe and scroll -

i customising navigation bar way in swift navigationitem.title = "support" let menubutton = uibarbuttonitem(image: uiimage(named: "menuicon"), style: uibarbuttonitemstyle.plain, target: self, action: "showmenu:") navigationitem.rightbarbuttonitem = menubutton self.navigationitem.sethidesbackbutton(true, animated:false) i customising navigation item in view controller , table view controller. problem navigation hiding when swipe in view controller or scroll in table view controller. how fix navigation bar being hidden on swipe , scroll means should not hidden everytime. the following code should work you: class viewcontroller: uiviewcontroller { @ibaction func toggle(sender: anyobject) { navigationcontroller?.setnavigationbarhidden(navigationcontroller?.navigationbarhidden == false, animated: true) //or animated: false } override func prefersstatusbarhidden() -> bool { return navigationcontroll...

polymer - All tests fail in Web Component Tester for Firefox -

after creating clean copy of polymer starter kit, running tests using web component tester ("test" gulp task) results in tests failing in firefox. the tests run through fine in both chrome , ie. the error is: firefox 39 ✖ my-greeting-basic.html timed out loading http://localhost:2000/components/polymer-starter/my-greeting-basic.html? <unknown> @ done @ /components/mocha/mocha.js:1846:0 <unknown> @ runner.prototype.run/< @ /components/mocha/mocha.js:5213:0 <unknown> @ eventemitter.prototype.emit @ /components/mocha/mocha.js:616:0 <unknown> @ start/< @ /components/mocha/mocha.js:5203:0 <unknown> @ runner.prototype.runsuite @ /components/mocha/mocha.js:5103:0 <unknown> @ start @ /components/mocha/mocha.js:5201:0 <unknown> @ runner.prototype.run @ /components/mocha/mocha.js:5226:0 ...

html - Table with fixed thead inside of position:absolute block -

i have html table wrapped block position:absolute . want make first row (with th or td , or wrapped thead ) fixed @ top, , other table should scrollable, without fixed height. i've tried this, inside of position:absolute didn't work: https://jsfiddle.net/dpixie/byb9d/3/light/ html, body{ margin:0; padding:0; height:100%; } section { position: relative; border: 1px solid #000; padding-top: 37px; background: #500; } section.positioned { position: absolute; top:100px; left:100px; width:800px; box-shadow: 0 0 15px #333; } .container { overflow-y: auto; height: 200px; } table { border-spacing: 0; width:100%; } td + td { border-left:1px solid #eee; } td, th { border-bottom:1px solid #eee; background: #ddd; color: #000; padding: 10px 25px; } th { height: 0; line-height: 0; padding-top: 0; padding-bottom: 0; color: transparent; border: none; white-space: nowrap; } th div...

json - Modify a JavaScript Object while iterating its properties -

can javascript implement pass-by-reference techniques on function call? see, have json below , need traverse node. while traversing, if current item object , contains key nodes , must add property isparent: true that exact same item . i'm having difficulty on creating traversal function such feature, , tried search traversal functions, found returns new json object instead of changing exact json being processed. var default_tree = [ { text: "applications", nodes: [ { text: "reports data entry", nodes: [ { text: "other banks remittance report" }, { text: "statement of payroll deduction" }, ... ] }, { text: "suspense file maintenance", nodes: [ { text: "banks individual remittances" }, ...

rounding - Is it possible to circumvent Matlab epsilon? -

i have 2 arrays of numbers identical. when take difference array of half small numbers (on order of 1e-16), , half identically 0. i'm positive due rounding issues; i.e. difference between 2 entries less epsilon. that said i'd still show difference between entries (even if extremely small). there way circumvent matlab's epsilon tolerance? perhaps using clever scaling of arrays? edit : here's example of issue. array a accurate 15 digits (being copied c file output), while array b comes matlab. take 1 element of a 1.00002429399044 . subtract corresponding entry in b , displays 1.00002429399044 . difference between them 2.22044604925031e-16 according matlab. means there must more digits in entry of b being displayed. consider same scenario element of a being 1.00003105215213 . difference between number , element in b displays 1.00003105215213 0 . have hard time beleiving in case numbers stored same - if display more digits in matlab expect see differen...

html - Make links all the same width -

i have buttons change width according text inside buttons. how make them same width? i've tried editing css , adding min-width:100px , width:100px; doesn't work. a { min-height: 0px; min-width: 0px; line-height: 45px; border-width: 0px; margin: 0px; padding: 6px 13px 5px; letter-spacing: -1px; font-size: 20px; } div { z-index: 7; white-space: nowrap; min-height: 0px; min-width: 0px; line-height: 38px; border-width: 0px; margin: 0px; padding: 0px; letter-spacing: 0px; font-size: 24px; left: 1148px; top: 425px; visibility: visible; opacity: 1; transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -0.0025, 0, 0, 0, 1); } <a href="#" class="tp-button red small">mit</a> <div class="tp-caption noshadow tp-fade tp-resizeme start" data-x="center" data-hoffset="200" data-y="bottom" data-voffset="-50" data-speed=...

ios - STHTTPRequest how i can implement https? -

i have app communicate dedicated server, want implement https communication... i'm using sthttprequest wrapper requests, example request: __block sthttprequest *up = [sthttprequest requestwithurlstring:@"http://www.server.com/page.php"]; up.postdictionary = @{@"pass":@"xxxx","user":@"username"}; up.completionblock = ^(nsdictionary *headers, nsstring *body) { }; up.errorblock = ^(nserror *error) { }; [up startasynchronous]; for server i'll buy ssl certificate, how can implement https client ios app? i'm trying create best solution secure data, not use self-signed certificate... have read vulnerability "man in middle" attack.

android - Listview with checkedtextview repeating the checked items -

i have implemented listview custom arrayadapter, each row consists of checkedtextview widget. when check first item of listview , scroll down, find other items of listview gets checked, , more scroll down , find elements checked. looks first child check how replicates other listview child not visible. i know have option of using choicemode, not working custom arrayadapter, , have use custom arrayadapter. object type string arrayadapter, have found online examples of custom models maintain checkbox tag, using string, can't to. i pasting code of adapter: @override public view getview(final int position, view convertview, viewgroup parent) { // todo auto-generated method stub final viewholderclass viewholder; if(convertview==null) { layoutinflater layoutinflater = (layoutinflater) context.getsystemservice(context.layout_inflater_service); convertview = layoutinflater.inflate(r.layout.disruption_routes_list_child, ...

Formatting floating point values in Java -

this question has answer here: prevent round off in string.format(“%.2f”, doublevalue) in java 4 answers i tried use this: string t="4.99999999"; t = string.format("%.2f",float.valueof(t)); i wanted print 4.99 , wrote 5.00 . know why? there 2 issues, here. 1 floats can't differentiate between 4.99999999 , 5.0 , i.e. float.valueof() parses 5.0 . doubles do have enough precision. other issue 5.0 correct behavior %2f . you're asking 2 decimal points, , 4.99999999 rounds 5.00. since string.format() behavior isn't want, want, i.e. why 4.99 correct behavior use case? edit: if you're trying truncate 2 two decimal points, here: how can truncate double 2 decimal places in java

mysql - Inventory Management with doctrine and PHP -

i'd make database, doctrine , interface in php/symfony2 . it's company sells clothing. have table stock product elements , table product clothes. could guide me start ? here start: http://tutorial.symblog.co.uk/ this tutorial shows how create blog symfony , doctrine , twig . if rename blog entity product , change it's properties fit product model go. more on working doctrine in official documentation here: http://doctrine-orm.readthedocs.org/en/latest/tutorials/getting-started.html

indexing - Understanding mongodb find query more -

just quick question in relation following mongodb query: var queryparams = { $or: [ {'stats.created_by': userid}, {'user_list.user_id': userid}, {'invite_list.user_id': userid}, {'invite_list.email': useremail} ], deleted: false }; this query given itemmodel.find(queryparams); - im trying understand table scan impact here? understanding full scan based on deleted attribute , filter on $or clause. ok, ran following explain , items scanned index on deleted. db.items.find({$or: [ {'stats.created_by': '559cd76338e42c533a83b8a7'}, {'user_list.user_id': '559cd76338e42c533a83b8a7'}, {'invite_list.user_id': '559cd76338e42c533a83b8a7'}, {'invite_list.email': 'some@something.com'} ], deleted: false}).explain(); can make improvements here? thanks. ...

apache pig - Pig Optimization on Group by -

lets assume have large data set per below schema layout id,name,city --------------- 100,ajay,chennai 101,john,bangalore 102,zach,chennai 103,deep,bangalore .... ... i have 2 style of pig code giving me same output. style 1 : records = load 'user/inputfiles/records.txt' using pigstorage(',') (id:int,name:chararray,city:chararray); records_grp = group records city; records_each = foreach records_grp generate group city,count(records.id) emp_cnt; dump records_each; style 2 : records = load 'user/inputfiles/records.txt' using pigstorage(',') (id:int,name:chararray,city:chararray); records_each = foreach (group records city) generate group city,count(records.id) emp_cnt; dump records_each ; in second style used nested foreach. style 2 code run faster style 1 code or not. i reduce total time taken complete pig job.. so style 2 code achieve ? or there no impact in total time taken? if confirms me can run similar code in cluster large d...

Is there any method in Java to init a set by step 1 or other length? -

for example, init set [1,2,3, ...,100]. usually, follows: for(int = 1;i <= 100;i++ ){ set.add(i); } is there method more conveniently? such somemethod(startindex, endindex, step); by using that, can init set [1,2,3,4,5] or [1,3,5,7,9] or others. you can use java 8 streams. for example : set<integer> myset = intstream.range(1,101).boxed().collect(collectors.toset()); or odd numbers : set<integer> myset = intstream.range(1,101).filter(i->i%2==1).boxed().collect(collectors.toset()); intstream.range easy way obtains numbers in given range. then can apply filters if want of numbers. finally can collect them collection wish.

sql - How to create table where columns in first table are fields in another table? -

table_1 t1_id name ------------- 1 mark 2 stieve table_2 t2_id month amt t1_id ---------------------------- 1 jan 200 1 2 feb 400 1 3 jan 500 2 expected output view_table_3 t1_id name jan feb ----------------------- 1 mark 200 400 2 stieve 500 0 in view_table_3 need make columns jan , feb fields in table_2 , respective amt. please how can output? in postgresql can install tablefunc extension: create extension tablefunc; in extension find crosstab(text, text) function . ugly function work (putting mildly), want: select * crosstab( 'select t1_id, name, month, coalesce(amount, 0) table_1 join table_2 using (t1_id)', 'values (''jan''), (''feb''), (''mar''), (''apr''), (''may''), (''jun''), (''jul''), (''aug''), (...

go - Goroutines don't work in parallel -

given following code: package main import ( "fmt" "runtime" "time" ) func f(from string) { := 0; < 3; i++ { fmt.println(from, ":", i) //runtime.gosched() } } func main() { runtime.gomaxprocs(runtime.numcpu()*2) time.sleep(100) go f("i not parallel") go f("neither me") var input string fmt.scanln(&input) } the output in cases is: i not parallel : 0 not parallel : 1 not parallel : 2 neither me : 0 neither me : 1 neither me : 2 and sometimes: neither me : 0 neither me : 1 neither me : 2 not parallel : 0 not parallel : 1 not parallel : 2 when runtime.gosched() uncommented seems ok. have tried changing gomaxprocs number 2 numcpu, number of goroutines, cycles: none work in parallel. why strange behaviour? edit: ok, seems context-switching heavy work , not done without reasonable matters. 1 thing sti...

django - Setting all serializer fields to be required -

i have next serializers: class addressserializer(serializers.modelserializer): class meta: model = address class clientserializer(serializers.modelserializer): address = addressserializer() class meta: model = client fields = ('id', 'email', 'address') the models: class address(models.model): street = models.charfield(max_length=50, default='') zip = models.charfield(max_length=5, default='') state = models.charfield(max_length=50, choices=states ,default='') suburb = models.charfield(max_length=50, default='') num = models.charfield(max_length=7, blank=true, default='') country = models.charfield(max_length=50, default='') ref = models.charfield(max_length=120, blank=true) class client(models.model): address = models.onetoonefield(address, null=true) email = models.emailfield(unique=true, default='') the expected behaviour have addre...

php - Mandrill - How do I retrieve the message content html that was just sent? -

i'm using mandrill api php. i sending mail message: $result = $mandrill->messages->sendtemplate($template_name, $template_content, $message); $mandrill_return_data = current($result); since message content saved 24 hours, retrieve html sent , save db. $message_content = $mandrill->messages->content($mandrill_return_data['_id'])['html']; unfortunately, doesn't work , returns following error: a mandrill error occurred: mandrill_unknown_message - no message exists id '446740d7b61e4403b11379db4e1d45b0' i did googling , found this answer , explains takes few minutes index message in system , noticed case. trying figure out solution on how retrieve message content html , save db. i suppose use cron job run every few hours or after sends message, or run ajax command retrieve message content html after specified timeout, both of solutions seem hacky. i'm hoping more elegant solution doesn't require whole lot of addi...

Mysql Match…against query performance in InnoDB Mysql 5.6 -

Image
i need search records in table contains millions of records. have updated mysql version 5.1 5.6. i using like in query taking around 15 sec 30 sec. currently have modified query use match... against feature of mysql 5.6 innodb. query goes this. select job.idjob, job.idemployer ..... job ( ( job.itjobstarttype=2 , job.dtplannedend >= '2015-07-06' ) or ( job.itjobstarttype=1 , ( ( job.itjobendtype=2 ) or ( job.dtjobend>='2015-07-06') ) ) or ( job.itjobstarttype=3 , ( (job.dtjobend >='2015-07-06') or (job.itjobendtype=2) ) ) ) , match(vcjobtitle, lvjobcompanydescription, vccompanyname, vcsalarydesc, vccity, vcqualificationrequired,vcjobreference, lvjobkeywords ) against ('test' in natural language mode) order job.itjobband asc, job.vcranking desc, ...

Meaning of Depth header in WebDAV PROPFIND method -

i writing in php create virtual file system using webdav. i trying head around propfind request method. rfc 4918 mentions it, i’m not sure understand. can clarify this: what role of depth value (0, 1, infinity)? has folders vs files? why client make multiple propfind requests on folder? i think might me sort out of rest. thanks what role of depth value (0, 1, infinity)? has folders vs files? for directories: depth 0: retrieve properties of directory depth 1: 0 + properties of files in directory depth infinity: 1 + properties of files in sub-directories of directory (recursively) for files has no effect. the depth applies other webdav methods.

Reset issue in datatables -

i using data tables in application. while sorting column records reset.means, if on page 2,3,4,etc , if click on header sort data, data gets reset , on first page. want sort data page on currently. possible? using default code $(document).ready(function() { $('#example').datatable( { "processing": true, "serverside": true, "ajax": "scripts/server_processing.php", "deferloading": 57 } ); } ); see answer if want sort current page only. agree it, there little no sense that. however, using datatables api can stay on same page when sorting occurs. the solution store current page number when user changes page or performs search: var cur_page = 0; $('#example').on('page.dt search.dt', function(){ var info = table.page.info(); cur_page = info.page; }); then when user sorts page, need restore page. reason order.dt event triggered again when change page...