Posts

Showing posts from March, 2012

Grouping the array in php -

sample array values: array ( [0] => '2014-07-04 ' [1] => 246 ) array ( [0] => '2014-07-04' [1] => 213 ) array ( [0] => '2014-07-04 ' [1] => 274 ) array ( [0] => '2014-07-04 ' [1] => 249 ) array ( [0] => '2014-07-04 ' [1] => 253 ) array ( [0] => '2014-07-04 ' [1] => 23 ) array ( [5] => '2014-07-04 ' [6] => 11) array ( [5] => '2014-08-04 ' [6] => 1743 ) array ( [5] => '2014-08-04 ' [6] => 1.31 ) array ( [5] => '2014-08-04' [6] => 172 ) array ( [5] => '2014-08-04 ' [6] => 179 ) array ( [5] => '2014-08-04 ' [6] => 1709 ) array ( [5] => '2014-08-04 ' [6] => 176 ) now want separate array 2 array below: firstarray=>array( array ( [0] => '2014-07-04 ' [1] => 246 ) array ( [0] =...

python - PIP install error with git repository packages -

i have old django project needs deploy now. need install exact versions used in project. in project's requirements.txt there packages git repos. while installing requirements using pip install -r requirements.txt throwing following error. file "/home/nyros/desktop/new/rmkenv/local/lib/python2.7/site-packages/pip/req.py", line 70, in __init__ req = pkg_resources.requirement.parse(req) file "/home/nyros/desktop/new/rmkenv/local/lib/python2.7/site-packages/pip/_vendor/pkg_resources.py", line 2606, in parse reqs = list(parse_requirements(s)) file "/home/nyros/desktop/new/rmkenv/local/lib/python2.7/site-packages/pip/_vendor/pkg_resources.py", line 2544, in parse_requirements line, p, specs = scan_list(version,line_end,line,p,(1,2),"version spec") file "/home/nyros/desktop/new/rmkenv/local/lib/python2.7/site-packages/pip/_vendor/pkg_resources.py", line 2512, in scan_list raise valueerror("expected...

apache - Cloudflare bug random 302 redirections -

i've issue cloudflare, (randomly) have 302 redirections on random non-existing subfolders, give examples : get /en/home > 302 > /en/home/swetz > 302 > /en/home > 302 > /en/home/qutis > 302 > /en/home > 200 /en/home > 302 > /en/home/zaiue > 302 > /en/home/zaiue/widut > 302 > /en/home > 200 when disable cloudflare, seems work , no sign of strange redirections. i've noticed these redirections happen on resources when header "cf-cache-status" set miss. it's annoying because "err_too_many_redirections" happen totally breaks website : javascript, styles , images not loaded... please open support ticket & can take look. wouldn't add redirect unless set pagerule instructing so, sounds may have configured incorrectly. forwarding & cache status different things & shouldn't have play here.

c++ - Comparison of two common comparison algorithms and their Big O help please -

today professor gave 2 take home questions practice upcoming array unit in c , wondering sorting algorithm these 2 problems resemble , big o is. now , not coming here expecting answers , have already solved them, not confident in answers post them udner each question , if wrong, please correct me , explain error in thinking. question 1: if decide go through array's( box ) element( folders ) 1 @ time. starting @ first element , comparing next. if same comparison ends, if both not equal moves on comparing next 2 elements [2] , [3]. process repeated , stop once last 2 elements compared , note array sorted last name , looking same first name! example: [ harper steven, hawking john, ingleton steven] my believed answer: i beleive o(n) because it's going on elements of array comparing array[0] array[1] , array[2] array[3] ect ect. process linear , continues until last 2 compared. not logn because aren't multiplying or diving 2. final question: suppose have box of ...

android - MPAndroidChart - How to change the color of PieChart center Background? -

im trying use mpandroidchart library develop circular chart. pie chart available. tried giving 2 xvalue coordinates, 1 color similar background. got similar circular chart. i'm not able change background color , font color of center text inside pie chart? thanks! there 2 possible solutions: retrieve paint object used chart draw "center-hole" , modify way want paint p1 = mchart.getpaint(chart.paint_hole); p1.setcolor(...); paint p2 = mchart.getpaint(chart.paint_center_text); p2.setcolor(...); or use this, if display 1 value anyway: circledisplay

ios8 - Cordova 3.5.1 with iOS 8 device, remote debugging on Safari 7.1 -

i've exported ad hoc distribution of cordova app testing purpose. after installing ota on ipad ios 8 , connecting mac, it's not possibile use remote debugging of safari, doesn't show app in developer menu. is there solution or alternative safari remote debugging on ios device? edit: updating safari 7.1 broke web inspector on ad hoc distribution on ios 7 devices, before update worked, having same issues? i have checked , safari ios 8 remote debugging works latest nightly build you can grab 1 here http://nightly.webkit.org/ edit looks safari 7.1 came out, according https://discussions.apple.com/thread/6537575 solves inspector issues

r - Plot polygons with different colors and not overwrite the previous polygons if overlapped -

i graphing several n-edge polygons on same plot. let say: 1/ n=3: draw polygon 3 edges, color "pink" 2/ n=6: draw polygon 6 edges, color "grey". @ point, see first polygon in step 1 overlapped one. in case, want keep "pink" color of first polygon , color rest "un-overlapped" area of 2nd polygon "grey" color. i have tried code follow, display "grey" polygon, instead of "pink" , "grey" areas. btw, walked around problem "draw 6-edge polygon (n=6) first, , draw 3-edges polygon (n=3)". changing drawing order biggest polygon smallest one, can keep color of biggest , smallest polygons @ end. however, steps mentioned @ beginning of questions can see plotting areas increasing when n (number of edges) keeps increasing. if have suggestions, please advice me. thank much! cat("\014") rm(list=ls()) ############################# # first polygon #n=3 xx3=c(0,-3,3);xx3 yy3=c(1,1,-2);yy3...

print in single line in matlab command line -

how print command line in matlab. output print statements in single line. for example, for i=1:4 disp(i) => or others print statement! end output: 1234 not: 1 2 3 4 an option using fprintf for i=1:4 fprintf('%d',i) end fprintf('\n') %//add line break @ end and if want linebreaks @ specific points use \n escape sequence , allows formatting such spacing: for i=1:12 fprintf('%10d',i) if mod(i,3)==0 fprintf('\n'); end end

SAS: Table name with too many characters -

sas has 32 character limit table- , column-names. have scenario want select table , join table b (where table b has name above 32 characters). if try write in proc sql, error saying table b has name exceeding 32 characters. anyone know how can arround this? assuming working non-sas dbms, sql server, should use passthrough sql process select, works rdbms's syntax , doesn't have 32 character limitation. ie: proc sql; connect oledb (... init string ... ); create table work.mydata select * connection oledb ( ... sql server or whatever syntax ... ); quit; you ask dba construct view had < 32 character long name.

java - How to get Password history? -

i want last 3 passwords used (set) user , don't want set them again when going set again same password. api should use password history. visit link https://developers.google.com/admin-sdk/directory/v1/guides/manage-users https://developers.google.com/admin-sdk/directory/v1/reference/users/update afaik, there no "previous password" in of apis. i use one-way hash function save last passwords inside datastore table, , compare these. i know of no google product offer that.

javascript - Is there any conditional formatting in moment.js? -

i working on countdown using moment.js. nice if have conditional formatting. here have var count_down = moment().hour(23).min(30); alert( count_down.format('h[h ]m[min ]s[s]') ); that displays: 0h 43min 20s i know if there format expression var format = 'h[h ]m[min ]s[s]'; if (count_down.hour() === 0) format = 'm[min ]s[s]'; alert( count_down.format(format) ); displaying: 43min 20s i have not seen in doc though. a moment object represents time-of-day, not make sense count-down. should use moment's duration object purpose instead. moment doesn't yet have direct support formatting durations, this: var d = moment.duration('23:30'); var s = (d.hours() > 0 ? d.hours() + 'h ' : '') + d.minutes() + 'min ' + d.seconds() + 's'; alternatively, can try moment-duration-format plugin, still have handle conditional evaluation yourself.

header - h1 elements above div using z-index -

i tried place h1 element above div element using css property z-index , it's not working! here's html: <div id="header"> <div id="headerblock"> </div> <h1>this header text</h1> </div> the #headerblock has black surface including transparency. want h1 appearing above #headerblock. mentioned z-index property isn't working. have solution this? or @ least reason why it's not working? thanks. gotta have position on h1. h1 { position:relative; z-index: 500; } http://jsfiddle.net/y9cthv8r/1/

Division using Counts in Oracle SQL -

basic question, trying division sql statements return single value. i want number of rows value less 40 in 'random_num' column divided total number of rows keep getting error. mind pointing out how this/ select count( ) / ( select count ( ) abc) abc random_num < 40 create table abc (continent varchar2(30), country varchar2(30), random_num number, yr number) insert abc values ('asia', 'india', 50, 2005) insert abc values ('asia', 'japan', 100, 2006) insert abc values('asia', 'korea', 35, 2007) insert abc values ('asia', 'china', 200, 2008) a simple way use case count rows value < 40; select count(case when random_num < 40 1 end)/count(*) ratio abc a simple sqlfiddle test with.

java - Posting photo from Cordova to Spring Web Service -

i writing proof of concept app consists of sencha touch/ cordova hybrid application accesses phones camera api, takes picture , uploads spring server. have got the mobile application jamming properly. have managed take picture having issues posting spring end. when debug server can see app hitting web service correctly, image byte[] seems blank. debugged on client side using android logcat , there image being sent client side. think problem lies webservice receiving posted image. my basic client side code follows : function onphotourisuccess(imageuritoupload){ var url=encodeuri("http://192.168.2.4:8080/app/api/rest//uploadimage/"); var params = new object(); params.your_param_name = "something"; //you can send additional info file var options = new fileuploadoptions(); options.filekey = "the_name_of_the_image_field"; //depends on api options.filename = imageuritoupload.substr(imageuritoupload.lastindexof('/')+1)...

swift - Music Player Timer -

func configureplayer() { player.addperiodictimeobserverforinterval(cmtimemakewithseconds(1, 1), queue: dispatch_get_main_queue()) { (cmtime) -> void in var timenow = int(self.player.currenttime().value) / int(self.player.currenttime().timescale) var currentmins = timenow / 60 var currentsec = timenow % 60 var duration: nsstring = "\(currentmins):\(currentsec)" self.durationoutlet.text = duration // <<- green line here self.slideroutlet.value = float(timenow) } } i'm creating music player , works fine, crashes when try duration timer count or slider animate. works fine 2 seconds, crashes. call method in viewdidload . there no errors @ except green line pointed above. i think there problem durationoutlet outlet. so make sure durationoutlet connected storyboard. here sample project more info.

javascript - Chosen.js doesn't work well with Angular directive -

i created plunker code question here http://plnkr.co/edit/mtarpoasqqq6oseqls3a?p=preview this html code of list <select ng-model="modselectedstate" id="inputlocation-" name="filter_location" class="location" ng-options="state state.full_name state in states" chosen="states"> <option value="">state</option> as can see created directive , named "chosen", here code: app.directive('chosen', function ($http) { var linker = function (scope, element, attr) { scope.$watch(scope.states, function (oldval, newval) { element.trigger('liszt:updated'); }); scope.$watch(attr.ngmodel, function () { element.trigger('liszt:updated'); }); element.chosen({disable_search_threshold: 20}); }; return { restrict: 'a', link: linker } }); please note using older version of 'chosen" requires 'liszt...

ruby on rails - current_cart is undefined when trying to access it from line_items controller? -

i trying make user redirect_to current_cart after click "add cart" link. doing in line items controller, , using railscasts source code reference. https://github.com/ryanb/railscasts-episodes/blob/master/episode-141/store/app/controllers/line_items_controller.rb when click "add cart" link error: undefined local variable or method `current_cart' here lineitemscontroller: class lineitemscontroller < applicationcontroller def create @product = product.find(params[:product_id]) @line_item = lineitem.create!(:cart => current_cart, :product => @product, :quantity => 1, :unit_price => @product.price) flash[:notice] = "added #{@product.title} cart." redirect_to current_cart_url end end here cartscontroller: class cartscontroller < applicationcontroller def show @cart = current_cart end end thanks help. looks line items controller missing current_cart method: def current_cart # should fin...

python - Unsupported operand type(s) for +: 'NoneType' and 'str' and 'int' -

code: string1 = " right" g = lambda x: x ** 2 print(g(8)) + str(string1) error: traceback (most recent call last): file "c:/users/computer/desktop/testing.py", line 3, in <module> print(g(8)) + str(string1) typeerror: unsupported operand type(s) +: 'nonetype' , 'str' code2: tried adding too: g = lambda x: x ** 2 + " should right!" print(g(8)) error: traceback (most recent call last): file "c:/users/computer/desktop/testing.py", line 2, in <module> print(g(8)) file "c:/users/computer/desktop/testing.py", line 1, in <lambda> g = lambda x: x ** 2 + " should right!" typeerror: unsupported operand type(s) +: 'int' , 'str' i tried int , str still had problems? also when fixing, please explain how fixed code works :) dont want copy fixed line you adding result of print() , str() , print() returns none . you wanted print result of...

Get and set date and time (RTC) in DOS with assembly? -

Image
need , set datetime (rtc) using assembly. read set date , time need use int 1ah (func 05h ). wrote program change time , date. seems have done right, time not change: here code: ;program (and set) current time , date (int 1ah) .model tiny .code org 100h ; СОМ-program start: call show_time ; display curr time mov ah,9 lea dx,promt ; show prompt enter new time int 21h lea si,hour ; read hours call input ; cmp cl,0ffh ; if error jz endtime ; stop enter time mov dl,':' ; add ":" after hours mov ah,2 int 21h lea si,min ; read mins call input mov ch,[hour] cmp ch,23h ; if hours not more 23 jg errortime ; if more - display error mov cl,[min] ; if mins not more 59 cmp cl,59h jg errortime ; if more - display error mov ah,03 int 1ah ; setup new time call show_time ; display curr time endtime: ;--date operations call ...

mp4 - Play raw h264 annexB with html <video> element -

i use library nvidia encoder sdk (c++) generate raw h264 stream (annex b). don't record stream file, want broadcast video in live html video element. so, know need ? need mux raw h264 stream mp4 container ? using annex b not problem live streaming ? can use http protocol ? thanks answer.

ios - iOS8 touch position is limited in Landscape, as if window is Portrait on one side? -

i'm having bizarre problem here ios8. i've been googling , bashing head against wall couple of days no luck. i'm not sure how explain it, here goes... apps have been running fine under ios7, compiling using xcode 6/ios8 i'm having few strange orientation problems. i'm not using xib file, instead creating window , view programatically. i'm running opengl in view, , handling else inside opengl. so, i'm collecting touches , passing them gl routines. has been fine forever, til now. now ios8 seems if "touch window" rotating touches in landscape limited 1 side of screen, if display window landscape, touches within portrait window set on 1 side of screen. what seems bizarre touches come through view on screen normal, y value stops @ 320 , goes no further. x acts normally. if turn device portrait (the view controller not auto rotate), works, in landscape switches strange behaviour. i've tried can think of without changes, , not sure begin w...

Scala Apply Method in companion object -

i have created companion object scala class apply method in can create instance of class without using 'new'. object stanfordtokenizer{ def apply() = new stanfordtokenizer() } class stanfordtokenizer() extends tokenizer{ def tokenizefile(docfile: java.io.file) = new ptbtokenizer(new filereader(docfile), new corelabeltokenfactory(), "").tokenize.map(x => x.word().tolowercase).tolist def tokenizestring(str: string) = new ptbtokenizer(new stringreader(str), new corelabeltokenfactory(), "").tokenize.map(x => x.word.tolowercase()).tolist } however when try instantiate stanfordtokenizer class without 'new' e.g. standfordtokenizer.tokenizestring(str) . i error value tokenizestring not member of object stanfordtokenizer however, if explicitly include apply method standfordtokenizer.apply().tokenizestring(str) work. i feel missing fundamental companion objects. can shed light on me? ^ ...

Unable to launch my android application -

i unable view application in emulator. have tried increasing adb timeout 10000 ms. result same. please tell me problem is. console output: [2014-09-22 12:52:51 - notificationexample] ------------------------------ [2014-09-22 12:52:51 - notificationexample] android launch! [2014-09-22 12:52:51 - notificationexample] adb running normally. [2014-09-22 12:52:51 - notificationexample] performing com.example.notificationexample.notification activity launch [2014-09-22 12:52:51 - notificationexample] automatic target mode: launching new emulator compatible avd 'avd_for_nexus_7_2012_by_google' [2014-09-22 12:52:51 - notificationexample] launching new emulator virtual device 'avd_for_nexus_7_2012_by_google' [2014-09-22 12:54:07 - emulator] emulator: warning: requested ram size of 1024mb large environment, , reduced 768mb. [2014-09-22 12:54:09 - emulator] emulator: warning: opening audio input failed [2014-09-22 12:54:09 - emulator] [2014-09-22 12:54:11 - notificatione...

actionscript 3 - Rotation and movement in AS3 -

i want make minigame background (maze) rotating around same point, immovable playermc that's in middle of stage. rotation using 2 mcs, 1 parent, rotate, , 1 nested maze move according mouse/keyboard movement unfortunately, x , y axes on maze moved @ 90deg movement 'up' change 'right'. i realise sin , cos or translation matrix should trick, reason can't right. here short gif summarising problem: http://blackdragonschronicles.strefa.pl/public/vertigo.gif appreciate in matter you use matrix solves pretty nicely. in small example have movieclip called box sitting on stage. pivot in top left corner (0,0). if want rotate cube center first translate matrix half of width , height. rotate arbitrary angle, , apply matrix transformation box. var angle:number = math.pi/64; var m:matrix = new matrix(); m.translate(-box.width >> 1, -box.height >> 1); stage.addeventlistener(event.enter_frame, loop); function loop(e:event):void { m.ro...

java - Error: Main method not found in class. can anybody will give me a proper solution for this error please -

error: error: main method not found in class app, please define main method as: public static void main(string[] args) code: class app { public static void main(string[] args) { double accounts[]; accounts=new double[100]; accounts[2]=1225.33; system.out.println("account 2 overdue $"+accounts[2]); } } i using editplus run , execute program. if trying run class need main method. add main method class , put code trying execute inside main method , should execute. post code have it's easier understand trying do. public static void main(string[] args) { //code goes here }

add - Sql query added to title? -

in c# windows forms: i'm having trouble adding sql query result text toolstripmenuitem.text. the toolstripmenuitem title should be, company + how many orders there in sql table company should update every x secounds. every 5 seconds adds query result text. problem is "adds" it. after first 5 seconds looks ok "rexton 1" 5 seconds after shows "rexton 1 1" , on... here code: //rexton ordre klar til bestilling sqlconnection con = new sqlconnection(@"data source=" + globalvariables.hosttxt + "," + globalvariables.porttxt + "\\sqlexpress;database=ha;persist security info=false; uid='" + globalvariables.user + "' ; pwd='" + globalvariables.psw + "'"); sqlcommand command = con.createcommand(); command.commandtext = "select count(*) bestillinger firma = @rexton , udlevering between @date , @dateadd"; ...

Run MySql from Java failed -

i'm trying run mysql command java process using process exec the code: string s = "mysql -h192.168.0.1 -u user -password db_name-e \"select * table\" system.out.println(s); process p = r.exec(s); p.waitfor(); when i'm running sql query command line works great, java process ' usage: mysql [options] [database]... mysql options. without -e parameter seems work, no error of course nothing happens. in win& machine works great, not on deploy linux machine. any ideas i'm doing wrong? example of java using mysql: import java.sql.connection; import java.sql.drivermanager; import java.sql.sqlexception; import java.sql.statement; import java.sql.resultset; // assume conn created jdbc connection (see previous examples) statement stmt = null; resultset rs = null; try { stmt = conn.createstatement(); rs = stmt.executequery("select foo bar"); // or alternatively, if don't know ahead of time // query select....

java - Eclipse suggests Null Pointer exception, though I believe I initialized my object -

as title says have npe error. happens on line: while (getwidth() > bowl.getx()+10) { if remove it, shows happens on next line: bowl.move(10.0, 0); i concluded eclipse not see "bowl" initialized. why? doesn't "new goval" deal that? i've seen in 1 of threads here solution split declaration , initialization different lines, think unlikely primary solution (besides, didn't in case) suggestions on code? this code supposed create circle, put in left-upper corner of screen, , move circle after mouse-button clicked. circle drawn successfully, npe message shows after click. import acm.program.*; import acm.graphics.*; import java.awt.event.*; public class animation extends graphicsprogram { public void init() { goval bowl = new goval(10,10); add(bowl); addmouselisteners(); } public void mouseclicked(mouseevent e) { while (getwidth() > bowl.getx()+10) { bowl.move(10.0, 0); pause(50); } } private go...

Windows batch file not working properly -

my batch file not executing start serial_new.exe, terminates serial_new.exe. opens , closes immediately. echo off c: cd c:\wamp\www\mobilesms\ start serial_new.exe echo testing echo.. ping 1.1.1.1 -n 1 -w 5000 > nul taskkill /f /im serial_new.exe try start "serial_new" serial_new.exe start command needs title first argument.

php - Selecting multiple rows in a Select statement using PDO -

i have 2 tables, want select first id of salles each responsible (he may have many -> array()) . so want select salles responsible have, , did statement (which returns empty array , unsure of why): $sels = $db->prepare("select salle salleresp resp = :resp"); $sels->bindparam(':resp',$rsb['matricule']); $sels->execute(); $rss = $sels->fetchall(pdo::fetch_assoc); $questionmarks = str_repeat("?,", count($rss)-1) . "?"; $selectsalle1 = $db->prepare("select * salle salleid in ($questionmarks) "); $selectsalle1->execute($rss); $showall=$selectsalle1->fetchall(pdo::fetch_assoc); when do: print_r($showall); it return empty array: array() any suggestions please? select * salle salleid in (select salle salleresp resp = :resp) or select * salle left join salleresp on (salle.salleid = salleresp.salle) resp = :resp)

powershell - Running a script when you launch a certain Program -

is possible run script when launching particular file? (access in case) if so, possible using windows task scheduler? also, keep in mind used powershell develop script. maybe can use wmi event watcher. snippet waits calc.exe launched, runs script adjust priority low. afterwords loops in waiting next instance of calc.exe spawned. powershell script runs in background changing specific process priority low whenever ran $prog = get-process -name calc | ?{$_.priorityclass = [system.diagnostics.processpriorityclass]::idle} while($true) { $query = "select * __instancecreationevent within 1 targetinstance isa 'win32_process' , targetinstance.name = 'calc.exe'" $eventwatcher = new-object management.managementeventwatcher $query $event = $eventwatcher.waitfornextevent() $prog = get-process -name calc | ?{$_.priorityclass = [system.diagnostics.processpriorityclass]::idle} } additional info. ...

r - How Do I Calculate Proportions Of Data Subsets? -

i've got code below need with. i'm asking data science coursera class "are americans financial satisfaction affected previous year's annual s&p500 gain/loss?". i'm trying plot graph amount of observations either satisfied or more or less satisfied, against entire population (a proportion) y axis, , "percentchange" x-axis. posted entire code further down, in case necessary understand i'm trying do. of these observations in same table "finalresults" , listed under variable column categorical, named "financialsatisfaction" . i'm not sure go here, big problem i'm having how calculate proportions based on "percentchange" in final results table. right below had tried, way off. need filter satisfaction proportions year, x-axis each year's percentage change. appreciated, near knowledgeable enough r figure out. satisfied <- subset(finalresults, financialsatisfaction == "satisfied") moreor...

If i update wordpress would i lose my custom made theme -

i looking develop own wordpress theme. if there wordpress update, lose theme , changes? thanks absolutely not. wordpress updates won't touch in theme directory, assuming you've built custom theme. if modifying 1 of default themes directly (e.g. twentyfourteen) might updated if update themes. in case you'd want using child theme. but question sounds you're talking custom theme, not overwritten. here's more information on wordpress updates: http://codex.wordpress.org/updating_wordpress

ruby - Best practice for ordering values in an ActiveRecord database by a 'given value' of string in Rails? -

i'm sure common issue when working databases, i'm trying set activerecord database in rails (although think apply database systems), can order rows based on value assign strings. for example, i'd order items based on common less common moderate rare none i can think of few ways it, each 1 ends seeming little messy. hoping common enough issue there established best-practice going this. it looks need enum : enum status: [:none, :rare, :moderate, :less_common, :common] after have methods item.none? , item.status #=> none etc. using enum should create integer field in table, , each status saved integer none -> 0 , rare -> 1 etc. explicitly map relation between attribute , database integer. for sorting status in case write: yourmodel.all.order(:status)

java - How to create an arraylist from a file where the input for the program is IntegerType? -

forgive me if may seem elementary/answered not understanding how apply program. i'm trying create program accepts array of either integers or strings text file sorted other classes isbetterthan() method in sort classes. how can accept input text file line line create array of integertype or stringtype? (integer/string , file user input.) as sits, i'm getting error either "no suitable method" array class or "incompatible types". thanks. import java.util.arraylist; import java.util.scanner; import java.io.*; public class insert { public static void main(string[] args) throws ioexception { //variables string filename; integertype line; arraylist<integertype> alist = new arraylist<integertype>(); //ask file scanner scan = new scanner (system.in); system.out.print ("enter pathname of input file: "); filename = scan.nextline(); scanner s = new scanner(n...

Using strings in C++ -

i made program in java new in c++ , using strings has been imposible. wondering if point me in direction me "translate" program c++. how use strings , maybe see in code worth mentioning. note: not asking of direct translation, info me it, code reference. import java.io.bufferedwriter; import java.io.outputstreamwriter; import java.util.scanner; public class dragoncurve{ public static void main(string[] args){ try{ scanner sc = new scanner(system.in); bufferedwriter log = new bufferedwriter(new outputstreamwriter(system.out)); int n; while((n = integer.parseint(sc.nextline()))!=-1){ log.write(dragon(n)+"\n"); } log.flush(); }catch(exception e){ e.printstacktrace(); } } public static string dragon(int n){ if(n>2){ string aux = dragon(n-1); return aux+"l"+reverse(aux); }else if(n==2) return "llr"; else if(n==1) ...

java - Finding the middle letter and make it uppercase.. am stuck and the end .. :( -

here finding middle letter of each element of array , making upper case , merge it'll give me result e:g- {boy, india, apple} following code trying till now. public class findmiddle { public static void main(string[] args) { arraylist<string> al = new arraylist<string>(); al.add("boy india apple"); string str[] = al.toarray(new string[al.size()]); string newar[]; string delimiter = " "; newar = str[0].split(delimiter); (int = 0; < newar.length; i++) { char[] c = newar[i].tochararray(); (int j = 0; j < c.length; j++) { if (j == c.length / 2) { c[j] = character.touppercase(c[c.length / 2]); system.out.println(c[j]); } newar[i] += c[j]; } } } } it's giving me o d p. i want them merged original elements boy india apple. that...

rstudio - Applying for loop in R to compute frequency distribution -

Image
suppose have data frame several categorical features. how compute freq distribution table using loop instead of finding individual distributions i used following code: data b c 1 class 1 1 m 2 class 2 0 f 3 class 3 0 m 4 class 1 1 f 5 class 1 1 f 6 class 2 1 m 7 class 1 0 f 8 class 1 0 f 9 class 2 1 m 10 class 2 1 m 11 class 3 1 f 12 class 3 0 f >b<-data$b >b.freq<-table(b) >b.freq 0 1 5 7 i want variables in larger set loop. please help thanks if want apply table function columns, can use lapply : > lapply(data, table) $a class 1 class 2 class 3 5 4 3 $b 0 1 5 7 $c f m 7 5 update: how create plots: par(mfrow = c(1, length(data))); lapply(data, function(x) barplot(table(x)))

php - fwrite adds an empty line at textfile -

i have problem fwrite . do. data textfile print table. after print values user should able select data should deleted (i key). when he/she clicks on delete file post key has deleted. of works. update array deleting key , works. data has rewritten textfile file adds space causes array have "undefined offset" error. have rid of blank line. code : <?php // opening required file include("deletefunc.php"); $obj = new deletefunc(); $result = $obj->getmedata(); // posted value (the key has deleted array) $deletekey = $_post['rownumber']; $updatearray = array(); for($i=0; $i<count($result); $i++){ if($i==$deletekey){ } else{ $updatearray[$i] = $result[$i]; } } var_dump($updatearray); // deleting data form textfile (replacing) $filename="phones.txt"; $file = fopen($filename,"w"); foreach($updatearray $row){ fwrite($file, $row); } ?> this guess : your problem comes fact element (exce...

Cordova, Phonegap Crash Reports -

i'm experiencing random crashes cordova , having problems replicating it, know if it's possible log crash reports external server? thanks much. try splunk mint ( bugsense) => https://mint.splunk.com/ all uncontrolled crashes can viewed in mint console. example (put mint libraries in path). there available in ios , possible trace html5 events. package edu.esade.yourapp; import android.os.bundle; import org.apache.cordova.*; public class yourapp extends cordovaactivity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); mint.initandstartsession(this, mint_api_key); super.init(); // set <content src="index.html" /> in config.xml super.loadurl(config.getstarturl()); //super.loadurl("file:///android_asset/www/index.html"); } }

php - CI routing $this->agent->is_mobile() -

is there way in ci routing file can find out if view using mobile? and if rotate them different page? i've got 2 sets of controllers 1 mobile , 1 desktop i'd urls same. i've tried adding following code routes config file i'm getting error... am thinking totally wrong? $this->load->library('user_agent'); if ($this->agent->is_browser()) { $route['default_controller'] = "index"; } elseif ($this->agent->is_mobile()) { $route['default_controller'] = "m/index"; } the error i'm getting undefined property: ci_router::$load from examining ci system files, appears loader class loaded after router class, $this->load doesn't exist yet. check out ci hooks, though: https://ellislab.com/codeigniter/user-guide/general/hooks.html in addition, might try using head.js ( http://headjs.com/ ) , defining screen widths responsive design. enables build web site , change css chang...

html - CSS presedence of selector over class -

.formwrap input[type="text"] { font-size: 12px; } .bigger { font-size: 14px } <div class="formwrap"> <input type="text" class="bigger" /> </div> why above not make text of input field 14px? when using input[type="text"] selector how can target particular class child of formwrap ? is there better method give inputs particular style able make adjustments inputs (hopefully based on class)? the first selector has higher specificity .bigger class. to increase specificity of .bigger class, this: .formwrap input[type="text"]{ font-size: 12px; } .formwrap input[type="text"].bigger{ font-size: 14px } or (not recommended): .bigger{ font-size: 14px !important; }

php - Issue with session_regenerate_id and Chrome prefetch/render -

i have issue session functionality , way chrome prefetching/rendering. attempting interface piece of forum software (esotalk) custom laravel 4.3 app. have authentication event listeners cause laravel create php session (in addition built in laravel session) allows forum , app share authentication details. on access of forum, , if user not logged in - shared information exists (i.e. user has logged in on laravel app), forum log in user using information available in session. for part works fine except chromes prefetching appears breaking things. if monitor forum using debugger can see when type out forum url before hit enter chrome access forum. following through debugger can see needs , successful in logging in. final step forum regenerates session id stop hijacking. breaks. looks chrome ignores new session id (sent via http setcookie header) when hit enter go forum (and make whole new request) using original session id. id doesn't exist set new 1 , consequently lose logged i...

qt - QMdiArea: First tab works fine, second tab's content is way too small -

Image
situation : central widget of application have qmdiarea in tabbed mode (wrapped in custom class inherited qmdiarea ). when add first qmdisubwindow via addsubwindow() still fine, meaning window , contents maximized take space of qmdiarea . however, add second sub window, following problem arises: problem : content of second window not displayed, instead content first continues (despite fact second tab visually has focus), reduced in size. takes few pixels. if switch first sub window/tab (either clicking size-reduced widget automatically goes max size or selecting first tab header) , selecting 2nd again, fine = widget/editor of 2nd tab displayed , maximized. but until close second tab, in case content first displayed (as expected), again in small size! screenshot: another related test case: 1st tab created , displayed full size expected. if resize overall qmainwindow , faint border appears around widget in tab. appears in mixed state between maximized , normal mode border...

c - 3d array print address after deference twice? -

why 3d array print address after being dereferenced twice? please me understand code posted below, (assume array begins @ location 1002). int main() { int a[2][3][4]={ { 1,2,3,4, 4,5,6,7, 9,1,1,2 }, { 2,1,4,7, 6,7,8,9, 0,0,0,0 } }; printf("%u %u %u %u\n",a,*a,**a,***a); //a == *a == **a, print address 1002. why? } **a has type int * , points first int in 3d array *a has type int (*)[4] , points first row of 3d array a has type int (*)[3][4] , points first 2d array in 3d array &a has type int (*)[2][3][4] , points whole 3d array so pointers point same address. it's type of pointer different. following code may illustrate point. int main( void ) { int a[2][3][4]={ 1,2,3,4, 4,5,6,7, 9,1,1,2, 2,1,4,7, 6,7,8,9...

java - Every time I write to excel, it overwrites the entire file with a blank file - PUZZLED -

what trying ontestfailure (testng) trying write pass/fail specified column. in below code, wanted little test write fail specified cell. what's happening is, instead of writing pass/fail specified cell, literally overwrites entire file , erases of data , puzzled why that's happening. have looked on here , googled cannot find answer. below following code: @override public synchronized void ontestfailure(itestresult tr){ try { workbook workbook = workbook.getworkbook(new file(testdata), workbooksettings); writableworkbook wb = workbook.createworkbook(new file(testdata), workbook); writablesheet ws = wb.getsheet("ordereditqa3"); label label = new label(5,2, "fail"); ws.addcell(label); wb.write(); } catch (ioexception e) { e.printstacktrace(); } catch (biffexception b){ system.out.print("error!"); } catch (writeexception we){ system.out.print(""); ...

java.util.scanner - How do you input data into a constructor from scanner? -

i trying take constructor(string, string, double) , set value in scanner input. appreciated. code list below. my programs can assign values put in, want able assign them keyboard , use 1 constructor method accomplish this. thanks i have broken 2 classes: import java.util.scanner; public class employeetest { public static void main(string [] args) { scanner input = new scanner(system.in); employee employee1 = new employee("james", "ry", 3200); employee employee2 = new employee("jim" , "bob" , 2500.56 ); system.out.println("what employyee 1's first name? "); employee1.setfname(input.nextline()); } } class employee { private string fname; private string lname; private double pay; public employee(string fname, string lname, double pay) { this.setfname(fname); this.lname = lname; this.pay = pay; system.out.println(...

c++ - How to have more than one examples in Doxygen? -

i using doxywizard. under expert tab, in input item-list, @ example_path, have included 2 paths, lead 1 .cpp file, each. however, in generated documentation, see one, regardless of order. in doxyfile, see this: example_path = ../../../inria/rkd/samaras/final/code/main_boost.cpp \ ../../../inria/rkd/samaras/final/code/main.cpp what missing? if there solution editing doxyfile directly, interested. example_path lists directories store example files. if want add example specific class, have reference in header file of class. example_path = ../../../inria/rkd/samaras/final/code /** \example main_boost.cpp * example of how use main_boost. */ /** \example main.cpp * example of how use main. */ see more info here: http://www.stack.nl/~dimitri/doxygen/manual/commands.html#cmdexample