Posts

Showing posts from August, 2011

What is the scope of public variable in different methods of a same class in Console C# -

i have class named data used retrieve user's data class data { public string firstname; public string lastname; public void getdata() { firstname = "abc"; lastname = "xyz"; } public static xdocument getdatatoxml() { var objget = new data(); objget.getdata(); xdocument doc = new xdocument( new xelement("firstname ", objget.firstname), new xelement("lastname", objget.firstname)); return doc; } public void display() { string fdata = firstname; //i "firstname" value null why???? } } class program { static void main(string[] args) { var obj = new data(); obj.getdata(); obj.display(); console.readline(); } } why null value when call di

android - Fragment navigation -

i'm creating app, 1 main activity , fragments. i'm trying control happen on backpress using code on mainactivity: @override public void onbackpressed() { if (getfragmentmanager().getbackstackentrycount() == 0) { this.finish(); } else { getfragmentmanager().popbackstack(); } } the structure of app this: mainativity --> fragment1 --> fragment2 --> fragment2 ... (back press should me fragment1) when created fragment2 added fragment1 backstack, , when pressing still see fragment2 in background. how can fragment1 , fragment1 show? i'm not sure how commit fragment. helpful. while commit: // initialize fragment transaction. fragmenttransaction ft = getsupportfragmentmanager().begintransaction(); // record steps transaction. ft.replace(r.id.home_frame_layout_for_fragments, basefragments[i], // add transaction backstack tag of first added fragment ft.addtobackstack(basefragments

javascript - Rails: Include Javascript_include_tag outside default folders -

i have template i'm trying include on rails aplication. template has it's own structure don't want mess with. lets call template "material". i've put files under my vendor/assets folder, have structure: railsapp/vendor/assets/material/material inside last "material" folder, have folders js , css. way i've created file "material.js" includes: //= require material/js/jquery-2.1.1 //= require material/js/functions //= require material/js/bootstrap so can call js want. here problem: how can call material.js application.html.erb ? <%= javascript_include_tag '/vendor/assets/material/material/material', 'data-turbolinks-track' => true %> does not work... thanks in advance. i create new js file, let's material.js . in app/assets/javascripts/material.js : //= require material/material then in config/application.rb , need add: config.assets.paths << rails.root.join('ve

java - Eclipse-PMD Configure ruleset globally -

so using plugin eclipse-pmd ( http://sourceforge.net/projects/pmd/files/pmd-eclipse/update-site/ ) in shared version control enviroment. we have multiple smaller projects in entire project. out of box seems plugin requires individual configuration every single project. way works it searched .pmd file in project , read information that. but it's inconvenient 10-20 subprojects. there general setting under preferences -> pmd. doesn't seem apply globally, if global checkbox checked. what want: want configure plugin respect single ruleset-file in 1 place. there problem configuring subproject-specific: cannot configure relative path rulesetfile in .pmd-file. problem absolute path file checked version control ... every commit else have readjust. found commit: https://github.com/pmd/pmd/pull/36 cannot seem make work way it's described. so, did achieve looking for? edit: cannot specify other file not ".ruleset" in .pmd-file <rulesetfile> wi

java - JavaMail - Unable to send mail using SSL -

i'm trying send mail enabling ssl using javamail office365 host. when i'm using host smtp.gmail.com it's working fine not working smtp.office365.com below approach: public class sendmail { public static void main(string args[]){ string username = "abc@xyz.com"; string password = "abc123"; properties properties = new properties(); properties.put("mail.smtp.host", "smtp.office365.com"); properties.put("mail.smtp.socketfactory.port",995); properties.put("mail.smtp.socketfactory.class","javax.net.ssl.sslsocketfactory"); properties.put("mail.smtp.auth", "true"); properties.put("mail.smtp.ssl.enable", "true"); session session = null; if (authenticationrequired) { session = session.getinstance(properties, new javax.mail.authenticator() { p

android - What's the proper way to implement a custom SimpleCursorAdapter? -

i need same functionality of simplecursoradapter custom bindview() method. that's practically difference have in custom adapter, , want have rest of functionallity of simplecursoradapter stay is. is enough extend cursoradapter ? more looking @ source of simplecursoradapter 1 of constructors commented as: @ deprecated option discouraged, results in cursor queries being performed on application's ui thread , can cause poor responsiveness or application not responding errors. how make sure custom adapter doesn't run on activity thread? need of other methods of simplecursoradapter such swapcursor() ?

Getting id from stream in a loop for use in edit form pyrocms -

i using pyrocms streams module loop through content {{ streams:gallery}} <div class="col-lg-3 col-md-4 col-sm-4"> <a href="#"> <div class="ratio" style="background:url({{gallery_images:image}})"></div> </a> <div class="text-center"> <h5>{{title}}</h5> </div> </div> <!-- form code below go here using gallery stream --> {{ /streams:gallery }} i id of current looped item , use in stream form edit content. so {{ if user:logged_in }} {{ streams:form stream="gallery" mode="edit" edit_id="1" include="page_image|deschtml"}} {{ form_open }} <span class="click-to-edit"> <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> edit </span> <span class="inline-edit"> {{ error }} {{ page_image:input }}

jquery - Load html templates to JavaScript variable -

i saving html templates single file. file contains loads of templates (more 50). <script type="text/html" id="template-1"> <p>template 1</p> </script> <script type="text/html" id="template-2"> <p>template 2</p> </script> i need load templates js variable. i have looked @ jquery load method loads template attach dom not need here. any jquery or angularjs solution work me. you can make regular ajax call using $.get , filter out elements response (without attaching dom). for example $.get("templateurl", function (data) { var $doc = $(data); var firsttemplate= $doc.filter('#template-1').html() var secondtemplate e= $doc.filter('#template-2').html() //..load rest of templates variables });

node.js - Context menu click/open event with Atom Shell/Electron? -

i'm trying capture click on tray icon click context menu on osx, according docs disabled in osx reason: platform limitations: on os x clicked event ignored if tray icon has context menu. i've wondering if there way know when tray icon context menu interacted with? relavent code: var app = require('app'); var path = require('path') var menu = require('menu'); var menuitem = require('menu-item'); var tray = require('tray'); var appicon = null; var menu = null; app.on('ready', function(){ appicon = new tray(path.join(__dirname, 'images/icon.png')); appicon.on('clicked', function(event, bounds) { console.log('clicked'); }); menu = new menu(); menu.append(new menuitem({ label: 'quit', id: 'quit', click: function() { app.quit(); } })); appicon.setcontextmenu(menu); }); now works on os x (10.11.4). please check. main.js: // load in dependencies var a

spring mvc - the array list from database is not displaying on browser but i can see it on the eclipse console -

this controller @requestmapping(value = "/users/{userid}/providers/{providerid}/check", method = requestmethod.get) public string initnewdocumentform121(@pathvariable("userid") int userid,@pathvariable("providerid") int providerid, model model) { list<jdbcdocument> documents = this.clinicservice.findbyprovideridanduserid(providerid, userid); system.out.print("findbyprovideridanduserid"); system.out.print(documents); return "users/myproviders"; } i can see documents array on eclipse console not on browser. <select id="provider" class="form-control"> <option th:value="0" >select service provider</option> <option th:each="document : ${documents}" name="name" th:value="${document.id}" th:text="${document.name}">[name]</option> </select> this html. cannot see output on browser. p

linux - fconfigure refuses to set baud rate to 921600 -

in expect script, i'm trying replace spawn kermit direct access serial port/console under ubuntu 14.04. the code simple: set device "/dev/ttyusb1" set device_handle [open $device w+] fconfigure $device_handle -mode "921600,n,8,1" -handshake none #spawn -open $device_handle my problem tcl (8.6) or expect (5.45) refuse set baud rate 921600. from strace output, can see baud rate set 460800 instead (in tcsetsw command ioctl() ). this: $ grep tcsetsw strace.out.* strace.out.28667:ioctl(6, sndctl_tmr_stop or sndrv_timer_ioctl_ginfo or tcsetsw, {b460800 -opost -isig -icanon -echo ...}) = 0 strace.out.28667:ioctl(6, sndctl_tmr_stop or sndrv_timer_ioctl_ginfo or tcsetsw, {b460800 -opost -isig -icanon -echo ...}) = 0 strace.out.28667:ioctl(6, sndctl_tmr_stop or sndrv_timer_ioctl_ginfo or tcsetsw, {b460800 -opost -isig -icanon -echo ...}) = 0 i have tested lower baud rates - 9600, 115200, 460800 - , tcl calls ioctl() correct baud rates. if try set 9216

meta predicate - Prolog binding arguments -

in sicstus prolog, there's predicate: maplist(:pred, +list) pred supposed take 1 argument - list element. how can pass 2-argument predicate, first argument defined? in other languages written as: maplist(pred.bind(somevalue), list) maplist(p_1, xs) call call(p_1, x) each element of xs . built-in predicate call/2 adds 1 further argument p_1 , calls call/1 . indicate further argument needed, helpful use name p_1 meaning "one argument needed". so if have predicate of arity 2, say, (=)/2 , pass =(2) maplist: ?- maplist(=(2), xs). xs = [] ; xs = [2] ; xs = [2,2] ... since definition in sicstus' library unfortunately, incorrect, rather use following definition: :- meta_predicate(maplist(1,?)). :- meta_predicate(maplist_i(?,1)). maplist(p_1, xs) :- maplist_i(xs, p_1). maplist_i([], _p_1). maplist_i([e|es], p_1) :- call(p_1, e), maplist_i(es, p_1). see this answer more. just nice further example lists of lists. ?- xss = [[

javascript - Angular-flexSlider start at specific slide using value from the scope not working -

i'm using angular-flexslider , specified start slide using value scope. doesn't work. startat take currentslide value not 5. $scope.currentslide=5; <flex-slider slide="slide in slides track $index" start-at="currentslide"> <li> <img ng-src="{{slide}}"> </li> does 1 know how fix this? thanks in advance. ` it looks angular-flexslider expects integer, not expression: https://github.com/thenikso/angular-flexslider startat: 0, //integer: slide slider should start on. array notation (0 = first slide) try: $scope.currentslide = 5; <flex-slider slide="slide in slides track $index" start-at="{{ currentslide }}"> <li> <img ng-src="{{slide}}"> </li> </flex-slider>

java - Force execution of a Maven phase -

i have maven pom pre-integration-test , post-integration-test phases follows. <execution> <id>start-server</id> <phase>pre-integration-test</phase> <goals> <goal>start-server</goal> </goals> <configuration> </configuration> </execution> <execution> <id>stop-running-server</id> <phase>post-integration-test</phase> <goals> <goal>stop-server</goal> </goals> <configuration> <skip>false</skip> </configuration> </execution> how force post-integration-test phase executed when pre-integration-test phase fails? right now, if pre-integration-test phase fails post-integration-test phase doesn't executed. taken http://maven.apache.org/surefire/maven-failsafe-plugin/ if use surefire plugin running tests, when have test failure, build stop @

Extending Blade in Laravel - Creating a custom form object -

the documentation on extending blade in laravel 5 doesn't seem have depth , i'm struggling understand if want possible. note: using laravel 5.1 this example laravel docs give extending blade. blade::directive('datetime', function($expression) { return "<?php echo with{$expression}->format('m/d/y h:i'); ?>"; }); now want have blade file looks this: @form('horizontal') {{ $form->text('email') }} {{ $form->text('password') }} {{ $form->submit }} @endform then want new $form object created whenever use @form , have available use after use @form doesn't need available after @endform after bit of googling , messing around have found can this: \blade::directive('form', function($expression) { return '<?php $form = new app\form'.$expression.'; ?> <?php echo $form->open(); ?>'; }); (this updated previous edit) that's of way t

powershell - Script runs fine in ISE but fails from Command Prompt -

i have following script: add-computer -domainname ("a.b.c.d") -credential (new-object system.management.automation.pscredential("a.b.c.d\abcdadmin", (convertto-securestring "1234qwer" -asplaintext -force))) obviously domain not 'a.b.c.d' follows that. has no special characters or lead me believe cause problems. ise output: add-computer : cannot add computer '<removed>' domain 'a.b.c.d' because in domain. @ line:1 char:1 + add-computer -domainname ("a.b.c.d") -credential (new-object system. ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + categoryinfo : invalidoperation: (20012ua95009jz:string) [add-computer], invalidoperationexce ption + fullyqualifiederrorid : addcomputertosamedomain,microsoft.powershell.commands.addcomputercommand so runs fine in ise (with exception it's in domain), command prompt says otherwise: at line:1 char:143 + ..

java - Can I inject primitive variable into mocked class using annotation? -

for example have handler: @component public class myhandler { @autowired private mydependency mydependency; @value("${some.count}") private int somecount; public int somemethod(){ if (somecount > 2) { ... } } to test wrote following test: @runwith(mockitojunitrunner.class} class myhandlertest { @injectmocks myhandler myhandler; @mock mydependency mydependency; @test public void testsomemethod(){ reflectiontestutils.setfield(myhandler, "somecount", 4); myhandler.somemethod(); } } i can mock variable somecount using reflectiontestutils . can somehow mock using mockito annotation? there isn't built-in way this, , beware @injectmocks has downsides well : mockito's @injectmocks more of courtesy fully-safe feature, , fail silently if system under test adds fields. instead, consider creating constructor or factory method testing: though test code should live in tests , not production classes,

python - PyDev run configuration: ImportError: No module named -

Image
i using liclipse on osx , trying run django application using eclipse run configuration (this manages virtualenv?). app not of creation works in production assume environment needs corrected. app structured as: pydev project folder --manage.py --requirements.txt --django-app-folder -----config-folder --------__ini__.py --------settings.py --------evniroments.py --------urls.py --------wsgi.py -----app-folder --------__ini__.py --------lots of other stuff when try run application fails import module: this appears common, @ least there several other questions comparable , many dated ones such as: eclipse + pydev importerror , importerror: cannot import name... not answer question of how configure eclipse run correctly pydev? i have followed docs @ pydev , guidance in referenced links such removing interpreter settings pydev , adding , "check if interpreters synchronized environment". here pythonpath run config using: and interpreter settings under pydev prefe

How to find spark master URL on Amazon EMR -

i new spark , trying install spark on amazon cluster version 1.3.1. when sparkconf sparkconfig = new sparkconf().setappname("sparksqltest").setmaster("local[2]"); it work me , came know testing purpose can set local[2] when tried use cluster mode changed sparkconf sparkconfig = new sparkconf().setappname("sparksqltest").setmaster("spark://localhost:7077"); with getting below error tried associate unreachable remote address [akka.tcp://sparkmaster@localhost:7077]. address gated 5000 ms, messages address delivered dead letters. reason: connection refused 15/06/10 15:22:21 info client.appclient$clientactor: connecting master akka.tcp://sparkmaster@localhost:7077/user/master.. could please let me how set master url. if using bootstrap action https://github.com/awslabs/emr-bootstrap-actions/tree/master/spark configuration setup spark on yarn. set master yarn-client or yarn-cluster . sure define number of executors memor

java - Jar not visible, but javaw.exe is running -

on 1 of windows systems, have problem running jar file. when double click on jar file, first jframe (splash screen) appears , hides again,but main jframe doesn't become visible ... when monitoring services, noticed javaw.exe keeps running ... when launching jar command prompt (java -jar c:\myjar.jar), works fine ... i've tried creating output file while running jar, , file created, remains empty (java -jar c:\myjar.jar > d:\output.txt) does have idea problem ? java application close (javaw.exe close) after of threads finishes work. disposing thread used produce jframe , other threads still running (and waiting something). i can not further without more inforamtion specific application (e.g. code)

MS Access linked tables automatically long integers -

i have large amount of linked tables in access database going refreshed regularly , manipulated via queries. however, access automatically determining important fields long integers because beginning values of field 0s. when value not 0, goes 4 decimal places. since have many tables , since replaced each week new table of same name (thus link), not feasible manually change formatting of fields double within excel document itself. there way override linked table field "number" automatically double? edit: running reports going exported excel documents each week. have set "active" folder has current excel files need import. each week excel files in active folder deleted , replaced files of same name , format, new data. why using linked tables files. linked table example: revised_full_cost change 615.194 0 402.402 0 1548.193 -4464 5329.836 0 versus actual excel file: revised_full_cost change 615.194

JQuery Array in Ajax post seems to serialise and appear as one element in controller list/array -

i have array in jquery holds id & value of attributes need pass mvc controller. array seems populate correctly in jquery , ajax post controller works too. however, value being passed controller appears flat single element in controller array (i.e. array values flattened 1 sequential string value). here jquery: var attlistarray = new array(); table.find('tr').each(function (i, el) { var tds = $(this).find('td'), attname = tds.eq(0).text(), attvalue = tds.eq(1).text(), attid = tds.eq(2).text(); attlistarray[i] = attid + '~' + attvalue; alert(attlistarray[i] + ' - ' + i); }); $.ajax({ type: "post", async: true, contenttype: "application/json;charset=utf-8", url: "@url.action("saveform", "home")", data: '{"parms":"' + formelements + '" , "attl

c++ template function with predicate support -

i want implement priority queue using template.i tried getting error , want pass custom predicate support less function. #include <iostream> using namespace std; template <typename t, std::size_t n, typename lessfunction> class myclass { typedef std::size_t size_type; public: void push( const t& t) { // size_type index ;//(some value .. 5) //...// if(lessfunction(m_buffer[index], t)) { /// } } private: t m_buffer[n]; }; struct mycompare { bool operator() (int& x, const int& y) { return abs(x) < abs(y); } }; int main() { myclass<int , 8, mycompare> obj; obj.push(1); return 0; } i getting error. /home/sanju/code/circular-buffer/main.cpp:17: error: no matching function call 'mycompare::mycompare(int&, const int&)' if(lessfunction(m_buffer[index], t)) please correct me. , have 1 more question how can template

excel - Tableau can't publish workbook. Grayed out -

Image
i'm trying publish workbook, button grayed out. i'm signed in on server button publish grayed out. below screenshot; i'm struggling problem, appreciated! thanks in advance! so, given you're signed in tableau server , "sign out" button disabled "publish workbook...", i'm going assume workbook uses 1 or more published data sources. in order publish workbook different tableau server, try following: create local copies of data sources replace published data sources local copies sign out old server , sign new server publish data sources new server publish workbook new server

android - Gradle: how to include an existing, complete project as a subproject? -

i git clone complete gradle project "completegradleproja" github , include local project submodule. "complete gradle project" mean can go directory "completegradleproja" , issue command cd completegradleproja && gradle build to build it. my directory structure looks this, myproj |---completegradleproja | |---build.gradle | |---build.gradle my question is: how can call "completegradleproja/build.gradle" without changing of root "build.gradle"? the following root "build.gradle" config not help. apply plugin: 'java' dependencies { compile project(':completegradleproja') } i got error message failure: build failed exception. * went wrong: not determine dependencies of task ':compilejava'. > not determine dependencies of task ':compilejava'. "completegradleproja" android porject , "completegradleproja/build.gradle" looks this buil

r - Unexpected Symbol in As Formula, Can't Find -

i've been using as.formula setting glm, , can't figure out unexpected symbol is. part of problem character vector i'm converting long. it's 700 words + inserted in between in order turn formula. error presents follows: error in parse(text = x, keep.source = false) : <text>:2:10080: unexpected symbol with following snippet of text: 2: c_1_e + campaign_search_payroll_generic_1_p + campaign_search_performing_core_keywords + campaign_self_employment_e + campaign_self_employment_p + campaign_withholding + campaign_youtube + sou things know sure: no item repeated. no symbols other alphanumerics , underscore ( _ ). no item starts number. i'm not versed enough in r understand reading documentation as.formula or function call itself. any ideas? the <text>:2:10080 giving location of error. 2nd line, 10080th character. consider: parse(text="1 + 1 + 2\n - 3 b") # error in parse(text = "1 + 1 + 2\n - 3 b"

nlp - keywords in NEGATIVE Sentiment using sentiment Analysis(stanfordNLP) -

my requirement read input text , undergo sentiment analysis. if sentiment analysis negative should negative keywords used in context. the following code snippet achieve sentiment analysis: string tweet="the movie worst"; properties props = new properties(); // props.put("pos.model", "d:\stanford_api's\english-left3words-distsim.tagger"); props.setproperty("annotators", "tokenize, ssplit, pos,lemma,parse, sentiment"); pipeline = new stanfordcorenlp(props); int mainsentiment = 0; if (tweet != null && tweet.length() > 0) { int longest = 0; annotation annotation = pipeline.process(tweet); (coremap sentence : annotation.get(coreannotations.sentencesannotation.class)) { tree tree = sentence.get(sentimentcoreannotations.annotatedtree.class); int sentiment = rnncoreannotations.getpredictedclass(tree

Cordova ios File Transfer Error: The request timed out -

i'm using filetransfer plugin downloading files.the issue large files have error filetransfererror { body = ""; code = 3; "http_status" = 0; source = "https://api.serveur.com/api/download/boite%20%c3%a0%20outils/vid%c3%a9os/4-box-metiers-neutre.mp4"; target = "file:///users/msuser/library/developer/coresimulator/devices/ae92034c-d2d6-4067-a02b-eb21e2c29e14/data/containers/data/application/f3aefa35-6b7a-441a-a0ef-b5efb7348c56/documents/download/4-box-metiers-neutre.mp4";} 2015-06-10 16:14:21.976 apps[27281:159543] file transfer error: request timed out. the same issue asked here without solution cordova. filetransfer plugin. how catch connection timeout error files structures different between each os. should use cordova-plugin-file access targets in order cross-compatible file management system. paths explained there .

python - Produce both versions x32 and x64 under PyInstaller -

i have installed python 2.7.xx x64 , trying build executables pyinstaller. do have chance build both artifacts x32 , x64 existing python x64? current pyinstaller script shown below in app.spec file: pyinstaller src/app.spec # -*- mode: python -*- import os import platform pyside import qtcore onefile = false console = false platform_name = platform.system().lower() app_name = {'linux': 'app', 'darwin': 'app', 'windows': 'app.exe'}[platform_name] # include imageformats plugins plugins=os.path.join(os.path.dirname(qtcore.__file__), "plugins\\imageformats") static_files = tree(plugins, 'plugins\\imageformats') static_files += [('app.ico', 'src\\app.ico', 'data')] # analyze sources = analysis(['src\\app.py'], hiddenimports=['pkg_resources'], hookspath=none, runtime_hooks=none) pyz = pyz(a.pure) if o

How to create an histogram of asteriks from a Java array of number repetitions? -

i have array repetitions of numbers , need show them in "histogram" made "*". histogram should looks this: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 1 2 3 4 5 6 7 8 9 10 i have array int[] repetition = new int[] {4,6,4,4,6,5,7,4,3,3}; and able print horizontally this: 1***** 2****** 3**** 4**** 5****** 6***** 7******* 8**** 9*** 10*** how can create vertical histogram? first compute maximum height of histogram. max=0; for(int i: repetition) if(i>max) max=i; then, print this, top bottom: for(j=max;j>=1;j--){ //for each possible height of histogram. for(k=0;k<repetition.length;k++) //check height of each element if(repetition[k]>=j) system.out.print("*"); //print * if k-th element has @ least height j. else system.out.print(" "); //else,

c# - Multiple objects containing SerialPort with same SerialDataReceivedEventHandler -

i have 2 objects (of same class) each contain serialport object. class has method handles serialport.datareceived event , used both serialport objects. when instantiate each object in separate application, each port handles datareceived event individually expected. when instantiate 2 instances of com_front_end class in same application , send data 1 serial port other, both port's datareceived event handlers fire. short, i'll call "cross-talk". my class structure looks this: public class com_front_end { private serialport_custom port; private lockobject; public com_front_end(string portname, string baudrate) { // other code port = new serialport_custom(portname, baudrate, new serialdatareceivedeventhandler(serialdatareceived)); port.open(); } private void serialdatareceived(object sender, serialdatareceivedeventargs e) { //lock (lockobject) // lock not needed here. 1 serialdatareceived e

javascript - ExtJS Find the id of an element -

i have app mvc model, in view create slider listeners, want listeners in controller class, , want id of element, generated variable tree panel.... this code ext.require('ext.slider.*'); ext.define('app.view.viewtablacontenido', { extend: 'ext.window.window', id: 'viewtablacontenido', shadow: false, alias: 'widget.tablacontenido', initcomponent: function() { var anchopanatallares = window.screen.width; var altopantallares = window.screen.height; var anchotoc = 330; var altotoc = 473; if (anchopanatallares <= 1024) { anchotoc = 282; altotoc = 373; } function addurl(value, p, record) { return value ? ext.string.format( '<a href="'+value+'"target="_blank"'+'>ver metadato'+'</a>' ):''; } var treestore = ext.getstore('capa'); var tree = ext.create('ext.tree.pane

hadoop - How to efficiently find top-k elements? -

i have big sequence file storing tfidf values documents. each line represents line , columns value of tfidfs each term (the row sparse vector). i'd pick top-k words each document using hadoop. naive solution loop through columns each row in mapper , pick top-k file becomes bigger , bigger don't think solution. there better way in hadoop? 1. in every map calculate topk (this local top k each map) 2. spawn signle reduce , top k mappers flow reducer , hence global top k evaluated. think of problem 1. have been given results of x number of horse races. 2. need find top n fastest horse.

Applying custom font to the whole Android Application? -

before jump negative comments/votes, specify have read every question on `stackoverflow regarding topic, , have applied solutions, still have not succeeded applying entirely. so, asking question, because answers found 4-5 years ago, , wondering if there better solutions now. i repeat question: there better way listed override whole font family in whole app 1 font? (all views used in app)? thanks in advance! cheers! the best way still put .ttf or .otf font file in assets folder. derive custom textview class , fix its' font once , don't have call settypeface() everywhere. that all.

javascript - Strip contact information from email -

i have users enter emails like: john smith <john@example.org> i have regex /(.+[ <>])/g not correct this. i have output like: john@example.org i want email component, , want ignore else user may give. edit: people getting confused. want input turn out output. has nothing validation. have validation. has cleaning input before gets validation. assuming e-mail input has "@" symbol, can select single token e-mail makes symbols you'd accept. example: [a-za-z0-9.]*?@[a-za-z0-9.]* test test test john smith@hotmail.com test will result in smith@hotmail.com e-mails can contain dashes , underscores ( john-smith@hotmail.com ), consider adding them [a-za-z0-9.] character class, making [a-za-z0-9.\-_] , or whatever characters feel appropriate.

swift - How to change UITableViewCellAccessoryType.Checkmark's color? -

Image
here's code: cell.accessorytype = uitableviewcellaccessorytype.checkmark but when run app, can't see checkmark. then set background color black, , can see white checkmark. how change checkmark's color other colors blue? yes can it. just set tintcolor of cell. cell.tintcolor = uicolor.whitecolor() cell.accessorytype = uitableviewcellaccessorytype.checkmark swift 3 let acell = tableview.dequeuereusablecell(withidentifier: "cell")! acell.tintcolor = uicolor.red acell.accessorytype = .checkmark return acell you can attributes inspector

sql - Getting 0 rows returned on query -

so let me start basic table layout tables involved: #zip_code_time_zone +----+----------+-----------+ | id | zip_code | time_zone | +----+----------+-----------+ | 1 | 00544 | -1 | | 2 | 00601 | -3 | | 3 | 00602 | 0 | | 4 | 00603 | -3 | | 5 | 00604 | 0 | +----+----------+-----------+ #pricing_record +------+---------------+--------------------+ | id | location_code | service_center_zip | +------+---------------+--------------------+ | 7119 | tx725 | 79714 | | 7121 | tx734 | 75409 | | 7122 | tx737 | 78019 | | 7124 | tx742 | 75241 | | 7126 | tx751 | 77494 | +------+---------------+--------------------+ #transaction_record +----+-----------------+------------------+--------------+--------------+ | id | truck_stop_code | create_date | gps_verified | central_time | +----+-----------------+------------------+-

three.js - Get 3D cube from an Obb3 -

given obb3 (center, halfvector , axis[3]), how can create cube has same bounds obb3 ? i'll use cube display obb3 bounds. i use vector_math , three.dart libraries far, code : matrix3 rot_mat = new matrix3(node.box.axis0[0], node.box.axis1[0], node.box.axis2[0], node.box.axis0[1], node.box.axis1[1], node.box.axis2[1], node.box.axis0[2], node.box.axis1[2], node.box.axis2[2]); vector3 diag = rot_mat.absoluterotate(node.box.halfextents.clone()); var geometry = new cubegeometry(diag[0] * 2.0, diag[1] * 2.0, diag[2] * 2.0); var material = new meshbasicmaterial(color: 0x00ff00, wireframe: true, blending: normalblending, side: doubleside, shading: flatshading); var obj = new mesh(geometry, material); obj.position = node.box.center; obj.matrix.setrotation(rot_mat); obj.updatematrix(); scene.add(obj); thanks lot :]

asp.net mvc - Elegant way to model multiple reviewers for a form in MVC with Entity First -

how model data on form there multiple reviewers. create multiple collections or use array , adding type field? or else? when used multiple instances commented out, created multiple mainform_id in employee table. //main form public class mainform { public int id { get; set; } public virtual icollection<employee[]> employeearray { get; set; } //public virtual icollection<employee> employeereviewing { get; set; } //public virtual icollection<employee> employeesupervisor { get; set; } //public virtual icollection<employee> employeemanager { get; set; } //public virtual icollection<employee> employeebigboss { get; set; } } //employee public class employee { public int id { get; set; } public int programentryid { get; set; } public int reviewertypeid { get; set; } public virtual mainform mainform { get; set; } public virtual reviewertype reviewertype { get; set; } } i not store collections dire

List and it's references in Python -

this question has answer here: how clone or copy list? 14 answers i going through python doc when came upon lists , confused these :- 1. >>> = [1, 2, 3] >>> b = >>> a.append(4) >>> [1,2,3,4] >>>b [1,2,3,4] >>> = [] >>> print(a) [] >>> print(b) [1, 2, 3, 4] how can appending a change both a , b using a=[] changes a , not b . as know id(a) != id(a[:]) why doing a[:]=[] changes a ? thank you. references variables point objects in memory. doing b = is making b point same memory location a pointing. this means through both variables b , a can modify same contents in memory, , explains "why modifying b modifies a ". now, when a = [] you creataing new empty list in memory , making a pointing it... of course general explanation, think gives intuiti

azure method blows up if the records does not exist -

i using method azure mobile services tutorial: await todotable.lookupasync(id) . have 2 rows in table of id 1,2. if await todotable.lookupasync(1) , works , return record. if await todotable.lookupasync(8) see how it's going handle null, blows not found exception. thanks on this. null mean there is record id = 8 , value `null'. in case do not have record. different. what observe should observe if do not have record . and standard rest based http services. if record not there, http 404 service. azure mobile services nothing more combination of web api , wrapping (plumbing) code application. , every web api call non-existent record result http 404 error. and said in comments, should wrap code around try - catch blocks , inspect exception. in .net 4.5/4.6 there new httpclient type along httpresponsemessage , httprequestmessatge. former has ensuresuccessstatuscode() method. which, if called trigger exception. in older versions of framework th

delphi - Get list of process -

i need list of process pid. know how pid handle , viceversa, problem i'm not 1 create process, don't have handle nor pid. didn't find information on how on internet. is there function returns list of process pid? i mean pids of 'chrome.exe', example. both vcl , firemonkey solutions appreciated. this platform-specific, , such there nothing in firemonkey or vcl it. have use platform apis directly. for instance, on windows can use createtoolhelp32snapshot() , process32first() , process32next() : taking snapshot , viewing processes or can use enumprocesses() : enumerating processes either approach getyou list of filenames , pids, can filter list filename(s) interested in.

How to install and setup hybris opencommerce framework? -

i need hybris-commerce-suite-5.0.4.0.zip(api) , install setup of framework.i need understand hybris how made.also me other java ecommerce supported frameworks made on spring. most people learn hybris starting hybris core trail ( https://help.hybris.com/6.0.0/hcd/d5582c7cd2d5443891003ed071b26193.html ). the hybris core trail set of exercises teach hybris core functionality. core trail fundamental trail you'll find in selection of trails(i.e., core, commerce, promotion engine trail); if don't know start - start @ core trail. the aim of technical trails provide hybris trainees tutorial trail covering main themes , best-practices of hybris core platform. the material can used both in training course , @ home self-study. the zipped source code based on hybris' cuppy , cuppytrail extensions, can downloaded here: cuppy.zip (https://help.hybris.com/6.0.0/downloads/trails/core/cuppy.zip) if want complete source code of final solution, can here: cuppytrai

c# - Iterating through a list of elements inside an element with a specific index -

i have xml-document i'm trying extract data from. <folder> <list index="1"> <item index="1" > <field type="image"> <url>https://www.test.com/0001.png</url> </field> </item> <item index="2"> <field type="image"> <url>https://www.test.com/0002.png</url> </field> </item> </list> etc... i'm trying list of fields have type "image" inside of list index 1. there multiple lists in xml have other indexes, want extract ones list index 1. how go about? i tried do: foreach (var list in xmldoc.descendants("list")) { if (list.attribute("index").value == "1") // list { foreach (var field in list) { if (field.attribute("type") != null && field.attribute("type").value == "image") { messagebox.show(field.element

java - How to pass same String value from adapter to two different activities -

i have ticketadapter class in onclick method i'm passing string value (i.e ticket.getid() ) ticket pojo class) ticketdetailactivity class, want pass same value 1 more activity i.e saveticketdetailactivity class public class ticketadapter extends baseadapter { protected list<ticket> tickets; public void onclick(view v) { activity activity = getactivity(); intent intent = new intent(getactivity(), ticketdetailactivity.class); intent.putextra("com.qurater.csr.ticket.id", ticket.getid()); getactivity().startactivity(intent); activity.overridependingtransition(r.anim.slide_left_detail, r.anim.stay_in_place_detail); } here click when intent fired i'm getting value (i.e ticket.getid() )in ticketdetailactivity class. now want same value reference in saveticketdetailactivity .class want value i'm sending string data server url needs id , data. i can hardly imagine scenario when data needs passed 2 activities in parallel. may

How do I impliment a clock/timer in Java? -

how impliment clock/timer in java? have program saves file data in memory future use. i'd add timer check time file created , when has changed. current time - cached time = duration it sounds want check file's metadata , compare systems time. getlastmodifiedtime , setlastmodifiedtime method sound need. you can read here .

caching - Website html doesnt update for users because of cache -

i making website , running issue website cache users. develop website , have set chrome developer tools disable cache website development. issue when release new change prod users don't update because of browser cache. when delete cache website manually on friends computer works cant expect new updates. there anyway me around versioning or something? have looked around cant seem find anything. edit: know can prevent caching @ don't want prevent caching seems bad design what resources being cached? suspect js/css files, way handle add query param version path of resources in order force browser load new file if version changed, this: <script type="text/javascript" src="your/js/path/file.js?v=1"></script> <link href="/css/main.css?v=1" media="screen,print" rel="stylesheet" type="text/css"> and when release new update of website, replace version follows: <script type="text/ja

xcode6 - trying to make a button spin in Xcode with 6.3.2 objective-C -

i watched video on how make button spin in objective-c. entered code in video except got syntex errors/ "!". new xcode , know of basics javascript. please have been trying figure out long. this did in viewcontroller.h: // viewcontroller.h #import <uikit/uikit.h> #import <quartzcore/quartzcore.h> #import <avfoundation/avfoundation.h> this part in code "!", doesn't seem "()". when take part out it's fine button doesn't seem recognized when called later on in viewcontroller.m. i'll explain each "!" says write of code i'm getting each error. separate code ill put 2 "//" next it. @interface viewcontroller : uiviewcontroller( // ! method type specifier must start '-' or '+' i 3 error messages on next line of code. iboutlet uibutton *button; //! iboutlet attribute ignored when parsing type, expected selector objective-c method, , expected ')' ) //! expected id

yii2 - Why use yii\helpers\Html instead of just typing -

just basic newbie question understand reasoning. why should 1 use html helpers available in yii2, or can't type tags if strong in our html skills. example: seen in basic views... <h1><?= html::encode($this->title) ?></h1> why should not type... <h1>my title</h1> it's you. but using framework helpers, widgets , coding styles, can keep code consistency, reduce errors, bugs , lower security risks. using example. imagine $this->title set name of user in main layout file: <?php $this->title = $user->name; ?> <h1><?= $this->title ?></h1> now, let's imagine user managed set username <script>console.log('i can steal cookies now!');</script>notahacker in registration form (also because decided save directly database instead of using framework). that render following: <h1><script>console.log('i can steal cookies now!');</script>notah

JavaScript get event with closure function? -

hi havr problem event , pass closure function want (this) varaible i use console.log(e); its show undefined >> sloution best sloution :) i try code <script> for(var i=0;i<a.length;i++){ a[i].addeventlistener("keydown",(function(e){ return function(){ if (e.keycode == 13 && !e.shiftkey){ console.log(e); // e undefined problem console.log(i); // value no problem here //now iam use closure value //var = this; } }; })(e), false); } </script> why not directly access e inside function <script> a[i].addeventlistener("keydown",(function(){ var index=i; return function(e){ if (e.keycode == 13 && !e.shiftkey){ console.log(this); console.log(e); console.log(index); } }; })(), false); working

parsing - How Get The text on a separate line with JSOUP in Android? -

a part of html in site ( http://example.com ) is: //if html code is: <div class="text-co"> <div class="title"> <a href="">00</a> <a href="">11</a> <a href="">22</a> </div> </div> <div class="text-co"> <div class="title"> <a href="">33</a> <a href="">44</a> <a href="">55</a> </div> </div> and android code is: string url = "http://example.com"; progressdialog mprogressdialog; @override protected void doinbackground(void... params) { try { document document = jsoup.connect(url).get(); elements description = document.select("div[class=title] a"); desc = description.text(); } catch (ioexception e) { e.printstacktrace(); } retu

javascript - modifiy multiple react components on trigger -

i have input forms use on several places on single-page website. there single react-component class named subscribe contains whole <form> allowing user enter email , subscribe newsletter. when user submits subscribes in <subscribe> , want change content of every occurence of <subscribe> on page. easy single <subscribe> user used, can not find suitable way modifiy state of other <subscribe> components. i'm, using plain javascript modifiy dom-nodes. is there way directly in react? yeah, better done flux comment said in post. should store changes , manipulate storage data service. you can check https://facebook.github.io/flux/ further information. but, if you're rendering page react can set state page , pass 1 prop in each <subscribe> component. should manipulate submission in same page or through mixin not let component job state changed well. in page: getinitialstate: function () { return { already