Posts

scaling - Android - setScaleX/Y makes image clipped -

Image
i have banner @ bottom of screen, , use setscalex + setscaley zoom fit screen width. before , after : the main different that, bottom part of image clipped after scaling (you can see bottom part of white horn in banner cut) below code (adview banner dimension 320x50) displaymetrics metrics = new displaymetrics(); getwindowmanager().getdefaultdisplay().getmetrics(metrics); float scale = metrics.widthpixels / metrics.density / 320; adview.setscalex(scale); adview.setscaley(scale); any solution? thanks! p.s. may suggest using smart banner adsize of adview. however, can't use smart banner reasons can play setscalex/y trick. set adsize smart_banner , layout_width match_parent change in xml android:layout_width="match_parent" android:layout_height="wrap_content" ads:adsize="smart_banner"

javascript - JQuery cut an image w/o cropping plugin -

i trying show part of image jquery, example, 0 - 200 px of it's width. i have solved problem, so... i want know if there's easier way, instead of creating div each image , using script each time. a way of animating it, right left, instead of left right. this script, suggestion? $("button").click(function(){ if($('#hello2').css("opacity") != "0"){ $('#hello2').animate({ "width" : "0px", "opacity" : "0" }); } else{ $('#hello2').animate({ "opacity" : "1", "width" : "500px" }); } }); fiddle thanks in advice i changed use background:url() property instead of separate div, effect looks little different though. but @ least have animate width of div. $(document).ready(function () { $("button").click(function () {...

ruby - Delete from where? -

below have written piece of code that's supposed count number of occurrences of characters in string , display result in hash. idea rid of letter in string right after i've counted don't put hash more once. my original code this: def letter_count_spec(str) letter_count = hash.new #create hash letter = str.split('') #separate letters letter.each{ |e| if( /[a-za-z0-9]/.match(e) ) occurances = letter.count{ |x| x==e} letter_count[e] = occurances letter.delete(e) #delete letter end } return letter_count end letter_count_spec("cat") result: => {"c"=>1, "t"=>1} i lose "a"! so tried this: def letter_count_spec(str) letter_count = hash.new #create hash letter = str.split('') #separate letters letter.each{ |e| if( /[a-za-z0-9]/.match(e) ) occurances = letter.count{ |x| x==e} letter_count[e] = occurances end } letter.each{ |e| ...

java - why spring handles only unchecked exceptions -

i want know why spring handles unchecked exceptions..... can 1 explain reason behind . spring using design patterns avoid checked exceptions ? spring using design patterns avoid checked exceptions ? not design pattern best practices exception handling . consider below code: public void consumeandforgetallexceptions(){ try { ...some code throws exceptions } catch (exception ex){ ex.printstacktrace(); } } what wrong code above? once exception thrown, normal program execution suspended , control transferred catch block. catch block catches exception , suppresses it. execution of program continues after catch block, if nothing had happened. how following? public void somemethod() throws exception{ } this method blank one; not have code in it. how can blank method throw exceptions? java not stop doing this. i want know why spring handles unchecked exceptions? personally prefer unchecked exceptions declared in throws c...

Connecting Mongodb to C++ API #include problems -

i got mongoshell , json file set up. need connecting mongodb c++ i typed in command prompt gave a syntax error. (my file name connectormain.cpp) -i/usr/local/include -l/usr/local/lib -pthread -lmongoclient -lboost_thread-mt -lboost_filesystem -lboost_program_options -lboost_system app/connectormain.cpp -o connectormain this person had same problem: mongo c++ driver: mongo/client/dbclient.h: no such file or directory the reason there need type in cmd pmt because allow access weird #inclue files like: #include "mongo/client/dbclient.h" i've visited http://api.mongodb.org/cplusplus/current/files.html and dbclient.h file #pragma once #ifdef mongo_expose_macros #error dbclient.h c++ driver consumer use #endif #define libmongoclient_consumer #include "mongo/client/redef_macros.h" #include "mongo/pch.h" #include "mongo/client/connpool.h" #include "mongo/client/dbclient_rs.h" #includ...

How can i install a local rpm using puppet -

i trying install particular rpm using puppet, init.pp is: class nmap { package {'nmap': provider => 'rpm', source => "<local path rpm>", } } and rpm in ...modules/nmap/files if move rpm manifests, , provide rpm name in source => '' class nmap { package {'nmap': provider => 'rpm', source => "rpm-name.rpm", } } it works, how can specify source path ../files/ , puppet apply successfully when use : source => 'puppet:///files/nmap-6.45-1.x86_64.rpm', i error: debug: executing '/bin/rpm -i puppet:///files/nmap-6.45-1.x86_64.rpm' error: execution of '/bin/rpm -i puppet:///files/nmap-6.45-1.x86_64.rpm' returned 1: error: open of puppet:///files/nmap-6.45-1.x86_64.rpm failed: no such file or directory error: /stage[main]/nmap/package[nmap]/ensure: change absent present failed: execution of '/bin/rpm -i puppet:///files/nmap-6.45-1.x86_6...

algorithm - Finding bridges in graph without recursion -

i have code find bridges in connected graph: void dfs (int v, int p = -1) { used[v] = true; tin[v] = fup[v] = timer++; (size_t i=0; i<g[v].size(); ++i) { int = g[v][i]; if (to == p) continue; if (used[to]) fup[v] = min (fup[v], tin[to]); else { dfs (to, v); fup[v] = min (fup[v], fup[to]); if (fup[to] > tin[v]) printf("%d %d", v, to); } } } how rewrite without using recursion? know, it's possible , should use stack, line must executed after recursive call of dfs() , can't achieve stack: fup[v] = min(fup[v], fup[to]) so, how rewrite algorithm iteratively? you want make "stack frame" structure struct frame { frame(int v, int p, int i, label label); int v; int p; int i; }; // constructor here and, say, stack<frame> . between of these fields, it's possible simulate call stack ( untested ...