Posts

Showing posts from August, 2014

java - app crashes when creating view (android.view.InflateException) -

public class childrenslist extends fragment { @nullable @override public view oncreateview(layoutinflater inflater, @nullable viewgroup container, @nullable bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.childrens_list,container,false); //return rootview; imagebutton pigsbutton = (imagebutton) rootview.findviewbyid(r.id.pigsbutton); imagebutton jackbutton = (imagebutton) rootview.findviewbyid(r.id.jacksbutton); imagebutton hansgretbutton = (imagebutton) rootview.findviewbyid(r.id.hansgretbutton); imagebutton mermadbutton = (imagebutton) rootview.findviewbyid(r.id.mermaidbutton); imagebutton rapbutton = (imagebutton) rootview.findviewbyid(r.id.rapunzalbutton); imagebutton redridbutton = (imagebutton) rootview.findviewbyid(r.id.ridingbutton); imagebutton threebearsbutton = (imagebutton) rootview.findviewbyid(r.id.bearsbutton); imagebutton ugduckbutton = (imagebutto...

c - Ints from text file are being read twice using fscanf to store into arrays -

int main(int argc, char **argv) { file *file = fopen("offices.txt", "r"); char officearray[10]; int ycoordinate[10]; int xcoordinate[10]; int i=0; int x, y; char office; while(fscanf(file, "%c,%d,%d", &office, &x, &y) > 0) { officearray[i] = office; xcoordinate[i] = x; ycoordinate[i] = y; printf("%c,%d,%d \n", officearray[i], xcoordinate[i], ycoordinate[i]); i++; } fclose(file); return 0; } i have text file of node letters , coordinates: a,1,1 b,1,5 c,3,7 d,5,5 e,5,1 my output is: a,1,1 ,1,1 b,1,5 ,1,5 c,3,7 ,3,7 d,5,5 ,5,5 e,5,1 ,5,1 i can't tell why getting double integer reads text file. i needed include newline command in fscanf call. while(fscanf(file, "%c,%d,%d\n", &office, &x, &y) > 0)

multithreading - How do I correctly pass information from a long-running thread to the UI thread in Android? -

my app has chat feature. when app first starts up, spawn listener thread listen incoming data: public class mainactivity extends appcompatactivity { public static linkedlist<message> chatlist; protected void oncreate(bundle savedinstancestate){ super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); chatlist = new linkedlist<message>(); handler listenerthreadhandler = new handler(); mylistener mylistener = new mylistener(listenerthreadhandler, mainactivity.this); thread listenerthread = new thread(mylistener); listenerthread.start(); } } my chat feature fragment/tab within main activity. has standard window viewing chat, plus edittext , button sending chats: <linearlayout android:id="@+id/chat_window" android:orientation="vertical"> <listview android:id="@+id/received_chats" android:stackfrombottom="true" ...

javascript - Google Maps API and using the distance in a calculation -

i've implemented gmaps api website, , have system user can search location, , return distance between , set location of choosing. however, im wondering if there way take distance returns , use elsewhere on site, calculations of delivery prices based on how far away entered location is, etc etc. cheers help.

Mapping Azure Service Fabric services to a certain node type -

creating services (or actors in case of reliable actors) in service fabric application vs template effortless. defining node types in azure portal easy. how map service/actor run on specific node type? you can using placement constraints. more information on can found in "placement constraints , node properties" section of this article. in short, you'd need set placement properties on cluster , set placement constraints on service using statefulservicedescription.placementconstraints .

c# - Azure Notification Hub installation not updating tags -

Image
i attempting update tags of installation within azure notification hub after registration. following several guides this, notably here , here . both of these guides suggest following code should work plainly not; tag never gets updated. there no errors, , can guarantee installationid correct. guessing setting path/value of tag incorrectly. // in constructor: var _notificationhub = notificationhubclient.createclientfromconnectionstring(settings.connectionstrings.notificationhub, settings.defaults.notificationhubname); // in webapi endpoint: var installationupdates = new list<partialupdateoperation>(); var userdetail = _userdetailrepo.get(id); installationupdates.add(new partialupdateoperation { operation = updateoperationtype.replace, path = "/tags/interestedin", // incorrect? value = interestedin.toupper() }); userdetail.interestedin = interestedin; await task.whenall( _userdetailrepo.insertorreplace(userdetail), _notificationhub.patchi...

py.test - How to print output when using pytest with xdist -

i'm using py.test run tests. i'm using pytest-xdist run tests in parallel. want see output of print statements in tests. i have: ubuntu 15.10, python 2.7.10, pytest-2.9.1, pluggy-0.3.1. here's test file: def test_a(): print 'test_a' def test_b(): print 'test_b' when run py.test , nothing printed. that's expected: default, py.test captures output. when run py.test -s , prints test_a , test_b , should. when run py.test -s -n2 , again nothing printed. how can print statements work while using -n2 ? i've read pytest + xdist without capturing output , bug report . i see explain issue in github https://github.com/pytest-dev/pytest/issues/1693 pytest-xdist use sys stdin/stdout control execution, way show print out should std.err. import sys def test_a(): print >> sys.stderr, 'test_a' def test_b(): print >> sys.stderr, 'test_b' not idea, work. also should note arg -s has...

javascript - Add a query string to anchor link from query embedded in current URL -

how dynamically add "?q='query'" (where 'query' query string search box , embedded in the current page url example.com/search/?='query') anchor link on page? an example of can found on website: https://www.ecosia.org/search?q=test here page include links '?q=test' query added them (e.g. https://www.ecosia.org/images?q=test ) thank help this append querystring page url onto every link on page. var qs =window.location.search; $('a').each(function(){ var href = $(this).attr('href') $(this).attr('href',href+qs) })

sql - How can I ORDER BY a column Text? -

i'm trying order by column in sql server text type. how can that? couldn't find in internet.. you can't. text deprecated . use varchar (max)

algorithm - MATLAB: Fast creation of random symmetric Matrix with fixed degree (sum of rows) -

i searching method create, in fast way random matrix a follwing properties: a = transpose(a) a(i,i) = 0 i a(i,j) >= 0 i, j sum(a) =~ degree ; sum of rows randomly distributed distribution want specify (here =~ means approximate equality). the distribution degree comes matrix orig , degree=sum(orig) , know matrices distribution exist. for example: orig=[0 12 7 5; 12 0 1 9; 7 1 0 3; 5 9 3 0] orig = 0 12 7 5 12 0 1 9 7 1 0 3 5 9 3 0 sum(orig)=[24 22 11 17]; now 1 possible matrix a=[0 11 5 8, 11 0 4 7, 5 4 0 2, 8 7 2 0] a = 0 11 5 8 11 0 4 7 5 4 0 2 8 7 2 0 with sum(a)=[24 22 11 17] . i trying quite time, unfortunatly 2 ideas didn't work: version 1: i switch nswitch times 2 random elements: a(k1,k3)--; a(k1,k4)++; a(k2,k3)++; a(k2,k4)--; (the transposed elements aswell). unfortunatly, nswitch = log(e)*e (with e=sum(sum(nn)) ) in ...

Java Reflection to load classes -

i given external folder called "atm". in folder, contains files ends .class. how load it? i've been using class.forname. not work. i need load use java's reflection on it. you have 2 options: make sure folder in class path when start program create java.net.urlclassloader load classes

sql - How resolve my query wrong when update columns -

i have code: @selected_ids = params[:authorization][:contract_number] @selected_ids.zip(params[:authorization][:contract_number]).each |id, value| authorization.where(contract_number: params[:authorization][:contract_number]).update_all(value_solve: params[:authorization][:value_solve], situation: 2) end haven't error, in console generate query processing refinancingscontroller#new html parameters: {"utf8"=>"✓", "search_employee_by_cpf"=>"11111111111", "authorization"=>{"value_solve"=>["", "4345", "454", ""], "contract_number"=>["22", "33"]}, "commit"=>"reserve"} sql (344.2ms) update "authorizations" set "value_solve" = '--- - '''' - ''4345'' - ''454'' - '''' ', "situation" = 2 "auth...

websocket - How to create wss request on localhost on local machine -

we using 2 hpps servers, 1 using lampp, using nodejs. lampp https using 443 default port. https://localhost:443/test/index.html var websocketendpoint = 'wss://localhost:9000'; connection = new websocket(websocketendpoint); connection.onmessage = function (ping) { name = message.data; } we have created seperate https server under /temp/ folder using nodejs below. index.js var https = require('https'); var fs = require('fs'); var express = require('express'); var expresswss = require('express-ws')(express()); var appws = expresswss.app; appws.use('/uploads',express.static('./uploads')); var options = { key: fs.readfilesync('fake-keys/key.pem'), cert: fs.readfilesync('fake-keys/crt.pem') }; var port = number(process.env.port || 9000); https.createserver(options, appws).listen(port, function () { console.log('listening on port:' + port); }); when making request via ws:// with...

java - AspectJ module dependency with Maven - How get working the Inter-type declarations methods of a dependency module -

Image
this situation: i have maven project my-project-aj-dependency composed 2 jar modules: my-project-aj-dependencyjarwithaj (where have inter-type declaration , see ahah() method below inside aspect appwithaj_ahah.aj ) my-project-aj-dependencyjarwithoutaj my problem use declared method defined in aspect of first module inside second module, missed something. my poms configuration following: maven project pom ( my-project-aj-dependency ): <?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <name>myprojectajdependency</name> <modelversion>4.0.0</modelversion> <groupid>com.madx</groupid> <artifactid>my-project-aj-dependency</artifactid> <version>...

SymmetricDS: No enum constant org.jumpmind.symmetric.io.data.transform.ColumnPolicy.specified -

i'm doing multi-homing symmetricds 2 nodes (server , client) , single mysql database, , transformation table , column, @ client node appear error "java.lang.illegalargumentexception: no enum constant org.jumpmind.symmetric.io.data.transform.columnpolicy.specified". i (un)delete column_policy sym_transform_table , nothing happened. what's wrong? this going fix problem: update sym_transform_table set column_policy = 'specified' column_policy = 'specified'; commit;

android - GcmNetworkManager OneoffTask ExecutionWindow needed? -

i starting implement gcmnetworkmanager trigger sync when user gets internet connection back when looking @ docs oneofftask says setexecutionwindow mandatory mandatory setter creating one-off task however want execute when user has internet , sounds execute before user has internet in window of windowstartdelayseconds , windowenddelayseconds . so mean network manager execute task sometime before windowenddelayseconds or mean once internet has been restored execute in time? it means cgm try execute @ point between windowstartdelayseconds , windowenddelayseconds after has been registered, taking in consideration specified network state. for example, if use .setexecutionwindow(30, 40) , use .setrequirednetwork(task.network_state_connected) , means task executed @ point between 30 , 40 seconds after being registered only if connected network. so yes, executed before windowenddelayseconds , depends on network state.

Add a row to a matrix in Julia? -

how can add row matrix in julia? for example, mat = [1 2 3; 3 4 2] and want add row x = [4 2 1] @ end. tried: push!(mat, x) but gives error. for concatenation of matrix such way can so: mat = [mat;x] or use function vertical concatenation: vcat(mat,x) read more these operations in documentation .

Elasticsearch: Sort on different fields depending on type -

i have 2 types in index ( event , city ) , i'm trying sort them date. date's field name different each type: event value in updated_at field , city date in update_at field in 1 of nested objects of city_events nested object array (note filtering region_id ). i've tried specifying each field in sort array this: "sort": [ { "city_events.updated_at": { "order": "desc", "nested_path": "city_events", "nested_filter": { "term": { "city_events.region_id": 1 } } } }, { "updated_at": "desc" } ] but unfortunately doesn't mix 2 types together. instead, first sorts cities nested city_events.updated_at field , appends events @ bottom sorted updated_at field. how mix , sort 2 together? as alternative solution i've tried sorting nested city_events.upd...

JSON Data Binding Window Store App Using C# -

i'm trying fetch items text file, in json format (data.txt): [ { "name": "store", "items": [ { "lev": "1", "brand": "imported" } ] } ] now want show these items in separate listview, name used heading on top. please guide me. in viewmodel create properties: private string _name; public string name { { return _name; } set { if (_name != value) { _name = value; propertychanged?.invoke(this, new propertychangedeventargs(nameof(name))); } } } private ienumerable<jsonobject> _items; public ienumerable<jsonobject> items { { return _items; } set { if (_items != value) { _items = value; propertychanged?.invoke(this, new propertychangedeventargs(nameof(items))); } } } and method void parsejson(string json) { v...

javascript - Google Analytics Event Not Working - file download click event added dynamically -

i have added jquery snippet attaches event hrefs open pdf. can see firing event never tracked in analytics $( document ).ready(function() { //attach event dispatcher links pdf files //register event in analtyics $('a[href*=".pdf"]').click(function(e) { ga('send', 'event', 'pdf', 'download', 'digital content', $(this).attr('href')); console.log($(this).attr('href')); //console log working each time link clicked }); }); analytics code added in head such <script type="text/javascript"> (function(i,s,o,g,r,a,m){i['googleanalyticsobject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new date();a=s.createelement(o), m=s.getelementsbytagname(o)[0];a.async=1;a.src=g;m.parentnode.insertbefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create'...

javascript - Input.checked creates Dynamic element that needs to be bound to input -

i have filter , i'm dynamically creating li elements when input checked, issue can't seem clear input when click on element. i'm looking bind input , dynamic together. thank in advance. html: <ul class="options flavorprofiles"> <li class="fl"><input type="checkbox" class="chk" id="ftsweet" value="sweet" /> <label for="ftsweet">sweet</label></li> <li class="fl"><input type="checkbox" class="chk" id="ftsavory" value="savory" /> <label for="ftsavory">savory</label></li> <li class="fl"><input type="checkbox" class="chk" id="ftspicy" value="spicy" /> <label for="ftspicy">spicy</label></li> <li class="fl"><input type="checkbox...

css3 - SVG: text inside text (or using css) -

Image
i'm looking way position text inside text (see example image). basically see on example char 't' text inside . simplest way implement text mask on rectangle. in case won't work since inner text array of phrases , need see them all. i'm open kind of solution. i'm trying svg + snapsvg library. i'm opened css solutions too. update: (in case wrapping text word or sentence) you can use text-align:justify , this: div { text-align: justify; border:1px dashed red; margin:auto } .w600 { width: 600px; } .w200 { width: 200px; } <div class="w600">lorem ipsum dolor sit amet, consectetur adipiscing elit. aliquam feugiat turpis ut lectus semper sollicitudin. nullam turpis metus, eleifend ut mattis nec, vehicula justo. in ac rhoncus urna. praesent sodales et felis non pretium. vestibulum eros augue, venenatis in cursus at, tincidunt ac sapien. nullam quis purus luctus ex ullamcorper fringilla vel odio....

variables - Why compilation fails? [Java] -

interface rideable { string getgait(); } public class camel implements rideable { string getgait() { return " mph, lope"; } } why compilation fail? don't know why compile error? by default modifier interface's method public. when implement it. need public. add public getgait method should resolve it

groovy - LoadTest SoapUI not work with script to increse value -

Image
i use soapui 4.5.1. have testsuite 4 steps, see below, , load test. each teststep in context. - properties; create 1 variable "number" , set value ( eg: 100); - groovy script : increment variable (+1) , set new value; - property transfer : transfer value variable "number" , put on element in xml inside request. goal run loadtest "loadtest-request" , check time each request on interval of 60 seconds. soapui_4_5_1.png problem each request don't update new value executed on step "property transfer". the solution question here answer: scope of property problem. when change scope , used scope testcase, work correct.

c# - listbox not showing any results -

i want listbox in visual studio list courses in course table (from database) application runs fine listbox remains empty code i'm using: protected void listbox1_selectedindexchanged(object sender, eventargs e) { string sqlcon = "data source = localhost; persist security info = true; user id = localhost; password = ****; unicode = true"; oracleconnection con = new oracleconnection(sqlcon); con.open(); oraclecommand cmd = new oraclecommand(); cmd.connection = con; cmd.commandtext = "select coursename course"; cmd.commandtype = commandtype.text; oracledatareader dr = cmd.executereader(); dr.read(); while(dr.read()) { listbox1.items.add(dr.getstring(1)); } } there @ leat 3 errors in code , logic problem. errors first: you call read without doing record loaded read. when reach loop code have loaded first record, read inside w...

c# - Using linq with dynamic model in Razor View -

Image
using dynamic model on mvc page , attempting use linq "skip" , "take" in each loop. however, every time error: my code this: @model dynamic @foreach (var article in model.articles.take(2)) { <div class="col-md-4"> <a href='@url.action("details", "content", new { id = article.id }, null)'> <img class="img img-responsive" src="@(article.imageurl)" /> </a> @article.title </div> } thanks since take extension method, need include namespace using system.linq in mvc razor, @using system.linq

java - MinMaxAI checkers implementation -

i can't seem min max ai work. code far. error saying allscores array empty won't set move bestscored move. appreciated. int[] move; public static int makemove(board board, int currentplayercolor, int maxingplayercolor){ int score = 0; int[] moveindex={}; if (rules.gameover(board)[0]==1){ if(rules.gameover(board)[1] == maxingplayercolor){ system.out.println("1"); return score = 1; } else if(rules.gameover(board)[1] == math.abs(maxingplayercolor-1)) { system.out.println("-1"); return score = -1; } else{ system.out.println("0"); return score = 0; } } else { int[][] availablemoves = board.availablemoves(board, currentplayercolor); int[] allscores = {}; system.out.println("loop length: "+ availablemoves.length); for(int x = 0; x<availablemoves.length; x++){ board te...

android - Update notification to remove chronometer (KitKat) -

i need show notification , update on course of lifetime. in particular, need change flags, such "show chronometer". that, documentation states should call notificationmanager.notify() same id. so idea have these methods: private void showinitialnotification() { notificationcompat.builder builder = new notificationcompat.builder(this); ... mnotificationmanager.notify(notification_id, builder.build()); } private void addchronometerflag() { notificationcompat.builder builder = new notificationcompat.builder(this); ... builder.setuseschronometer(true); mnotificationmanager.notify(notification_id, builder.build()); } private void removechronometerflag() { notificationcompat.builder builder = new notificationcompat.builder(this); ... builder.setuseschronometer(false); mnotificationmanager.notify(notification_id, builder.build()); } this works ok in android 5.1 , 6.0, in android 4.4 (and below, guess?) the chronometer not rem...

The webpart is duplicated in case of the SharePoint app updating -

i have sharepoint hosted app. there list in app, , brought through web part on page. <div> <webpartpages:webpartzone runat="server" frametype="none" id="webpartzone" > <webpartpages:xsltlistviewwebpart runat="server" listurl="lists/ideaslist"> </webpartpages:xsltlistviewwebpart> </webpartpages:webpartzone> </div> everything works there 1 problem, in case of application updating page on placed web part replaced (html code), web part duplicated (on page 1 more copy of web part added below). how add web part on page wasn't duplicated in case of updating? i had same issue , did remove webparts before update. can delete them manually via url. option implement event receiver delete webparts before. hope helps you.

java - How to to add values from a file into an array using split? -

i have following code: bufferedreader metaread = new bufferedreader(new filereader(metafile)); string metaline = ""; string [] metadata = new string [100000]; while ((metaline = metaread.readline()) != null){ metadata = metaline.split(","); (int = 0; < metadata.length; i++) system.out.println(metadata[0]); } this what's in file: testtable2 name java.lang.integer true test testtable2 age java.lang.string false test testtable2 id java.lang.integer false test i want array have @ metadata[0] testtable2 , metadata[1] name , when run @ 0 testtable2testtable2testtable2 , , @ 1 i'd nameageid , outofboundsexception . any ideas in order result want? just print metadata[i] instead of metadata[0] , split each string "[ ]+" (that means "1 or more spaces" ): metadata = metaline.split("[ ]+"); as result, following arrays: [testtable2, name, java.lang.integer,...

bash - Cannot create a symlink inside of /usr/bin even as sudo -

when try symlink binary in /usr/bin folder, operation not permitted error: sudo ln -s /usr/bin/python2.7 /usr/bin/python2 ln: /usr/bin/python2: operation not permitted even sudo, error. el capitan's new system integrity protection feature prevents changes several core parts of os x, including of /usr, root. local customizations, such you're doing, belong in /usr/local instead. /usr/local/bin doesn't exist default, can create , put custom binaries (an aliases) in it: sudo mkdir -p /usr/local/bin sudo ln -s /usr/bin/python2.7 /usr/local/bin/python2 (note /usr/local/bin doesn't exist default, is in default path, create it, it'll searched commands.) it's possible disable system integrity protection, it's best leave on , customization in more appropriate locations. see this apple.se question more details .

Send data from radar gun to raspberry pi (Python Scripted) -

so trying speed hot wheels radar gun or radar gun matter rpi using python.. first possible? second how 1 go this? other option building own radar using doppler sensor or that.. ideal have full control on build.. what guys recommend? fyi using baseball pitching backstop built son has sensors detect balls , strikes utilizing python , rpi. incorporate speed...

jquery - Responsive column width-height size -

to show data use jquery datatables need limit max-width 1 of column 200px in .css file use rule: table tbody > tr > td { max-width: 200px; } that limit width of columns if content it's longer 200px invade next column , mix content of next column. what need is, if content longer tha 200px cell expand height , content continue in next line. so tried use options jdatatables : $('#idtable').datatable({ "columns": [ null, null, null, null, null, { "widht": "200px" }, null, null, null, ], }); but doesn´t change anything my table tag looks this: <table width="100%" class="table table-hover display nowrap" id="idtable" cellspacing="0"> sorry bad grammar, if need more info ask me. this should ...

loops - Android Studio: Iterate through images in drawable for onClick imageButton -

i have 8 imagebuttons set id's imagebutton1 imagebutton8. when click on particular button (imagebutton2 example) want loop through images in drawable folder named image1....image10, , set image imagebutton each click. i have looked @ various loops solve there have led nowhere. here snippet of loop attempt: updated 26/4/16 solved //updated 25/4/16 imagebutton btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8; imagebutton[] btns; int[] drawables = new int[]{r.drawable.image1,r.drawable.image2,r.drawable.image3,r.drawable.image4,r.drawable.image5,r.drawable.image6,r.drawable.image7,r.drawable.image8}; @override protected void oncreate(bundle savedinstancestate) { btn1 = (imagebutton) findviewbyid(r.id.imagebutton1); btn2 = (imagebutton) findviewbyid(r.id.imagebutton2); btn3 = (imagebutton) findviewbyid(r.id.imagebutton3); btn4 = (imagebutton) findviewbyid(r.id.imagebutton4); btn5 = (imagebutton) findviewbyid(r.id.imagebutton5); btn6 = (imagebutton...

python - Check Type: How to check if something is a RDD or a dataframe? -

i'm using python, , spark rdd/dataframes. i tried isinstance(thing, rdd) rdd wasn't recognized. the reason need this: i'm writing function both rdd , dataframes passed in, i'll need input.rdd underlying rdd if dataframe passed in. isinstance work fine: from pyspark.sql import dataframe pyspark.rdd import rdd def foo(x): if isinstance(x, rdd): return "rdd" if isinstance(x, dataframe): return "dataframe" foo(sc.parallelize([])) ## 'rdd' foo(sc.parallelize([("foo", 1)]).todf()) ## 'dataframe' but single dispatch more elegant approach: from functools import singledispatch @singledispatch def bar(x): pass @bar.register(rdd) def _(arg): return "rdd" @bar.register(dataframe) def _(arg): return "dataframe" bar(sc.parallelize([])) ## 'rdd' bar(sc.parallelize([("foo", 1)]).todf()) ## 'dataframe' if don't mind addit...