Posts

Showing posts from January, 2012

c# - EntityFrameworks inserts already inserted related item -

im trying create user, connect user model called event. var user = new applicationuser { name = "test", email = "test@test.com" }; var userresult = usermanager.create(user, "password"); if (userresult.succeeded) { signinmanager.signinasync(user, ispersistent: false, rememberbrowser: true); @event.createdby = user; @event.createdbyid = new guid(user.id); db.events.add(@event); db.savechanges(); } but db.savechanges() throws validation error on applicationuser model: user email exists: test@test.com (even though didnt exists before request) so seem ef trying reinserted inserted user. the event model have these setters/getters public virtual applicationuser createdby { get; set; } public virtual guid createdbyid { get; set; } and works great if current singned in user instead of signing new one. i have tried set @event.createdbyid , skip @event.createdby , ef doesnt save reference database. this line crea...

javascript - AJAX: Asynchronously posting a file to a server -

i want post file server asynchronously without posting form. have following code: var fileinput = document.getelementbyid('fileinput'); var file = fileinput.files[0]; var formdata = new formdata(); formdata.append('file', file, file.name); var xhr = new xmlhttprequest(); xhr.open('post', 'http://servername/controllername/analysefile', true); xhr.setrequestheader('content-type', 'multipart/form-data'); xhr.send(formdata); however, when method executed on server, post body contains no files. following asp.net mvc4: [httppost] public jsonresult analysefile() { int filescount = request.files.count; if(filescount == 0) { throw new exception('no files...'); } // stuff } the files collection contains no files , can't figure out why. appreciated. in view, can do: <form> <input name="input1" id="input1"/> <input name="input2" id="input2"/> <input ...

node.js - Proper way to create indexes during deployment -

i creating expressjs api , using mongodb. have decent understanding of indexes , understand expensive create when there data in database. in ms sql server create indexes when creating database tables. question handle creation of indexes in post call in express app or achieve using scripts when deploymening application? for example need geospatial indexing. would index creation handled in express app this? //express post call let col = db.collection( 'collection' ); col.createindex( // someindex ); col.insertone( //some document ); i looking best method creating 'initial' state of mongodb , creating indexes need collections before these collections contain documents. so, may happen, have lot of data in database while deployment , not want indexing terrible. here's mongodb can help. can indexing in background not prevent read , write operations database while index builds.a simple command: db.collection.createindex( { a: 1 }, { background: tr...

javascript - beforeunload event and JQuery Dialog immediately closes after switch screen -

good day, here structure of .php main.php of navibar here. there's iframe screen contents. content1.php content 1 contains textfields. jquery dialog if leaving screens. content1 code : $(window).bind('beforeunload', function(e){ dialog(); }); dialog(); $('form[name="rowform"]').on('submit', function (e) { e.preventdefault(); }); var fieldnamestocheck = xxxxx; var previousvaluefieldnames = xxxxx; if (detectchangesoninputs(fieldnamestocheck, previousvaluefieldnames)) { $("#unsaved-values-confirmation-dialog").dialog("open"); $('.ui-dialog :button').blur(); } for close , refresh event, beforeunload event fine. when start hitting navibar, happen is, dialog shows , closes. is there wrong in codes? thanks!

java - radio button not doing it's action -

every time click radio button in2cm , try convert, there nothing showing when click convert button. if possible show me how use list box, put on list box , make gui more easier use. buttongroup convertgroup=new buttongroup(); jr=new jradiobutton[10]; jr[0]=new jradiobutton("inch cm"); l1 = new jtextfield(25); l2 = new jtextfield(25); length1 = new jlabel("ft", swingconstants.left); length2 = new jlabel("cm", swingconstants.left); convertgroup.add(jr[0]); jr[1]=new jradiobutton("meter feet"); length = new jlabel("m = ", swingconstants.left); l1 = new jtextfield(25); l2 = new jtextfield(25); length1 = new jlabel("ft", swingconstants.left); length2 = new jlabel("cm", swingconstants.left); convertgroup.add(jr[1]); jr[2]=new jradiobutton("mile km"); mi2km = new jtextfield(25); km2mi = new jtextfield(25); length3 = new jlabel("mile", swingconstants.left); length4 = new jlabel("km...

sap - Employee Qualification Infotype 0024 -

in transaction pa30 after enter personnel number , select infotype 0024, display qualifications of employee (if have any). i want create report 3 parameters ('qualification group', 'name' , 'proficency' ) , after user inserts data, display employees have skills. if access table pa0024, has no entries, question is: in table (or where) can find employees qualifications? other suggestions on how make report help. as recall, qualifications can stored in pd tables. qualifications objets type 'q' stored in hrp1000. relations between employee , qualifications stored hrp1001. field adatanr of relation key entry in table hrpad31 (i think) contains rating of employee qualification. others tables t77ts (holds qualification ids , text) , t77tp (holds qualification scale ids , texts) there function module in function group "rhpp", such rhpp_q_profile_read (using p objects in objects parameter)

xampp - How do I find what causes a blank white screen in WordPress? -

am trying build test environment wordpress project using xamp. apache listening on localhost:8080 mysql 3306 root no password changes did in wp-config dbname wp-db dbhost locallhost:8080 dbuser root wordpress root folder in c:/xamp/htdocs/wordpress before changing dbhost local host localhost:8080 getting "error establishing connection database" jus getting full white screen. please advise. million in advance. white screens php errors. try debug , see php errors getting. may have error in wp-config.php or missing core wordpress file or folder. add define( 'wp_debug', true ); define( 'wp_debug_log', true ); in wp-config.php , debug.log file in wp-content. add line define( 'wp_debug_display', true); to wp-config.php log , dump them browser. see https://codex.wordpress.org/wp_debug

android - Remove side spacing from button in linearLayout -

Image
i have layout designed far notice side space around both buttons name "save" have marked red color, want remove spacing. both buttons wrapped inside linearlayout orientation set "vertical", tried using layout_weight, marginleft , marginright no success. here's how xml code looks buttons inside linearlayout <linearlayout android:id="@+id/buttonsection" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <!--this layout save , change currency buttons--> <button android:id="@+id/savebutton" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="save" android:layout_weight="1" /> <button android:id=...

android - RecyclerView automatically scrolls to WebView/Fresco SimpleDraweeView item -

when put item asynchronically loaded content expandable height, such webview or fresco's simpledraweeview, view scrolls item (if it's example partially visible on screen, scrolls after item loaded). have experienced issue? put android:descendantfocusability="beforedescendants" in layout xml. prevent scrolling asynchronously loaded contents. <android.support.v7.widget.recyclerview android:id="@+id/my_list" android:layout_width="match_parent" android:layout_height="match_parent" android:descendantfocusability="beforedescendants" />

java - Retrieving Android_Id on the moment user installs the app -

how can retrieve data(for eg.android id) in android app on moment user installs app.in other words,i want save adnroid_id when user haven't opened app. in advance. p.s. have code retrieving android_id(no need that) check out answer answers similar query how start service when .apk installed first time in short, not possible till app started.

regex - How can I detect laughing words in a string? -

i'm trying detect laughing words "hahahaha" , "lolololol" in string. currently i'm using following regex: ^((.*?)|)(\b[ha]|\b[lo])(.*?)$ however, doesn't work purposes. works , matches words totally unrelated laughter, such 'kill', because looks word contains letters l, o, h, a. how can detect laughing words (like "hahaha" or "lololol") in string? try pattern: \b(?:a*(?:ha)+h?|(?:l+o+)+l+)\b or better if regex flavour support atomic groups , possessive quantifiers: \b(?>a*+(?:ha)++h?|(?:l++o++)++l++)\b

java - Upload file to slack with Retrofit2 -

i'm trying upload file (heap dump) slack channel using retrofi2 latest release version. @override public void oncreate() { super.oncreate(); slackapi = new retrofit.builder() .baseurl("https://slack.com/") .build() // .create(slackapi.class); } @multipart @gtconverterannotation(value = gtconverterannotation.gson) @post("api/files.upload") call<responsebody> uploadfile( @part("token") string token, @part("file") requestbody file, @part("filetype") string filetype, @part("filename") string filename, @part("title") string title, @part("initial_comment") string initialcomment, @part("channels") string channels); requestbody file = requestbody .create(mediatype.parse("multipart/form-data"), heapdump.heapdumpfile); final call<responsebody> call = sl...

c++ Send File from Server to Client -

im working on new project send file computer computer b on internet. have in general accomplish that? want simple, so: computer sends computer b on forwarded port , computer b saves comes. this thought of: check if file has been send checking flagfile. need open upnp port on a, file f. try connect b on forwarded port p. send file b b saves file f on defined path. creates success send file flagfile if connecting fails, try again after m minutes. if know functions this, please tell me. im looking around , there many actually. it's difficult know begin question phrased. if looking libraries/frameworks, first of i'd recommend against doing sort of thing in c++ unless performance of huge importance you. instead use go or node or python or ruby or java. assuming want in c++ , learning experience, here function calls you'd need learn if decided use sockets api: socket : creates file-like object can write data on computer , read on computer b. bind : ass...

java - Check if a object is a instance of a class (but not a instance of its subclass) -

for example: public class foo{} public class bar extends foo{} .... void mymethod(foo qux){ if (checkinstance(qux,foo.class)){ .... } } how can check if qux instance of foo (but not instance of subclass of foo)? is: checkinstance(qux,foo.class)=true checkinstance(qux,bar.class)=false is there kind of statement instanceof check? or should use qux.getclass().equals(foo.class) if have this, way getclass().equals(foo.class) option you've suggested. however, goal of oo design allow treat any foo in same fashion. whether or not instance subclass should irrelevant in normal program.

spring - How to show values only from specific java classes? -

i have table contains sorts of attributes set in constructors of java classes. need show attributes when want easy way nullpointers. have tried jstl if , jstl choose trick. <c:choose> <c:when test="${empty animal.getearsize()}"> not set! </c:when> <c:otherwise> ${animal.getearsize()} </c:otherwise> </c:choose> but when try run http status 500 - exception occurred processing jsp page. animal variable in jstl loop , not animals have earsize in constructor. what doing wrong here? there way or way jstl choose or if? edit: i'm using method in controller gives map animal objects i'm looping through. public africanelephant(string color, string bodycovering, string name, double weight, gender gender, int earsize) { super(color, bodycovering, name, weight, gender, maxnumberofeggs, earsize); } public parrot(string color, string bodycovering, string name, double weight, gender gender) { su...

java - Checking if the given String has equally matching parenthesis -

found interesting problem solving questions online , here is. you check given string str if contains matching parenthesis. example input: [ ] , [ ( ] ) , { [ ] } , { [ } ] , { [ } ) , { ] } example output: equal, equal, equal, equal, not equal, not equal i have managed complete requirements feature using basics, wondering if there better way of doing it? string str = "{[(])}(){}"; int pairs = 0; boolean unabletofind = false; arraylist<character> anchar = new arraylist<character>(); (int = 0; < str.length(); i++) { anchar.add(str.charat(i)); } if (str.length() % 2 == 0) { while (pairs != str.length() / 2) { (int = 1; < anchar.size(); i++) { char = (char) anchar.get(0); char b = (char) anchar.get(i); if (a == '{' && b == '}' || == '[' && b == ']' || == '(' && b == ')...

java - Hibernate 5 showing error in glassfish 3.1 server -

i using hibernate 5 , java 1.7 , glassfish 3.1 server . i have implement sample program fetching records db includes above stuff. when run program on apache tomcat server working fine. but when try run same program on glassfish server shows following error: java.lang.nosuchmethoderror: javax.persistence.table.indexes()[ljavax/persistence/index; i dont understand wrongs me. please body me solving issue. glassfish 3.1 supports jpa 2.0 , trying use feature introduced in jpa 2.1, hence error. can fix either downgrading jpa provider, or upgrading glassfish match jpa provider.

html - Hover Share Button Over Every Image -

i using embedded quiz platform, see https://output.jsbin.com/pabopusulo . i want make every image hover "share button" centered in middle. facebook share code: <div class="fb-share-button" data-layout="box_count"></div> i tried doing using css calling div display:block; did not work. not sure if possible. please keep in mind, new coding. thanks all. update: embedded script: <script type="text/javascript" src="//cdn.playbuzz.com/widget/feed.js"></script> <div class="pb_feed" data-embed-by="6c7dc1a3-ea2c-490e-8b3f-8526cdf5bcb4" data-game="/drishtib10/what-is-your-personality-type-according-to-your-perception" data-recommend="false" data-game-info="false" data-comments="false" data-shares="false" ></div> do mean this? note: can't see result here because of security reason, created bin this. .w...

python - Read all files from folder and edit -

i trying read fasta files test folder , put name of file in headers of individual file. code working first file , dont proceed second file , return error. me find bug in code or edit it. thanks import sys, glob, os, string header = '' check = 0 path = "./test/" dirs = os.listdir(path) file in dirs: fp = open(file, "r") fpx = open('%s_output.txt' % file, 'w') line in fp: if line.startswith('>'): line = line.rstrip() check = check + 1 if check >= 1: header = line fpx.write(header + '_' + file + '\n') else: line = line.rstrip() fpx.write(line + '\n') it provide error message getting! think must fail "file not found" because try open file name instead of path. try fp = open(os.path.join(path, file), "r") : import sys, glob, os, string header = '' ...

content management system - How to get list of cms pages based on a particular theme in magento? -

i have created cms pages 2 themes of single store view. want show cms pages links in front end specific theme. i.e. cms page links should come used in particular theme. have used below function extract cms pages.. public function getcmspages(){ $storeid = $this->helper('core')->getstoreid(); $cms = mage::getmodel('cms/page')->getcollection() ->addfieldtofilter('is_active',1) ->addstorefilter($storeid); $url = mage::getbaseurl(); $html = ""; foreach($cms $cmspage): $page = $cmspage->getdata(); if($page['identifier'] == "no-route" || $page['identifier'] == "enable-cookies" || $page['identifier'] == "empty"){ /* nothing */ } else { if($page['identifier'] == "home"){ $html .= "<li><a href=\"$url\" title=\"".$page['title']."\"...

java - Recursively sum of an array -

i have program i'm trying make class adding array integer 2 100 increment of 2 , using recursion. answer should summation of 2 100 increment of 2 (2+4+6+....+100); here program looks far: public class arraysindepth { public static void main(string[]args){ int size, sum; int[] array = new int [101]; sum = sum(array,2); system.out.println("the sum of numbers " +sum); } public static int sum(int[] arr,int index){ int sumofnumbers=0; arr[index] = index; sumofnumbers = sumofnumbers + arr[index]; enter code here if(index<arr.length) { sumofnumbers = sum(arr,index); index += 2; return sumofnumbers; } else{ return 0; } } } but getting error every time. , can not run it. answer should summation of 2 100 increment of 2 (2+4+6+....+100); please me someone. in lot of trouble. thank you. the way now, returning value arr[index] @ every depth, without summing anything. algorithm should this: public int sum(int[] arr, i...

Need help in porting Java code to PHP -

i need develop marketplace api orders , post shipping walmart in php. code library/help sample provided in java. not java. need understanding / coding in php. here code in java. link api developers guide https://developer.walmartapis.com/#self-written-code-expert this app on cpanel server. import org.apache.commons.codec.binary.base64; import java.security.keyfactory; import java.security.privatekey; import java.security.signature; import java.security.spec.pkcs8encodedkeyspec; public class sha256withrsaalgo { private static string consumerid = "b68d2a72...."; // trimmed security reason private static string baseurl = "https://marketplace.walmartapis.com/v2/feeds"; private static string privateencodedstr = "miiceaibadanbgkqhkig9w0baqefaa......"; //trimmed security reasons public static void main(string[] args) { string httpmethod = "get"; string timestamp = string.valueof(system.currenttimemillis()); string stringto...

Adding buttons like the picture -

Image
i trying create buttons picture below, controls should use? https://design.google.com/icons/ ora if building hybrid app ionic can use library of icon http://ionicons.com/

scala - how to avoid spark NumberFormatException: null -

i have general question derived specific exception have encountered. i'm querying data dataproc using spark 1.6. need 1 day of data (~10000 files) 2 logs , transformations. however, data may (or may not) have bad data after not succeeding in full day query, tried hour 00-09 , got no error. tried hour 10-19 , got exception. tried hour hour , found out bad data in hour:10. hour 11 , 12 fine basically code is: val imps = sqlcontext.read.format("com.databricks.spark.csv").option("header", "false").option("inferschema", "true").load("gs://logs.xxxx.com/2016/03/14/xxxxx/imps/2016-03-14-10*").select("c0","c18","c7","c9","c33","c29","c63").registertemptable("imps") val conv = sqlcontext.read.format("com.databricks.spark.csv").option("header", "false").option("inferschema", "true").load(...

perl - difference between pipe and pipe- while writing to a program -

different ways write data program way1: open(writeme, "| program arguments"); print writeme "data\n"; close(writeme); way2: open(writeme, "|-", "program arguments"); print writeme "data\n"; close(writeme); please explain, difference between them? there no difference. there differences between 2 forms in other cases [1] , there no differences example given. however, there 1 benefit of using three-argument form of 1 can take advantage when using function of open . open , system , run program directly (rather invoking shell execute it) when command passed list of multiple values. means following avoids invoking shell: open(writeme, "|-", "program", "arguments"); there many benefits avoiding shell middle-man. primary benefit lack of need convert variables shell literals. in other words, open(writeme, "|-", "program", "--", $file); is simple way of...

java - List<List<Double>> to double[][] for JAMA or other libs -

i cannot list> double[][] work on linear algebra package jama . have sort of list coordinates : [[2.63, 11.087, -12.054], [2.357, 13.026, -15.29], [1.365, 16.691, -15.389], [0.262, 18.241, -18.694]] and trying put these coordinates jama class double[][]. tried use method toarray, failed. double[][] array = list.toarray(new double[list.size()][]); how that? or there other packages cope svd, need here, using list of lists? guava has doubles class has toarray takes collection<? extends number> , thereby take list<double> , convert array. so... list<list<double>> mylist; double[][] myarray = new double[mylist.size()][]; (int i=0, n<mylist.size(); i<n; i++){ myarray[i] = doubles.toarray(mylist.get(i)); }

javascript - jQuery - Cannot retrieve Input Number value -

this question has answer here: how allow numeric (0-9) in html inputbox using jquery? 65 answers <input id='nb' name="nb" type="number" placeholder="number"/> jquery.val() returns value if there numbers, empty if there letter. chrome shows input number arrows (and work), can type letters too.. weird thing btw on mozilla , ie8 becomes normal input text (guess have old mozilla) any idea ? couldn't find on jquery doc specific number inputs .val() suggestion input type="text" instead html5 input input type="number" : //html <input id="inp" type="text" /> //javascript (jquery needed) function onlynumbers(evt) { // options enter, backspace, home, end, arrows, etc. var arrayexceptions = [8, 13, 16, 17, 18, 20, 27, 35, 36, 37, 38, 39, 40, 45, ...

git - Ssh not recognizing public key -

a list of things i've done: generated (public) key puttygen , saved (public key) 'id_rsa' in users/user/.ssh folder entered .ssh key in bitbucket settings when i'm trying git push code bitbucket repository ask passphrase -> although when enter passphrase permission denied(publickey) . i've tried deleting public key, make new one, use passphrase , nothing worked. doing wrong? // git init / remote etc. done already λ git push --set-upstream origin master enter passphrase key '/c/users/user/.ssh/id_rsa': permission denied (publickey). fatal: not read remote repository. needlessly i'm working on windows. haven't experienced problems on osx system.

php - Doctrine order by causing Uncaught exception -

the following code causing uncaught exception: class visual echo(produtocontroller::listaprodutovitrinefiltroordenadopelomenor("tv", "nome", "precodevenda", "asc")); class controller $produtos = daogenerico::findbystringorderby("produto", $tipopesquisa, $nome, $parametro, $ordem); dao public static function findbystringorderby($classname, $field, $string, $order, $orderparam){ $bd = new bd(); $bd->conectar(); $result = $bd->getentitymanager()->getrepository($classname)->createquerybuilder('e') ->where('e.'.$field.' :'.$field) ->setparameter($field, '%'.$string.'%') ->orderby($order, $orderparam) ->getquery() ->getresult(); return $result; } error: fatal error: uncaught exception 'doctrine\orm\query\queryexception' message 'select e produto e e.nome :nome order precodevenda asc' in c:\xampp\htdocs\tra...

jquery - Is this a threading issue? -

i'm using cherrypy 5.0.1 server-side framework. the following code performs searches on local disk's files. searches strings fed front-end's ajax calls. import cherrypy import os import os.path import json def searchforfiles(search_path, base_filename): directory = os.path.abspath(search_path) files = [] f in os.listdir(directory): if os.path.isfile(f): files.append(f) hit = [] f in files: if fnmatch.fnmatch(f, '*' + base_filename + '*'): hit.append(f) hit = json.dumps(hit) return hit class gui_db_interface: # whatever codes here...... @cherrypy.expose def searchforfiles(self, search_path, base_filename): return searchforfiles(search_path, base_filename) the front-end code: var searchsimilarfiles = function(event, filename_base) { var $uls = $('div#overview_box ul.existing_files'); var current_input = $('input#primary_input').v...

java - Im losing my mind with threads -

i want objects of class: public class chromosome implements runnable, comparable<chromosome> { private string[] chromosome; public double fitness; private random chromogen; public chromosome(double[] candidate) { super(); //encode candidate per parameter; using matrix storage chromosome = encode(candidate); chromogen = new random(); } //de-fault public chromosome() { super(); chromogen = new random(); //de-fault genotype chromosome = new string[6]; } /** * implemented */ public void run() { //i hope leaving empty works... } public int compareto(chromosome c) { return (int) (fitness - c.fitness); } /** * fitness stored in chromosome! */ public void setfitness(arraylist<double[]> target) { fitness = ff.fitness(this, target); } public double getfitness() { return fitness; } ...

vba - add page break with macro (if there isnt any page break) -

i want add page break before every heading 1 , evey \page bookmark. code work : sub pagebreack(isok) if isok <> true exit sub end if selection.goto = wdgotoline, = wdgotofirst application.browser.target = wdbrowsepage = 1 activedocument.builtindocumentproperties("number of pages") if > 1 activedocument.bookmarks("\page").range.select selection.insertbreak type:=wdsectionbreakcontinuous 'wdsectionbreaknextpage end if application.browser.next next each p in activedocument.paragraphs if left(p.style, 9) = "heading 1" p.range.select selection.previous.insertbreak type:=wdsectionbreakcontinuous end if next selection.find.clearformatting selection.find.replacement.clearformatting selection.find .text = "^12": .replacement.text = "^m": .forward = true: .wrap = wdfindcontinue: .format =...

android - Cannot use Bitnami Node.js for building Cordova App. Because npm not recognized -

i downloaded node.js , apache ant bitnami . , set environmental variables android sdk , java jdk , apache ant , node.js . i have checked path echo %path% command in cmd , results as c:\programdata\oracle\java\javapath; c:\windows\system32; c:\windows; c:\windows\system32\wbem; c:\windows\system32\windowspowershell\v1.0\; c:\program files\microsoft sql server\110\tools\binn\; c:\program files (x86)\windows live\shared; c:\program files(x86)\winscp\; c:\program files (x86)\windows kits\8.1\windows performance toolkit\; c:\program files\java\jdk1.8.0_74\bin; c:\bitnami\apache-ant-1.9.2-bin\apache-ant-1.9.2; c:\softwares\android-sdk_r24.0.2-windows\android-sdk-windows\tools; c:\softwares\android-sdk_r24.0.2-windows\android-sdk-windows\platform-tools; c:\bitnami\nodejs-0.12.2-0; but showing this, c:>npm -v 'npm' not recognized internal or external command, operable program or batch file. please suggest fixing this. thanks found it. ...

javascript - Replace _.forEach with something else -

i have problem. i've made long function has 4 _.foreach in it. want replace of _.foreach else lodash or else. so, have many arrays of object , want iterate on both of them , compare values both of them. i've made it, want better solution have cleaner code. here function: function refreshfruits() { _.foreach($scope.fruits, function(fruit, index){ _.foreach(vm.toupdate.somethinglikefruits, function(somethinglikeafruit, dindex) { .foreach(somethinglikeafruit.p, function(dep, nindex) { _.foreach(fruit.l, function(leg, legindex) { if(leg.name === dep.legname) { leg.disc = dep.discl; leg.fore = dep.projection; } }); }); }); }); } where fruits array of objects, vm.toupdate.somethinglikefruits array of objects , p , l arrays. split refreshfruits(...

java - How to implement Recursion -

hello trying implement recursion in 1 of assignments. these classes. public class bear implements totempole { int bearcount; public bear(totempole rest){} public bear() { bearcount = 3; } public int power() { return + 5; } public int height(){ return bearcount + 5; } public boolean chiefpole(int bearcount){ if(this.bearcount >= bearcount){ return true; } else { return false; } } } // snake class public class snake implements totempole { public snake(totempole rest){} int bearcount; public snake() { bearcount = 0; } public int power() { return + 3; } public int height(){ return bearcount + 1; } public boolean chiefpole(int bearcount){ if(this.bearcount >= bearcount){ return true; } else { return false; } } } // eagle class public class eagle implements totempole { int bearcount; public eagle(){ bearcount = 0; } public int power()...

Ubuntu ruby gem location -

i trying use prawn gem. trying out basic hello world example, on ubuntu machine. require 'prawn' prawn::document.generate("hello.pdf") text "hello world!" end first problem was using ruby 1.9.1, produced error , said needed ruby 2.0, using rvm updated 2.2.1. everytime run this, error /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require': cannot load such file -- prawn (loaderror) /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require' prawnpdf.rb:1:in `' now bit newbie ubuntu , ruby matter, assume issue is looking in wrong place prawn gem have installed ie looking in old verison of ruby. when run $ ruby -v ruby 2.2.1p85 (2015-02-26 revision 49769) [i686-linux] what doing wrong? appreicated. follow given step. 1: rvm list rvm rubies ruby-2.0.0-p643 [ x86_64 ] ruby-2.2.1 [ x86_64 ] =* ruby-2.2.4 [ x86_64 ] 2: rvm use < ruby-version > # instances ruby-1.9.3-p125 rvm use...

laravel - Laravel5.2 custom directive variable type change -

i have problem creating custom laravel blade directive. want create directive @message($message) . argument expected associative array (and 100% sure $message contains array). code: index.blade.php: <?php $message = array("item" => "value"); ?> @if(isset($message)) @message($message) @endif custom directive declaration: blade::directive('message', function($message){ if(is_array($message)){ return "<?php print 'is array'; ?>"; }else{ return "<?php print 'is not array'; ?>"; } }); no matter do, output says, not array. searched everywhere, didnt find answer. can explain?

Python Sqlite - Select Only Spans of Rows with Multiple Words -

i have book in sqlite table has 1 sentence per row. there on 30k rows/sentences , format of table cannot changed (it break many other things). i have several different spans of ids more or less divide book paragraphs. in tuples in list, i.e. [(0,2), (3,6), (7,10) ...] or [(0,3), (4,9), (10,13) ...], etc. i need able return spans contain 2 words or more. is, find "water" , "earth" within same span/paragraph. i looked @ making views using each group of spans using group_concant combine sentences, find no way since views cannot appended. making 1000s of select calls 'select * in book id between ? , ? and...' not seem efficient. is there way return spans have hits single statement or maybe way use temporary table combine them? if they're sequential (or can force ordering id correlate spans), can use python grouping applying arbitrary key each group, , using part of groupby. eg: from itertools import repeat, izip, chain, groupby opera...

php - FormField for Varchar to a <select> + other as free text -

for standard varchar (or text ) db field i'd replace set of fixed options - still allow "other" selected , user enter string of choice. class mydataobject extends dataobject { static $db = array( 'myvarchar' => "varchar", ); function getcmsfields() { $fields = parent::getcmsfields(); $fields->replacefield( 'myvarchar', somefield( 'myvarchar', 'choose option or enter text', array(1 => 'option1',2 => 'option2') ) ); return $fields; } } so i'm looking use somefield , user see drop down values option1, option2 , other. if option1 or 2 selected saved myvarchar. if other selected allow specifying text directly of myvarchar normal. i'm hopeful there is, in case of other answers i've received, pre-existing module this. ...

Selenium (Java) - Keep clicking a button until specific text is present in an element and fail if certain amount of time is exceeded -

i have scenario can stop engine clicking button starts background process , can see current status of engine every time after clicking refresh status button in page. issue time varies engine stop 30 seconds 2 mins depending upon load on server. don't want write while loop thread.sleep() it's bad idea , unnecessarily increase test time in selenium. there intuitive way wait 20 seconds every time , click refresh status button until offline text present in element , have timeout of 3 mins whole process? you can extend expectedconditions class , override static method texttobepresentinelementlocated if see implementation pretty simple: public static expectedcondition<boolean> texttobepresentinelementlocated( final locator, final string text) { return new expectedcondition<boolean>() { @override public boolean apply(webdriver driver) { try { string elementtext = findelement(locator, driver).gettext(); ...

amazon web services - Where can I manage uploaded IAM user SSL certificates in AWS? -

Image
i uploaded custom ssl certificate , key use cloudfront via aws cli ami user: $ aws iam upload-server-certificate --server-certificate-name my-cert --certificate-body file://https-cert.crt --private-key file://private-key.pem i got json response including certificate id , further information. aim use custom ssl certificate (ami user certificate or acm certificate pruchased through aws) radio button option remains disabled. expected active after having added certificate user. i can't find hint missed or uploaded certificate has gone. solution: missing /cloudfront/ path key problem. following command let me upload , choose certificate in cloudfront. aws iam upload-server-certificate --server-certificate-name my-cert --certificate-body file://https-cert.crt --certificate-chain file://ca-chain.crt --private-key file://private-key.pem --path /cloudfront/ cloudfront not have access all of uploaded server certificates (such certs might upload use elb). can acce...

git - Bitbucket: fork to existing repository -

i have empty repository b on bitbucket , want fork 1 existing repository b. how can this? on website bitbucket allows fork in new repository. i see 2 options: if don't need bitbucket call fork can clone repository , push repository b. of "fork" is. git clone git@bitbucket.com:user/repo cd repo git remote add my-clone git@bitbucket.com:you/repo-b git push --mirror my-clone if need bitbucket call fork fork, can take advantage of fact bitbucket wikis repositories make local copy of wiki, delete repository b, fork repository repository b, push wiki repository b. git clone http://bitbucket.org/you/repo-b/wiki repo-b.wiki cd repo-b.wiki # have @ files in repo-b.wiki , make sure complete # delete repository b bitbucket # fork repository repsitory b using bitbucket web ui # push wiki back: git push origin master

javascript - js function not changing value -

i have following code. first time function called iframe changes contents newpage second time function called page doesn't change. <!doctype html> <html> <head> <meta charset="iso-8859-1"> <title>submit</title> <script> var url = 1; function seturl(url){ var win1 = "http://localhost/audio/src/submit1.html" ; var win2 = "http://localhost/audio/src/newpage.html"; if (url === 1){ document.getelementbyid('iframe').src=win2; url=2; } else{ document.getelementbyid('iframe').src=win1; url=1; } } </script> </head> <body> <iframe src="http://localhost/audio/src/audio.html" style="width:0;height:0;border:0; border:none;"></iframe> <iframe id="iframe" style="border:0; " src=...

python - install local package into virtualenv using setuptools -

i have virtualenv multiple little projects in it. consider equal, folder structure looks this: categorisation_ml/ categorisation.py setup.py __init__.py nlp/ nlp.py setup.py __init__.py etc/ __init__.py i want install both packages same virtualenv both accessible everywhere within virtualenv. using this , this guide, have created setup.py script (for categorisation in case): from setuptools import setup, find_packages setup( name = "categorisation", version = "1.0", scripts = ['categorisation.py'] ) then, run python setup.py install , seems complete successfully. when cd nlp/ , enter python command line , try import categorisation , get: importerror: no module named categorisation . what missing?

AngularJS UI-grid filter OR option -

we using ui-grid in 1 of our project , can apply 2 filters on each column supported ui-grid. have filters arrays mentioned below: { field: 'age', filters: [ { condition: uigridconstants.filter.greater_than, placeholder: 'greater than' }, { condition: uigridconstants.filter.less_than, placeholder: 'less than' } ] this return rows matches both criteria. perfect. now add "or" condition in between these filters both filters can applied or 1 of them can applied. don't see support in ui-grid feature. idea how achieve functionality? any appreciated. the scope within grid not same controller's scope. therefore, must use grid.appscope: var cellselecttemplate = '<select ng-change="change(status, row.entity)" ng-model="status" ><option ng-repeat="stat in grid.appscope.datastatuses" value="{{stat.id}}">{{stat.status}}</option></...

indexing XML Solr Schemaless mode -

i'm using solr in schemaless mode, , want index xml files, using post command via shell. i've configured in solrconfig.xml managedschemadefinition , commented classicindexschemafactory . the post command index files: bin/post -c mycollection server/solr/docs/*.xml where docs folder in i've insert xml files want index mycollection . the problem in mycollection overview, num docs=0 , , in schemabrowser tab there aren't fields of xml indexed. am missing configuration steps?

javascript - Button not calling a function -

i creating simple array counter , sorter school , have encountered problem count button calling count() function. here's code. <!doctype html> <html> <head> <script language=javascript> var products = ["printer","tablet","router","keyboard","headset"]; function sort() { products.tostring() document.getelementbyid("result").innerhtml = "unsorted array = " + products; products.sort(); products.tostring(); document.getelementbyid("result2").innerhtml = "sorted array = " + products; } function count() { document.getelementbyid("count").innerhtml = "the amount of items in array is: " + fruit.length; } </script> <title>task 2</title> </head> <body> <input type="button" name="butt1" value="so...

c++ - Indefinite size of an array -

this question has answer here: how define member array size @ runtime 3 answers i trying make simple program counts number of vowels , consonants user's name has. size of array dependent on how many letters user's name has. i'm using queue display letters. when ever run program, .exe file crashes. tried change array size number instead of variable , worked. problem in using variable size of array, think. there anyway fix it? can still use variable size of array. here code #include <iostream> #include <queue> using namespace std; int main() { int i; char bin[i]; queue<char> name; int v = 0, c = 0; cout << "how many letters name have?:"; cin >> i; cout << "enter letters of name 1 one:\n"; { (int k = 0; k < i; k++) { cout << " ...