Posts

Showing posts from September, 2012

android - Image not sized correctly when loading -

Image
i using parse (i know it's dying service) fetch , store images me. included in these authenticated facebook user's profile pictures. pictures 50x50. if download image locally, throw in drawables folder, , load via xml ( android:src="@drawable/dummy" ) result. it's want: but when load image parse , load circularimageview, result: as can see, head shrunk :( here's code: the circularimageview in xml: <de.hdodenhof.circleimageview.circleimageview android:id="@+id/main_list_profile" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginleft="@dimen/activity_horizontal_margin" android:layout_marginright="@dimen/activity_horizontal_margin" android:layout_margintop="@dimen/activity_vertical_margin" android:layout_marginbottom="@dimen/activity_vertical_margin" android:src="@

c++ - Understanding a loop output -

can explain me why output follows? why loop runs second time after (int i) gets value 9, not less 5? it seems if (int i) greater 5 still adds 3 body won't run second time. why? #include <iostream> using namespace std; int i=0; int main() { for(;i<5;i+=3){ i=i*i; } cout << << endl; //output: 12(i) it works way, more or less: i = 0 < 5 ? yes, keep on i*i = 0 i+=3 => ==3 < 5 ? yes, keep on i*i = 9 i+=3 => 12 < 5 ? no, exit loop you write for(initialization; condition; excuteattheendofcycle) : initialization executed once @ beginning, condition evaluated before each cycle, excuteattheendofcycle ( i+=3 , in case), it's executed @ end of each cycle, before further evaluation of condition

unity3d - 'Input' does not contain a definition for 'GetMouseButton' how is this possible? -

i've wanted try developing touch screen reason said: 'input' not contain definition 'touched' then tried old fashioned way, worked me million times, doesn't. 'input' not contain definition 'getmousebutton' does know source of problem? void update() { if(input.getmousebutton(0)) debug.log("pressed left click."); if(input.getmousebutton(1)) debug.log("pressed right click."); if(input.getmousebutton(2)) debug.log("pressed middle click."); } oh god, stupid. i've reinstalled unity, vs , maybe twice. , didn't see caused problem... problem named script 'input' oh gooood

asynchronous - Scala how can I return an async string back -

i have login form attempts login users email , password , done in async way. first check if email or password fields blank , if want return back. thing new scala , not know how return string in asynchronous way. code def login= action.async {implicit request=> case class login(password:string,email:string) val formm = form(mapping( "email"->text, "password" -> text)(login.apply)(login.unapply)) val getdata= formm.bindfromrequest.get val email = getdata.email var password = getdata.password var idd = -1; if (email.isempty() || password.isempty()) { // how can make ok() return async ok("empty fields"); } else { val tryout = sql"""select id,password profiles email=$email , password=$password;""".as[(int,string)] db.run(tryout).map { result => ok(result.tostring()) } } my problem ok() in

c# - Downloading string from URL and loading ListBox with the returned data? -

i'm downloading string file website, need information , load listbox text, unfortunately im getting error every time click in button event. my code: var httpclient = new httpclient(); var text = await httpclient.getstringasync(@"http://photo-51.netau.net/changelog"); streamreader sr = new streamreader(@text, system.text.encoding.default);//here have invalid path character error string line; while ((line = sr.readline()) != null) { listbox1.items.add(line); } i have , invalid character in path. how can fix it? streamreader you're using expects path file read. @text you're passing treated path file, that's why exception. you can reference msdn, streamreader constructor. can see, string parameter defined the complete file path read. now there multiple ways of reading string line line, i'll put here 1 requires least changes in original code

c++ - What is Happening to my Sieve of Eratosthenes Program? -

Image
i'm trying solve challenge question of summing primes under 2 million. knowing full naive approach take long, decided implement sieve of eratosthenes counter record sum. works 512500 after receive error: is input size big code handle? if that's case, how can improve code avoid error. if that's not possible, better algorithm implement these purposes? here header code: #ifndef numbersieve_h #define numbersieve_h class numbersieve { public: numbersieve(); virtual ~numbersieve(); int eratosthenessieve(int num); private: void setsieve(int nums[],int size); int current_prime; int current_prime_address; void updatesieve(int nums[],int size,int start); bool updatecurrentprime(int nums[],int size,int start); bool notcomplete; void printsieve(int nums[],int size); int primesum; }; #endif // numbersieve_h here implementation file: #include "numbersieve.h" #inclu

math - Java confusion initializing variables within different cases -

my source code below attempting create program calculate area diameter , circumference of circle when user enters a,c, or d. want return correct response depending on user input. managed 3 return within first case earlier separating them proved difficult ideas? import java.util.scanner; public class test { public static void main(string[] args) { scanner sc = new scanner(system.in); system.out.print("this program determine area, circumference or diameter circle. type area c circumference , d diameter"); // prompt user input of capitol character while (!sc.hasnext("[a-z]+")) { system.out.println(sc.next().charat(0) + " not capital letter! non alphanumeric values not permitted."); // error response unnaceptable character a-z specified range of acceptable characters } char c = ' '; c = sc.next().charat(0); // looking through user input @ character @ position 0 switch (c

express - Node.Js: Signed cookie can't be found -

using mean environment (with express 4), create cookie this. //webserver.js app.use(cookieparser(„somesecretkey“)); //somescript.js res.cookie(‚testcookie‘, ‚testvalue', {signed: true, maxage: 999999, httponly: true}); in script, try check existence of cookie this. //someotherscript.js if(req.cookies.testcookie){ console.log("cookie exists“+req.cookies.testcookie); }else{ console.log(„no cookie“+req.cookies.testcookie); //always undefined } i checked browser cookie , exists console keeps logging there no cookie (cookie undefined) when press refresh or visit page. change cookie unsigned , remove secret key, can access it!? why can’t cookie found once signed? the expressjs documentation res.cookie tells us: when using cookie-parser middleware, method supports signed cookies. include signed option set true . res.cookie() use secret passed cookieparser(secret) sign value. res.cookie('name', 'tobi', { s

precision - Efficiently Store Decimal Numbers with Many Leading Zeros in Postgresql -

Image
a number like: 0.000000000000000000000000000000000000000123456 is difficult store without large performance penalty available numeric types in postgres. question addresses similar problem, don't feel came acceptable resolution. 1 of colleagues landed on rounding numbers 15 decimal places , storing them as: 0.000000000000001 so double precision numeric type can used prevents penalty associated moving decimal numeric type. numbers small purposes more or less functionally equivalent, because both small (and mean more or less same thing). however, graphing these results , when large portion of data set rounded looks exceptionally stupid (flat line on graph). because storing tens of thousands of these numbers , operating on them, decimal numeric type not option performance penalty large. i scientist, , natural inclination store these types of numbers in scientific notation, does't appear postgres has kind of functionality. don't need of precision in number, wa

Python - exact same loop works inconsistently 'int' object is not iterable - not iterating over int -

i need run loop twice in function 2 different things. works fine in 1 place fails run in other, though there no discernible difference between two. this loop for each in problem.getsuccessors(coord): #each in [((x,y), 'dir', num)...] it runs fine second time, giving me correct solution, def recursivedfs(coord, stck, actions, visited, problem): repush = false print "iterate", problem.getsuccessors(coord) each in problem.getsuccessors(coord): #each in [((x,y), 'dir', num)...] if not each[0] in visited: repush = true if repush: stck.push(coord) if problem.isgoalstate(coord): print coord, " goal state" return stck else: if coord in visited: print "revisited ", coord else: visited.append(coord) print "visited ", coord print "iterate", problem.getsuccessors(coord) each in pr

c - strtol not changing errno -

i'm working on program performs calculations given char array represents time in format hh:mm:ss . has parse individual time units. here's cut down version of code, focusing on hours: unsigned long parsetime(const char *time) { int base = 10; //base 10 long hours = 60; //defaults out of range char localtime[bufsiz] //declares local array strncpy(localtime, time, bufsiz); //copies parameter array local errno = 0; //sets errno 0 char *par; //pointer par = strchr(localtime, ':'); //parses nearest ':' localtime[par - localtime] = '\0'; //sets ':' null character hours = strtol(localtime, &par, base); //updates hours parsed numbers in char array printf("errno is: %d\n", errno); //checks errno errno = 0; //resets errno 0 par++;

node.js - socket.io-redis not forwarding messages to sockets on a namespace -

i have solution application emitting messages using socket.io-emitter , socket server handling messages. the socket server receives messages client browser without issue not pickup messages other application sent on redis adapter. i've debugged redis adapter , can see messages being received , can see associated correct namespace. appear not firing socket.on() event the server code has more going on boils down following io.adapter(redisio({host: redishost, port: redisport})); io.of('/mynamespace').on('connection', function(socket) { // message never gets fired socket.on('other-server-message',dosomething); // message works fine socket.on('message-from-browser-client',dosomethingelse); } ); there isn't documentation around great i realised issue was. misunderstanding socket.io-emitter doing. i sending message emitter , trying capture on server , push out clients. emitter broadcastin

python - Email not sending with django 1.9 -

i've been trying email working project i've been working on, believe it's configured correctly, here settings.py, command i'm running, , traceback when stop it. email configuration: #email configuration default_from_email = #email address server_email = #email address email_use_tls = true email_host = "smtp.gmail.com" email_port = 587 email_host_user = #email address email_host_password = "**********" command: send_mail("test", "test", "from_email@gmail.com", ["to_email@gmail.com"], fail_silently=false) traceback: ^ctraceback (most recent call last): file "<console>", line 1, in <module> file "/home/django/djangoapps/connectedfeedback/py3_env/lib/python3.4/site-packages/django/core/mail/__init__.py", line 61, in send_mail return mail.send() file "/home/django/djangoapps/connectedfeedback/py3_en

Finding a object in a HASH_TABLE using item feature on EIFFEL -

i having problem comparing 2 objects in hash_table person class attributes such name, b-day, status of relationship, spouse name, spouse id. composed of attributes code: list: hash_table[person, integer_64] put(id1, id2: integer_64) local p1, p2: person p1 := model.list.at(id) -- or p1 := model.list.search(id) p1 := model.list.found_item -- same error below end error: source of assignment not compatible target. the features used return "detachable g" i think should doing "if attached" ensure item feature returns correct object type , assign? i'm not sure how cast object though. the error triggered calling above feature the reason need these functions work can sort easier the features return detachable g because possible no element found. therefore need use object tests, e.g. if attached model.list [id1] p1 , attached model.list [id2] p2 ... -- use p1 , p2 end

css - Extend placeholder selector in Stylus -

Image
in sass, can @extend %placeholder selectors place of selectors tree, such as: .category { .category-dropdown { button { visibility: hidden; @extend %category-hovered-button; } } &:hover { %category-hovered-button { visibility: visible; } } } working on lib sass (v3.2.5) but in stylus, can't @extend similar way. i think it's because of different nature of stylus placeholder selectors. so how can dry thing in stylus? tried replace $ . , , tried move &:hover subtree before .category-dropdown . here's possible solution: .category { $prefix = selector() hovered() { /{$prefix}:hover {selector('^[1..-1]')} { {block} } } } category-hovered-button() { +hovered() { +cache() { visibility: visible } } } .category-dropdown { button { visibility: hidden category-hovered-button() } } .category-other { {

Better way to perform multiple selects in one mysql query? -

i've got insert query contains several select statements. feel there's got better (more efficient, more optimized, etc) way this. suggestions? insert log (logtype, subtype, src_ip, dst_ip, dst_port, query) values (2, 1, (select src_ip query uid="123"), (select dst_ip query uid="123"), (select dst_port query uid="123"), (select query query uid="123")) insert log (logtype, subtype, src_ip, dst_ip, dst_port, query) select 2, 1, src_ip, dst_ip, dst_port, query query uid="123"

r - Error when installing swirl in RStudio 3.1.2 -

hey tried installing swirl running following command: install.packages("swirl") i got following error: ------------------------- anticonf error ------------------------- -- configuration failed because libcurl not found. try installing: * deb: libcurl4-openssl-dev (debian, ubuntu, etc) * rpm: libcurl-devel (fedora, centos, rhel) * csw: libcurl_dev (solaris) if libcurl installed, check 'pkg-config' in path , pkg_config_path contains libcurl.pc file. if pkg-config unavailable can set include_dir , lib_dir manually via: r cmd install --configure-vars='include_dir=... lib_dir=...' -------------------------------------------------------------------- error: configuration failed package ‘curl’ * removing ‘/home/franco/r/x86_64-pc-linux-gnu-library/3.1/curl’ warning in install.packages : installation of package ‘curl’ had non-zero exit status * installing *source* package ‘rcurl’ ... ** package ‘rcurl’ unpacked , md5 sums checked checking curl-

Matlab Function and Input -

function area = traparea(a,b,h) % traparea(a,b,h) computes area of trapezoid given % dimensions a, b , h, , b % lengths of parallel sides , % h distance between these sides % compute area, suppress printing of result area = 0.5*(a+b)*h; this example. know how declare values suppose a=5,b=4,h=8 in seperate .m file , calling original function ie, traparea, using .in statement? example .in a=5 please help if understand, want create script file. create filename called "myscript.m" (pick name like), , place in same folder "traparea.m" located. then, in file "myscript.m", put following: a = 5; b = 4; h = 8; result = traparea(a,b,h) % 1 way show result fprintf('my result %f\n', result); % way display result once have created 2 files "myscript.m", , "traparea.m", type "myscript" @ command line.

php - Can't sort query results in ascending order -

i'm trying sort following select query in ascending order meds_name, can't figure out i'm doing wrong. it's instead sorting names start lower case letters first, , following start upper case. query works when interpret , execute in mysql, not in yii. can see i'm going wrong: $specs = yii::app()->db->createcommand() ->select("im.*,m.name meds_name,mf.name meds_freq_name, mr.name meds_route_name,mu.name meds_unit_name, concat_ws('/',im.meds_startmm,im.meds_startyyyy) meds_startdate, concat_ws('/',im.meds_endmm,im.meds_endyyyy) meds_enddate") ->from('indiv_meds im') ->leftjoin('meds m', 'im.meds_name=m.id') ->leftjoin('med_freq mf', 'im.meds_freq=mf.id') ->leftjoin('med_route mr', 'im.meds_route=mr.id&#

java - Mirroring an array -

i trying mirror array. in other words, if create array looks (the user gives size): 0 2 4 6 7 8 9 10 11 12 after mirroring, should this: 0 2 4 2 0 8 9 10 9 8 however, doesn't work when make 3 x 5 array or bigger. repeats same number this: 0 2 4 2 2 8 9 10 8 8 this code far: import java.util.scanner; public class mirror { public static void main (string [] args) { scanner kb = new scanner (system.in); system.out.println("please enter number of rows: "); int rows = kb.nextint(); system.out.println("please enter number of columns:"); int columns = kb.nextint(); int [][] mirror = new int [rows][columns]; int sum =0; (int r = 0; r<mirror.length; r++) { (int c = 0; c<mirror[r].length ; c++) { mirror[r][c]= sum; sum= sum+2; } } (int r = 0; r<mirror.length; r++) { (int c = 0; c<mirror[r].length ; c++) { system.ou

c# datagridview checkbox check if other column value is 0 -

Image
i have datagridview checkbox column(header: status) , textbox column(header: quantity). want check automatically checkbox column if quantity 0. loop through rows if datagridview this: foreach (datagridviewrow row in datagridview1.rows) { //check column 3 quantity if (row.cells[3].value.tostring() == "0") { //get checkbox in column 1 , cast checkbox datagridviewcheckboxcell cell = row.cells[1] datagridviewcheckboxcell; cell.value = cell.truevalue; } }

ruby on rails - Rake db:migrate duplicate with Devise -

so i'm having issues migrations in rails.. have 2 migrations 1 add users table , 1 add devise users... now im getting error when try run rake db:migrate activerecord::statementinvalid: sqlite3::sqlexception: duplicate column name: email: alter table "users" add "email" varchar default '' not null which tells me both migrations trying add column email users table.. user table create migration class createusers < activerecord::migration def change create_table :users |t| t.string :name t.string :email t.string :password_digest t.timestamps null: false end end end devise added users migration class adddevisetousers < activerecord::migration def self.up change_table(:users) |t| ## database authenticatable t.string :email, null: false, default: "" t.string :encrypted_password, null: false, default: "" ## recoverable t.string :reset_pa

java - Is it unnecessary to verify the same methods as the methods being mocked in Mockito? -

i see same methods being verified methods being mocked in mockito (example below). there added benefit call mockito.verify() in these cases? //mock method fooservice fs = mock(fooservice.class); when(fs.getfoo()).thenreturn("foo"); //method under test fs.dosomething(); //verify method verify(fs).getfoo(); the method should fail if fs.getfoo() not called. why call verify ? see benefit if need use argumentcaptor in verify assert parameters; besides argumentcaptor case, unnecessary? the mockito documentation repeatedly says redundant. appears verbatim both in verify(t) 's javadoc multiple single-line comments in code block in mockito's main class javadoc section 2 : although possible verify stubbed invocation, it's redundant. if code cares get(0) returns, else breaks (often before verify() gets executed). if code doesn't care get(0) returns, should not stubbed. not convinced? see here . note linked article, " asking , t

c - sscanf to convert to a long integer -

can explain output of lines below: sprintf(tempstr,"%s%2s%s",year_str,month_str,day_str); count=sscanf(tempstr,"%ld%s",&tempout,other); it creates numeric date, using day, month , year values. but, how convert numeric value long integer ? for e.g.: can tell me, if year , month , day 2016 , 02 , , 08 , output value in tempout . here, how input taken: char date_str[20]; char day_str[2]; char month_str[2]; char year_str[2]; time_t now; struct tm* current_time; /* current time */ = time(0); /* convert time tm structure */ current_time = localtime(&now); /* format day string */ sprintf(day_str,"%02d",current_time->tm_mday); /* format month string */ sprintf(month_str,"%02d",current_time->tm_mon + 1); /* format year string */ sprintf(year_str,"%d",current_time->tm_year); /* assemble date string */ sprintf(date_str,"%s%

wordpress - Exact same PHP only produces correct output once instead of twice -

the plugin being used events calendar pro, , website wordpress. this code below isn't linking each 'past event' image it's relevant event. instead links homepage. the titles of events link correct place however, same code being used in both places, i'm stumped. any ideas? <?php foreach( $events $event ) : ?> <div class="tribe-mini-calendar-event"> <div class="list-info"> <div class="tribe-events-event-image"> <a href="<?php tribe_event_link( $event ); ?>"><?php echo tribe_event_featured_image( $event, 'medium' ); ?></a> </div> <h2 class="tribe-events-title"><a href="<?php tribe_event_link( $event ); ?>"><?php echo $event->post_title; ?></a></h2> <div class="tribe-events-duration"> <?php echo date_i18n( get_option('

model - Laravel 5: how to safely override the default User::create() for two tables? -

with laravel 5.2, have guest user provide first , last names when signing up. first_name , last_name fields different model people that's table extended profiles: users id email username people user_id first_name last_name profile ... in default authcontroller , calls create method of user class this: /** * create new user instance after valid registration. * * @param array $data * * @return user */ protected function create(array $data) { return user::create([ 'name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password']), ]); } but should overwrite method creates user adding data above 2 tables? you can add 1 one relation user people model. once create user, can call user , add details follows: $user->people()->create(['first_name]=>$request->input('first_name')); refer

Excel weekly fortnightly monthly budget if statement -

my spread sheet has columns expenses weekly, fortnightly , month. assist myself trying simplify weekly amount using if statement. example weekly (a1), fortnightly (b1), monthly (c1). d1 needs end weekly amount overall. a1 $10 if has value show value otherwise leave blank because either b1 or c1 have value. b1 $30 if has value divide 2 , show otherwise leave blank because a1 or c1 has value. c1 $85 if has value multiply 12 , divide 52 , show otherwise leave blank because a1 or b1 has value. in advance this compound if should need (parens emphasize calculation , not necessary): =if(b2>0,(b2),if(c2>0,(c2/2),if(d2>0,(d2*12/52),"no values"))) propagate down through column want normalized weekly expense , should result in this: weekly fortnightly monthly normalized item 10.00 10.00 item b 30.00 15.00 item c 85.00 19.62 item d

swift - Implement Alamofire into DDD structure -

qustion i have following structure class uitableviewcontroller (presentation) -> class contents(domain) -> class api(infrastructure) contents class gets raw data via api class , forms contents , passes uitableviewcontroller. i use alamofire networking in api class. i’ve looked through stackoverflow , found examples uitableviewcontroller directly accesses api class. direct access presentation layer infrastructure layer should not do. how return value alamofire how achieve implementing alamofire ddd structure? i want achieve this uitableviewcontroller class mytableviewcontroller: uitableviewcontroller { var contents: contents? override func viewdidload() { super.viewdidload() let priority = dispatch_queue_priority_default dispatch_async(dispatch_get_global_queue(priority, 0)) { // task self.contents = contents.get("mycontents") self.tableview.reloaddata() } } } contents class contents: nsobject { stat

arcgis - How to Display Show Attachment in Info Window -

i using below code display identifier popup.if click on particular point display information point in info window(popup).but if specify show attachments true not display attachments.in map server have image points.so need display info window image. map.on("load", mapready); var parcelsurl = "my map server"; //map.addlayer(new arcgisdynamicmapservicelayer(parcelsurl, // { opacity: 20 })); function mapready() { map.on("click", executeidentifytask); //create identify tasks , setup parameters identifytask = new identifytask(parcelsurl); identifyparams = new identifyparameters(); identifyparams.tolerance = 3; identifyparams.returngeometry = true; identifyparams.layerids = [0]; identifyparams.layeroption = identifyparameters.layer_option_all; identifyparams.width = map.width; identifyparams.height = m

C++ removing node from back --singly linked list -

why won't code delete last element of linked list? create current pointer transverse through list , break out of loop..(next point within struct called card_node). should simple answer, not sure why won't delete last node in list" card_node *current; current = front; while ( current->next->next != null){ { current = current-> next; } card = current->next->card; return a; delete current->next; current->next = null; } return current->next->card; // return !! delete current->next; // never executed current->next = null; update as comment below ask further input, here update tried keep original principles. if (front == nullptr) // special handling of empty list { // nothing return - add error handling - throw exception perhaps // or: return ???; // default card perhaps } if (front->next == nullptr) // special handling of list 1 element { // 1

copy/move all databases from one server to another mysql -

currently have test server 'x' has many databases data in it.i want copy data server ie 'y'.both on same mysql version.i read posts regarding same.i know how create sql file , run it.but there other quick way without creating sql files databases.should use replication?is replication applicable in scenario because there no master/slave configratn here. you can use below 2 approaches- master/slave: less downtime hardly 1 10 minutes. slave catch master can migrate site/app new server. binary copy: can copy binary files mysql data directory , move new server data directory. take time copy , move date 1 server server. note: before binary copy need take full dump backup in case of issue not loosing data.

sql server - SQLServer 2008 UPSERT merge without repeating the values -

i have created pseudo upsert statement works, due fact data insert or update might quite large, in order reduce network bandwidth, define data updated or inserted once. for brevity, in example have incuded 2 fields , both have short data length, in real system there may dozens of fields, , of them may long. merge part t using (select id) s on(s.id = t.id) when matched update set id='abcd-000',description='new description' when not matched insert (id,description) values('abcd-000','new description'); in example, id unique, if therecord exists should updated, if not exist new record should inserted. you can use this: merge part t using ( select 'abcd-000' id, 'new description' newdescription ) s on (s.id = t.id) when matched update set t.description=s.newdescription when not matched insert (id,description) values(s.id, s.newdescription); also, no need set id='abcd-000' on when mat

Deserialize complex JSON data in C# -

i'm amateur in c# programming. have json data looks following { type: "xxx", width: "xxx", datasource: { "chart": { "caption": "xxx" }, "data": [ {}, {} ] } } i'm having whole data escaped string. after unescape when i'm using javascriptserializer follows var data = ser.deserialize<dictionary<string, object>>(chartdata); i'm able "type", "width" as data["width"] data["type"] now have value of "caption". suggestion how that, believe dictionary structure need changed i'm stacked lack of knowledge in c# if know object's scheme man want create class represents in , deserialize json it: yourknownclass obj = jsonconvert.deserializeobject<yourknownclass>(json); console.writeline(obj.datasource.chart.caption.value); another option using dynamic type (there n

qt - How to catch the model update signal in ListView -

is there way catch model update signal in qml. here sample program. have rectangle on top of there listview. on mouse updating listmodel. code: rectangle{ id: root anchors.fill: parent listmodel { id: fruitmodel listelement { name: "apple" cost: 2.45 } listelement { name: "orange" cost: 3.25 } listelement { name: "banana" cost: 1.95 } } component { id: fruitdelegate row { spacing: 10 text { text: name } text { text: '$' + cost } } } listview { id: list anchors.fill: parent model: fruitmodel delegate: fruitdelegate onmodelchanged: { console.log(

html - Boostrap columns colliding -

whenever resize website mobile view of 320 x 480, 2 of columns filled text collide each other , mash text. tried doing without columns using "container-clearfix" didn't solve problem. the first image shows how website text looks on 320 x 480 small mobiles image 1 here js fiddle : http://jsfiddle.net/52vtd/14124/ #big-image { position: relative; z-index: -1; width: 100%; height: 600px; background-repeat: no-repeat; background-size: cover; } .col-md-12 { padding-left: 0px; padding-right: 0px; } #text-four { position: absolute; overflow: hidden; text-align: center; bottom: 450px; vertical-align: middle; left: 20%; } #text-four-p { position: absolute; overflow: auto; bottom: 830%; left: 15%; text-align: center; } .us { position: absolute; overflow: auto; bottom: 250%; left: 15%; text-align: center; } .eu { position: absolute; overflow: auto; bottom: 250%; right: 15%;

java - How to reflect changes in preferences to class? -

i created simple class "user" has attribute string username . i'm assuming since android uses java, can create custom classes , it'll use them accordingly. in settingsactivity.java, have: protected void onpostcreate(bundle savedinstancestate) { super.onpostcreate(savedinstancestate); addpreferencesfromresource(r.xml.pref_general); sharedpreferences sharedpref = getpreferencescreen().getsharedpreferences(); edittextpreference edittextpref = (edittextpreference) findpreference("username"); edittextpref.setsummary(sharedpref.getstring("username", "default")); //sharedpref.registeronsharedpreferencechangelistener(this); } public void onsharedpreferencechanged(sharedpreferences arg0, string arg1) { // current summary preference pref = findpreference(arg1); if(pref instanceof edittextpreference){ edittextpreference etp = (edittextpreference) pref; pref.setsummary(etp.gettext());

oracle11g - instr() in oracle 11g -

sql> select instr('stringrings','rin',-4,1) dual; instr('stringrings','rin',-4,1) ------------------------------- 7 when provide search position -4 , searches backward right left, returns match position 7 though whole pattern not match given search starting position. here partial pattern matches in original string. sql> select instr('stringrings','rin',-5,1) dual; instr('stringrings','rin',-5,1) ------------------------------- 7 here same result... sql> select instr('stringrings','rin',4,1) dual; instr('stringrings','rin',4,1) ------------------------------ 7 but here, in positive direction search ignores partial pattern match , gives position exact pattern matches.. can explain me? why double standards? no double standarts: select instr('stringrings','ri

Saving zip list to csv in Python -

how can write below zip list csv file in python? [{'date': '2015/01/01 00:00', 'v': 96.5}, {'date': '2015/01/01 00:01', 'v': 97.0}, {'date': '2015/01/01 00:02', 'v': 93.75}, {'date': '2015/01/01 00:03', 'v': 96.0}, {'date': '2015/01/01 00:04', 'v': 94.5} i have error: _csv.error: sequence expected my code here: import csv res = zip_list csvfile = "/home/stm/pycharmprojects/isbak_trafik/example.csv" open(csvfile, "w") output: writer = csv.writer(output, lineterminator='\n') writer.writerows(res) writer.writerows expects sequence of values writing single row csv file. using original code: import csv res =[{'date': '2015/01/01 00:00', 'v': 96.5}, {'date': '2015/01/01 00:01', 'v': 97.0}, {'date': '2015/01/01 00:02', 'v': 93.75}, {'

php - How can I make my query output the row value instead of the field value -

below code. ouputs field names instead of row values. please how can make output rows have on database? <?php $conn_error = "could not connect"; $correct = "all correct!"; $host = "localhost"; $username = "ifacool"; $password = "1234"; $mysql_db = "ifacool"; if (!mysql_connect($host, $username, $password) || !mysql_select_db ($mysql_db)) { die ($conn_error); } else{ echo $correct . '<br>'; } $query = "select 'firstname', 'password' ifacooltable id = 1 "; if ($query_run = mysql_query($query)) { while ($query_row = mysql_fetch_assoc ($query_run)){ $firstname = $query_row['firstname']; $password = $query_row['password']; echo $firstname . ' password ' . $password . ' exactly.<br>'; } } else { echo "query failed"; } ?> use backticks ` instead of single

Elasticsearch children-father issue with 'has_parent' -

having following mapping... curl -xput 'localhost:9200/myindex' -d '{ "mappings": { "my_parent": {}, "my_child": { "_parent": { "type": "my_parent" }}}}' ... following parent: curl -x put localhost:9200/myindex/my_parent/1?pretty=true' -d '{ "title" : "microsiervos - discos duros de 10tb", "body" : "empiezan sacar dd de 30gb en el mercado" }' and following children: curl -xput 'localhost:9200/myindex/my_child/2?parent=1' -d '{ "user": "pepe" }' if following has_child query: curl -xget 'localhost:9200/myindex/my_parent/_search?pretty=true' -d '{ "query": { "has_child": { "type": "my_child", "query" : { "query_string" : { "default_field" : "user&qu

sql - Oracle not able to insert exception into table -

i have below procedure trying track exceptions i_log table.to test whether working or not have made ora-00933: sql command not ended error in query trying insert i_option table. when run procedure dbms output line printing error below not getting inserted i_log table: others exception in ext_i_option - id:1000196-933----ora-00933: sql command not ended below procedure: create or replace procedure "ext_i_option"(in_id in number default 0) err_code varchar(100); err_msg varchar(100); in_event_id number; in_db_link varchar2(50); in_env_id number; l_sql varchar2(5000); l_sql1 varchar2(5000); begin i_row in i_cur loop l_sql2 := insert i_option(id) select distinct(so.id) ) icard i; end loop; exception when others err_code := sqlcode; err_msg := substr(sqlerrm, 1, 200); insert i_log (i_id) values (

c++ - Declare variable in global/function scope. Stack difference? -

why there different stack variables if declare them in global or function scope? 1 of 2 example crashes, because of stack overflow. one, define variable inside scope. does crash: constexpr size_t max = 1000000; // customise int main() { int arr[max]; return arr[max - 1]; } does not crash: constexpr size_t max = 1000000; // customise int arr[max]; int main() { return arr[max - 1]; } info: cygwin, gcc 4.9 edit: know, second example have memory in data segment. how big can data segment be? big heap area? the first 1 constexpr size_t max = 1000000; // customise int main() { int arr[max]; return arr[max - 1]; } you declare array in function, goes stack limited , cause stack overflow. the second 1 constexpr size_t max = 1000000; // customise int arr[max]; int main() { return arr[max - 1]; } you declare @ global, should accesible between function goes heap (rather big). not using stack here. source : static , global variable in memo

MySQL Workbench: Reconnecting to database when "MySQL server has gone away"? -

i have lot of tabs , queries open in mysql workbench. left open before went sleep, morning getting error mysql server has gone away when trying run queries. the database up, , able connect if open new connection on mysql workbench, current connection dead. how reconnect? i don't want open new connection have copy queries , tabs over. done it. query menu -> reconnect server

python - Name not definef error when using Class -

i facing issue code framed class. basically before file functions defined in it. so when trying execute file using command python filename.py, working fine needed. code sample follows: # getting tenant list # fetch creation_date of tenant if exists def get_tenants(): # fetch tenant list tenants_list = keystone.tenants.list() # fetch tenant id tenant in tenants_list: tenant_id = tenant.id . . . get_tenants() so shown in aboce code in file trying call get_tenants function, working fine needed no error. now have created class moved functions in same. above function rewritten follows now. def get_tenants(self): # fetch tenant list tenants_list = keystone.tenants.list() # fetch tenant id tenant in tenants_list: tenant_id = tenant.id then have called function follows: billing = billingengine() billing.get_tenants() but, getting error follows: root@devstack:/opt/open-stack-tools/billing# pyth

php - .htaccess in subfolders -

i read tons of topics here on so, reason not works me, , totally confused. know, mess something, cant figure what. i have site, , index.php calling router, , show content want. i've created admin' page, , want webserver use /admin/index.php every request starting /admin/ here try: rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^admin/(.*)$ admin/index.php?action=$2 [l,nc] rewriterule ^(.*)$ index.php?action=$1 [l] i echoing information both index.php see handles request. if writing http://localhost says frontend . when try http://localhost/admin/ says frontend again. if moving admin' line below first rule this: rewriterule ^(.*)$ index.php?action=$1 [l] rewriterule ^admin/(.*)$ admin/index.php?action=$2 [l,nc] then http://localhost/admin/ says admin good! but if try http://localhost/admin/users not there, because admin's router should handle that, says frontend . how should

android - Upload data to server in queue -

i creating application in user enter bunch of data can images, audio, video etc. android application. if internet not available then, data inserted in queue (database in case). , whenever internet available queue 1 single bunch of data taken , uploaded server , uploaded data removed queue. when first bunch of data completed then, second bunch of data taken queue upload server. i have used tape library of square http://square.github.io/tape/ the problem whenever data taken queue , after finishing upload operation, tape library return call queue , next bunch of data taken upload operation. but, if call not returned process of uploading can stopped. can have alternative tape library? what disadvantages of using tape library?

ios - Issue on TableView Cell -

Image
here i'm developing expanded tableviewcell ,while tableview didselectrowatindexpath method using cell expand, here used 2 tableview cell's but need button action secondcell expanded.can please how can implement here below code, - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { // disable touch on expanded cell uitableviewcell *cell = [self.thetableview cellforrowatindexpath:indexpath]; if ([[cell reuseidentifier] isequaltostring:@"expandedcellidentifier"]) { return; } // deselect row [tableview deselectrowatindexpath:indexpath animated:no]; // actual index path indexpath = [self actualindexpathfortappedindexpath:indexpath]; // save expanded cell delete later nsindexpath *theexpandedindexpath = self.expandedindexpath; // same row tapped twice - rid of expanded cell if ([indexpath isequal:self.expandingindexp