Posts

Showing posts from May, 2015

How to write Japanese characters in excel using poi in java? -

i using poi write excel sheet facing trouble when try write japanese character in excel.some ascii characters printed instead of japanese . tried in many way solve can't. can 1 me. here code. public void readexcel() throws ioexception { workbook = new hssfworkbook(); worksheet = workbook.createsheet("fieldcount"); hssffont font = workbook.createfont(); font.setcolor(hssffont.color_red); font.setboldweight(hssffont.boldweight_bold); // create style hssfcellstyle cellstyle = workbook.createcellstyle(); cellstyle.setfont(font); hssfrow row1 = worksheet.createrow(0); hssfcell cella1 = row1.createcell((short)0); cella1.setcellstyle(cellstyle); cella1.setcellvalue("object type"); hssfcell cella2 = row1.createcell((short)1); cella2.setcellstyle(cellstyle); cella2.setcellvalue("object name"); hssfcell cella3 = row1.createcell((short)2); cella3.setcellstyle(cellstyle); cella3.setcellvalue(&quo

c++ - Alternative Characters - HackerRank -

i beginner, alternative code welcomed. program crashes after inputing values. want know more problem, since have seen many time. #include<cstdio> #include<vector> #include<iostream> #include<string> using namespace std; int main() { vector<string> str; int n,i=0,count=0,a=0,b=1; string j; cin >> n; while(i<n) { cin >> j; str.push_back(j); i++; } for(i=0;i<n;i++) { while(b!='\0') { if(str[i][a] == str[i][b]) { count++; } a++; b++; } } cout << count; return 0; } in order strange program work should 3 things: set init values a , b on every external loop step; change b!='\0' condition str[i].c_str()[b]!='\0' in order check not b , string literal; call string::c_str() method on strings, because not guaranteed string null-terminated, c-style strings stand condition. for(i=0;i<n;i++) { = 0; b =

xcode6 - Xcode 6 Image not Visible on larger screens -

Image
i using xcode 6.1.1 . image universal(2x) used in 1 of view-controllers. it visible on small screen sizes(till 4.7 inch ), not on larger screens. reason? location: relative group, devices: universal, width: any, height: any, types: bitmaps, render : default welcome stackoverflow, the first thing need enable size class options in file inspector in xcode 6 storyboard . ( xcode 6 has changed way lot xcode 5 ). (check use size classes here) the way setting constraints has changed way better. have @ 2 way of constraints can set up. you might have noticed former size class, can set constraints layouts. (which mentioned below base values) . later meant iphones in potrait , landscape mode. for enabling constraints different layouts. need install these layouts attributes inspector in storyboard . (see have checked wc hany means width compact height any) in xcode 6 , support 9 res

php - MySQL Getting last 5 entries for each id in a SELECT - WHERE IN statement -

i select last 5 entries each of id in select - in statement. //how last 5 entries each id select * table1 id in (111,222,333,.....) order date desc limit 5 edit: example of how data structure id date name 111 7-nov anna 111 8-nov belle 111 9-nov mary 111 10-nov john 111 11-nov robert 111 12-nov gary 111 13-nov rick 222 8-apr sarah 222 9-apr lee 222 10-apr margaret 222 11-apr lisa 222 12-apr 222 13-apr alex 222 14-apr kelly 222 15-apr lucas desired results id date name 111 13-nov rick 111 12-nov gary 111 11-nov robert 111 10-nov john 111 9-nov mary 222 15-apr lucas 222 14-apr kelly 222 13-apr alex 222 12-apr 222 11-apr lisa i not sure can done in mysql. have tried looking @ answers posted , can't find answers. it pseudo code, think works. try this select id, substring_index(group_concat( some_column_1 order date desc),',',5) substring_index(group_concat( some_column_2 order date desc),'

jquery - C# web-api post to function with two parameters -

i trying post 2 parameters following function dont manage reach function: public void setshopsubcategories([frombody]string userid, int []subcategories ) { } this how post: var subcategories = [ 1, 2, 3, 4, 5]; var userid = "123"; $.ajax({ type: "post", url: "/category/setshopsubcategories/", contenttype: 'application/json; charset=utf-8', data: json.stringify(userid, subcategories), success: function () { alert("ok"); }, error: function () { alert("error"); } when post 1 parameter goes , can reach function: public void setshopsubcategories([frombody]string userid ) { } var userid = "123"; $.ajax({ type: "post", url: "/category/setshopsubcategories/", contentty

Java mailto Illegal character colon? -

im trying send email attachment, keeps saying: exception in thread "awt-eventqueue-0" java.lang.illegalargumentexception: illegal character in opaque part @ index 64: mailto:recipient@mailserver.com?subject=thepdffile&attachment=c:\users\rascal\appdata\local\temp\freelancerlist-16-12-2014_09-227568200505392670736.doc java code: desktop desktop = desktop.getdesktop(); string message = "mailto:recipient@mailserver.com?subject=thepdffile&attachment=\""+path; urlencoder.encode(message, "utf-8"); uri uri = uri.create(message); desktop.mail(uri); should colon right? why??? you're calling urlencoder.encode , ignoring result. suspect trying achieve this: string encoded = urlencoder.encode(message, "utf-8"); uri uri = uri.create(encoded); ... although @ point you'll have encoded colon after mailto part well. suspect really want like: string query = "subject=thep

sql - Mysql DISTINCT not working in my language properly -

i have problem distinct in sql select. have table following values in column: sítotisk sitotisk when use distinct - result "sítotisk" ...db system think, same word, need words have seperaly. that's collation problem. guess you're using accent insensitive collation. can check in server/db/table properties. try select distinct yourcolumn collate utf8_bin ... you might want take @ these questions address same issue: how conduct accent sensitive search in mysql how mysql work “case insensitive” , “accent insensitive” in utf-8

How can I run matlab m file with arguments and handle that argument in m file? -

how can run matlab m file arguments? can run same code in octave arguments not find corresponding code in matlab . after running m file on command line arguments, need handle argument in m file. here corresponding octave code works perfectly: #! /usr/bin/octave -qf arglist = argv(); here command run above m file perfectly: ./solver.m this_is_argument_of_m_file what corresponding matlab codes? update: by command line, mean operating system command line(terminal, windows cmd), not matlab command line. you should know there's difference between scripts , functions. mathworks had dedicated part of documentation difference. script not take input arguments, functions can, don't need to. can recognize function first functional code in m-file function . function uses own workspace, script uses matlab's base workspace. for example: function out = fcn_name(in1, in2, varargin) furthermore, can program using oo in matlab, think should start reading li

angularjs - "ghost" clusters when customizing markercluster icon using angular-leaflet-directive -

i'm trying customize angular-leaflet markerclusters following code : overlays: { defaultoverlay: { type: 'markercluster', name: 'defaultoverlay', visible: true, layeroptions: { showcoverageonhover: true, disableclusteringatzoom: 15, iconcreatefunction: custommarkercluster } } } i have test sample of 7 markers, defined : markers: [ { _id: "548f0ab268dc96e7587c0f8f", layer:"defaultoverlay", group: "testgroup1", lat: 20.973368, lng: 40.849463, title: "imperium", message: "215 rockaway parkwa

php - Moodle Configuration error in mysql version update -

Image
i configuring moodle 2.8.1 version. while configuring loads page server checks validated. i have sorted errors , displaying 1 server check error is mysql (5.0.81-community-nt) version 5.5.31 required , running 5.0.81 where have installed newer version of phpmyadmin is: but don't understand why moodle gives me error like: it says running mysql version 5.0.x have installed newer version of mysql 5.6.x plz me out through this. thank you go htdocs , find moodle "config.php" on $cfg->dbtype = 'mysqli'; change $cfg->dbtype = 'mariadb'; it means should change dbtype mariadb instead off mysqli

git ignore whole folder excluding one file -

hey not work me: vendor/* !vendor/predis/ vendor/predis/* !vendor/predis/predis vendor/predis/predis/* !vendor/predis/predis/lib vendor/predis/predis/lib/* !vendor/predis/predis/lib/predis vendor/predis/predis/lib/predis/* !vendor/predis/predis/lib/predis/profile vendor/predis/predis/lib/predis/profile/* !vendor/predis/predis/lib/predis/profile/serverversion24.php where did make mistake? what actual state of repository? i believe want have just: vendor/* prior creating .gitignore file, git add vendor/predis/predis/lib/predis/profile/serverversion24.php . tracked. after create .gitignore file (or add mentioned line it) untracked files in vendor directory ignored. [edit] (correction after helpful comments, thanks!) please keep in mind cannot ignore file tracked. if want that, need execute command git update-index --assume-unchanged against files want ignore - change local repository, not shared. more details see how ignore files locally in git? .

c# - Add subtotals to Gridview & percentage difference -

i have gridview derived sql statement. want display subtotals each column , display overall percentage increase/decrease between 2 date ranges. how go this? <%@ page title="" language="c#" masterpagefile="~/masterpage.master" autoeventwireup="true" codebehind="sales-comparison.aspx.cs" inherits="towelsrusv3.sales_comparison" %> <asp:content id="content1" contentplaceholderid="contentplaceholder1" runat="server"> <div class="panel panel-info"> <div class="panel-heading"> <h1 class="panel-title text-center">sales comparison</h1> </div> <div class="panel-body"> <div class="row"> <div class="col-lg-8"> <asp:gridview id="gridview1" runat=&q

c++ - The implementation of std::forward -

i'm reading overview of new c++ (c++11/14) (pdf only) , @ slide 288 gives implementation of std::forward : template<typename t> // lvalues (t t&), t&& std::forward(t&& param) // take/return lvalue refs. { // rvalues (t t), return static_cast<t&&>(param); // take/return rvalue refs. } and gives implemention in text: the usual std::forward implementation is: template<typename t> struct identity { typedef t type; }; template<typename t> t&& forward(typename identity<t>::type&& param) { return static_cast<identity<t>::type&&>(param); } what difference? why latter usual implementation? the problem first can write std::forward(x) , doesn't want, since produces lvalue references. the argument in second case non-deduced context, preventing automatic deduction of template argument. forces write std::fo

.net - Google Apis Strong naming in binaries -

Image
i'm trying receive google users app.... installed 2 packages nuget - google apis client library 1.9.0 , google.apis.admin.directory.directory_v1 environment windows7, vs2010 .net4.0 framework i've got warning: the primary reference "google.apis" not resolved because has indirect dependency on framework assembly "system.net.http, version=1.5.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a" not resolved in targeted framework. ".netframework,version=v4.0". resolve problem, either remove reference "google.apis" or retarget application framework version contains "system.net.http, version=1.5.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a". i understand connect somehow strong naming - tried source , compile it, though source code not adjust vs2010 .... is there way install/compile source/whatever can me use packages? or.. maybe receive data(users data) without using apis thanks

java - Axis client sends three request for each Call.invoke() method -

hi working on webservice client using apache axis 1.4. below stub code: soapenvelope soaprequest = new soapenvelope(); service service = new service(); org.apache.axis.client.call _call = createcall(); commonshttpsender reqhandler = new commonshttpsender(); commonshttpsender resphandler = new commonshttpsender(); _call.setoperation(_operations[0]); _call.setclienthandlers(reqhandler, resphandler); _call.setusesoapaction(true); _call.setsoapactionuri(""); _call.setencodingstyle(null); _call.setproperty(org.apache.axis.client.call.send_type_attr, boolean.false); _call.setproperty(org.apache.axis.axisengine.prop_domultirefs, boolean.false); _call.setsoapversion(org.apache.axis.soap.soapconstants.soap11_constants); _call.invoke(soaprequest); while calling invoke method sending request 3 times. if remove setclienthndler function send once.but need function in code. please suggest meth

logging - Postgresql log to distant logstash server -

i'm setting logs's collector. have application send log using syslogappender (log4j) distant log server. can save applications logs , postgresql database logs, using curl command-line. logs server elk server (all in same cluster). but want send postgresql logs automatically, appender , application logs. possible postgresql.conf file? or have use logstash forwarder? (if possible avoid use of forwarder) you can either log postgres file , have loggstash-forwarder send central log server. secure requires use of ssl cert. you can output postgress syslog , have rsyslog send logs log server. postgres -> syslog (postgresql.conf) log_destination = 'syslog' syslog_facility = 'local0' syslog_ident = 'postgres' rsyslog -> logstash (/etc/rsyslog.conf) format facility.loglevel @@server address:port (@ udp, @@ tcp) local0.* @@db-private:5544 logstash input input{ syslog{ type => syslog port => 5544

c# - How to Get callback after Visual Studio Solution gets Build through VS SDK? -

i using code written below.. envdte.dte dte = (envdte.dte)marshal.getactiveobject("visualstudio.dte.12.0"); dte.executecommand("file.saveall"); // saving files before building dte.executecommand("build.rebuildsolution"); // buidling solution i want execute subsequent code statements after successfull build of solution . there callback defined notifies successful/unsuccessful build .. first, if using extension (add-in or package), don't use way of getting dte instance, because marshal.getactiveobject(...) returns running instance of dte, , if have 2 instances of vs open, wrong instance. correct way is: for add-ins: instance passed in onconnection method. for packages: see howto: envdte.dte instance visual studio package . second, see article: howto: performing action before or after build visual studio macro or add-in the best approach use ivsbuildableprojectcfg.advisebuildstatuscallback method ivsbuildstatuscallback.buildend

java - How to Sort a HashTable -

this question has answer here: how keep order of elements in hashtable 5 answers may know why hashtable number not in order? after reach number. please, need expert. helps appreciated. alot!! code in jsp file. <% vector vrow2 = new vector(); vector vfruit = new vector(); hashtable htitem = new hashtable(); vrow2.addelement("apple"); vrow2.addelement("banana"); vfruit.addelement(vrow2); htitem.put("1", vfruit); htitem.put("2", vfruit); htitem.put("3", vfruit); htitem.put("4", vfruit); htitem.put("5", vfruit); htitem.put("6", vfruit); // if htitem put 6 show correct order result 6,5,4,3,2,1 htitem.put("7", vfruit); // if htitem put 7 show incorrect order result 6,5,4,3,2,1,7 htitem.put("8", vfruit); // if htitem put 8 show result 6,5,4,3,2,1,8,7 htitem.

c++ - How to typecast wxObject to wxVariant? -

i have map of wxobject..but want typecast wxvariant. void mwdataviewtable::initcolumnvalues(wxstring targetcolumn,wxstring sourcecolumn , std::map<wxobject,wxobject> srctargetvalue) { wxvariant srcvalue; wxvariant tgtvalue; int srccolumnpos = getcolumnposition(sourcecolumn); int tgtcolumnpos = getcolumnposition(targetcolumn); int rows = m_rowdatalist.size()-1; //without header for(int i=0;i< rows;i++) { getvalue(srcvalue,i,srccolumnpos); tgtvalue = (wxvariant)srctargetvalue[srcvalue] ;// typecasting setvalue(tgtvalue,i,tgtcolumnpos/*toggle-column*/); } } in highlighted line doing typecasting..but giving me error says "error 1 error c2678: binary '<' : no operator found takes left-hand operand of type 'const wxobject'" error coming in xstddef.h file. dont have idea why happening or if typecasting wrongly. please..! in std::map , key values used sort , uniquely ident

c# - How to identify only change rows in datagrid which is bind ObservableCollection in WPF MVVM -

i have data grid bind observable collection. first load data database. if change 1 row , click on save button should update particular row. if add new rows, when click save id should insert rows database. don't have doubt update , insert database. problem how identify row changes. <datagrid selectedindex="{binding selectedintex}" isenabled="{binding iskeyset}" canuserdeleterows="false" canuseraddrows="false" name="dgwtemplatedetails" selectionmode="single" itemssource="{binding ordertemplatelist, mode=twoway}" selecteditem="{binding selectedordertemplate}" isreadonly="false" autogeneratecolumns="false" width="auto"> <datagrid.columns> <datagridtextcolumn header="change state" visibility="visible" binding="{binding changestate}"/> <datagridtext

python - How do I update this Text Box's text in Tkinter? -

Image
so making stopwatch in python tkinter, have loop updating time working, have loop clears text box, , updates text box new number. although doesnt work, reason doesnt clear it, keeps adding numbers box. here code have used, if able have @ me appriciate lot :) import time tkinter import * root = tk() root.title("stopwatch") #textbox screen screen = text(root, height = 1, width = 20, bd=10) screen.grid(row=0, column=0) #active variable global stopwatch_active stopwatch_active = false stop_time = 0 stop_minutes = 0 #command starting stopwatch def start_com(): stop_btn.config(state=normal) stopwatch_active = true start_btn.config(state=disabled) global stop_time stop_time += 1 screen.insert(end, stop_time) root.after(1000, start_com) #button starting stopwatch start_btn = button(root, text = "start", width = 10, bd = 5, command = start_com) start_btn.grid(row=1, column=0, sticky=w) #button stopping stopwatch stop_btn = but

javascript - how to implement parasitic inheritance to avoid nesting -

Image
i follow inheritance structure shown above. create engineer using syntax: var mark = new employee(id).workerbee(project).engineer(); to achieve syntax, have create nested object following parasitic inheritance pattern so: function employee(id) { this.id = id; this.workerbee = function(project) { this.project = project; this.engineer = function() { ... return this; }; return this; }; } to avoid deep layers of nesting, trying rewrite using prototypes. how can rewrite code achieve same goal above ? function employee(id) { //variables this.id = id this.name = ""; this.dept = "general"; //methods this.getid = function() { return this.id } } employee.prototype.workerbee = workerbee; function workerbee(project) { //variables this.projectname = project th

powershell - Ping TimeToLive - just get back number -

when this: $pinging = get-wmiobject win32_pingstatus -filter "address='localhost'" | select-object timetolive i back: @{timetolive=128} how number out , not @ thing around it? i need call later in below...which erroring think becuase not looking @ number only: switch($pinging) { {$_ -le 128} {return "this windows server"; break} } error: cannot compare "@{timetolive=128}" "128" because objects not same type or object "@{timetolive=128}" not implement "icomparable" two options: either use -expandproperty parameter in select-object > $result = get-wmiobject win32_pingstatus -filter "address='localhost'" | select-object -expandproperty timetolive > $result 128 or access property directly on variable assign object to > $result = get-wmiobject win32_pingstatus -filter "address='localhost'" | select-object timetolive > $result.

php - Display counting variable in for -

so i'm trying learn php.. <form action="momo.php" method="post"> <label for="number1">repeat:</label> <input type="text" name="number1"> <br> <label for="text1">text:</label> <input type="text" name="text1"> <br> <input type="submit" name="send"> </form> if(isset($_post['number1'])) { $number1= $_post['number1']; $text1= $_post['text1']; if(is_numeric($number1)) { echo "numerical!<br><br>"; for($i=0;$i<$number1;$i++) { echo $text1; } } else { echo "not numerical!"; } } ..and i've managed make work! cannot make count each result though, i've tried count() i'm not sure

java - Passing data from BroadCastRecevier to activity -

i have sms reader application , showing senderno , message body custom listview. incoming messages have registered broadcast receiver , populating listview. whenever new message coming in broadcast receiver able want data passed onto activity. the code snippets : mainactvity.java public class mainsmsactivity extends activity{ private listview smslist; smsadapter smsadapter; private smsdao smsdao; private list<smsdao> smsdatalist; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_sms_demo); smsdatalist = new arraylist<smsdao>(); intent intent = new intent(); intent.setaction("com.mobile.sms.incomingsms"); sendbroadcast(intent); populatesms(); } public void populatesms(){ uri inboxuri = uri.parse("content://sms/inbox"); string[] reqcols = new string[] { "_id&

css - How to enable responsiveness on fixed-width site built on Bootstrap? -

i have problem bootstrap. needed fixed-width layout, added div.wrap wrapper whole page width:1170px attribute , got want. later figured out trick disables responsive in bootstrap. is possible built responsive website fixed-width layout on bootstrap? how enable responsive now? thank you. have tried max-width: 1170px; instead of width: 1170px ?

c# - MVC date range between min and max value -

Image
i trying add range date in model. i have added following property class [required] [datatype(datatype.date)] [display(name = "date schedule")] [range(typeof(datetime), datetime.now.tostring("dd/mm/yyyy"), datetime.now.adddays(120).tostring("dd/mm/yyyy"), errormessage = "please select valid date")] public datetime? dateschedule { get; set; } it gives me following error how can assign min , max value dateschedule ? in calendar control should display date today 120 days (in class have added 120 days). attributes accept constants parameters. we know datetime.now isn't constant, changes depending on when code runs. , range attribute determined @ compile time. you need create custom validator shown below :- public class dateattribute : rangeattribute { ////your code }

django - (yet another) Custom templatetag raising KeyError when DEBUG=False -

i'm trying use custom templatetag (this 1 actually: https://djangosnippets.org/snippets/2875/ ), on project works fine long debug=true. when it's false, relevant error part is: file "...app/templatetags/helper_tags.py", line 15, in change_lang path = context['request'].path file "...local/lib/python2.7/site-packages/django/template/context.py", line 56, in __getitem__ raise keyerror(key) keyerror: 'request' i've seen lot of questions , have done settings of them seen suggest are: 1) views.py uses django.shortcuts.render: from django.shortcuts import render def home(request): return render(request, 'home.html') 2) settings.py contains: allowed_hosts = ['*'] django.conf import global_settings template_context_processors = global_settings.template_context_processors + ( "django.core.context_processors.request", ) i've created new project same django version (1.6.2) tries imitate proble

swift - iOS Simulator Custom Location issues -

i having issues ios simulator , custom location setting iphone. when run app first time simulator opened finds location of user without issues, if change custom location, , run app again gives same location first time, despite having changed custom location. if instead set debug> location > none in simulator, , change location in product > schemes > edit schemes in xcode itself, have no issues. every time change location way have first set location none in simulator. problem code, or quirk of simulator wouldn't find real iphone? import uikit import corelocation import mapkit var userlocationcity : string! var userlocationdate : string! var safeusername : string! class tinderviewcontroller: uiviewcontroller, cllocationmanagerdelegate { override func viewdidload() { super.viewdidload() pfgeopoint.geopointforcurrentlocationinbackground { (geopoint: pfgeopoint!, error: nserror!) -> void in if error == nil { println(geopoint)

Spring boot Jar Authentication exception -

i trying deploy spring boot application jar , application running , tried http://localhost:8080 in browser , showing dialog box enter authentication details username , password . please me on how solve issue. did see password logged @ info on startup? username "user". docs here .

android - "File not Found" exception in dexDebug task of build -

error:execution failed task ':app:dexdebug'. > com.android.ide.common.internal.loggederrorexception: failed run command: d:\androidsdk\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output c:\users\奇異果kiwi\androidstudioprojects\myapplication\app\build\intermediates\dex\debug --input-list=c:\users\奇異果kiwi\androidstudioprojects\myapplication\app\build\intermediates\tmp\dex\debug\inputlist.txt error code: 1 output: unexpected top-level exception: java.lang.runtimeexception: c:\users\憟?iwi\androidstudioprojects\myapplication\app\build\intermediates\classes\debug: file not found @ com.android.dex.util.fileutils.readfile(fileutils.java:51) @ com.android.dx.cf.direct.classpathopener.processone(classpathopener.java:169) @ com.android.dx.cf.direct.classpathopener.process(classpathopener.java:144) @ com.android.dx.command.dexer.main.processone(main.java:632

android - Send sms when a specific link is sent -

would know if there way of sending sms, let's orderid etc ecommerce site dedicated number, when link clicked. mobile web link, if specific link clicked, it'll take body of sms, number sent , either send directly or place in message app.

JavaFX TableView controls are not repainted correctly after remove item / add new item -

i using observablelist control items , every time delete item , tableview removes datasource. the view not being updated i'm still seeing items. difference removed item can not selected anymore. similar problem: javafx listview , treeview controls not repainted correctly in following code: final tablecolumn<tmachinetype, string> testertype = new tablecolumn<tmachinetype, string>( bundle.getstring("table.testertype")); testertype .setcellvaluefactory(new propertyvaluefactory<tmachinetype, string>( "testertype")); testertype .setcellfactory(new callback<tablecolumn<tmachinetype, string>, tablecell<tmachinetype, string>>() { @override public tablecell<tmachinetype, string> call( final tablecolumn<tmachinetype, string> param) { final tablecell<tmachinetype, strin

java - Comparable and compareto -

i have problem. have class extends class , implements comparable. when tried compile program had error: flight not abstract , not override abstract method compareto. anyway, code of flight this: class flight extends keyflight implements comparable<flight>{ public keyflight kf; public boolean departure; public void flight(){ keyflight kf=new keyflight(); boolean departure=false; } public int compareto(keyflight other){ if (kf.time==other.time){ if (kf.key<other.key){ return kf.key; } else { return other.key; } } else { if (kf.time <other.time){ return kf.key; } else { return other.key; } } } } thank in advance! you should use implements comparable<keyflight> instead of implements comparable<flight> as want compare 2 keyflights rather flights itself. type of parameter defines in compareto, should match type specified in implements clause going compare with. another issue code is, in constructor re

ElasticSearch query using match or term? -

i use match query search field "syslog_5424" { "query":{ "filtered":{ "query":{"match":{"syslog5424_app":"e1c28ca3-dc7e-4425-ba14-7778f126bdd6"}} } } } here query result: { took: 23, timed_out: false, -_shards: { total: 45, successful: 29, failed: 0 }, -hits: { total: 8340, max_score: 17.623652, -hits: [ -{ _index: "logstash-2014.12.16", _type: "applog", _id: "auptbuwksotkslj7c27d", _score: 17.623652, -_source: { message: "132 <14>1 2014-12-16t12:16:09.889089+00:00 loggregator e1c28ca3-dc7e-4425-ba14-7778f126bdd6 [app/0] - - platform's mbean server", @version: "1", @timestamp: "2014-12-16t12:16:10.127z", host: "9.91.32.178:33128", type: "applog", syslog5424_pri: "14", syslog5424_ver: "1", syslog5424_ts: "2014-12-16t12:16:09.889089+00:00", syslog5424_host: "loggregat

java - Reading an image as byte array with Android: skImageDecoder::Factory returned null -

i have spring mvc web service returns image byte array. output in json format. format png here's code snippet image. bufferedimage img = imageio.read(new file(caminho.replace("/", "//"))); imagem = ((databufferbyte) img.getraster().getdatabuffer ()).getdata(); when run server, output: [{"id":0,"caminhomdpi":null,"caminhohdpi":"c:/users/marcos/pictures/postos/drawable- mdpi/esso_logo.png","caminhoxhdpi":null,"caminhoxxhdpi":null,"imagem":"aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaa....] eventually, other symbols appear on "imagem" field. suppose right, i'm not sure. on android app, have routine download image , store blob in database. receive json format , transform class jackson. i've logged "imagem" field , looks same. my problem can't transform image. here's code snippet: byte[] img_bandeira = cursor.get

javascript - Snow and html stuff -

i'm newbie javascript, , boss ask me chrismas card. i'm using threejs render snow effect on page (found it, great one) using script : http://seb.ly/demos/jssnownew/snow3d.html but canno't put html component, cause, understand, script creates div @ end of body, , put snow into. let snow sticked @ top, , put text / div / css after. how can make ? thanx the snow rendering in canvas element, simple css: canvas { position: fixed; top: 0; } should trick having fixed top of webpage though might last element added body. however, you'd more accurate answers if shown code.

mongodb - hack for "mongo db connection refused due to blocked port errno 10061" -

i m trying connect db in mongolab: >> mongo ds123456.mongolab.com mongodb shell version: 2.6.1 connecting to: ds123456.mongolab.com/test 2014-12-16t14:13:41.738+0100 warning: failed connect 54.74.247.101:27017, reason: errno:10061 no connection made because target machine actively refused it. 2014-12-16t14:13:41.741+0100 error: couldn't connect server ds123456.mongolab.com:27017 (54.74.247.101), connection attempt failed @ src/mongo/shell/mongo.js:148 exception: connect failed i assume this question answers first problem of access being blocked on port. the obvious solution contact network admin. wonder if there alternative? thanks in advance.

Default scope for queries using Python + Flask-SqlAlchemy -

i writing application using python + flask-sqlalchemy extension. i have following code: class resource(db.model): __tablename__ = 'resources' id = db.column(db.integer, primary_key=true) created_at = db.column(db.datetime) updated_at = db.column(db.datetime) is_active = db.column(db.boolean) key = db.column(db.string(64)) title = db.column(db.string(64)) def __init__(self): self.created_at = datetime.now() self.updated_at = datetime.now() self.is_active = 1 @app.route('/resources', methods=['get']) def resources_get_all(): get_limits() resources = [] data = resource.query.filter(resource.is_active == 1).limit(limit).offset(offset).all() row in data: resources.append( resources_show(row) ) return envelope(resources) is there way make queries database automatically implement .filter(modelname.is_active == 1).limit(limit).offset(offset) ? not want kee

c# - Testing a get/set with Moq -

i'm trying test set of property, don't know how can in particular case. i'm using .net 4.5 , moq framework. i've method: public invoice approve(invoice invoicetobeapproved) { var approvedinvoicestatus = invoicestatusrepository.first<approvedstatus>(); invoicetobeapproved.car.remainingseats -= 1; if (invoicetobeapproved.car.remainingseats < 0) { throw new businessexception("there no remaining seats"); } invoicetobeapproved.invoicestatus = approvedinvoicestatus; invoicerepository.update(invoicetobeapproved); context.savechanges(); return invoicetobeapproved; } i'm doing unit test (not integration test, i'm not going db). what want test invoicetobeapproved.car.remainingseats -= 1; i tried using verifyget, can't reach property. part of test this var newinvoice = invoiceservice.approveinvoice(invoice); invoicestatusrepository.verify(x => x.first<approvedstatus>());

ruby - Private method and encapsulation : Prevent accidental private method overriding -

i trying understand how encapsulation mechanism works in ruby : class def public_method_a; p private_method; end; private def private_method; 'a'; end; end class b < def public_method_b; p private_method; end; private def private_method; 'b'; end; end now when try run code, here : 1. > a.new.public_method_a => "a" 2. > b.new.public_method_b => "b" 3. > b.new.public_method_a => "b" basically, third call refers private method defined in b , not in a. java developer's point of view, encapsulation violation. call private_method should refer method defined in class call made. in ruby, seems more matter of context. right ? how can make sure private methods never called outside respective class ? doing wrong ? thank in advance help. nutshell: private means message can't have explicit receiver. that's all; nothing more. it removes message public api, nothing re

php - How to find fields by an array which contains multiple values by using like %% search -

i trying multiple fields match ids(1, 2, 3) %% search. have tried make work 2 hours, hasn't worked though looks pretty simple. $ids = array ('1','2','3'); $result = $this -> model -> find ('all', array( 'conditions' => array( 'model.category like' => '%'.$ids.'%') )); i need somebody's help. i'd suggest build 'conditions' array separately. example: $ids = array ('1','2','3'); $conditions = array(); foreach($ids $id){ $conditions['or'][] = array( 'model.category like' => '%'.$id.'%') } $result = $this->model->find('all', array('conditions'=>$conditions));

servlets - Issues while deploying java EE app -

i deploying java ee application. encountered error while building , deploying it. trying interpret have no clues. i'm using jdbc , glassfish 4.01 experimental purpose. severe: servlet [registrationrequesterporttypeportimpl] , servlet [registrationcoordinatorporttypeportimpl] have same url pattern: [/registrationservice_v10] severe: exception while deploying app [bank] severe: exception during lifecycle processing and following error: warning: web application [unknown] registered jdbc driver [com.mysql.jdbc.driver] failed unregister when web application stopped. prevent memory leak, jdbc driver has been forcibly unregistered. warning: web application [unknown] registered jdbc driver [org.postgresql.driver] failed unregister when web application stopped. prevent memory leak, jdbc driver has been forcibly unregistered. severe: exception while deploying app [bank] : servlet [registrationrequesterporttypeportimpl] , servlet [registrationcoordinatorporttypeportimpl

java - Error in Maven and JAXB -

i've written small java program using jaxb. in eclipse working fine! everthing works... then involved maven , when execute jar (generated maven) following error: dez 16, 2014 2:51:15 pm com.sun.xml.internal.bind.v2.util.xmlfactory createparserfactory schwerwiegend: null org.xml.sax.saxnotrecognizedexception: http://javax.xml.xmlconstants/feature/secure-processing @ org.apache.xerces.parsers.abstractsaxparser.setfeature(unknown source) @ org.apache.xerces.jaxp.saxparserimpl.setfeatures(unknown source) @ org.apache.xerces.jaxp.saxparserimpl.<init>(unknown source) @ org.apache.xerces.jaxp.saxparserfactoryimpl.newsaxparserimpl(unknown source) @ org.apache.xerces.jaxp.saxparserfactoryimpl.setfeature(unknown source) @ com.sun.xml.internal.bind.v2.util.xmlfactory.createparserfactory(unknown source) @ com.sun.xml.internal.bind.v2.runtime.unmarshaller.unmarshallerimpl.getxmlreader(unknown source) @ com.sun.xml.int

Post vs Post_via_redirect in Rails 4 not behaving in expected way -

i'm stumped in particular part of m. hartl's rails guide (ch 8) integration testing. trying validate user login/logout, here's testing code(not working): ##doesnt work test "should display user logout behavior" login_path assert_template 'sessions/new' assert_select "a[href=?]", signup_path, count: 3 assert_select "a[href=?]", login_path, count: 2 post_via_redirect login_path, session: {email: @user.email, password: "password"} assert_redirected_to @user assert logged_in? assert_select "a[href=?]", signup_path, count: 0 assert_select "a[href=?]", login_path, count: 0 delete logout_path follow_redirect! assert_template 'static_pages/home' assert_not logged_in? assert_select "a[href=?]", login_path, count: 2 assert_select "a[href=?]", signup_path, count: 3 end however, making these modifications make work: #works test "should displa