Posts

Showing posts from September, 2012

java - How to get return type of constructor lambda -

i wondering if possible return type of supplier assigned constructor. e.g. supplier<foo> sfoo = foo::new; how "foo.class" supplier? have been using typetools solve problem other things. this works, example: supplier<foo> sfoo = () -> new foo(); class<?> fooclasss = net.jodah.typetools.typeresolver.resolverawarguments(supplier.class, sfoo.getclass())[0]; // fooclass == foo.class but if assign supplier like: supplier<foo> sfoo = foo::new , return type cannot resolved... any thoughts? don't have use typetools btw... seems parsing method references not supported typetools. there's open issue similar problem. in general such feature quite fragile runtime lambda representation not specified , implementation dependent. may break 1 day. if need class suggest passing actual class<?> argument.

python - Issue in generating all permutations of columns in a dataframe in Ipython -

i working in ipython , trying generate permutations of columns present in dataframe . issue have 15 columns in dataframe , code doesn't reach end , keeps on executing. here current code: df = pd.read_csv(filename, sep = ';', error_bad_lines=false) def all_perms(str): if len(str) <=1: yield str else: perm in all_perms(str[1:]): in range(len(str)): #nb str[0:1] works in both string , list contexts yield perm[:i] + str[0:1] + perm[i:] allperms_list = [] p in all_perms(df.columns[:len(df.columns)]): allperms_list.append(p) i followed this example . have 16 core , 32gb memory system , have been running code last 1.5 hours still executing , doesn't reaching end. there fundamental issue in code have? how can make run faster without affecting final result? read itertools.permutations option. how can modify current code include itertools.permutations , achieve same result?

yii2 - Yii 2 FileValidator -

i'm new yii 2 , reading documentation , experimenting. using activeform , trying file upload, keep getting error "please upload file" though appears file has been uploaded when step through code. model code public function upload() { if ($this->validate()) { $destination = yii::getalias('@app/uploads'); $this->brochure->saveas($destination . '/' . $this->product_id . '.' . $this->brochure->extension); return true; } else { return false; } } controller code public function actionupdate($id) { $model = $this->findmodel($id); if (yii::$app->request->ispost) { $model->load(yii::$app->request->post()); $upload = uploadedfile::getinstance($model, 'brochure'); if ($upload !== null) { $model->brochure = $upload; $result = $model->upload(); } // if model

Efficiently get largest 3 integers in C++ Linked List (unsorted) -

i heard there std functions give largest n integers of array, how linked list? i think solution have few loops iterate on linked list, seems if there simpler solution in c++ libraries. thanks. i if can't use data structure: typedef std::list<int> intlist; instlist list = <your_values>; int top[3]; (size_t = 0; < 3; i++) top[i] = std::numeric_limits<int>::min(); intlist::iterator it, end; (it = list.begin(), end = list.end(); != end; ++it) { const int& value = *it; if (value > top[2]) { top[0] = top[1]; top[1] = top[2]; top[2] = value; } else if (value > top[1]) { top[0] = top[1]; top[1] = value; } else if (value > top[0]) { top[0] = value; } }

c++ - Why can't I call a class's non-default constructor in another file? -

this question has answer here: “undefined reference to” in g++ cpp 2 answers i new c++. have started writing class called row, , trying call non-default constructor create row object in separate main.cpp file, keep getting error not understand. can explain me i've done wrong? here 3 files: row.h #ifndef row_h #define row_h #include<vector> #include<iostream> class row { std::vector<int> row; public: // constructor row(std::vector<int> row); }; #endif row.cpp #include<vector> #include<iostream> #include "row.h" // constructor row::row(std::vector<int> row_arg) { row = row_arg; } main.cpp #include<vector> #include<iostream> #include "row.h" using namespace std; int main() { vector<int> v = {1, 2, 3, 4}; row row(v); return 0; } the error re

multisite - How to use an IP address for a multi-site in Drupal 8? -

this url seems claim it's not possible. workarounds on site doesn't work, , information dated. question is... why work in drupal 8, when put in sites.php file: $sites = array( // url ==> path 'test.localhost' => 'default', 'test2.localhost' => 'somepath', ); but not this: $sites = array( // url ==> path 'test.localhost' => 'default', '127.0.0.1' => 'somepath', ); and how make work? it known bug dont go way. have setup additional virtual host , setup drupal there. can partially link site , modify configuration - filesystem related opration not drupal nor apache/nginx operation.

java - How to apply operator precedence for calculator? Library? Is ANTLR the right library to use? -

i'm trying make calculator app applies operator precedence. however, haven't been able find clear references on how apply in java. understand have use recursive descent parser (unless there's method or better way this). if so, better me code parser myself? or should utilize library. while browsing forums, came upon answer suggested using antlr find seems language grammar rather applying operator precedence in expressions. if it's better me code recursive descent parser myself, please link me references on how so? if should use library, please link me 1 examples how apply operator precedence? i'm not sure how apply antlr operator precedence , haven't seen clear references in docs either on how apply leaves me doubts whether or not right library use. thanks! i don't see why mixing antlr operator precedence. antlr parser (and lexer) generator. use bison/flex same result. now, precedence if given grammar (there might error, i've se

Magento events are not firing -

i have weird situation. trying hook on sales_order_save_after event won't work. debug doing mage::log() in mage.php see events firing. suprirsing, printing resource_get_tablename , core_collection_abstract_load_before few times (24 lines altogether) , nothing else. make more confusing, when save product (by going manage products) prints big list of events (as expected). idea how debug this? want send email out on sales_order_save_after event. just confirm, have logging enable under system->configuration->developer->logging

java - Convert string to JSON and get value -

i have string: {"markers":[{"tag":"1","dep":"2"}]} how convert json , value tag , dep ? you need jsonobject this jsonobjectrequest jsobjrequest = new jsonobjectrequest(request.method.get,url, null, new response.listener<jsonobject>() { @override public void onresponse(jsonobject response) { string tag, dep; jsonarray jarray = response.getjsonarray("markers"); jsonobject msg = jarray.getjsonobject(0); tag = msg.getstring("tag"); dep = msg.getstring("dep"); } }

elasticsearch - Aggregations on an array in a nested query -

i trying query users have @ least 1 color in common particular user , have been able unable figure out how aggregate results can user along colors have in common. part of document sample user follows: { // ... other fields "colors" : [ { "id" : 1, "name" : "green" }, { "id" : 7, "name" : "blue" } ] } this query getting colors in common user has colors red, orange , green: { "query": { "nested": { "path": "colors", "scoremode": "sum", "query": { "function_score": { "filter": { "terms": { "colors.name": [ "red","orange","green" ] } }, "functions&

java - Is it possible to use Predicate<T> when creating queries for Jinq? -

my question jinq , , using version 1.8.9 latest release. i trying use jinq implementing general reusable jpa (java persistence api) typesafe query method java 8 lambda (functional interface) predicate method parameter. unfortunately, can not make work java 8 predicate instead can use similar predicate type (provided jinq) method parameter, avoid dependencies jinq in method signatures, , therefore prefer java 8 predicate if possible? jinq provides functional interface "where": package org.jinq.orm.stream; public interface jinqstream<t> extends stream<t> { @functionalinterface public static interface where<u, e extends exception> extends serializable { public boolean where(u obj) throws e; } i can implement query method want (but undesirable coupling) using above interface in method signature this: public list<t> select(jinqstream.where<t, exception> wherepredicate) instead of above coupling jinq in method signa

ruby on rails - switching from pg gem to mysql, causing error -

my app using pg gem faced issues switched pg mysql when run bundle cause error. my gem file source 'https://rubygems.org' # bundle edge rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.0.13' # use pg database active record # gem 'pg' gem 'mysql2' # use scss stylesheets gem 'sass' gem 'sass-rails', '~> 5.0' # use uglifier compressor javascript assets gem 'uglifier', '>= 1.3.0' # use coffeescript .js.coffee assets , views gem 'coffee-rails', '~> 4.0.0' # user authentication gem 'devise', '~> 3.2' # use materialize css gem 'materialize-sass' gem 'material_icons' # use jquery javascript library gem 'jquery-rails' # build json apis ease. read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 1.2' #for authorization gem 'the_role' group :doc # bundle e

Wordpress user roles - gravity form User Registration - conditionally add_role -

Image
my wordpress site has 2 types of user. when sign up, nominate user type, , want assign 1 of 2 roles, depending on user type are. my user registration page has radio button, new user chooses whether between 2 types of registration. lets call registration types 'cat' , 'dog' purpose of discussion. i have added cat/dog radio button gravity form, user can select 'dog' - radio button defaults 'cat'. field 'registeras'. gravity form user registration allows me set role on new user. choose 'dog' new registrations the gravity form used gather new user data has confirmation redirect them cat-or-dog page: the cat-or-dog page has template assigned - let's call 'cat-or-dog.php'. contains code: <?php /* template name: cat or dog */ if (isset($_get['regas'])) { if ($_get['regas']=='dog') { global $current_user; var_dump($current_user->roles); $current_user->add_role('dog'); echo "

excel - Handle many ComboBox_Change Event -

well i'm new in vba programming. i'm creating form helps me quotations, , there part of form shows items i've registered, this: my form comboboxes so purpose of comboboxes change or delete correponding item according option choose, , have lot of them in userform, making hard create many combobox event programs (like combobox1_change, combobox2_change, ... combobox50_change). , then, main question is: how in vba without loosing lot of time making same code different objects? create 1 code comboboxes. i understand can in way below, i'm sure has better way do. sub combobox1_change() call mycode end sub sub combobox2_change() call mycode end sub sub combobox50_change() call mycode end sub sub mycode() i=1 50 if controls("combobox" & i).value = "change" call mysecondcode end if next end sub i spent 30 minutes searching question, didn't find me. hope guys understood question. in advance. update: axel richter,

Can't log into ASP.NET MVC site once on IIS -

i got asp.net mvc application hosted on local windows/iis server. went login page when try log in says, error: error occurred while processing request this non-descript... my gut feeling when did web deploy, didn't deploy localdb(?) users' credentials stored. before try re-deploy entire app, i'd see if can offer guidance. on right track? there other possible causes/solutions should investigate? i'm using default registration/login system in project start with, , woks fine in vs. did regular web deploy iis server, , site works fine until go log in. fixed: issue caused (as suspected) inaccessibility of localdb users' credentials stored. vs uses light db instead of making install sql express or alternative (much iis express works better debugging full iis). when push application iis vs, database wasn't connecting. found other question, , top answer fixed issue. how deploy asp.net mvc 4 application using localdb local iis on wind

Fast append before string on each new line -

i have couple of pretty large text-files (1 gb each) have 1 generated word on each line. want append string before each of generated words. whether it's java, c#, c, c++, or ruby doesn't matter. while can't program myself, can compile , run it. example: file.txt: aoos ahsd gaata sdffg output: appendaoos appendahsd appendgaata appendsdffg any welcome! depending on tools have available, can use sed , awk or perl : sed 's/^/append/' inputfile >outputfile awk '{print "append"$0}' inputfile >outputfile perl -pne 's/^/append/' inputfile >outputfile if want write own program, can filter programs relatively easy in c: #include <stdio.h> int main (void) { int ch, lastch = '\n'; while ((ch = getchar()) != eof) { if (lastch == '\n') printf ("append"); putchar (ch); lastch = ch; } return 0; } just compile as, example, myprog , run: mypr

django - Should Entry.author be a ForeignKey to User or UserProfile? -

in django, want filter queryset using list of user s active user following . i've opted extend user class rather replace custom class, although i'm not sure right choice. hence have userprofile class, has manytomanyfield other userprofiles, , onetoonefield user . my queryset looks entry.objects.filter(author__in=request.user.userprofile.following.all()) author foreignkeyfield user rather userprofile , i'm change entry.author point userprofile s instead. so questions are, in decreasing priority: is right have author userprofile instead? because have entry.author.user.username not intuitive. might better replace builtin user class custom class has data need? is right userprofile 's following manytomanyfield other userprofile rather user ? since users can follow each other , entries people, makes totally sense make author userprofile both models logically in same level

Laravel 4: Dynamic db selection using Capsule -

just trying understand how capsule works in laravel. works correctly defined, however, new page opened again take backs old connection information instead of new connection defined. i believed setasglobal() makes available particular session atleast, however, guess conceptually wrong here. it nice if can guide through right way make new database connection available globally via capsule, there various other ways, seems more promising. it nice if explain following commands in more simpler way (the comments written per in documentation, however, above nice): // set event dispatcher used eloquent models... (optional) $capsule->seteventdispatcher(new dispatcher(new container)); // set cache manager instance used connections... (optional) $capsule->setcachemanager(...); // make capsule instance available globally via static methods... (optional) $capsule->setasglobal(); // setup eloquent orm... (optional; unless you've used seteventdispatcher()) $capsule-&

python - How to check if an input matches a set of desired values without repeating myself? -

this question has answer here: how test 1 variable against multiple values? 16 answers i want able this, inputs of 1, "d" or "dog" call do_something() , whereas other input call do_something_else() . command = input("type command") if command == (1 or "d" or "dog"): do_something() else: do_something_else() currently, not work, because python evaluating truthiness of (1 or "d" or "dog") , true , of course. then, since command true string, do_something called. i know how 1 way: if command == 1 or command = "d" or command = "dog" . works fine; however, involves lot of repetition, , i'm sure there must way shorten that. i suppose make list of valid commands, valid_commands = [1,"d","dog"] , check if command in valid_commands , seems workaro

MYSQL for selecting values from table and show with comma separator -

i have 2 tables: sales table =============================== id cust_id total_price =============================== 1 1 1000 2 2 1500 sales_item table ====================================================== id sales_id cust_id product quantity ====================================================== 1 2 2 pen 2 2 2 2 pencil 3 3 1 1 book 2 4 1 1 pencil 2 i need query these 2 tables inorder following result: ========================================= sales_id cust_id product ========================================= 2 2 pen,pencil 1 1 book,pencil can me query these 2 tables inorder above result?? i tried using group_concat. hers have

android - How to get text's coordinate inside a TextView? -

i have situation:there 2 textviews, one's gravity left|centervertical , other's right|centervertical. when wraping them, texts must wrap positions exactly, left left ,right right. achive this, have coordinate of text inside textview, can calculate offset, how text's coordinate inside textview without inner padding? i think there no solution text's coordinate inside textview without inner padding value. if want text's coordinate, should calculate using view's location , inner padding value. public float gettextpositionx(textview textview) { return textview.getx() + textview.getpaddingleft(); } public float gettextpositiony(textview textview) { return textview.gety() + textview.getpaddingtop(); }

android - Implementing BootstrapNotifier on Activity instead of Application class -

i using altbeacon library beacon detection. after checking out sample codes on beacon detection, implement interface bootstrapnotifier on application class instead of activity , used detecting beacons in background. have noticed beacon detection in background stops when bootstrapnotifier implemented on activity . don't want app detect beacons launched hence have not implemented bootstrapnotifier on application class.i have specific requirement want beacons detected after particular activity launched , thereafter beacons should detected in background. altbeacon library have provisions achieving this? thanks. sample code yes, possible detect beacons in background after activity starts, still need make custom application class implements bootstrapnotifier . the reason necessary because of android lifecycle. activity may exited backing out of it, going on new activity , or operating system terminating in low memory condition if have taken foreground. in lo

java - Spring security 4.x login redirects to '.../favicon' instead of expected URL -

i have spring security java configuration @configuration @enablewebsecurity public class blogwebsecurityconfigurer extends websecurityconfigureradapter { @override public void configure(websecurity web) throws exception { web.ignoring().antmatchers("/resources/**"); } @override protected void configure(httpsecurity http) throws exception { http .authorizerequests() .antmatchers("/").permitall() .antmatchers("/resources/**").permitall() .antmatchers("/detail/**").permitall() .antmatchers("/post/**").hasrole("admin") .anyrequest().authenticated() .and() .formlogin() .loginpage("/login").defaultsuccessurl("/")

java - Tasks in Spring -

i have application (spring 4 mvc+ jpa + mysql+maven integration example using annotations) , integrating spring hibernate using annotation based configuration; , want create task in order use in controller having task: @configurable public class smssendertask implements runnable { protected static final logger logger = loggerfactory.getlogger(smssendertask.class); @autowired smssender smsservice; private string msg; private string to; public smssendertask(string msg, string to) { super(); this.msg = msg; this.to = to; } @override public void run() { try { smsservice.sendsms(msg, to); } catch (unsupportedencodingexception e) { logger.error(e.getmessage()); } catch (clientprotocolexception e) { logger.error(e.getmessage()); } catch (ioexception e) { logger.error(e.getmessage()); } } } and other one public class smss

exception for filling matrix in C# -

i have code block below, when i'm filling matrix , if put enter or space instead of numbers mistake, program stop, know needs add exception don't know or how add trycatch in code or should write in body of trycatch code: int row = 0; int col = 0; int[ , ] matrix1; row = convert.toint16( console.readline( ) ); col = convert.toint16( console.readline( ) ); matrix1 = new int[ row, col ]; console.writeline( "enter numbers" ); ( int = 0; < row; i++ ) { ( int j = 0; j < col; j++ ) { matrix1[ i, j ] = convert.toint16( console.readline( ) ); } } if want display message , exit can use int row = 0; int col = 0; int[ , ] matrix1; int row = 0; int col = 0; int[ , ] matrix1; row = convert.toint16( console.readline( ) ); col = convert.toint16( console.readline( ) ); matrix1 = new int[ row, col ]; console.writeline( "enter numbers" ); try { ( int = 0; < row; i++ ) { ( int j = 0; j < col; j++ ) { m

c++ - Visual Studio Programming -

i have assignment not understanding. focusing on for, while, , while statements chapter. question goes follows... "the payroll manager @ kenton incorporated wants program allows him enter unknown number of payroll amounts each of 3 stores: store 1, store 2, , store 3. program should calculate total payroll , display te result on screen." i lost on start. guess confusing me "an unknown number of payroll amounts". don't know how make user transistion entering next stores payroll amounts. question says nothings using sentinel value, doesn't not use sentinel value. any or advice appreciated!!!! since there 3 stores, may want keep payroll amounts each separate though specs don't seem care. way can use special store code of 0 indicate you're done. pseudo-code follows: store1 = 0 store2 = 0 store3 = 0 print "enter store, or 0 end: " input storenum while storenum <> 0: print "enter payroll amount: "

python - Get xpath of a link in a webpage containing "sometext" -

i'm using scrapy (web crawling framework). there way can xpath of element (containing "sometext") in web page can extract elements similar xpaths? don't want xpaths hardcoded because crawling multiple websites. i'm new scrapy , have been searching days , can't find :( you have explicitly specify element want scrape either use xpath or regular expression or library beautifulsoup . 1 way of not explicitly specifying xpath traverse dom , extracting elements need. in case need kind of mechanism identifying elements want scrape. should write different spiders scraping different websites. scraping multiple website single spider make task harder , not practice either. for deploying , running spiders can scrapyd

sql - Postgres select (group by type) -

this question has answer here: grouped limit in postgresql: show first n rows each group? 5 answers i have table like: id name type rating 1 name1 1 98 2 name2 1 17 3 name3 2 77 4 name4 2 53 5 name5 2 23 6 name6 4 64 7 name7 3 78 8 name8 3 56 9 name9 3 22 10 name10 4 56 11 name11 4 99 . ... . .. how can select table, , example (2,3...etc, n) rows of each 'type' highest rating? result example(for 2 rows): id name type rating 1 name1 1 98 2 name2 1 17 3 name3 2 77 4 name4 2 53 7 name7 3 78 8 name8 3 56 6 name6 4 64 11 name11 4 99 . ...

.net - "Could not resolve coreclr" path on Ubuntu 14.04 -

tl;dr i'm following documentation @ http://dotnet.github.io/getting-started/ ubuntu 14.04. when run dotnet run outputs could not resolve coreclr path , immediatly exit non 0 return code, , can't find in documentation i'm supposed do. more details actually, unexpected occured before that: though added deb [arch=amd64] http://apt-mo.trafficmanager.net/repos/dotnet/ trusty main sources, there's not dotnet package. there's dotnet-dev package, it's package installed. when run dotnet new , dotnet restore , or dotnet compile , seems ok. when run locate coreclr find several files match. in particular there's /usr/share/dotnet-dev/runtime/coreclr directory several .dll s , .so s in it. there's $home/.dnx/packages/runtime.ubuntu.14.04-x64.microsoft.netcore.runtime.coreclr/1.0.1-rc2-23616/runtimes/ubuntu.14.04-x64/native/libcoreclr.so file use dotnet-nightly . tried, still working. dotnet not installing , dotnet-dev broken. sou

jquery - Remove class not working -

why removeclass function not working in case? button turn grey-background once not active. add class seems work fine. $(".tiles").click(function() { var divname = this.value; $(this).addclass("active") $("#material" + divname).fadein('3000').siblings('.material').hide(); $(this).siblings('.tiles').removeclass("active") }); .material { display: none; } .active { background: red; color: #13223d; border: 1px solid #13223d; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class='type' id='type3'> <h3>1.2.valj material</h3> <div class='tile_btn'><span id='marmorskivorcount'>0</span> <button class='tiles' type='button' name='material' value='1'>marmorskivor</button> </div

hadoop - Issue while launching HIVE shell -

i unable launch apache hive(0.14) ,i getting following error "exception in thread "main" java.lang.runtimeexception: java.lang.runtimeexception: unable instantiate org.apache.hadoop.hive.ql.metadata.sessionhivemetastoreclient" i have copied contents of hive-default.xml.template hive-site.xml ,but modified following fields <property> <name>javax.jdo.option.connectionurl</name> <value>jdbc:derby://child1:1527/metastore_db;create=true</value> <description>jdbc connect string jdbc metastore</description> </property> <property> <name>javax.jdo.option.connectiondrivername</name> <value>org.apache.derby.jdbc.clientdriver</value> <description>driver class name jdbc metastore</description> </property> i did not modified other fields in hive-site.xml , please can 1 suggest me on how resolve issue. br, sanumala install file slf4j-log4j1

c# - Entity Framework 7 and SQLite typeless (aka sql_variant in SQL Server) column -

in previous project used sqlite database , in 1 of tables had column undefined type column able store type (datetimes in datetime format, decimals in decimal format , etc). retrieve data used ado.net. in current case ef code first fits better needs. tried ef 7.0.0-rc1-final throws exception on adding migration. so there way create entity property of type object , update database using ef?

html - How to get individual values from multiple checkbox dynamically using php? -

i trying individual values checkbox , $mail_aspects['active'] , $mail_aspects['aspect_id'] . but using below code, able values $mail_aspects['active']=1 . need both checked , unchecked values update in db. can on issue? <form method='post' style='display: inline-block;'> <div class="col-md-12"> <?foreach ($customer['mail_aspects'] $mail_aspects) { ?> <table> <tr> <td> <label> <input type="checkbox" name="mail_aspects[]" <?=($mail_aspects['active'] == '1') ? 'checked' : ''?> value="<?=$mail_aspects['active']?>,<?=$mail_aspects['aspects_id']?>"> <?=$mail_aspects['aspects_name']?>

textbox - how to solve attempted to divide by zero in c#? -

i getting bug, wrote code below code: decimal amnt; decimal.tryparse(txtamnt.text, out amnt); int tnure=1; int.tryparse(txttnre.text, out tnure); txtddctamnt.text = (amnt /tnure).tostring("0.00"); when in textbox value 0 getting error.if possible give answer me. how using if check before dividing zero? if(tnure != 0) txtddctamnt.text = (amnt / tnure).tostring("0.00"); else txtddctamnt.text = "invalid value";

symfony form repeated bits -

i've got couple of entities use traits same properties , same behaviour without repeating code. a example "startdate" , "enddate" blogposts, articles, or whatever want give start/enddate displaying purposes. (please don't ask why want give blogpost enddate). as can imagine, form elements repeated well. what best approach prevent repeating of bit of code in formtype's? i've considered listeners/subscribers, isn't depending on actual data. i use trait here, , call method in trait. work quite well, might bit weird. also, not use of symfony's form features might want. is there symfony form feature can use here? a possible solution using trait. trait yourrepetitivefieldstypetrait { public function buildformyourrepetitivefields(formbuilderinterface $builder, array $options) { // add form fields } } then include trait in each type need it. , call method in buildform : $this->buildformyourrepetiti

api - Javascript how to hide Consumer Key and Sercret in WebApp? -

i building webapp supported parse backend. when using parse, have add consumer key , secret every request. know, if use parse in ios or android app, ok because source code not released. however, in web app, can read source code of web , parse consumer key , sercret, , hack parse data. i wondering if there approach can hide consumer key , secret when building web app. thank help! ok, if use javascript it's going difficult hide kind of information. if use scripting language php, ruby, node.js etc can hide information. catch every request make js 3rd party application , add keys , secrets on server side, not exposed public. let me know if useful or if have question.

rally - Heirachical grid group by features and userstotries ,subuserstories and task -

i have rally data in userstories associated features. want show heirarchical features , usetstories ,subuserstories , tasks n level. possible ? eg. feature1 - userstory 1 - subuserstory1 - - subsubuserstory1 - task - task - subsubuserstory1 - task subuserstory2- - subsubuserstory3 - task - subsubuserstory4 - task userstory 2 - subuserstory 3 - subsubuserstory5 - subsubuserstory6 userstory 3 -subuserstory 4 - subsubuserstory7 - subsubuserstory8 also want show testcase count each userstory/substory in rally app . see rally.ui.grid.treegrid . there full example of tree grid starts on pi/feature level , includes associat

sql - generic query using jpa -

consider following table: |row |name |last_name |nacionality |team |1 |adam |ritch |usa |titans |2 |scoth |buffalo |usa |titans |3 |jhon |veron |usa |islanders |4 |dylan |schdit |usa |bulls imagine form these fields (name, last_name, nacionality , team) none field mandatory. need take account fields user informed, for example : if user informed nacionality = usa , team = titans aplication need retrieve rows 1 , 2. in jpa application did: em.createnativequery ("select name info_people name = ? , last_name = ? , nacionality = ? , team = ?") remark : "?" filled values inserted user, in case, 3 , 4 "?" filled values usa , titans respectively. but no row returned, wrong query? i agree @jb nizet comment, indeed can create query dynamically based on user's request, can design query consider null values, not need dynamic query build. you can accom

XOR encryption/decryption when the key is more than one byte long? -

suppose character 'b' used key xor encryption. in case, encrypting plain text done xor-ing each byte (character) of text ascii code of 'b'. conversely, plain text can obtained ciphered text xor-ing 'b's ascii code again. understood. however, how 1 encrypt when key (password) string of characters? suppose encrypting password 'adg'. in case, plain text ciphered via xor-ing each of bytes value of xor d xor g? if not, how? a way repeat key cover plain text. e.g. key = rtti, plaintext = "how one" text: how 1 key: rttirttirttirttirtti each character in plain text xor'd corresponding key character below it.

Use of OpenGL in Windows phone 8 -

i developing app windows phone 8 want use opengl in android , ios searched in internet not found stuff helpful me please suggest me if possible wp8? unfortunately, opengl not supported on windows phone. can use direct3d in windows phone 8 or xna in windows phone 7/8. edit/update: if want use opengl on windows phone 8, can use angle project opengl api built on top of directx.

How to return simple text from php web service using ajax and jquery -

this question has answer here: why javascript “no 'access-control-allow-origin' header present on requested resource” error when postman not? 29 answers i want simple log in task using php web service. trying authenticate username , password on basis of text result echoing in php. php: <?php // include confi.php include_once('confi.php'); $found = false; $email = isset($_post['email']) ? mysql_real_escape_string($_post['email']) : ""; $password = isset($_post['password']) ? mysql_real_escape_string($_post['password']) : ""; if(!empty($email) && !empty($password)){ $login=mysql_num_rows(mysql_query("select * `login` `email`='$email'

java - From Binary Search to 3-ary Search -

the reason because 3-ary search less convenient binary search because @ every call 3-ary search needs 2 confronts, while binary search one: 3-ary costs 2log 3 (n) , binary log 2 (n). known fact. i had idea. there algorithm called ternary search allows find maximum of function f upon array, provided maximum one. below java code: public static <t> int ternarysearch(t[] array, function<t,double> f){ int l = 0, r = array.length, m1 = l + (r-l)/3, m2 = r - (r-l)/3, valutation; while( m1 != m2 ) { valutation = f.apply(array[m1]).compareto(f.apply(array[m2])); switch(valutation) { case -1: { r = m1; m1 = l + (r-l)/3; m2 = r - (r-l)/3; break; } case 0: { l = m1; r = m2; m1 = l + (r-l)/3; m2 = r - (r-l)/3; break; } case 1: { l = m2; m1 = l

java - android postgresql database connection error -

i try connect android app postgresql databse doesn't connection dr iver running connection not working. here java code: private void initdatabase() { try { class.forname("org.postgresql.driver"); } catch (classnotfoundexception e) { return; } connection connection = null; string url = "jdbc:postgresql://10.0.2.2/seminarkurs"; try { connection = drivermanager.getconnection(url , "postgres", "postgres"); toast.maketext(getapplicationcontext(), "connection successful!", toast.length_long).show(); connection.close(); } catch (sqlexception e) { toast.maketext(getapplicationcontext(), "connection failed! check output console", toast.length_long).show(); e.printstacktrace(); return; } } and here logcat: 01-16 14:40:17.192 8044-8053/com.example.damian.schulkalender e/system﹕ uncaught exception thrown finalize

android - locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER) returns null -

i've location app send location of phone database. when try location network (no 3g on) works! when turn 3g on doesn't work because code: locationmanager.getlastknownlocation(locationmanager.gps_provider); always return null. here full locationhandler.. code of locationhandler class. package info.androidhive.loginandregistration.location; import android.content.context; import android.content.intent; import android.location.address; import android.location.geocoder; import android.location.location; import android.location.locationmanager; import android.util.log; import java.io.ioexception; import java.util.list; import java.util.locale; public class locationhandler { context mcontext = null; context ctx; double lat; double long; location localization; locationmanager locationmanager; boolean gpsactivate = false; boolean gprsactivate = false; boolean getubicationbool; private double mlastlatitudelocation = 0; private d

api - Contentful.php SDK missing -

when requesting: php composer.phar install contentful/contentful as stated in tutorial, require function suggested composer. however, when requesting: php composer.phar require contentful/contentful this feedback received: problem 1 - requested package contentful/contentful not found in version, there may typo in package name. how install sdk in case? way implement contentful php? contentful developer here. the contentful/contentful package available beta. install beta quality package append :@beta command. full command this: php composer.phar require contentful/contentful:@beta while manually copy sdk project, i'd advice against you'll have keep date manually.

javascript - Sending web storage stored JWT to server when refresh button hit -

i building web app using javascript (koa.js backend). not want make full page refreshes, requests ajax requests api. using jwt user authentication , want save in web storage . these something, blog post 1 , blog post 2 , have read on security against csrf, need use web storage token keeping on client. know localstorage persists across browser quit-relaunches. the question is; are there a, convenient implement , secure, way achieve keeping authenticated user authenticated between page refreshes caused non-programmatic way when using jwt , web storage , e.g. browser button hit? your question little broad, there several answers depending on more information you're developing in (what language, limitations) i can recommend few reads start , possibly shape question further. first, article going on basics of handling jwt tokens: https://auth0.com/blog/2014/01/27/ten-things-you-should-know-about-tokens-and-cookies/ another place start looking @ auth0's imple

android - The results from places autocomplete are not appearing in my google places search -

so i'm working on project involves google places , have point correctly parsing existing google places json results and, bonus end user, implemented places autocomplete textview . working fine. problems arose when tried requerying places api using autocomplete data user had selected through autocomplete service. i've done fine gerry rigging working in first place after trying search places suggested in autocomplete box, wind no results (which doesn't make sense). the reason know autocomplete working fact suggestion text pops in first place. reason know places api working on non-queries have results , on queries have results. here places search url happens on search: private string baseurl = "https://maps.googleapis.com/maps/api/place/search/json?"; and parameters added (in form of enum) are: location("location", ""), minprice("minprice", "0"), maxprice("maxprice", "4"),

android - One Interface for Multiple Fragments -

can please tell me if i'm solving correctly or if should go route? this simplified example: have 1 activity , 2 fragments. each fragment has button when clicked, relays click activity , toast pops within activity. i know fragment communicates activity through interface. if have multiple fragments have similar interface. example, here both fragments use onclick type of interface communicate activity static interface onclickedlistener{ public void buttonclicked(view v); } is better to a) create separate interface class , attach within both fragments. example fragment 1: public class fragment1 extends fragment implements onclickedlistener{ private onclickedlistener clickedinterface; public fragment1() { // required empty public constructor } @override public void buttonclicked(view v) { } @override public void onattach(activity activity) { super.onattach(activity); this.clickedinterface = (onclickedlistener)activity; }} fragment 2: public clas

angularjs - Error after using ngAnimate: TypeError: Cannot read property 'ng-scope' and 'col-sm-6' of undefined -

i've added angular animation project. placed index.html , app.js. there i've missed? in advance index.html <script src="http://code.angularjs.org/1.2.1/angular-animate.js"></script> app.js angular.module('portfolio', ['ui.bootstrap','ui.router', 'nganimate', 'service', 'ctrl']) console: error typeerror: cannot read property 'ng-scope' of undefined @ lookup (angular-animate.js:294) @ performanimation (angular-animate.js:563) @ angular-animate.js:358 @ m.$digest (angular.js:16215) @ m.$apply (angular.js:16429) @ g (angular.js:10823) @ t (angular.js:11021) @ xmlhttprequest.w.onload (angular.js:10962)(anonymous function) @ angular.js:12793(anonymous function) @ angular.js:9526m.$digest @ angular.js:16217m.$apply @ angular.js:16429g @ angular.js:10823t @ angular.js:11021w.onload @ angular.js:10962 angular.js:12793 type