Posts

Showing posts from March, 2012

angularjs - Hide nav-button depending on the current state change -

how can hide/show button based on current view? <ion-nav-buttons side="right"> <button id="search_button" class="button button-icon ion-ios-search button-clear" ng-click="search()"> </button> </ion-nav-buttons> if have parent controller containing views can following : .controller("parentcontroller", function($scope){ var self = this; $scope.$on('$statechangesuccess', function(event, tostate, toparams, fromstate, fromparams){ self.showbutton = (tostate.name == "yourstatename"); }); }); html : <div ng-controller="parentcontroller parentctrl"> <ui-view> </ui-view> <ion-nav-buttons side="right"> <button id="search_button" class="button button-icon ion-ios-search button-clear" ng-click="search()" ng-if="parentctrl.showbutton"> </button>

winforms - a value type of "void" cannot be used to initialize an entity type of "System::string^" -

i following tutorial on youtube creating forms , i'm getting error when doing doing. i've searched on , cannot figure out. here video https://www.youtube.com/watch?v=lkhgpwuclc8&list=pls1qulwo1rizz6udid--i09eoimrmphs0&index=22 below code the part that's in bold part throwing error string^ strcharname = openchardialog1 ->initialdirectory = openchardialog1->filename; private: system::void openbutton_click(system::object^ sender, system::eventargs^ e) { stream^ opencharacter; openfiledialog^ openchardialog1 = gcnew openfiledialog; if (openchardialog1->showdialog() == system::windows::forms::dialogresult::ok) { if ((opencharacter = openchardialog1->openfile()) != nullptr ) { string^ strcharname = openchardialog1->initialdirectory = openchardialog1->filename; messagebox::show(strcharname); opencharacter->close(); } } } typo: string^ strchar

shell script : if array value was greater than a number then run a command -

i have a files containing usernames , users sent count mail per line . example (dont know how many line have ) : info.txt > 500 example1 40 example2 20 example3 .... .. . if number greater x , want run commands containing user name , act on user . getarray() { users=() # create array while ifs= read -r line # read line users+=("$line") # append line array done < "$1" } getarray "/root/.myscripts/spam1/info.txt" # know part incorrect , need here : if [ "${users[1$]}" -gt "50" ] echo "${users[2$] has sent ${users[1$]} emails" fi please help thanks not knowing how many lines of input have no reason use array. indeed, more useful if assume input infinite (an input stream), reading array impossible. read each line , take action if necessary: #!/bin/sh while read -r count user; if test "$count" -gt 50; echo "$user

python - AttributeError: 'module' object has no attribute 'sleep' . My mini-game doenst Work -

here code: import pygame import sys import os sys import * pygame import * os import * pygame.init() #colour acronym chart #| black = blck | grey = gry | dark = drk | white = wht #| deep = dp | metal = mtl | light = lht | #| blue = bl | baby = bby | maroon = mrn | #| red = rd | fire = fr | orange = orng | # window colour index wht = (255, 255, 255) blck = (0, 0, 0) dp_gry = (32, 32, 32) mtl_gry = (96, 96, 96) lht_gry = (160, 160, 160) dp_bl = (0, 0, 102) lht_bby_bl = (0, 128, 255) dark_maroon = (102, 0, 0) fire_red = (255, 0, 0) light_orange = (255, 128, 0) #end of colour module display_width = 800 display_height = 600 gamedisplay = pygame.display.set_mode((display_width,display_height)) pygame.display.set_caption('hard drive') clock = pygame.time.clock() carimg = pygame.image.load('car1.png') car_width = 45 car_height = 45 def car(x,y): gamedisplay.blit(carimg,(x,y)) def te

hadoop - How much data is considered "too large" for a Hive MAPJOIN job? -

edit: added more file size details, , other session information. i have seemingly straightforward hive join query surprisingly requires several hours run. select a.value1, a.value2, b.value join b on a.key = b.key a.keypart between b.startkeypart , b.endkeypart; i'm trying determine if execution time normal dataset , aws hardware selection, or if trying join data. table a: ~2.2 million rows, 12mb compressed, 81mb raw, 4 files. table b: ~245 thousand rows, 6.7mb compressed, 14mb raw, 1 file. aws: emr-4.3.0, running on 5 m3.2xlarge ec2 instances. records matches 1 or more records in b, logically see @ 500 billion rows generated before pruned clause. 4 mappers allocated job, completes in 6 hours . normal type of query , configuration? if not, should improve it? i've partitioned b on join key, yields 5 partitions, haven't noticed significant improvement. also, logs show hive optimizer starts local map join task, presumably cache or stream smaller table

R: read.table producing unexpected results on tab delimited data file -

i'm noob r. running r studio in windows , i'm having heck of time trying understand what's happening following read.table command. continents=read.table("country2continent.tsv",sep="\t", col.names=c("country","continent"),fileencoding = "utf-8",strip.white = true) questions: if try print column of data on command line "continents$country" command, data totally garbled. examined garbled data , found special characters "\t" embedded. have rid of special characters causing issues? if view continents data frame in r studio, looks correct. because examining r data frame shows row 61 has issue. should read "cote d'ivoire africa" reads "cote divoire africa". in row (row 61), apostrophe missing in divoire , there tab between divoire , africa. there lot of country / continent pairs following "cote d'ivoire africa" did not own rows. suggestions on how fi

javascript - Adding an object in a function in fabric.js -

i trying add objects when user clicks on different object. below code not work. tried adding setcoords, did not seem anything. interestingly enough, remove works intended. advice var showeron = 0; //0 == off 1 == on var sprayoption = 0; var massageoption = 0; var trickleoption = 0; function selectshower() { if(showeron == 1) { showerbutton.fill = 'yellow'; canvas.add(showerspray); canvas.add(showermassage); canvas.add(showertrickle); } else { showerbutton.fill = 'white'; showerspray.fill = 'white'; showermassage.fill = 'white'; showertrickle.fill = 'white'; sprayoption = 0; massageoption = 0; trickleoption = 0; canvas.remove(showerspray); canvas.remove(showermassage); canvas.remove(showertrickle); } } showerbutton.on('selected', function() { showeron = 1 - showeron; selectshower(); canvas.deactivateall(); });

android - OpenCV4Android Circular Object Tracking -

i new opencv , trying track circular object using find contours on android using 3.1.0. following sample color blob detector write code, drawcontours() function never draws when run application. here oncameraframe() function, doing processing. can tell me doing wrong? edit: new version of code: still not work expected. drawcontours() draws around black objects, , function produces noisy result. here looks like. public mat oncameraframe(cvcameraviewframe inputframe) { mat rgba = inputframe.rgba(); mat graymat = new mat(); imgproc.cvtcolor(rgba, graymat, imgproc.color_rgba2gray); mat processedmat = new mat(); imgproc.threshold(graymat, processedmat, 0, 255, imgproc.thresh_binary); list<matofpoint> contours = new arraylist<matofpoint>(); list<matofpoint> matchedcontours = new arraylist<matofpoint>(); mat hierarchy = new mat(); imgproc.findcontours(processedmat, contours, hierarchy, imgproc.retr_list, imgproc.chain_

javascript - reset ng-model from controller in ng-repeat -

i trying create list of editable inputs list of items. want user able edit of items, if change there mind can click button , reset way was. so far have working except reset. my html <div ng-app ng-controller="testcontroller"> <div ng-repeat="item in list"> <label>input {{$index+1}}:</label> <input ng-model="item.value" type="text" ng-click="copy(item)"/> <button ng-click="reset(item)"> x </button> </div> {{list}}<br> {{selected_item_backup}} </div> my controller function testcontroller($scope) { $scope.selected_item_backup = {}; $scope.list = [ { value: 'value 1' }, { value: 'value 2' }, { value: 'value 3' } ]; $scope.reset = function (item) { // know wont work many reasons, example of item = $scope.selected_item_backup; }; $scope.copy = function (item) { angular.copy(item, $scope.selected_item_

How do I convert my date and time stamp in R to date only stamp? -

this question has answer here: converting year , month (“yyyy-mm” format) date? 8 answers i new r. have large data set 1 of columns containing time stamp. format of column content e.g. sat mar 07 18:38:01 est 2015. want create additional column in data frame date. care in second column e.g. mar 07 2015. tried other similar questions addressing different format. in advance ! this works example. let me know if works full data set: x = "sat mar 07 18:38:01 est 2015" as.date(x, format="%a %b %d %h:%m:%s est %y") [1] "2015-03-07" see ?strptime more information on formatting codes parsing dates , times. update: per comment, add data set: if data frame called df , original column timestamp then... df$date = as.date(df$timestamp, format="%a %b %d %h:%m:%s est %y")

sql - Need help grouping a column that may or may not have the same value but have the same accounts -

how output data stored in table 1 each account number has has same cpt group's ones not match fall bottom of list? i have 1 table: select * cptcounts , displays format (relevant fields only): account originalcpt count modifiedcpt count 11 0 71010 1 11 71010 1 0 2 0 71010 1 2 0 71020 9 2 0 73130 1 2 0 77800 1 2 71010 1 0 2 71020 8 0 2 73130 1 0 2 73610 1 0 2 g0202 4 0 31 99010 1 0 31

javascript - Swap multiple uploaded input files -

Image
i try make file upload function in web application. i made enable upload 3 files on server, still have swapping files issue when try delete files. first code looks following: request.jsp html side <tr> <td class="tbcontent" rowspan="3" valign="middle" style="border-style: hidden solid solid solid;">attachment</td> <td class="tbcontent" valign="middle" style="border-style: hidden solid solid solid;"> <input type="file" id="docfile1" name="docfile1" size="50" style="width:85px;"/></td> <td class="tbcontent" valign="middle" style="border-style: hidden solid solid hidden;"> <input type="text" readonly="readonly" id="test1" class="test1" style="border:0;"/></td> <td class="tbcontent" valign=

java - While working with Selenium webdriver, why do we use linked list for gathering links or dropdown contents with mutliple matches? -

example code this, (this interview question asked me recently) list linkelements = driver.findelements(by.tagname("a")); list represents ordered list of objects, meaning can access elements of list in specific order, , index too. can add same element more once list. list allows null elements , can have many null objects in list you result in particular order 1 one. allow add duplicates. our result can have duplicates need in automation , if requirement different , not need duplicates can use other collection type.if use set not allow duplicates , it's unorder presentation of object. we use list because when using findelements() instead of findelement() expecting locator return more 1 element(not in every case or scenario). it's practice use list our data saved in list in ordered manner can use them properly. generally using list in below manner:- list<webelement> alloptions = dropdown.findelements(by."our locator"); ( webe

oracle - SQL multiple insert select in one row -

i'm new in sql , i'm trying put values in table has 2 foreign keys. create table room ( room_name varchar2(40 byte) , patient_id number , doc_name varchar2(50 byte) ) logging tablespace users pctfree 10 initrans 1 storage ( initial 65536 next 1048576 minextents 1 maxextents unlimited buffer_pool default ) noparallel; alter table room add constraint doc_room foreign key (doc_name) references doctor(doc_name) enable; alter table room add constraint patient_room foreign key (patient_id) references record(id) enable; created using left panel in sql developer . can see have 2 foreign keys. have no idea how add values columns patient_id , doc_name . so far did inserting 1 one table, resulted in having 3 different rows. what got: room_name | patient_id | doc_name --------------------------------------- emergency room | null | null null | 1 | null null | null | dr. john what want get:

java - Saving a vector in another vector and clearing the first one -

i have technical issue in coding. below defining vector of vectors: vector<vector<integer>> usupvec = new vector<vector<integer>>(); vector<integer> usup = new vector<integer>(); boolean isrep = false; (int = 1; <numsup ; i++) { usup.clear(); (int l = 0; l < i; l++) { if (supname[i] == supname[l]) { isrep = true; }} if (!isrep){usup.add(i);} (int j = i+1; j < numsup; j++) { if (supname[i] == supname[j]) { if (!isrep){usup.add(j);} }} isrep = false; usupvec.add((vector) usup); } my problem whenever clearing usup vector, vectors stored in usupvec cleared. in each iteration want define vector of integer numbers , store in vector of vectors , clear vector store new values , store again in vector of vectors.

mysql - Query Two Tables - but not trying to JOIN? -

i have 2 tables have identical columns. first table contains "current" state of particular record , second table contains previous stats of records (it's history table). second table has fk first table. i'd query both tables entire records history, including current state in 1 result. don't think join i'm trying "joins" multiple tables "horizontally" (one or more columns of 1 table combined 1 or more columns of table produce result includes columns both tables). rather, i'm trying "join"(???) tables "vertically" (meaning, no columns getting added result, results both tables falling under same columns in result set). not sure if i'm expressing make sense -- or if it's possible in mysql. to accomplish this, use union between 2 select statements. suggest selecting derived table in following manner can sort columns in result set. suppose wanted combine results following 2 queries: select f

Bootstrap Select - Set selected value by text -

how can change drop down if know text , not value? here select - <select id="app_id" class="selectpicker"> <option value="">--select--</option> <option value="1">application 1</option> <option value="2">application 2</option> </select> you can use jquery filter() , prop() below jquery("#app_id option").filter(function(){ return $.trim($(this).text()) == 'application 2' }).prop('selected', true); demo using bootstrap select , jquery("#app_id option").filter(function(){ return $.trim($(this).text()) == 'application 2' }).prop('selected', true); $('#app_id').selectpicker('refresh'); demo

haskell - Adding response header in Servant -

i trying figure out how add cors response header in servant (basically, set response header "access-control-allow-origin: *"). wrote small test case below addheader function errors out. appreciate figuring out error below. code: {-# language cpp #-} {-# language datakinds #-} {-# language derivegeneric #-} {-# language typefamilies #-} {-# language typeoperators #-} {-# language overloadedstrings #-} module main import data.aeson import ghc.generics import network.wai import servant import network.wai.handler.warp (run) import control.monad.trans.either import control.monad.io.class (liftio) import control.monad (when, (<$!>)) import data.text t import data.configurator c import data.maybe import system.exit (exitfailure) data user = user { name :: t.text , password :: t.text } deriving (eq, show, generic) instance tojson user instance fromjson user type token = t.text type userapi = "grant" :> reqbo

javascript - How to calculate and set the height for an element with jQuery? -

say have 1 parent div , 3 child divs so <div id="parent"> <div id="child1">...</div> <div id="child2">...</div> <div id="child3">...</div> </div> i want calculate , set height of child3 based on pseudo formula child3height = parentheight - child1height + child2height how can write in jquery , set way? first height of parent $('#parent').height , childs $('#child1').height() , apply simple mathamatics rule , height in variable. var child3height = $('#parent').height - ($('#child1').height() + $('#child2').height()); and store variable in child3 .height() property of jquery $('#child3').height(child3height);

linux - Plink > didn't return newline carriage -

this supposed basic. i'm running plink windows , want output file plink 192.168.229.128 -ssh -l root -pw password runsql.sh > result.log the runsql.sh output like 121211212 213212312 434234234 521312312 however result.log shows as: 121211212213212312434234234521312312 how can fix this? bunch! you seem have opened unix line ending file in notepad.exe or low-end editor, not understand line endings. if going check result in manner, can try adding @ start of script: [ "$ssh_connection" -a ! -t 1 ] && exec 1> >(sed 's/$/\r/') note there should better & more robust mechanism detect output being redirected on ssh session.

Go goroutine with channel strange result -

when run goroutines, 40 value, know concurrency why last number coming? suppose output must be: page number: 34 page number: 12 page number: 8 page number: 2 page number: 29 example source code : package main import ( "fmt" "io/ioutil" "net/http" ) func getwebpagecontent(url string, c chan int, val int) interface{} { if r, err := http.get(url); err == nil { defer r.body.close() if body, err := ioutil.readall(r.body); err == nil { c <- val return string(body) } } else { fmt.println(err) } return "xox" } const max_th = 40 func main() { // pln := fmt.println messages := make(chan int) j := 0; j < max_th; j++ { go func() { getwebpagecontent("http://www.example.com", messages, j) }() } routine_count := 0 var page_number int { page_number = <-messages routine_count++

cxf - Apache Camel : Corba Endpoint Message Error -

am calling corba server using cxf client. cxf client receiving response if primitive type, when server sending objects, fails below error the jdk version : jdk1.7.0_55 cxf version : 2.6.0 esb server : jboss fuse 6.0.0 error log says: 10:51:30,208 | warn | eadpool; w: idle | phaseinterceptorchain | 150 - org.apache.cxf.cxf-api - 2.6.0.redhat-60024 | interceptor {http://cxf.apache.org/bindings/corba/idl/subsprofileprov}balancemanagement.subscriberprofileprovisioncorbaservice#{http://cxf.apache.org/bindings/corba/idl/subsprofileprov}createsubscriberprofile has thrown exception, unwinding org.apache.cxf.binding.corba.corbabindingexception: org.apache.cxf.binding.corba.corbabindingexception: error reading streamable value @ org.apache.cxf.binding.corba.corbaconduit.close(corbaconduit.java:145)[171:org.apache.cxf.cxf-rt-bindings-corba:2.6.0.redhat-60024] @ org.apache.cxf.interceptor.messagesenderinterceptor$messagesenderendinginterceptor.handlemessage(messagesenderint

java - How to check TestNG Assert.assertEqual() conditional checking -

let me explain expecting have method following public void removebyobject() { try { dsrcollection dsrcollection = new dsrcollection(); dsrcollection. setnuid(180); dsrcollectionrepository.remove(dsrcollection); } catch (exception e) { // todo: handle exception e.printstacktrace(); } here want check particular method removebyobject() executed or not(also want involve assert.assertequal(dsrcollectionrepository.remove(dsrcollection),??)) . checking condition should actual value. or in more specific way object should appear in actual value place. requirement if application failed execute dsrcollectionrepository.remove(dsrcollection) should return asserterror message to make removebyobject() more testable can extract code in try block own method. e.g.: public class dsrcollectionrepositorymanager /* or whatever class called. */ { /* ... */ public void removebyobject() { try {

css - How do I get this custom font to work? -

i'm trying font named 'corleonedue' display on website i'm working on. btw, font used godfather movies. i downloaded font here: http://www.dafont.com/corleone.font i converted ttf file woff file here: https://andrewsun.com/projects/woffjs/woffer-woff-font-converter/ and css rule unsuccessfully used: @font-face { font-family: 'corleonedue'; src: url('fonts/corleonedue.ttf') format('truetype'); src: url('fonts/corleonedue.woff') format('woff'); } can please me font render/display on website? edit: i followed directions 1 of commenters (andrei), , i'm still having no luck. current css rule has been updated to: @font-face { font-family: corleonedue, sans-serif; src: url('corleonedue-webfont.eot'); src: url('corleonedue-webfont.eot?#iefix') format('embedded-opentype'), url('corleonedue-webfont.woff2') format('woff2'), url('corleon

utf 8 - UTF-8 encoding not working with data parsed from DBpedia using RDFLib in Python 2 -

i have following code parse data dbpedia output , add rdflib graph: for index, value in enumerate(output['results']['bindings']): #the encoding necessary parse non-english characters subj_raw = '<' + value['s']['value'].encode('utf-8') + '>' subj_refined = uriref(subj_raw) pred_raw = '<' + value['p']['value'].encode('utf-8') + '>' pred_refined = uriref(pred_raw) if 'http' in value['o']['value']: obj_raw = '<' + value['o']['value'].encode('utf-8') + '>' obj_refined = uriref(obj_raw) else: obj_raw = '"' + value['o']['value'].encode('utf-8') + '"' obj_refined = uriref(obj_raw) datagraph.add((subj_refined,pred_refined,obj_refined)) despite using .encode('utf-8') , non-ascii characters n

java - Pass null primary key with jOOQ to have it set by the database -

for rest service, receive object persist in database. want prevent user setting id. instead, database should assign value automatically sequence, postgresql's serial. if try null out id in jooq generated record, database error out when try store it. here's relevant ddl. create table todo ( id serial primary key, title text, url text ); here's relevant code. full code @ todo-backend . @post public todo addtodo(todo todo, @context dslcontext db) { final todorecord todorecord = db.newrecord(todo, todo); // errors out, violates not-null constraint on db todorecord.setid(null); todorecord.store(); todorecord.seturl("http://localhost:8080/" + todorecord.getid()); todorecord.store(); return db.selectfrom(todo) .where(todo.id.eq(todorecord.getid())) .fetchoneinto(todo.class); } versions dropwizard 0.8.5 jooq 3.7.2 postgres 9.5 java 1.8 some databases allow null values in keys

Import Eclipse Project To Android Studio error There are unrecoverable errors which must be corrected first -

Image
i new android , have project made in eclipse , want shift android studio when tried import project android studio gives me error. have attached image please me out. in big trouble.

bash - How to run mv command run recursively in Linux -

my environment: bash 3.5 linuxredhat i'm using following code rename of files in single directory. for file in *.* ; mv "$file" "add_$file" ; done now, want rename file recursively.and don't know how do. the first ideas find don't work, because {} returns ./ command: find . -type f -name "*.*" -execdir mv {} add_{} ";" we need something, removes ./ in front works in subdirectories too. echo 'f=$(basename "$1"); mv "$f" add_"$f";' > adhoc.sh chmod a+x adhoc.sh find . -type f -name "*.*" -execdir $pwd/adhoc.sh "{}" ";" at least works gnu-find . other finds might not have -execdir command. thanks skyking pointing error out. for linux, might find version of 'rename' in repository, has installed , isn't part of standard installation. if rename commandline, worth effort. rename , specify regex substitute command , can test firs

php - Pass resultset value to a javascript function -

i have 1 resultset, how can pass value javascript function ,and move internal pointer next row. <?php $q=mysql_query("select * tbl_map")or die(mysql_error()); $i=0; ?> <script> $(document).ready(function() { // initialize google maps api v3 var map = new google.maps.map(document.getelementbyid('map'), { zoom: 15, maptypeid: google.maps.maptypeid.roadmap }); var marker = null; function autoupdate() { <?php mysql_data_seek($q,$i); $row=mysql_fetch_assoc($q); $i++; ?> lat=<?php echo $row['latitude']; ?>; long=<?php echo $row['longitude']; ?>; navigator.geolocation.getcurrentposition(function(position) { var newpoint = new google.maps.latlng(lat, long); if (marker) { // marker created - move marker.setposition(newpoint); } else { // marker not exist - create marker = new google.maps.marker({ position: newpoint,

java - How to make JDatePicker text field formatted for input? -

org.jdatepicker used in app input field should editable, added datepicker = new jdatepickerimpl(datepanel, new datelabelformatter()); datepicker.settexteditable(true); but can write bs it: screenshot . need add mf = new maskformatter("##.##.####"); mf .setplaceholdercharacter('.'); to limit input mask. how this? jdatepickerimpl isn't jformattedtextfield. when choose date calendar it's formatted right way. datelabelformatter class: public class datelabelformatter extends jformattedtextfield.abstractformatter { private string datepattern = "dd.mm.yyyy"; private simpledateformat dateformatter = new simpledateformat(datepattern); @override public object stringtovalue(string text) throws parseexception { return dateformatter.parseobject(text); } @override public string valuetostring(object value) throws parseexception { if (value != null) { ca