Posts

Showing posts from June, 2012

r - dplyr summarise over nested group_by -

i have data frame this: date amount category 1 02.07.15 1 1 2 02.07.15 2 1 3 02.07.15 3 1 4 02.07.15 4 2 5 03.07.15 5 2 6 04.07.15 6 3 7 05.07.15 7 3 8 06.07.15 8 3 9 07.07.15 9 4 10 08.07.15 10 5 11 09.07.15 11 6 12 10.07.15 12 4 13 11.07.15 13 4 14 12.07.15 14 5 15 13.07.15 15 5 16 14.07.15 16 6 17 15.07.15 17 6 18 16.07.15 18 5 19 17.07.15 19 4 i calculate sum of amount each single day in category. attempts (see code) both not sufficient. summarise(group_by(testdata, category), sum(amount)) wrong output --> here sum calculated on each group category sum(amount) 1 1 6 2 2 9 3 3 21 4 4 53 5 5 57 6 6 44 summarise(group_by(testdata, date), s

hadoop - java.lang.NoSuchMethodError : org.apache.commons.io.FileUtils.isSymLink(Ljava/io/File;)Z -

i getting error while importing data using sqoop(master machine) oracle db in different machine(i.e., slave machine). have replaced commons.io.jar file also. maybe i'm late, faced same issue , solve it. solution me indicate in weblogic.xml jar must override same existing in weblogic: <weblogic-web-app ...> <container-descriptor> <prefer-application-packages> <package-name>org.apache.commons*</package-name> </prefer-application-packages> </container-descriptor> regards, jose. source: https://mycodingexperience.wordpress.com/2016/01/31/determine-run-time-jar-being-used/

jquery - Javascript files clashing, please suggest changes -

i making view page out of html code , source files of 2 bootstrap templates. both templates using different java script files different features. using both js files in 1 html view page, features of 1 js file not working. two js files using are: jquery-2.1.1.min.js , jquery-2.1.4.min.js please suggest alternative or way out combine both these files in single features working. <!-- jquery 2.1.4 --> <script src="plugins/jquery/jquery-2.1.4.min.js"></script> <!-- jquery ui 1.11.2 --> <script src="http://code.jquery.com/ui/1.11.2/jquery-ui.min.js" type="text/javascript"></script> <!-- resolve conflict in jquery ui tooltip bootstrap tooltip --> <script> $.widget.bridge('uibutton', $.ui.button); </script> <!-- bootstrap 3.3.2 js --> <!-- morris.js charts --> <script src="http://cdnjs.cloudflare.com/ajax/libs/r

in php remove keys and convert into a flat arrays -

Image
, want remove key "holiday_date" , falt arry array('2010-01-01','2010-01-02',...) smarter way rather loop? you need use array_column() , $tmp = array_column($tmp, 'holiday_date'); this pull out 'holiday_date' values internal arrays, , storing them in $tmp itself, after line, $tmp formed need. example: consider below array, $records = array( array( 'id' => 2135, 'first_name' => 'john', 'last_name' => 'doe', ), array( 'id' => 3245, 'first_name' => 'sally', 'last_name' => 'smith', )); applying, array_column() below, array_column($records, 'first_name'); will return, array ( [0] => john [1] => sally ) if using php version < 5.5, refer this quick implementation of array_column() .

java - Testing Color class in android not working as expected -

i trying write test cases java class in android application, , doesn't seem work expected. this test case: public void testgetcolor() throws exception { shadescolor color = new shadescolor(100, 200, 250); assert.assertequals(color.rgb(100, 200, 250), color.getcolor()); assert.assertequals(100, color.getred()); assert.assertequals(200, color.getgreen()); assert.assertequals(250, color.getblue()); } following shadescolor class. public class shadescolor { int color; public shadescolor(int red, int green, int blue) { color = color.rgb(red, green, blue); } public int getcolor(){ return color; } public shadescolor interpolate(shadescolor endcolor, double percentage){ int red = (int)(this.getred() + (endcolor.getred() - this.getred()) * percentage); int green = (int)(this.getgreen() + (endcolor.getgreen() - this.getgreen()) * percentage); int blue = (int)(this.getblue() + (endcolor.get

python - How to perform *synchronous* read/write into/from a asyncio transport object -

i using asyncio on windows , have reference transport object of named pipe: class datapipehandler(asyncio.protocol): def connection_made(self, trans): self.trans = trans # <<== reference transport object of type _proactorduplexpipetransport loop = asyncio.get_event_loop() server = loop.start_serving_pipe(lambda: datapipehandler(), r'\\.\pipe\test-pipe') now use self.trans synchronously write , read data named pipe. how can this? its important me synchronously kind of rpc call doing using pipe (writing , getting response quickly) , want block other activities of loop until "pipe rpc call" returns. if don't block other activities of event loop until rpc call done have unwanted side effects loop continue process other events don't want process yet. what want (the write pipe , read) similar calling urllib2.urlopen(urllib2.request('http://www.google.com')).read() event loop thread - here event loop activities blocked until

Accessing Rails 4.2.3 with Ruby 1.9.3 gives Byebug error -

i've been trying use ruby 1.9.3 , set rails since i've been having error deploying rails when using ruby versions >= 2.0. now, i've been running bundle install in cmd , gives me error: gem::installerror: byebug requires ruby version >= 2.0.0. error occurred while installing byebug (5.0.0), , bundler cannot continue. make sure 'gem install byebug -v '5.0.0'' succeeds before bundling. i've manually installed , doesn't work well. i've been typing rails commands including rails -v , i've been getting error not find byebug. how work around problem since i'm using ruby 1.9.3? there way me make ruby versions >= 2 work in windows 8? since byebug supports v2.0.0 default you can use older version of debugger tool rails debugger gem install debugger should suffice.

scala - Infinite recursion with Shapeless select[U] -

i had neat idea (well, that's debatable, let's had idea) making implicit dependency injection easier in scala. problem have if call methods require implicit dependency, must decorate calling method same dependency, way through until concrete dependency in scope. goal able encode trait requiring group of implicits @ time it's mixed in concrete class, go calling methods require implicits, defer definition implementor. the obvious way kind of selftype la psuedo-scala: object thingdoer { def getsomething(implicit foo: foo): int = ??? } trait mytrait { self: requires[foo , bar , bubba] => //this fails compile unless dothing takes implicit foo def dothing = thingdoer.getsomething } after few valiant attempts implement trait and[a,b] in order nice syntax, thought smarter start shapeless , see if anywhere that. landed on this: import shapeless._, ops.hlist._ trait requires[l <: hlist] { def required: l implicit def provide[t]:t = required.select[t

multithreading - Ada Thread Switching Using GtkAda -

a task created doesn't appear relinquishing control main thread run. i'm not sure why. since first attempt use multithreading in ada (under gnat gtkada), sure missing basic principle here. my main looks this: procedure main begin test_gui.gui_task.gui_initialize; test_gui.simple_switch_test; msg("done"); end; in package test_gui, spec , body code this: task type gui_type entry gui_initialize; entry gui_reset_switch_to_1; entry gui_display_message(message : string); entry gui_write_debug; end gui_type; gui_task : gui_type; and task body gui_type begin loop select accept gui_initialize initialize; end gui_initialize; or accept gui_reset_switch_to_1 reset_switch_to_1; end gui_reset_switch_to_1; or accept gui_display_message (message : in string) display_message(message); end gui_display_message; or accept gui_w

c# - Cannot call Web API in different project but same solution -

here situation. have 1 solution containing 2 projects : web api , web form. set both projects startup projects . in code behind, call web api this: private httpresponsemessage downloadfile(int id) { using (var client = new httpclient()) { client.baseaddress = new uri("http://localhost:8096/"); client.defaultrequestheaders.accept.clear(); client.defaultrequestheaders.accept.add(new mediatypewithqualityheadervalue("application/pdf")); httpresponsemessage response = client.getasync("api/document/" + id).result; return response; } } when click start in visual studio, if web api running on different port webform, "actively refused connection" (as exception said). so question is: how can make web api accept call without changing port ? don't want both projects run on same port. why can't call many external apis? thanks help.

Meteor: Where to store a selected object for a tempate -

i new meteor , have simple question can't seem find answer for... i have simple page list of people down left, , template shows details on right editing, actions , such. when click person on left, best place store selected person object template use? i've built 1 page stored in "selectedperson" session object, doesn't seem that's best place. advice on how store template , related js code without polluting session space? meteor templates support ability arbitrarily define variables within scope of template. you use events quite change current template data space reflect selected person. quick , dirty below <template name='personselector'> <div class='personlist'> <ul id='personslisting'> {{#if personsready}} {{#each persons}} <li class='person' data-id='{{this._id}}'>{{this.name}}</li> {{/each}}

Error when calling Rust from Python -

rust code: #[no_mangle] use std::thread; pub extern fn process() { let handles: vec<_> = (0..10).map(|_| { thread::spawn(|| { let mut _x = 0; _ in (0..5_000_001) { _x += 1 } }) }).collect(); h in handles { h.join().ok().expect("could not join thread!"); } } cargo.toml: [package] name = "embed" version = "0.1.0" authors = ["hustlibraco <hustlibraco@gmail.com>"] [lib] name = "embed" crate-type = ["dylib"] i build target/release/libembed.so , , create invoke.py in path: from ctypes import cdll lib = cdll.loadlibrary("target/release/libembed.so") lib.process() print("done!") executing, , error: -bash-4.2# python invoke.py traceback (most recent call last): file "invoke.py", line 5, in <module> lib.process() file "/usr/lib64/python2.7/ctypes/__init__.py&qu

java - Trying to run a program in Eclipse, it's asking for an ant build? -

novice programmer here. i'm working on small project, , i've started on pc. uploaded github, , opened on laptop can edit there. program runs on pc, when try run using eclipse on laptop, asks me ant build run as. have no idea ant build is, , don't have issue on pc (and both running eclipse). i went system properties , set java_home jdk , selected same 1 in preferences in eclipse, didn't seem either. suggestions appreciated. if using updated jdk, update apache ant, have tried run project under ant? run as->...ant build.. that. or try re-import project eclipse.

javascript - Creating a editor -

i'm trying understand object inheritance in js exercise, create online editor, 1 i'm writing on. but.. i'm little confuse here, want use data-* manipulate editor: <div class="editor__wrapper"> <div data-editor="toolbar"> </div> <textarea data-editor="textarea"></textarea> </div> so, trying initialize this: $(window).on('load', function() { $('[data-editor]').each(function() { var element = $(this); var editor = new editor(element); }); }); and editor: var editor = function(element) { this.element = element; }; but not want here.. i want initialize data-* create toolbar if toolbar , create editor if editor, make 2 inherit father commum properties. i'm little lost here, guys think this? there better way??? thanks. if trying setup editor handle create depending on value, can perform following: <script type="text/javascript"> $

angularjs - Trigger ng-model change on radio button? -

i have form radio buttons this: label.has_checkbox(for="workflow_{{workflowslug}}") input(type="radio" ng-model="form.workflow.slug" value="{{workflowslug}}" name="workflow" id="workflow_{{workflowslug}}") now when operate app manually , click radio, model set value of radio. problem when trigger click using jquery, radio button gets selected, model doesn't populated value. in angular supposed opposite direction. data affects view. if want set value programmatically should change ng-model within angular scope.

java - How can I force a Python ScriptEngine to flush its cache of imported modules? -

i using python scriptengine in java application execute python script imports various other python scripts. once main script completes , eval method returns, set engine object reference null , call garbage collector. next go , edit 1 of scripts imported main script , save it. next run method execute main python script before creating new scriptengine object , calling eval, when main script runs not pick changes imported script made. obviously imported scripts being cached somewhere (maybe jython?). i not want call reload in python script. there must way tell whatever doing caching flush or clear itself. anyone found solution problem? using netbeans 8.0.2, java 1.8 update 45, , jython 2.7 on windows 7. here java code. doesn't matter python script contains other import statements. scriptenginemanager scriptenginemanager = new scriptenginemanager(); scriptengine engine = scriptenginemanager.getenginebyname("python"); object result = engine.eval(); engine

grails - Data not persisted after return from service -

let me preface saying code working yesterday. rolled commits time when working. the thing different migration ran today remove columns tables. can't see how affect i'm doing google oauth authentication , in callback url google doing lot of saves/updates/etc.. controller calls single service everything. if query data while @ breakpoint return statement is, can see data. there no exceptions, validation errors, or lead me believe wrong. ideas? class mycontroller { def myservice def callback() { myservice.update() //at point when run x.get(1) returning null redirect uri: "..." } } @transactional class myservice { def update() { ... //if break @ return statement can run x.get(1) , returns return somedata; } } edit: i've found cause, don't understand how happening. i'm calling userdetailsservice.loaduserbyusername . method throwing nostackusernamenotfoundexception . i'm catching exception in code, causing tr

statistics bootstrap - Bootstrapping in Matlab - how many original data points are used? -

i have data sets 2 groups, 1 being smaller other. reason, using matlab bootstrapping function estimate performance of smaller group. have code draws on original data, , generates 1000 'new' means. however, not clear how many of original data points used each time. obviously, if original data used, same mean continue generated. can me out this? bootstrapping comes sampling replacement. you'll use same number of points original data, of them repeated. there variants of bootstrapping work differently, however. see https://en.wikipedia.org/wiki/bootstrapping_(statistics) .

eclipse - Import android gradle project when building sayes not found sdk -

Image
import android gradle project problem when building says not found sdk in eclipse luna

compilation - indirection requires pointer operand and expected expression errors -

i keep getting errors similar these: pitstop.cpp:36:23: error: indirection requires pointer operand ('double' invalid) cost = unleaded * gallons; ^ ~~~~~~~ pitstop.cpp:40:14: error: expected expression cost = super * gallons; ^ #include <iostream> #include <iomanip> using namespace std; #define unleaded 3.45; #define super {unleaded + 0.10}; #define premium {super + 0.10}; /* author: zach stow date: homework objective: */ double cost, gallons; string gastype, finish, stop; int main() { for(;;) { cout <<"hi, welcome pitstop.\n"; cout <<"enter type of gas need:"; cin >> gastype; cout << endl; cout <<"enter amount of gallons need:"; cin >> gallons; cout << endl; if(gastype == "finish"

javascript - minimum set of module/methods in jquery code for selector -

i reading jquery code now. found following methods suitable cross platform programming. (desktop, web browser , mobile app) $(selector) $.ajax() <----------i not sure if veryuseful $(selector).find() $(selector).bind() $(selector).unbind() $(selector).delegate() $(selector).remove() $(selector).attr() $(selector).html() i mean prefer javascript native code process logic business except selector/dom methods. means can use same logic code in qt/qml. is there minimum set of module/methods function above? my understanding want light-weight version of jquery. while may want use above functions, chopping down jquery won't give massive boost if looking for. of course, using native dom functions faster, but, free use both in conjunction well. there zepto ( http://zeptojs.com/ ) able of functions requested. in addition, http://projects.jga.me/jquery-builder/ can used build custom jquery build , can remove 'css', 'ajax', , 'effect' brin

html - Centering absolute element inside fixed width container -

i have fixed size parent image , absolute element of text nested inside. i .video-text center off browser window size , not fixed width of parent div. html: <div class="video-bg"> <img src="../images/video-bg.jpg" /> <div class="video-text "> <a href="#"><h3> watch video learn more</h3></a> </div> </div> css: .video-bg { position: relative; overflow: hidden; width: 1280px; } .video-bg img { width: 100%; } .video-text { position: absolute; top: 44%; left: 50%; } try setting position static rather relative. an element position: static; not positioned in special way; positioned according normal flow of page.

node.js - Pulling items from a collection using Handlebars -

i using node.js express , mongodb database utilizing mongoose , handlebars templating engine. have collection in database named players. have defined model, player.js, provides schema collection. when user enters players information gets stored database correctly. trying create list show playername , team on players homepage every player gets created. code have been trying write in handlebars: <div class="widget"> <ul> {{#each players}} <li><a href="#">{{playername}}, {{team}}</a></li> {{/each}} </ul> </div> can me understand how access each of items in question?

java - Getting email text from ImageHtmlEmail -

we using apache commons mail, imagehtmlemail. log every email sent - sent - in perfect world paste sendmail - headers , other information included. this troubleshoot problems we've been having turning text/plain rather text/html - because nice have record of system sent out stored in our logs. so - dream function take imagehtmlemail , return string - as sent . know render string myself, i'm bypassing whatever being done in library function, want capture. tried buildmimemessage , getmimemessage, think correct first step - leaves me question of how turn mimemessage string. i have sort of solution - love better one: /** * add content of type * * @param builder * @param content */ private static void addcontent(final stringbuilder builder, final object content) { try { if (content instanceof mimemultipart) { final mimemultipart multi = (mimemultipart) content; (int = 0; < multi.getcount(); i++)

javascript - How to automatically sign into Google OAuth for a single owner of Google Blogger account -

i trying take recent posts google blogger account , integrate them website. lately i've been playing around google oauth access token retrieve posts ajax requests. in order access token had open window google , manually sign in every time. is there way have site automatically sign google given credentials, access token , make ajax request recent posts blogger account? also possible javascript? i want able display of blogger posts on website without having display google's blogger page.

amazon web services - AWS Lambda w/ Node.js Dependencies -

i'm having quite bit of trouble getting node.js lambda script work. i've narrowed down fact script requires 2 nodes.js modules (request , mongojs). var request = require('request'), mongojs = require('mongojs'), db = mongojs('connection_string_here', ['events']); exports.handler = function(event, context) { var data = event.records[0].kinesis.data, body = new buffer(data, 'base64').tostring('utf-8'); db.events.insert({ event_id: '00030050-0000-1000-8000-30f9ed09e058', type: { primary: 'cameradiscovery', secondary: 'probe' }, source: { source_id: '40:16:7e:68:8b:5c', type: 'envr' }, payload: body, created_at: new date(), last_modified: new date() }, function(err, doc) { if (err) return context.fail(err); context.succeed('processed event'); }); }; how 1 ensure depend

entity framework - LINQ to Entities does not recognize the method , method cannot be translated into a store expression -

private void bindgrid() { advcontextef db = new advcontextef(); var query = r in db.mytable orderby r.createdate descending select new { r.id, r.code, r.mytable.relatedtables[0].thecenter.name }; radgrid1.datasource = query.tolist(); radgrid1.databind(); } i got following error when running code above. linq entities not recognize method 'advcontextef.mymethod get_item(int32)' method, , method cannot translated store expression. thank you instead of trying index r.mytable.relatedtables[0] , try using .firstordefault() . r.mytable.relatedtables.firstordefault().thecenter.name or name = r.mytable.relatedtables.select(rt => rt.thecenter.name).firstordefault()

c++ - Is `clang-check` failing to honor `-isystem`? -

for both clang , gcc, -isystem flag adds "system" include path, causes compiler not emit warnings related code found in headers. however, running clang-check on code, see following warning: in file included <myfile>.cpp:1: in file included <qt-path>/gcc_64/include/qtcore/qcoreapplication:1: in file included <qt-path>/gcc_64/include/qtcore/qcoreapplication.h:40: <qt-path>/gcc_64/include/qtcore/qobject.h:235:16: warning: potential memory leak return connectimpl(sender, reinterpret_cast<void **>(&signal), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 warning generated. ...so appear clang-check not treat -isystem include paths differently -i include paths. misusing tool or misinterpreting output (i.e., potential error in code)? there way explicitly ignore errors qt headers when running clang-check ? this because have include "qtcore" directory via-"isystem", in additi

java - How to get current selected tab index in TabLayout? -

when use actionbar tabs, use code. private int getcurrenttabindex() { actionbar actionbar = activity.getsupportactionbar(); actionbar.tab selectedtab = actionbar.getselectedtab(); if(selectedtab == null){ return 0; } return selectedtab.getposition(); } but how can using tablayout? use ontabselectedlistener . and in listener getposition() . something this: tablayout.setontabselectedlistener(new tablayout.ontabselectedlistener(){ @override public void ontabselected(tablayout.tab tab){ int position = tab.getposition(); } });

c# - Custom resolve nested dependencies -

suppose following class structure: classa (iclassb classb, iclassc classc) : iclassa classb (iclassc classc) : iclassb classc1 () : iclassc classc2 () : iclassc suppose want use classc1 whenever used resolve iclassa , i.e. container.getinstance<iclassa>() return new classa( new classb (new classc1()), new classc1() ) can in structuremap? (ideally, for<classa>().nest(x => x.for<iclassc>().use<classc1>()) , do.) this got: public interface iclassa { } public interface iclassb { } public interface iclassc { } public class classa: iclassa { public classa(iclassb classb, iclassc classc) { console.writeline("classa"); console.writeline(" classb: {0}", classb.gettype()); console.writeline(" classc: {0}", classc.gettype()); } } public class classb : iclassb { public classb(iclassc classc) { console.writeline("classb"); console.writeline(

compiler errors - Trouble Running A Python Script -

here's code: name = input("what's name? ") print("nice meet " + name + "!") but when enter name, example "john", gives me error: traceback (most recent call last): file "name.py", line 1, in <module> name = input("what's name? ") file "<string>", line 1, in <module> nameerror: name 'john' not defined the version of python i'm using "2.7.10". you need use raw_input rather input , latter attempts evaluate enter while former keeps string.

visual studio 2013 - 'ExpectedConditions' does not exist on type 'typeof protractor' -

i'm writing protractor test in typescript in visual studio 2013 , i'm getting error: property 'expectedconditions' not exist on type 'typeof protractor'. i read similar question ( here ) did not situation. this page objects code: class sheetobjects { ec = protractor.expectedconditions; showlist = element(by.buttontext('show list')); copyitem = element.all(by.binding('item.name')).get(2); copydiv = element(by.classname('md-inline-list-icon-label')); alertitem = element(by.binding('alert')); alertdiv = element(by.css('[ng-if="alert"]')) navigatetopage() { browser.get('https://material.angularjs.org/latest/#/demo/material.components.bottomsheet'); } waitforelements(element: any) { browser.wait(() => element.ispresent(), 5000); } clickon(element: any) { element.click(); } } module.exports = new sheetobjects(); this

mongodb - How to search a collection for every instance of a single keyword -

i'm trying figure out how search collection every instance of keyword. example, i'd search collection every instance of word "authenticated". below 1 of documents looks in collection contains keyword: { "_id": { "$oid": "55945938d28f9f3809002afc" }, "tags": ".source.s_net", "sourceip": "10.10.0.5", "seqnum": "11004", "program": "core", "priority": "info", "message": "<pppoe-jjcutter>: authenticated", "legacy_msghdr": "core ", "host_from": "10.10.0.5", "host": "10.10.0.5", "facility": "syslog", "date": "jul 1 14:18:48" } check github https://github.com/parthaindia/custommongo , getbycondition(string tablename, map condition) ,call method t

javascript - send image to server by passing datURL generated from canvas -

i tried save canvas image '~/image/upload' folder in application. error: failed load resource: server responded status of 405 (method not allowed). doing wrong here? var dataurl = canvas.todataurl(); $.ajax({ type: "post", url: "image/upload", data: { imgbase64: dataurl } }).done(function(o) { console.log('saved'); }); probably url need escaped var dataurl = encodeuricomponent(canvas.todataurl());

user interface - Terminating an exe built from a GUI in python from Background Processes -

i created simple gui in python 3.4 using tkinter 8.5. used cx_freeze build exe gui. when run exe, notice program still shows under 'background processes' in task manager after terminate using quit button or using close button in window. the gui works this: select file type drop down list, read file using command button , save separate file. problem happens if close gui after using it. if open gui , close using quit button or close button, not stay background process. is normal behave this? if not can terminate properly? the simplified code gui given below. function 'fileselect' calls functions module 'dataselect'. if needed, provide code 'dataselect' module also. from dataselect import * openpyxl import workbook tkinter import * tkinter import ttk, filedialog root = tk() root.title("select data file") # actual file selection based on combobox selection def fileselect(): file_type = filetype.get() if file_type == ".txt

javascript - Trying to make a youtube search function on my website with the youtube api -

as title says, i'm trying make youtube search function on website. i've got far: $(document).ready(function() { $("#searchbutton").click(function (e) { e.preventdefault(); var searchinput = $("#search"); $.get( "https://www.googleapis.com/youtube/v3/search", { part: 'snippet', maxresults: 1, q: searchinput, key: 'my_key' }, function (data) { console.log(data.items.id.videoid); } ); }); }); when press #searchbutton, puts input in 'searchinput' , puts searchinput in 'q'. here html-code: <form> <input type="text" id="search"/> <button type="submit" id="searchbutton">find</button> </form> for i'm trying make videoid output in console. problem when click on searchbutton, whole website doesn't respond anymore. can still

java - Property from properties file being read in the wrong encoding -

Image
i have properties file properties in portuguese language, using accented characters. these properties read 3rd party library (controls fx dialogs). somehow accented characters being read in wrong encoding (tested on ms windows). this have in properties file: dlg.yes.button = sim dlg.no.button = não and how looks on running app: all project files (including java sources , properties files) encoding in utf-8. can test on windows, think has related windows default encoding (cp1252). tried run app using utf8 encoding option -dfile.encoding=utf8, problem still persists any idea of why happening? property files treated iso-8859-1 files. documentation : the input stream in simple line-oriented format specified in load(reader) , assumed use iso 8859-1 character encoding; each byte 1 latin1 character. you need either save file iso latin-1, or write non-ascii characters using \u escapes.

java - FindViewById cannot be referenced from static context -

i trying access method, changes text field in ui, of activity java file. in game.java (normal java file in background) have static variables changed on time. want changes in these variables reflected in actual ui. hence, trying access method "changename" in displaymessageactivity.java reflect corresponding changes (display_message_activity.xml). this method in displaymessageactivity.java trying call game.java public void changename() { textview text = (textview) findviewbyid(r.id.petname); text.settext("" + game.name); } to call displaymessageactivity.changename() game.java, have change static method. public static void changename() { textview text = (textview) findviewbyid(r.id.petname); text.settext("" + game.name); } but doing gives me error "non-static method cannot accessed static context" "findviewbyid". tried making instance of displaymessageactivity.java in game.java access "changename"

r - Counting dates that don't exist -

i working on data frame contains 2 columns follows: time frequency 2014-01-06 13 2014-01-07 30 2014-01-09 56 my issue interested in counting days of frequency 0. data pulled using rpostgresql/rsqlite there no datetime given unless there value (i.e. unless frequency @ least 1). if interested in counting these dates don't exist in data frame, there easy way go doing it? i.e. if consider date range 2014-01-01 20-14-01-10, want count 7 my thought brute force create separate dataframe every date (note 4+ years of dates immense undertaking) , merging 2 dataframes , counting number of na values. i'm sure there more elegant solution i've thought of. thanks! sort date , gaps. start <- as.date("2014-01-01") time <- as.date(c("2014-01-06", "2014-01-07","2014-01-09")) end <- as.date("2014-01-10") time <- sort(unique(time)) # include start , end dates, missing dates

r - Reformatting data in order to plot 2D continuous heatmap -

i have data stored in data.frame plot continuous heat map. have tried using interp function akima package, data can large (2 million rows) avoid if possible takes long time. here format of data l1 <- c(1,2,3) grid1 <- expand.grid(l1, l1) lprobdens <- c(0,2,4,2,8,10,4,8,2) df <- cbind(grid1, lprobdens) colnames(df) <- c("age1", "age2", "probdens") age1 age2 probdens 1 1 0 2 1 2 3 1 4 1 2 2 2 2 8 3 2 10 1 3 4 2 3 8 3 3 2 i format in length(df$age1) x length(df$age2) matrix. gather once formatted in manner able use basic functions such image plot 2d histogram continuous heat map similar created using akima package. here how think transformed data should look. please correct me if wrong. 1 2 3 1 0 2 4 2 2 8 8 3 4 10 2 it seems though ldply can't seem sort out how w

c++ - Templated functions overload return type -

the following doesn't partial specialization (that cannot happen on templated function). plus functions don't overload return type. what's going on in following code?? #include <iostream> #include <string> #include <vector> template<typename t> t foo() { std::cout << "first"; return t(); } template<typename t, typename u> std::pair<t,u> foo() { std::cout << "second"; return std::make_pair<t,u>(t(),u()); } int main() { foo<int>(); foo<int,char>(); } you have 2 overloads of foo (really 2 function templates named foo ). 1 takes 1 template type argument: template<typename t> t foo(); and 1 takes 2 template type arguments: template<typename t, typename u> std::pair<t,u> foo(); you allowed overload on different template arguments. add overloads take non-type arguments: template <int i> void foo() { std::cout << "

java - Null Pointer Exception in Adapter for recyclerview -

i've been trying implement recyclerview activity keep getting nullpointerexception. first time making recyclerview if i'm doing wrong tell me. i'll show code tell where error at my main xml layout (called activity_main.xml) <android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/drawer" android:fitssystemwindows="true"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <include android:id=

c# - Unity for 3D Simulation? -

my team needs create visual simulator track hardware have. we tried using x3dom, amount of data sending proved more take. (i ended refreshing every 3 seconds.) we looking replacement can handle significant input stream. unity 3d came possibility. however, know used games. i not need kind of physics engine or other similar features. i feed coordinates , want show these objects moving on track coordinates specify. does unity fit that? yes, can input coordinates in unity , track objects. team using unity3d similar , input complex data structures pose matrices, etc.. you can import 3d objects unity well. import .obj unity.

java - Thread.sleep stops all nested Asyntasks -

i following tutes codelearn, , trying create asynctask generates tweets , executes asynctask write cache file. have thread.sleep, ui on first load waits until tweets written cache file. first execute aysnctask new asyncwritetweets(this.parent).execute(tweets); sleep 10 secs. but in logcat can see asyncwritetweets gets executed after 10 sec sleep. hence onpostexecute gets executed before tweets written cache file, giving blank screen. public class asyncfetchtweets extends asynctask<void, void, void> { private tweetlistactivity parent; arraylist<tweet> tweets = new arraylist<tweet>(); arraylist[] temp; public asyncfetchtweets(tweetlistactivity parent){ this.parent = parent; } @override protected void doinbackground(void... params) { int result = 0; log.d("async", "calling asycn"); (int i=0;i<4;i++){ tweet tweet = new tweet(); tweet.settitle("title a