Posts

Showing posts from September, 2011

java - Have very big trouble with my choice generator -

i tried make button random picks answer if click on it; there no errors shown, don't know if made mistakes. activity main java package infuso.choicemaster; import android.os.bundle; import android.support.v7.app.appcompatactivity; import android.view.menu; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.textview; import infuso.choicemaster.r; public class activity_main extends appcompatactivity { public button generate; public textview einleitung; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); final string[] mynames = {"call 3rd person in phonebook , ask activities", "drive 5 miles car fun", "call 14th person in phonebook , ask activities ", "send message @ whatsapp random people in contacts", "do workout"

java - Monitor shell script with monit -

i have shell script spawns java process i'd wrap in wrapper use monit. i've tried monit recommendation of #!/bin/bash name=`basename $1` case $2 in start) echo $$ > /var/run/service.pid; exec 2>&1 $1 1>/var/log/$name.stdout ;; stop) kill `cat /var/run/service.pid` ;; *) echo "usage: <path app> {start|stop}" ;; esac where i'd use wrapper.sh /usr/sbin/cmd start when this, see 2 procesess spun up. 1 exec in wrapper, , other java process. however, pid of $$ of /usr/sbin wrapper , not of actual java process. if "stop" service or kill pid, java process gets orphaned. on other hand, if run /usr/sbin/cmd in foreground , kill it, kill child process. you can't grab pid before run command, can use $! . also, suggest use nohup . like nohup $1 > /var/log/$name.stdout 2>&1 & echo $! > /var/run/service.pid

f# - How to set up non-trivial data persistence? -

most generally, question is: how set non-trivial data persistence in nice functional way? prefer answers people real experience, people have done it. happy hear other thoughts on subject. and now, let me clarify mean examples. let's have data program handles , needs keep. say, our old friend employee : module employees = type employee = { name: string; age: int; /* etc. */ } module employeespersistence = type employeeid = ... let getemployee: (id:employeeid -> employee) = ... let updateemployee: (id:employeeid -> c:employee -> unit) = ... let newemployee: (c:employee -> employeeid) = ... doesn't matter how persistence functions implemented, let's go relational database, or document-based database, or file on disk. don't care right now. and have program them: module somelogic = let printemployees emps = let print { name = name, age = age } = printfn "%s %d" name age seq.iter print emps so far straightfor

oauth - Dotnet open auth with Facebook and Email/Password login with aspnet_membership tables -

i'm building first mobile app in users can login. app talks webservices on site's backend. users can login/register via either facebook or an email/password combination in both cases (upon registration) add user data aspnet_membership tables, in case of facebook registration thing store facebook id. now, want use dotnetopenauth facilitate login , registration process. need alter code logic creates/retrieves data aspnet_membership database tables. is possible , if so, have code samples? first of all, should not alter aspnet_membership table. if so, underlying store procedures stop working. instead, want create new table userid primary key, , make one-to-one relationship aspnet_membership table. fyi: asp .net membership provider using more 10 years old, , not actively developing anymore. if developing new project, should consider using new asp.net identity support facebook login out of box.

tomcat - Spring Boot War file gets 404 on ec2 -

i put simple eclipse spring boot rest program. couple of endpoints return strings. building eclipse gradle plug-in. no problems, runs fine in eclipse provided tomcat instance. ran on native windows tomcat. deployed .war file using tomcat web application manager using deploy feature. runs fine. deployed ec2 ubuntu instance , again used tomcat web application manager , upload .war file. rest program correctly displayed in applications window not run. used following url, http://ec2-ip-address/demo-0.0.1-snapshot/hello i keep getting 404's. pretty sure tomcat deployment , ec2 environment appears correct because can run tomcat7-examples in ec2 instance no issues. appreciated. awselbrestserveraapplication.java file: package demo; import org.springframework.boot.springapplication; import org.springframework.boot.autoconfigure.springbootapplication; import org.springframework.context.annotation.componentscan; import org.springframework.context.annotation.configuration; @sprin

c++ - Show UAC prompt before access is denied by IoCreateDeviceSecure function -

i adding access control driver (winpcap's ndis 6 filter driver) running on windows 7 , 8. want let administrators (users in administrators group) use driver. used new iocreatedevicesecure function instead of original iocreatedevice call. my code belows: unicode_string sddl = rtl_constant_string(l"d:p(a;;ga;;;sy)(a;;ga;;;ba)"); const guid guidclassnpf = { 0x26e0d1e0l, 0x8189, 0x12e0, { 0x99, 0x14, 0x08, 0x00, 0x22, 0x30, 0x19, 0x04 } }; status = iocreatedevicesecure(adriverobjectp, sizeof(device_extension), &devicename, file_device_transport, file_device_secure_open, false, &sddl, (lpcguid) &guidclassnpf, &devobjp); my sddl string "d:p(a;;ga;;;sy)(a;;ga;;;ba)" means "allows kernel, system, , administrator complete control on device. no other users may access device." in https://msdn.microsoft.com/en-us/library/windows/hardware/ff563667(v=vs.85).aspx . it seems build-in administrator account can directly access device now

arrays - How to swap two dates in swift -

trying swap 2 dates in swift. gives me error saying: cannot subscript value of type '[mission]' index of type 'int' func sort (mission: [mission]) -> bool { (var = 0; < mission.count; i++) { println(mission[i].createdat) if mission[i].createdat.timeintervalsince1970 > mission[i+1].createdat.timeintervalsince1970 { var temp = mission[i] mission[i] = mission[i+1] mission[i+1] = temp } } println() return true } this function named sort, doesn't sort array. if you're trying sort array, should use builtin sort function: missions.sort { $0.createdat.timeintervalsince1970 > $1.createdat.timeintervalsince1970 } the function you've written it, compilable, cause fatalerror because try access out-of-bounds index. i goes 1 count - 1 , try mission[i+1] . fix should change range of loop stop @ count - 2 . the error compiler giving caused fact function param

javascript - How to click or trigger a hidden input file on Iphone (Embjer.js development) -

if press button, hidden input file can triggered: html: <button {{action 'addimage'}}>click me!</button> <input id="addattach" type="file" accept="application/*, image/*" style="display:none" /> js (ember.js): actions:{ addimage: function(){ em.$('#addattach').val('').click(); } } but doesn't work in chrome on iphone. try old fashioned way, don't believe jquery required: <button id="push" onclick="document.getelementbyid('add').click()">click me!</button> <input id="add" type="file" style="display:none">

php - Laravel 4 Pagination Buttons Not Working (Querying entire DB) -

i'll start saying i've consulted laravel 4 documentation on pagination , tried many methods work. i using eloquent laravel 4's pagination class. problem: in results page, i'm trying paginate results we'll call "trucks" db. works fine , want @ first (a limit of 5 results). problem when click 1 of page numbers (which don't appear accurate) created pagination, whole db queried , takes me wrong page. i'm using clauses , 3 dropdowns limit searcher's results pagination screws up. here's @ controller logic: $results = $query->paginate(5); return view::make('results')->with('trucks', $results); blade template @if ($trucks) @foreach ($trucks $truck) {{ $trucks->link() }} how can make sure page numbers work correctly , don't query entire db? in advance. i think might have use appends() method. $trucks->appends(array('sort' => 'votes'))->links() this work l

google chrome - Java + Native messaging doesn't work good -

i have problem java application , google chrome due npapi deprecation.. reading articles , blogs, i've found "solution" : native messaging . but examples made in c++/c#/python, , java there nothing.. if me this.. here's schema ( see image ): google chrome extension -> native messaging -> java app (jar) problem: extension calls java app, java app runs doesn't receive , when returns, nothing comes extension. here's code: chrome extension background.js : chrome.runtime.onconnect.addlistener(function(port) { port.onmessage.addlistener( function(message) { chrome.tabs.query({active: true, currentwindow: true}, function(tabs) { console.log( 'background.js received msg [' + message.text + ']'); console.log( 'port.postmessage({content: "generated background.js"}); [' + tabs[0].id + "/" + tabs[0].url + ']'); chrome.runtime.sendnativemessage('cnb.digitalsigning

c# - query multi-level entity with filter at the lowest level -

so have 3 entity classes: public partial class event { public event() { recurrences = new hashset<recurrence>(); } public int id { get; set; } public icollection<recurrence> recurrences { get; set; } } public partial class recurrence { public recurrence() { aspnetusers = new hashset<aspnetuser>(); } public int id { get; set; } public int eventid { get; set; } public icollection<aspnetuser> aspnetusers { get; set; } } public partial class aspnetuser { public aspnetuser() { recurrences = new hashset<recurrence>(); } public string id { get; set; } public string username { get; set; } public icollection<recurrence> recurrences { get; set; } } i event given aspnetuser.id using line entity. far have it's returning error: // get: api/events?userid={userid} public iqueryable<event> getevents(string userid) { return db.events

Google Apps Script - Sharing outside of domain -

Image
so have followed tutorial here, , works great... me. google forms file upload complete example what need add script google form, , allow users upload image along form. know put uploaded image in folder specified, that's fine, there won't huge number , can use corresponding time stamp. the problem have works expect when open form, follow link, , able upload image, when try share outside of domain (it's google business account), form works, link script gives me old: sorry, file have requested not exist. please check address , try again. stuff done google drive apps in google drive make easy create, store , share online documents, spreadsheets, presentations , more. learn more @ drive.google.com/start/apps. i have shared both form , script test gmail user. have published script webapp. version has been manage , updated, , latest. i've shared folder upload images into, it's not getting far, won't load script. everything else can find online shar

ruby on rails - A Model That Contains Other Models -

i may have terminology bit off, i'm going try explain as possible. i'm working on application has different types of products: suits, shoes, shirts. these separate models don't have similar point of inheritance. user, owns collection, should able add 1 or many of these collection. i thinking of using has_many :through, not seem elegant. have create 3 similar joining tables each model (or think). there better solution? , if solution requires modify structure is, there solution now? thank in advance. if user own collection, suits, shoes , shirts must belong user. also, need use nested attributes. so, you'll have like: user.rb has_many :suits has_many :shoes has_many :shirts accepts_nested_attributes_for :suits accepts_nested_attributes_for :shoes accepts_nested_attributes_for :shirts shirts belongs_to :user and than, can use form code add products: form_for @user |f| f.fields_for :shoes, @user.shoes.new |builder| builder.text_fiel

jquery - Append incremented number to multiple uploaded images using JavaScript -

append incremented number multiple uploaded images using javascript i'm trying upload multiple images our hp records manager database using serviceapi .net sdk. written in asp.net mvc. the images upload have same title uses same input field. i want able create loop append incremented number end of record title. (e.g upload_1, upload_2, upload_3....and on) <form action="record" method="post" enctype="multipart/form-data"> <input id="gpsearchtitle" type="text" name="recordtypedtitle" value="" required="true"/> <input id="choose" type="file" name="upload" multiple="multiple"/> <button type="submit">upload</button> </form> is there way of appending incremented number using javascript? update have tried doing this: <script> function appendno(){ var inp = document.getelementbyid('cho

Access-Control-Allow-Origin added to firebase.json but missing from the file response header -

below simple firebase.json. if read docs right should tag files 'access-control-allow-origin'. unfortunately none of files being tagged resulting in error: imported resource origin ' https://gaspush.firebaseapp.com ' has been blocked loading cross-origin resource sharing policy: no 'access-control-allow-origin' header present on requested resource. could take , let me know how allow files endpoints? { "firebase": "gaspush", "headers": [ { "source" : “**”, "headers" : [ { "key" : "access-control-allow-origin", "value" : "*" } ] } ], "public": ".", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ] } this maybe no longer relevant original question, ran similar issue new version of firebase. had accidentally placed "headers&quo

Creating a new File in Scala with PrintWriter -

i have created function create file. goal pass in json string , return new file contents of json string passed it. calling function in function as: val jsonfile: file = jsoncreate.getjsonfile(jsonstring) so far, way have follows: create new file not exist , call "myjson.json" i create printwriter object, idea of using create final file. so, read contents of json string, stringbuffer, , on printwriter. done, hope have file myjson.json contents of passed in json string. i not pleased result of efforts far. example, not sure if have used option way supposed used. not pleased way using vars. if declare val inside try, not able access in finally. go java way , put printerwriter option variable outside.this code smell not like. how can shorten , still retain right try catch , finally, close resources, etc. this first attempt @ writing function: import java.io._ import java.util.scanner object jsoncreate{ def createfile(jsonstring: string): file = {

parse string of array in php -

how parse string of array can value of variable sample string $str = 'prices[holiday:waterpark][person:1_person]'; sample variable $prices['holiday:waterpark']['person:1_person'] = 100; i have tried using variables.variable way in php this $prices['holiday:waterpark']['person:1_person'] = 100; $str = "prices\['holiday:waterpark'\]\['person:1_person'\]"; $str = str_replace('\\', '', $str); echo $$str; but thats not working , error "undefined variable: $prices['holiday:waterpark']['person:1_person']" try this <? $prices['holiday:waterpark']['person:1_person'] = 100; $str = "prices\['holiday:waterpark'\]\['person:1_person'\]"; $str = stripslashes($str); // careful passing $str untrusted source // make necessary variable filtering before! echo eval('return $' . $str . ';

caching - Most efficient way of storing database information in memory using C# -

i busy experimenting things in c#, can build web server liking. web server specially made project i'm working on. in hope run better other web servers. now i've been trying find efficient way store database information in memory of application. so far i've tried making class resembles table it's fields. creating new instance of class every row in table. create dictionary variables resembles indexes. 1 id, 1 username. it's working, consumes 3x memory compare table in database. example of i've done: class user() { public int id; public string name; //other columns, same way } as dictionary: dictionary<int, user> useridindex = new dictionary<int, user>(); user newuser = new user(); newuser.name = "something..."; useridindex.add(someid, newuser); i've tried datatable, wasn't success @ all. consumed @ least 50% more memory class , dictionaries method. i curious if there's other way, more efficient way of

generics - C# - Is it possible to pass a derived type from a BaseModel to a Repository<T> that needs the type? -

so have repository class needs type. i have basemodel class other models derived from. right have have new repository() call save, update, delete, etc. i able incorporate methods basemodel, can create object , call myobject.save(); call create repository , use it. so this: public class repository<t> { public void save(t entity) { // save here! } } public class basemodel { public string id { get; set; } public datetime created { get; set; } public void save() { // line needs type t. how pass this? using(var repository = new repository<t>()) { repository.save(this); } } } public class derivedmodel : basemodel { public string name { get; set; } } note: not using entity framework. so result of var myentity = new derivedmodel() { name = "my entity"; }; myentity.save(); if don't want use reflection create repository, use derived type type parameter b

java - What does cal.get(7) do from a Calender instance? -

i documenting code , need understanding little line. private calendar cal = calendar.getinstance(); if ((this.cal.get(7) != 7) || (this.cal.get(7) == 1)) { what cal.get(7) mean? ran on ide, , gave me result of 5. tried cal.get(6) , , got result of 169. if "cal" java.util.calendar, 7 day_of_week. however, shouldn't pass literal integers .get() method; use constants on calendar class instead. so, instance, equivalent of example: if ((this.cal.get(calendar.day_of_week) != calendar.saturday) || (this.cal.get(calendar.day_of_week) == calendar.sunday)) { (day_of_year has value of 6, way) the calendar class has large number of constants can use; see javadoc more info.

ExtJS grid emptyText not visible in panel with vbox layout -

i'm using ext js 5.1.0. if create grid in vbox layout no records, emptytext rendered in dom, height of grid calculated incorrectly , text not visible. there way automatically grow without having set height? ext.onready(function () { ext.define('foo', { extend: 'ext.data.model', fields: ['foo'] }); ext.define('foostore', { extend: 'ext.data.store', model: 'foo', data: [ /* { foo: 'foo1' }, { foo: 'foo2' } */ ] }); var foostore = ext.create('foostore', {}); ext.create('ext.panel.panel', { renderto: ext.getbody(), layout: { type: 'vbox', align: 'stretch' }, items: [ { xtype: 'grid', title: 'foo grid', store: foostore,

python - Tkinter button disable not working -

i'm new python , newer gui programming. i've got button , 2 spinboxes want disable after click start button. i've googled 5 different ways disable tkinter button , none seem work. theoretically spinboxes should disabled same way i'm not having luck. getting frustrated whole gui thing. self.gps_com , self.arduino_com 2 spinboxes as can see tried use update() button doesn't work. i've seen variations of code use disabled in caps, first letter cap'd , different variations of quotes. current syntax gives no warnings/errors spyder. i thought going easy find answer question i've been @ few hours. def onbuttonclickstart(self): self.labelvariable.set( self.entryvariable.get()) self.entry.focus_set() self.entry.selection_range(0, tkinter.end) self.button_start.config(state = 'disabled') self.button_start.update() self.gps_com.config(state = 'disabled') self.arduino_com.config(state = 'disabled&#

Pull private docker images from Google Container Registry w/o gcloud -

i'm using shippable push private docker images google container registry want pull either locally on laptop, or inside instance on google compute engine. i know command gcloud preview docker pull gcr.io/projectid/image-name works, can't rely on gcloud being installed on every machine may need pull image from. if run docker-compose -d on machine following error: pulling image gcr.io/projectid/image-name... pulling repository gcr.io/projectid/image-name traceback (most recent call last): file "<string>", line 3, in <module> file "/compose/build/docker-compose/out00-pyz.pyz/compose.cli.main", line 31, in main file "/compose/build/docker-compose/out00-pyz.pyz/compose.cli.docopt_command", line 21, in sys_dispatch file "/compose/build/docker-compose/out00-pyz.pyz/compose.cli.command", line 27, in dispatch file "/compose/build/docker-compose/out00-pyz.pyz/compose.cli.docopt_command", line 24, in dispat

javascript - jQuery: Counter for draggables (again!) -

this follow of post: jquery drag , drop count content of drop area? i'm rather new programming so, apologies dull question. trying count number of draggable elements dropped in a droppable. rather initialising count variable @ 0 , increase/decrease count each time draggable drops in droppable area, trying (potentially) less troublesome strategy of try counting total number of pills in droppable. i've tried ".count()", ".length" no success... here code. suggestions? <!doctype html> <html> <head> <title>my page</title> <meta charset="utf-8"> <script type="text/javascript" src="js/jquery-1.11.2.js"></script> <script src="js/jquery-ui.js"></script> <script src="js/jquery.ui.touch-punch.js"></script> <meta name="viewport" content="width=device-width, initial-scale=1"> <lin

Spring MVC: Moving from WebMvcAutoConfiguration to WebMvcConfigurerAdapter, losing static pages -

with spring mvc application extends webmvcautoconfiguration, can serve static pages project-top-level directory "static", quite convenient. (spring seems package static pages in built jar file?) but need more control on configuration, i'm instead extending application webmvcconfigureradapter. when this, lose static pages. what's spring mvc way have cake , eat too? preferably without using xml (annotations , code)? sure, depending on resources are, can add in webmvcconfigureradapter: @override public void addresourcehandlers(resourcehandlerregistry registry) { registry.addresourcehandler("/**") .addresourcelocations("classpath:/meta-inf/resources/", "/path/to/other/resources") } that should resources going again. see here more details.

Java 7 to 8 JAXB List issue -

i upgrading our system java 7 8 , noticed strange issue. read category tree data ebay using commerce api , unmarshal using jaxb. specific call use similar example on this page http://sandbox.api.ebaycommercenetwork.com/publisher/3.0/rest/categorytree?apikey=78b0db8a-0ee1-4939-a2f9-d3cd95ec0fcc&visitoruseragent&visitoripaddress&trackingid=7000610&categoryid=0&showalldescendants=true . category tree response: @xmlrootelement(name="categorytreeresponse", namespace="urn:types.partner.api.shopping.com") public class categorytreeresponse{ private ebaycategory category; @xmlelement(namespace="urn:types.partner.api.shopping.com") public ebaycategory getcategory() { return category; } public void setcategory(ebaycategory category) { this.category = category; } } ebay category object: public class ebaycategory { @xmlattribute private string id; private string name; private

excel - Sumproduct dates -

i have spreadsheet worksheet called “iso procedure master list” date procedure requested in column g (format m/dd/yyyy). in column h date procedure completed entered. column h uses same date format may contain blanks (procedure not completed yet). there 67 rows of information in spreadsheet span 2011 2015 , number continue grow. question , average time (in days) took procedure request (column g) completion of procedure (column h) of procedures requested in given year. in other words average (in days) time took complete procedures in given year. this answer in cell c34 in same workbook different worksheet called “iso matrix” . (this information not matter thought add in case) i have tried several sumproduct variations no success. assumptions: dates in columns g , h dates, not text string, data start in row 2, using row 1 headings. for convenience, assume have named ranges wish average requestdate , completedate you wish ommit rows procedure not finishe

javascript - Hide bootstrap's .dropdown-backdrop, CSS only -

is possible hide bootstrap's .dropdown-backdrop element dropdown (not on page) using css only? i've determined possible using javascript, jsfiddle here . however, accomplish without using additional js if possible. <!-- first dropdown: no backdrop --> <div id="firstdropdown" class="dropdown"> <button class="btn-dropdown-add btn btn-blue" data-toggle="dropdown"> first dropdown &#x25bc; </button> <ul class="dropdown-menu" role="menu"> <li><a class="a_dropdown_item" href="#business">business</a></li> <li><a class="a_dropdown_item" href="#my-events">event</a></li> </ul> </div> <!-- second dropdown: yes backdrop --> <div id="seconddropdown" class="dropdown"> <button class="btn-dropdown-add btn btn-

graphics - Using Java AWT to generate monochrome 1bitpp PNG with Ancillary Chunks -

Image
i trying generate png following ancillary chunks (header reference image) the ancillary chunks in reference image came gimp processing. whereas image generate java awt not have ancillary chunks. here header of png generating. please note critical chunks identical. here code fragment { : // color map contains colors black , white byte[] cmap = {0, 0, 0, (byte)255, (byte)255, (byte)255}; // create indexcolormodel setting white transparent color indexcolormodel monochrome = new indexcolormodel(8, 2, cmap, 0, false, 0); bufferedimage img = new bufferedimage(width_img, height_img, bufferedimage.type_byte_indexed,monochrome); graphics2d g2d = img.creategraphics(); : g2d.setcolor(color.white); g2d.fillrect(0, 0, width_img, height_img); font font = new font("arial bold", font.plain, 48); g2d.setfont(font); fontmetrics fm = g2d.getfon

c# - When to use a Mock v. Stub, or neither? -

i've been reading on mocks , stubs, differences , uses. i'm still bit confused, think i've got jist of it. now i'm wondering applications. can see use in creating "fake" objects in testing scenarios actual objects complicated haul around test 1 aspect. but let's consider application: i'm working on computational geometry library. our library defines points, lines, linesegments, vectors, polygons, , polyhedra, along bunch of other objects , usual geometric operations. given object stored list of points or directions, or lower level objects. none of these objects takes more few milliseconds generate. when i'm testing library, make sense use mocks/stubs anywhere? right use particular test cases. we're calling them stubs, don't think meet technical definition of stub. think better vocab be? "testcases"? "examples"? sourcecode: https://bitbucket.org/clearspan/geometry-class-library/src edit: note we're str

php - get record by date range in CodeIgniter -

i want search records between 2 dates in codeigniter have tried many methods not getting required result. my model function search($date1 , $date2 ){ $this->db->where('date<',$date1); $this->db->where('date >',$date2); $result = $this->db->get(); return $result; } my controller function getsearch(){ $date1 = $this->input->post('txtdate1'); // 02-06-2015 $date2 = $this->input->post('txtdate2'); // 19-06-2015 $data['result'] = $this->result_model->search($date1,$date2); $this->load->view("search_view",$data); } now want rows between 2 19 getting nothing. note: date type in mysql varchar 02-06-2015 suboptimal way store dates in sql, because don't collate sensibly. if can switch date or datetime data type, you'll able cool stuff indexing on date column. that's not asked. also, wonder if have inequalities wro

magento - Product count for products with status enabled -

i trying product count products enabled , not pending. first line of code provides me ability see how many products available, span class "online" needs show how many have been enabled, not awaiting approval. here code far. //my php $corehelper = mage::helper('core'); $datahelper = mage::helper('udprod'); $currencyhelper = mage::helper('itemique_dropship/currency'); $formhelper = mage::helper('itemique_dropship/form'); $productformhelper = mage::helper('itemique_dropshipvendorproduct/form'); $udprodsourcemodel = mage::getsingleton('udprod/source'); $productcollection = $this->getproductcollection(); $vendor = $this->getvendor(); $sortcol = $this->getsortcol(); $sortdir = $this->getsortdir(); //my phtml <div class="product-count"> <span class=“products"><?php echo $productcollection->getsize(), $datahelper->__(' products.') ?></span>

java - Get Largest Number from a list of numbers -

public void getjustrevisionsnumberdata(string duanum) { list<number> dua = new arraylist<number>(); dua = getrevisionsnum(duanum); // dua object -> 123, 843, 455, 565 // want 843 for(number number : dua) { system.out.println(number); } } getrevisionsnum public list<number> getrevisionsnum(string duanum) { session session = factory.opensession(); auditreader auditreader = auditreaderfactory.get(session); return auditreader.getrevisions(duavo.class, duanum); i'm trying largest number unable come solution. suggestions? you can keep track of largest number you've come across far in variable largestnumber , , once you've iterated through whole set, can print out system.out.println(largestnumber) outside of loop. double largestnumber = double.min_value; for(number number: dua) { if(number.doublevalue() > largestnumber) largestnumber = number; } system.out.println(la

ios - Pull to refresh UITableView without UITableViewController is not working -

i can't seem find working solution. i've tried other available solutions implement pull refresh in uitableview without uitableviewcontroller nothing happens. this relevant code: @iboutlet weak var tableview: uitableview! var peoplerefreshcontrol:uirefreshcontrol! override func viewdidload() { super.viewdidload() // additional setup after loading view. peoplerefreshcontrol = uirefreshcontrol() peoplerefreshcontrol.attributedtitle = nsattributedstring(string: "pull refresh") peoplerefreshcontrol.addtarget(self, action: "refresh", forcontrolevents: .valuechanged) // tried // peoplerefreshcontrol.addtarget(self, action: selector("refresh"), forcontrolevents: .valuechanged) tableview.addsubview(peoplerefreshcontrol) } func refresh(){ println("what!") } i can see circle spinning , text "pull refresh" when pull down, function "refresh" never called. doing wrong? there else sh

html - How can i disabled selection based on ng-model? -

i want disabled proxy input field selection till attestor selected , both fields readonly, if attestor not selected user should not able select proxy. new angularjs please how can implement logic using ng-model. main.html <div class="row"> <div class="form-group col-md-6"> <label for="attestorworker" class="col-md-4">attestor:</label> <div class="col-md-8"> <input type="text" class="form-control" id="attestorworker" required ng-model="attestordto.attestorworker" name="attestorworker" ng-click="openattestorsearch()" readonly="readonly"/> </div> </div> </div> <div class="row"> <div class="form-group col-md-6"> <label for="proxyworker" class="col-md-4">proxy :&l

html - responsive table using table layout -

Image
i've been trying figure out why table not displaying correctly on screen when @ 600px. tried on codepen , working okay there must stopping rendering on small screen. ( demo ) @media screen , (max-width:600px){ .sample{ background:blue; } table { border: 0; } table thead { display: none; } table tr { margin-bottom: 10px; display: block; border-bottom: 2px solid #ddd; width:100%; } table td { display: block; text-align: right; font-size: 13px; border-bottom: 1px dotted #ccc; width:100%; } table td:last-child { border-bottom: 0; } table td:before { content: attr(data-label); float: left; text-transform: uppercase; font-weight: bold; } } this on web browser @ 600px.

database - Fetch field of another Doc in CouchDB? -

i'm new couchdb , have simple task have no been able find straight answer. i have 2 related docs: order , invoice invoice = { id: "invoice_id", order: "order_id", values: [...] } order = { id: "order_id", **order_number: 12345** } i have defined map function select unfulfilled invoices, need order_number, in order doc. same transaction. how fetch order_number order when invoices? i've looked around , i'm getting many answers like: view collation, linked documents, include_docs=true, structure docs have both... i'm looking simplest way clear explanation. appreciate help. p.s. since i'm new i'm finding couchdb development involved. have map functions, need pushed couchinstance? or edit map functions in futon? there better ways develop against couchdb? see there's couchapp docs sparse , project hasn't been updated in while.

javascript - Using HTML5 canvas tutorial. Menu not working. Jquery plugin -

for reason code drawing portion of html5 canvas tutorial working quite fine. can't menu show up. <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <script type="text/javascript" src="sketch.js"></script> </head> <body> <div class="tools"> <a href="#colors_sketch" data-download="png" style="float: right; width: 100px;">download</a> </div> <canvas id="simple_sketch" width="1200" height="800"></canvas> <script type="text/javascript"> $(function() { $('#simple_sketch').sketch(); }); $(function() { $.each(['#f00', '#ff0', '#0f0', '#0ff', '#00f', '#f0f', '#000', '#fff'], function() { $('#colors_demo .tools').append("<a href=&

javascript - send data to the div tag only if the data is true -

i have ajax code gets time in seconds , pass div tag shown. thing is, want pass data div tag if pass if statement's test save space. example, want pass data div tag if seconds in less 30, if doesn't pass div tag, div tag shows null. instead of showing null, want stay @ 30 second mark without ajax function having pass data div tag. don't know if i'm saying makes sense you, if does, there way achieve i'm trying do? thanks. testing1.php <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script type = "text/javascript"> function timeoutajax(url,id,timeout) { $.ajax({ type: "post", url: url, error: function(xhr,status,error){alert(error);}, success:function(data) { document.getelementbyid( id ).innerhtml = data; settimeout(function() { timeoutajax(url,id,timeout); }, timeout); }

loops - c++ mathematical calculations -

i have solve problem using c++, , can't come solution. the condition is. in skyscraper there lot of offices, on every office door there must put plate number 1 number of last office. plate can contain 1 digit, if office number contains 2 digits there must 2 plates. how many plates total needed office doors. the text file duom.txt . value of "16". means theres 16 offices. this managed come with: # include <iostream> # include <cmath> # include <iomanip> # include <fstream> using namespace std; const char cdfv [] = ("duom.txt"); const char crfv [] = ("rez.txt"); int main() { int n; int m; int o; int z; ifstream fd (cdfv); ofstream fr (crfv); fd>>n; (int i=1;i<10;i++) { m=n+1; (int j=1;j>=10;j++) { o=n+2; } } z=m+o; fr<<z<<" "; } fd.close(); fr.close(); return 0; } i know not correct, please me this. glad if tried compiling it, because codeblo

playframework 2.0 - Writing custom Enumeratee with Scala and Play2 -

i having hard time understanding iteratee/enumeratee/enumerator concept. looks understood how create custom iteratee - there examples that . now i'm going write custom enumeratee. start digging code that, there not comments there lot of fold() , fold0() , foldm() , joini() . understood enumeratee made of iteratee sauce, still can't catch conception of writing own. so, if me example task give right direction. lets consider such example: val stringenumerator = enumerator("abc", "def,ghi", "jkl,mnopqrstuvwxyz") val myenumeratee: enumeratee[string, int] = ... // ??? val lengthenumerator: enumerator[int] = stringenumerator through myenumeratee // should equal enumerator(6, 6, 14) myenumeratee should resample stream splitting given character flow comma , returning length of each chunk ("abc" + "def" length 6, "ghi" + "jkl" length 6 , on). how write it? p.s. there iteratee i've wrote counting lengt