Saturday, 15 March 2014

Boolean Valued Response in C++ -



Boolean Valued Response in C++ -

this question has reply here:

c++ cin boolean(0,1) 3 answers

please, there way boolean valued response straight users in c++??. instance user reply yes or no not want store response in character or string variable straight boolean variable. thanks.

declare variable bool , take input 0 or 1 treated false or true respectively.

bool b; cin >> b;

c++

javascript - How do I call a method when an image has been fully loaded and rendered? -



javascript - How do I call a method when an image has been fully loaded and rendered? -

i need phone call method after image has been loaded , rendered in browser.

quick illustration big image:

http://jsfiddle.net/2clm4epv/

<img width="500px" src="http://www.digivill.net/~binary/wall-covering/(huge!)14850x8000%2520earth.jpg">

my method should called when image visible.

as discussed in comments utilize .load() function along phone call accomplish task,

html

<img id="bigimage" width="500px" src="http://www.digivill.net/~binary/wall-covering/(huge!)14850x8000%2520earth.jpg"/>

js

$('#bigimage').load(function(){ alert('loaded , redered'); }); demo

javascript jquery html css

big o - Algorithmic Upper Bound for my solution -



big o - Algorithmic Upper Bound for my solution -

i'm working on homework , want create sure analysis of upper bound solution correct.

here's do.

i read n characters input string. // o(n) construct min heap of size k(where k big constant). // o(n) retreive k entries min heap. // o(k *log n).

the complexity of solution hence o(n+ k·logn). wondering whether can safely approximate o(n), if take consideration k constant.

yes, if k constant, Θ(n + k log n) = Θ(n) + Θ(k log n) = Θ(n) + Θ(log n) = Θ(n).

big-o time-complexity

python - django template access to models -



python - django template access to models -

i having issue templating scheme in django, doing film list app larn more django , have declared models following:

class pelicula (models.model): nombre = models.charfield(max_length = 30) genero = models.charfield(max_length = 20) año = models.integerfield() def __str__(self): homecoming self.nombre

then have declared view following

def index(request): pelicula = pelicula.objects.all() homecoming render_to_response("index.html", dict(pelicula = pelicula, usuario = request.user))

so far know, not having problem here

then problem starts on template

<!doctype html> <html> <head> <title>mis peliculas favoritas</title> </head> <body> <h1>mis peliculas favoritas</h1> <ol> {% pelicula in pelicula.object_list %} <li><a href ="#">{{ pelicula.nombre }}</a></li> {% endfor %} </ol> <a href="agregar.html">agregar pelicula nueva</a> </body> </html>

so see, using loop objects in db, have 3, when run server, title shows , other link bellow named "agregar" shows except movies, wondering if problem between "pelicula" name instead of using pelicula used on declaring model, anyway have changed pelicula.object_list , didn't worked anyway

i believe having problem understanding how utilize info have through django template tags

thanks in advance , please forgive grammar not native english language speaker

in view code have pelicula = pelicula.objects.all() creates list of abjects database. send template same name, means have in template iterate on them. seek changing template this:

<h1>mis peliculas favoritas</h1> {% if pelicula %} <ol> {% item in pelicula %} <li><a href ="#">{{ item.nombre }}</a></li> {% endfor %} </ol> {% else %} didn't find any... {% endif %}

part of confusion seems come fact template code , view code separate. template doesn't know view code. context dictionary sets names can used in template , in template names have available utilize ones passed via dictionary. names in view , template here same in case because set them same. aren't same variables though, have same name. in template pelicula list of objects don't need utilize in template loop.

python django templates

Class not found Kryo exception in hive 0.13 - Hadoop -



Class not found Kryo exception in hive 0.13 - Hadoop -

i have genericudf (see code below) running fine on hadoop-1 , hive-0.12. when testing same genericudf using hive-0.13 + hadoop-2, getting below error.

vertex failed, vertexname=map 12, vertexid=vertex_1409698731658_42202_1_00, diagnostics=[vertex input: ccv initializer failed., org.apache.hive.com.esotericsoftware.kry o.kryoexception: unable find class: com.xxx.xxx.id1

here code udf.

package com.xxx.xxx; import org.apache.hadoop.hive.*; public class id1 extends genericudf { private mapredcontext context; private long sequencenum = 0; private static final int padlength = 10; stringbuilder sb = null; public objectinspector initialize(objectinspector[] arguments) throws udfargumentexception { sequencenum = 0; sb = new stringbuilder(); homecoming primitiveobjectinspectorfactory.javastringobjectinspector; } public object evaluate(deferredobject[] arguments) throws hiveexception { int sblength = sb.tostring().length(); if (sblength > 0) sb.replace(0, sblength, ""); string taskid = null; if (context.getjobconf() != null) taskid = context.getjobconf().get("mapred.taskid"); sequencenum++; if (taskid != null) { sb.append(taskid.replace("attempt_", "")); } int = 0; string seqstr = string.valueof(sequencenum); sb.append(seqstr); homecoming sb.tostring(); } public string getdisplaystring(string[] children) { homecoming "id1()"; } @override public void configure(mapredcontext context) { this.context = context; } }

i has hive-0.13, not able see post related error.

hadoop hive kryo

javascript - jQuery never calls .done() or .always() for ajax call -



javascript - jQuery never calls .done() or .always() for ajax call -

i'm having simple request:

$.get('ri/i18n/locale') .done(function() { console.log(this); }) .fail(function() { console.log(this); }) .always(function(){ console.log(this); });

unfortunately none of handlers ever called.

i cann confirm calling ri/i18n/locale in browser returns valid json string. i'm using jquery 1.11.1 .

any ideas what's wrong?

your issue might version of jquery using. before jquery 1.5, jqxhr object not returned $.get(), allows utilize promise behavior. the relevant jquery documentation.

javascript jquery ajax

How can I customize my infowindow android app borders? -



How can I customize my infowindow android app borders? -

hi guys have set customize image on everymarker infowindow on googlemap, on android application. can not fit image left, right , bottom border because, think, default infowindow properties have default padding or margin on content.

is possible fit image infowindow? here screenshot , code:

screen

xml :

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_horizontal|left" android:orientation="horizontal"> <imageview android:id="@+id/image_nuvoletta" android:layout_width="90dp" android:layout_height="60dp" android:layout_marginright="5dp" android:paddingleft="0px" android:adjustviewbounds="true" android:src="@drawable/ic_launcher"/> [...]

java snippet of getinfocontents

public view getinfocontents(marker marker) { /* distanza piedi e macchina sulla nuvoletta */ /***********************************************/ gpstracker gpstracker = new gpstracker(mainactivity.this); if (gpstracker.cangetlocation()) { string stringlatitude = string.valueof(gpstracker.latitude); string stringlongitude = string.valueof(gpstracker.longitude); double currentlat = double.parsedouble(stringlatitude); double currentlng = double.parsedouble(stringlongitude); double destlat = marker.getposition().latitude; double destlng = marker.getposition().longitude; final float[] results = new float[3]; location.distancebetween(currentlat, currentlng, destlat, destlng, results); float metri = results[0]; float km = math.round((double)metri/1000); int minuti_persona = (int)math.round(metri/125); //125 metri al minuto -> velocità media di 2,5 m/s int minuti_auto = (int)math.round(km/0.7); //700 metri al minuto -> velocità media di 42 km/h /***********************************************/ view v = getlayoutinflater().inflate(r.layout.custom_info_window, null); textview tvtitle = (textview) v.findviewbyid(r.id.title); textview tvsnippet = (textview) v.findviewbyid(r.id.snippet); tvsnippet.settypeface(tvsnippet.gettypeface(), typeface.italic); //indirizzo in corsivo textview tvpedonal_distance = (textview) v.findviewbyid(r.id.pedonal_time); textview tvcar_distance = (textview) v.findviewbyid(r.id.car_time); tvtitle.settext(marker.gettitle()); tvsnippet.settext(marker.getsnippet()); if(minuti_persona <=0) // stampa tempo per coprire la distanza { tvcar_distance.settext("a piedi: meno di united nations minuto"); }else { tvpedonal_distance.settext("a piedi: "+minuti_persona+ " minuti"); } if(minuti_auto <= 0) { tvcar_distance.settext("in auto: meno di united nations minuto"); }else { tvcar_distance.settext("in auto: " +minuti_auto+ " minuti"); } //prova immagine custom /***********************************/ imageview image; string currenturl="http://upload.wikimedia.org/wikipedia/commons/5/50/casa_natale_benito_mussolini_(1).jpg"; image = (imageview) v.findviewbyid(r.id.image_nuvoletta); picasso.with(v.getcontext()) .load(currenturl) .error(r.drawable.ic_launcher) //in caso di errore fa vedere questa immagine (un triangolo penserei) .resize(150, 110) .into(image); /***********************************/ homecoming v; }else { view v = getlayoutinflater().inflate(r.layout.custom_info_window, null); textview tvtitle = (textview) v.findviewbyid(r.id.title); textview tvsnippet = (textview) v.findviewbyid(r.id.snippet); tvtitle.settext(marker.gettitle()); tvsnippet.settext(marker.getsnippet()); homecoming v; } }

thank much

android android-layout infowindow