Posts

Showing posts from April, 2012

asp.net mvc - KendoUI grid never fires destroy method -

my kendoui never fires destroy method ? doing wrong. grid show data fails delete record. $("#registration-grid").kendogrid({ datasource: { type: "json", transport: { read: { url: "@html.raw(url.action("list", "participant"))", type: "post", datatype: "json" }, destroy: { url: "http://localhost:53669/api/participant/", type: "delete", datatype: "json" } }, schema: { data: "data", total: ...

c - How to end an input when enter is passed -

#include <stdio.h> #include <string.h> int main() { int array[1000]={0}, n, c, d, swap; printf("enter number of elements\n"); scanf("%d", &n); printf("enter %d integers\n", n); (c = 0; c<n; c++) scanf("%d", &array[c]); (c = 0 ; c < ( n - 1 ); c++) { (d = 0 ; d < n - c - 1; d++) { if (array[d] > array[d+1]) /* decreasing order use < */ { swap = array[d]; array[d] = array[d+1]; array[d+1] = swap; } } } printf("sorted list in ascending order:\n"); ( c = 0 ; c < n ; c++ ) printf("%d\n", array[c]); int result= array[n-1]-array[0]; printf("the difference between largest , smallest: %d",result); puts(""); return 0; } this program bubble sorts inputs first , gives output of differ...

shell - How to execute a php script from another php script? -

i have php files called file1.php, file2.php, file3.php . now, want run these php files 1 one other php file called all.php . mean file2.php executed after file1.php completed. file3.php executed after file2.php completed. how ? can use exec function ? safe hosting ? using cpanel in shared hosting. there way safe content in hosting ? thank ! you can use include() include('file1.php'); include('file2.php'); include('file3.php'); or include_once() include_once('file1.php'); include_once('file2.php'); include_once('file3.php'); or require or require_once require 'file1.php'; require 'file2.php'; require 'file3.php'; => require() produce fatal error (e_compile_error) , stop script => include() produce warning (e_warning) , script continue

wait for finished asynchronous process for getting current location in iOS app -

i current location of ios device in app using cllocationmanager , cllocation . works fine me. delivered location params latitude , longitude want use self created function. problem function getting current location runs in asynchronous process , not finished while starting next function. i use delegates in view controller getting current location. here code in swift: var latitude:cllocationdegrees = 0.0 var longitude:cllocationdegrees = 0.0 override func viewdidload() { super.viewdidload() //get current location , set vars latitude , logitude right values self.getcurrentlocation() //compute distance current location given location //the result of getcurrentlocation() still not exists @ time //latitude , longitude still have value 0.0 , not real value set getcurrentlocation() self.computedistancetogivenlocation(anotherlatitude: 10.0, anotherlogitude: 15.0) } how possible wait until function getcurrentlocation() finished before going on in ...

c# - How do I split an array into two different arrays and also, how do i allow the user to only enter in part of the array and not the maximum amount? -

i can't figure out how split array correctly can pass 2 separate arrays multiple different methods. end array @ point without program giving user error. can give me direction on , me fix program? using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace proj09lea { class program { // declare constant integer const int max = 10; static void main(string[] args) { // declare , array of integers int[] array = new int[max]; console.writeline("\nsaturday coder's bowling team"); console.writeline("enter in name , score each person on team."); console.writeline("for example, mary 143. hit enter when done.\n"); // fill array user input (int = 0; < array.length; i++) { // ask user enter data console.writeline(...

How to make soap post request using Volley library in Android -

i want make make soap post request using volley library. using following code , got error "http/1.1 400 bad request". in previous using soap library working fine need make request using volley library.i using following url " http://test.com/testapp/services/service.asmx?op=forgotpassword " public void forgotpassword(final string username,string url) { stringrequest sr = new stringrequest(request.method.post, url, new response.listener<string>() { @override public void onresponse(string response) { toast.maketext(mcontext, "success" + response, toast.length_short).show(); } }, new response.errorlistener() { @override public void onerrorresponse(volleyerror error) { showresponse(error); } ...

c# - Using Generic T to Determine Compiler-Chosen Overload -

i have following code. plan getsetting() call appropriate version of fromstring() , depending on type of t . public static t getsetting<t>(persistedsetting setting, t defaultvalue = default(t)) { return fromstring(registrysettings.getsetting(setting.tostring()) string, defaultvalue); } private static string fromstring(string value, string defaultvalue) { return value ?? string.empty; } private static int fromstring(string value, int defaultvalue) { int i; return int.tryparse(value, out i) ? : defaultvalue; } private static decimal fromstring(string value, decimal defaultvalue) { decimal d; return decimal.tryparse(value, out d) ? d : defaultvalue; } private static bool fromstring(string value, bool defaultvalue) { bool b; return bool.tryparse(value, out b) ? b : defaultvalue; } however, on line calls fromstring() , compile error: the best overloaded method match 'articlemanager.persistedsettings.fromstring(string, string)' ...

php - Redirect to index in subfolder -

i have .htaccess file inside root/en , when enter url root/en want site redirect root/en/public/index.php , find index there. have solution reason doesn't work: rewriteengine on rewritebase /en rewritecond %{request_uri} !en/public/ rewriterule ^(.*)$ en/public/$1 [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule .* index.php?/$0 [pt,l] if using front controller use: rewriteengine on rewritebase /en/ rewriterule ^$ public/index.php [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^((?!public/).+)$ public/index.php/$1 [l,nc]

C++ How can I call a template function with a template class? -

i have quick question program: how can call template function set , rather int ? have class here called set #include <iostream> #include <vector> using namespace std; template<typename t> class set { public: class iterator; void add(t v); void remove(t v); iterator begin(); iterator end(); private: vector<t> data; }; here's cpp: unfortunately, main cannot template function had make function addstuff , main calls template <class t> set<t> addstuff() { set<t> a; a.add(1); a.add(2); a.add(3); a.add("a string"); return a; } void main() { addstuff<set>(); //<< error here. if use addstuff<int>(), run //i can't add string it. required able add //different data types vector } your writing addstuff<set>() attempt resolve set<set> addstuff() meaningless. addstuff<std::string...

python - extract Meta tags from website using portia (scrapy) -

extract meta tags website using portia (scrapy) i want use portia extract meta tags website not showing head tag , starting body tag only i able extract data body tag you need annotate element within body , navigate element in head want map. annotate element on page, doesn't matter one. click settings icon either in annotation popup or within annotations panel on right-hand toolbox. click html element. warning lose mapped attributes annotation, click ok. click settings icon again, , time select head element. click settings icon yet again, , can select children elements within head . once you've selected element, click + field button create new field , map desired attribute value target field. see also: https://github.com/scrapinghub/portia/issues/60

user interface - how to provide size of button in clojure? -

i new clojure , using seesaw gui. wanted know how give size of button (or widget matter) in seesaw. i have tried (seesaw/button :text "done" :size [40 :by 40] :listen [:action done-handler]) and wrap button in seesaw/left-right-split . when button takes entire height , width of right side panel. how give size want? try :preferred-size instead of :size

java - Why InputStream.read() returns -1? -

my android smartphone tcpclient , chipkit wf32 wifi module tcp server. int bytesread; inputstream inputstream = socket.getinputstream(); while ((bytesread = inputstream.read(buffer)) != -1){ bytearrayoutputstream.write(buffer, 0, bytesread); response += bytearrayoutputstream.tostring("utf-8"); } the above code reads data stream , copies buffer. if no data coming block. getting -1. can explains reason getting -1? in document mentioned "end of stream reached". can explain meaning of that? thank you. if can read documentation see -1 signifies end of stream: inputstream.read() so it's natural -1 .

java - Quickfixj internal debug logs -

i'm using quickfixj 1.5 version. set logging level info in logj.properties file that: log4j.logger.quickfixj.msg.incoming=info log4j.logger.quickfixj.msg.outgoing=info log4j.logger.quickfixj.event=info but in application logs see debug logs of quickfixj. 27-11-2014 10:20:34.172 8372 [socketconnectorioprocessor-0.0] debug (fixmessagedecoder.java:157) detected header: pos=0,lim=1695,rem=1695,offset=0,state=1 27-11-2014 10:20:34.172 8372 [socketconnectorioprocessor-0.0] debug (fixmessagedecoder.java:176) body length = 1671: pos=0,lim=1695,rem=1695,offset=17,state=3 27-11-2014 10:20:34.172 8372 [socketconnectorioprocessor-0.0] debug (fixmessagedecoder.java:200) message body found: pos=0,lim=1695,rem=1695,offset=1688,state=4 27-11-2014 10:20:34.172 8372 [socketconnectorioprocessor-0.0] debug (fixmessagedecoder.java:207) found checksum: pos=0,lim=1695,rem=1695,offset=1688,state=4 27-11-2014 10:20:34.173 8373 [socketconnectorioprocessor-0.0] debug (fixmessagedecoder.java:22...

java - set number to char of string and sum that number -

for example : have edittext string , want convert every char of string constant number , sum number of characters , save on int variable. define custom hashmap char key , int value : hashmap<character,integer> charactermap = new hashmap<character, integer>(); charactermap.put('a',10); charactermap.put('p',20); charactermap.put('l',8); charactermap.put('e',4); sum of each character value : string data = "apple"; char[] chararray = data.tochararray(); int total=0; for(char ch : chararray){ total+=charactermap.get(ch); } system.out.print("total : "+total);

How to specify the width and height of an image in android for sw600dp-port-tvdpi drawable? -

i newbie android designing. developing app should suitable android devices including 7 inch , 9 inch tabs. i @ present designing res folder of type layout-sw600dp-port-tvdpi . i using drawable folder of type drawable-sw600dp-port-tvdpi . i have used image 19px 19px drawable-mdpi . can guide me how calculate pixels required tvdpi drawable? i have gone through developer's site , found out how pixels varies mdpi,hdpi , xhdpi. and lastly, how should specify size of required images in android? for tvdpi : resources screens somewhere between mdpi , hdpi; approximately 213dpi. not considered "primary" density group. intended televisions , apps shouldn't need it—providing mdpi , hdpi resources sufficient apps , system scale them appropriate. if find necessary provide tvdpi resources, should size them @ factor of 1.33*mdpi. example, 100px x 100px image mdpi screens should 133px x 133px tvdpi. more details : http://developer.android.com/guide/pract...

android - SQLite selecting date, with different date-format -

i'm trying select items date, format yyyy-mm-dd hh:mm:ss. thought work (from other threads on stackoverflow), doesnt: string selectquery = "select * " + table_log_workout + " strftime('%y-%m-%d', " + key_date_begin + ") = " + date; table_log_workout being table. key_date_begin being yyyy-mm-dd hh:mm:ss-dates. date being yyyy-mm-dd im trying find results with. date string literal , needs put in single quotes. or better yet, use ? placeholder , bind arguments. there's no syntax error since 2014-11-27 valid expression evaluates integer 1976.

PHP: is empty($var) equivalent to !$var -

for validating variable value can if(empty($var)){ } or this return true on empty string, 0 number, false, null if(!$var){ } what difference between 2 approaches, them equivalent? edit : examples behave different more pratical. edit2 : difference founded answers second throw notice if $var undefined. boolean value return? edit3 : $var mean variable value, or undefined variable. conclusion users answers : if(!$var) , empty($var) equivalent described here http://php.net/manual/en/types.comparisons.php , return same bool value on same variable. if(!$var) return php notice if $var not defined, not case (if write code) ides underline it. when checking simple variables if(!$var) should ok when checking arrays index ($var['key']) or object properties ($var->key) empty($var['key']) better using empty. the problem since !$vars shorter empty($vars) many of prefer first way you prefer first 1 because "shorter way"? ...

php - MySQL PDO WHERE = $variable -

i have php function want data database calling get_database_data() in function have 2 variables should used in where $variable1 = $variable2 . i know use "where ".$variable1." = ".$variable2 . it's works $variable2 , not $variable1 . something else use, or how make work? edit: there no errors, row don't rows returned edit2: i've got work, using: "where $variable1 = ".$variable2 you should use prepared statements. here snippet can used form function can return data need. should able modify quite needs. function get_database_data($variable1,$variable2) { $dbh = new pdo("mysql:host=url;dbname=somedb", "user", "pass"); $sqlupdate = "select * sometable {$variable1} = :variable2"; $sthupdate = $dbh->prepare($sqlupdate); $sthupdate->bindparam(':variable2', $variable2, pdo::param_str, 12); $sthupdate->execute(); ...

python - What is the difference between UTF8-in literal and unicode point? -

i came cross website show unicode table. when print letter 'ספר': >>> x = 'ספר' >>> x '\xd7\xa1\xd7\xa4\xd7\xa8' i characters '\xd7\xa1\xd7\xa4\xd7\xa8' . i think python encode word 'ספר' utf-8 unicode, because it's default, right? but when run code: >>> x = u'ספר' >>> x u'\u05e1\u05e4\u05e8' i u'\u05e1\u05e4\u05e8' , unicode point, right? how convert utf8-literal unicode point? @in first sample created byte string (type str ). terminal determined encoding (utf-8 in case). in second sample, created unicode string (type unicode ). python auto-detected encoding terminal uses (from sys.stdin.encoding ) , decoded bytes utf-8 unicode code points. you can make same conversion byte string unicode string decoding : unicode_x = bytestring_x.decode('utf8') to go other direction, need encode : bytestring_x = unicode_x.encode('utf8') you...

javascript - How to find only one class in a html that is exactly the same and have two classes with the same name when clicked with a mouse? -

i have 2 same html code html code one: <body> <div class="1">1</div> <div>2</div> <div class="3">3</div> <div>4</div> <div>5</div> <div>6</div> <div>7</div> <div class="1">1</div> <div>2</div> <div class="3">3</div> <div>4</div> <div>5</div> <div>6</div> <div>7</div> </body> as u can see html code same. need when click on div class of 1 make background of closest div class of 3 , not classes 3. example when click on first div of class 1 make first div class 3 red background. i tried few things using jquery, none of them worked me. here current jquery code: $(document).ready(function() { $(".1").click(function() { $(this).parent().closest(".3").css("background", "red"); }); }); thank you! her...

python - element is not clicked [selenium] -

i using selenium2library(python) our automation. method used def get_appointment_from_manage(self, date, appt_id): ref_date = "//*[@data-date=\"%s\"]" % date time.sleep(2) logging.info(date) logging.info(appt_id) while not self.is_element_present_by_xpath(ref_date) : self._current_browser().find_element_by_xpath("//*[@id=\"calendar1\"]/div[1]/div[3]/div/button[2]").click(); time.sleep(2) element = self._current_browser().find_element_by_xpath("//*[@data-aid=\"%s\"]" % appt_id) logging.info(element) actionchains(self._current_browser()).move_to_element(element).click().perform() the logging states element found doesn't click. part isn't clicking. element = self._current_browser().find_element_by_xpath("//*[@data-aid=\"%s\"]" % appt_id) logging.info(element) actionchains(self._current_browser()).move_to_element(element).click().perfo...

java - How to replace the usage of System.out or System.err by a logger? -

i have simple if condition in use system.out.println . know how can modify code in order replace usage of system.out logger ? if(myvar.getdate().equals(20141127) && myvar.getnumber().equals(1)) { system.out.println(""); } any suggestions ? thanks you can use logger utility log details. have @ apache log4j the logging simple log.debug("this debug message"); where log instance of logger for sample code can tutorial

liquibase data generate ChangeLog with extra spaces -

i migrating data mssql oracle.now generated changelog mssql specifying diff type data.i got following <insert tablename="test_table"> <column name="test_column" value="test_value "/> </insert> but test_value contains many spaces don’t have in mssql database.it has generated spaces.could 1 please me out why got spaces

c# - Move list of tables around -

for example, have matrix: var source = new[] { new[] { "r", "b", "g", "y" }, new[] { "r", "b", "g", "y" }, new[] { "r", string.empty, "g", "y" }, new[] { "r", "b", "g", "y" } } i want move empty string top position, first, create result equivalent to var result = new[] { new[] { "r", "string.empty", "g", "y" }, new[] { "r", "b", "g", "y" }, new[] { "r", "b", "g", "y" }, new[] { "r", "b", "g", "y" } } i want move empty string right, if needed create result equivalent to var result = new[] { new[] { "r", "g", "y", string.empty }, new[] { ...

c++ - Bytelandian gold coins wrong answer every time -

please me find why getting wrong answer bytelandian gold coins question. here solution coins #include <iostream> #include <cstdio> #include <map> #define max2(a, b) ((a) > (b) ? (a) : (b)) using namespace std; map <long long , long long > c; long long f(long long n) { if (n == 0) return 0; long long r = c[n]; if (r == 0) { r = max2( n , f(n/2)+f(n/3)+f(n/4) ); c[n] = r; } return r; } int main() { int t; long long n; scanf("%d",&t); while(t--){ scanf("%lld",&n); printf("%lld\n",f(n)); } return 0; } i new dynamic programming,so google question , trying implement spoj_coins , still getting wrong answer on both codechef.com , spoj. for problem, have take input until eof. taking input using test case. try code: #include <iostream> #include <cstdio> #include <map> #define max2(a, b) ((a) > ...

Apache Solr physical memory in Openshift -

Image
i have solr search agent running in openshift on small gear tomcat 7 cartridge testing purposes. admin page looks this: why physical memory 99.1% , 7.1 gb. these data taken , normal? looks solr admin panel showing physical memory being used on server whole, not in gear (linux container). there used metrics cartridge openshift ( https://blog.openshift.com/measuring-application-performance-with-the-openshift-metrics-cartridge/ ) looks it's gone now.

c# - The server factory could not be located for the given input: Microsoft.Owin.Host.HttpListener -

i have implemente signalr in window service. private idisposable signalr { get; set; } public void configuration(iappbuilder app) { var hubconfig=new microsoft.aspnet.signalr.hubconfiguration(); hubconfig.enablejsonp = true; app.usecors(corsoptions.allowall); app.mapsignalr(hubconfig); } private void startsignalrserver(stringbuilder sblog) { try { this.signalr = webapp.start(serveruri); //this throws exception //this.signalr= webapp.start<startup>(serveruri); sblog.append(string.format("{0}--------signalr server started------",environment.newline)); } catch (exception ex) { sblog.append(string.format("{0}exception in startsignalrserver=>{1}", environment.newline,ex.message)); } } exception:the server factory not located given input: microsoft.owin.host.httplistener the microsoft.owin.host.httplistener...

python pandas: case insensitive drop column -

i have df , want drop column label in case insensitive way. note: don't want change in df i'd avoid 'str.lower'. heres df: print df name unweightedbase base q6a1 q6a2 q6a3 q6a4 q6a5 q6a6 esubtotal name base 1006 1006 100,00% 96,81% 96,81% 96,81% 96,81% 3,19% 490,44% q6_6 31 32 100,00% - - - - - - q6_3 1006 1006 43,44% 26,08% 13,73% 9,22% 4,34% 3,19% 100,00% q6_4 1006 1006 31,78% 31,71% 20,09% 10,37% 2,87% 3,19% 100,00% is there magic can apply code below? df.drop(['unweightedbase', 'q6a1'],1) i think can create function perform case-insensitive search you: in [90]: # create noddy df df = pd.dataframe({'unweightedbase':np.arange(5)}) print(df.columns) # create list of column names col_list = list(df) # define our ...

java - `JCE cannot authenticate the provider BC` when running a JAR -

in scala project use "org.bouncycastle" % "bcprov-jdk14" % "1.51" cryptography. if test project in scala ide works fine. once make jar , try run via java -jar ... throws exception: exception in thread "main" java.lang.securityexception: jce cannot authenticate provider bc i use https://github.com/sbt/sbt-assembly making jar , here's java -version output: java version "1.7.0_72" java(tm) se runtime environment (build 1.7.0_72-b14) java hotspot(tm) server vm (build 24.72-b04, mixed mode) when making jar see output: [info] merging files... [warn] merging 'meta-inf/bckey.dsa' strategy 'discard' [warn] merging 'meta-inf/bckey.sf' strategy 'discard' [warn] merging 'meta-inf/lambdawo.sf' strategy 'discard' [warn] merging 'meta-inf/manifest.mf' strategy 'discard' [warn] merging 'reference.conf' strategy 'concat' [warn] merging 'rootdoc.t...

jquery - Window.popup Does not keep Session values -

when system in main window acts , when generate bill through ajax , after generate bill window.popup open automatically show details in bill format. on time log in session not stored, in short when window.popup open session value blank , after refresh main screen system log-out. possibilities : ajax creating issue session window.popup not support session . please give me suggestion ..... ajax creating issue session dont think so window.popup not support session nope, support session issue starting new session id. include following on top every page if on php starting session if(!isset($_session)){session_start();} including page opens on popup

javascript - Cordova/Phonegap select box not opening on soft touch on Android -

i created cordova/phonegap app , got few select elements, when click on selectbox see native select option pops , immidiatly closed, when hold long touch on element open correctly, problem happened on few devices , not have ideas? ok after alot of testing finaly got answer looking for. looks problem in cordova plugin called statusbar @ link cordova statusbar it seems when plugin attached android build causing issues selectbox in specific android versions. did not test in versions happened after removed code worked smooth. i hope someone

realtime push notifications in android -

i want create android app college. update users latest news posted in website. came know can parse website content android app. know if possible me trigger push notification users once news gets updated in website??? give me source can learn this yes possible trigger push notification users once news gets updated in website .please share problem more specically can answer in detail.

Laravel Eloquent: Rename fields only in Model Class -

i have table have many fields have bad names , containes underscores "_" want rename them (or give them alias) in class, not in table self, because table used other application don't changes in database. this example of want: what have: $model->foo_bar_wtf_man what want: $model->foobarwtfman i wouldn't call having _ in db names bad, here's easy way: // basemodel extending eloquent\model, other models extend basemodel public function __get($key) { return (parent::__get($key)) ?: parent::__get(snake_case($key)); } then can do: // either $foo->bar_baz_wtf; // or $foo->barbazwtf; that's generic solution. if want handle 'bad names' well, need accessors each 1 of them.

HL7 V3 ITS R2 - Person Name -

hello fellow hl7 developers, a question regarding xml representation of person/patient names came while browsed recent normative release of hl7 standard (release 2014). version of standard uses r2 (new schemas, changed datatypes). according standard (cd1/edition2014/infrastructure/itsxml/datatypes_its_xml.html, section 2.20.2), person name should represented xml elements "<given>", "<family>" etc. however, no such elements defined anywhere in xsd files accompany standard. how person name correctly rendered in xml in version of standard? regards, michael datatypes_its_xml.html filename of r1 version of specification. although looking @ r2 based version, r1 included information sake, , you've found it. use iso data types 21090 correct version schema. as names, in version if memory correct.

meteor - Using cfs:http-publish -

i'm trying use cfs:http-publish package @ https://github.com/collectionfs/meteor-http-publish . while i've got get - /api/list functionality working, don't know how obtain single document: (get - /api/list/:id - find 1 published document). can provide curl example of this, assuming collection of objections. eg: {a:3, b:2} , {a:4, b:3} , , requiring obtain object {a:3} . thanks. you need put in query function. http.publish({collection: mylist},function( ){ return mylist.find(this.query); }); this.query contains data sent request. curl http://localhost:3000/api/mylist?a=3 i don't know enough mongo know if potential security risk, if can comment on please do.

oop - The correct class hierarchy -

in general case have following document types: document header part (сlass documentheader) document header , detail parts (сlass documentdetail) both classes abstract , need inherit them in order realize required functionality: сlass documentheader {} class documentdetail : documentheader {} next, have concrete documents: consolidated order. contains consolidated data order (class order) detailed order. contains consolidated data , table part detail ordered products (class orderdetail) so, have problem: detailed order should inherit functionality consolidated order: class orderdetail : order {} both detailed , consolidated orders should inherit abstract classes: class order : documentheader {} class orderdetail : documentdetail {} please give idea, how realize that. thanks! i think should consider composition psuedo-ish code like class cdocument { public: cdocument ( idocumentheader header, idocumentdetails details ) : t...

java - Partition 2d array in sub-arrays -

i have partition 2d array (the size given user) sub-arrays given input number user. code wrote works of instances there need with. i taking square root of input number. example: if user inserts [10, 10, 9] means 10 * 10 array 9 sub-arrays. taking square root of 9 works fine because gives 3. if user inserts [8, 6, 6] takes square root of 6 , rounds longest side (which gives 3) , rounds down shortest (which 2). 3 * 2 = 6. works fine. then there situation 8. square root of 8 gives 3 , 2. array partitioned 6 sub-arrays. there way find better partitioning numbers 8, 14? or there way find optimal distribution such numbers (e.g. 2 * 4 = 8, 2 * 7 = 14)? you can calculate them bit different way: int x = math.round(math.sqrt(n)); int y = math.round(1. * n / x); thus you'll receive: n = 8 => x = 3, y = 3 n = 14 => x = 4, y = 4

stm32 - How to find value of APB1 Clock in STM32F429 -

can tell me how find apb1 clock frequency of stm32f429? , how calculate baud rate of stm32f429. p.s...please dont tell refer reference manual,as works done , tell me exact value of apb1 clock frequency thankyou using standard peripheral library, include stm32f4xx_rcc.h call void rcc_getclocksfreq(rcc_clockstypedef* rcc_clocks) , fill in structure pass values of bus clocks. the correctness of answer depends on value set hsi_value or hse_value (a global uint32_t set value in hz of system's oscillator). can find in application's startup c file. you should review values in startup file ensure core clock generated source expect (usually pll via internal (hsi) or external (hse) crystal). if correct , match aforementioned global constant answers given rcc_getclocksfreq correct.

osx - How to run java UI application on Mac from remote ssh terminal? -

on mac can connect ssh , run applications without display settings, e.g. open . run finder on mac screen remote terminal. this doesn't work java applications: java -jar demo/jfc/font2dtest/font2dtest.jar will throw: exception in thread "main" java.awt.headlessexception @ java.awt.graphicsenvironment.checkheadless(graphicsenvironment.java:207) @ java.awt.window.<init>(window.java:536) @ java.awt.frame.<init>(frame.java:420) @ javax.swing.jframe.<init>(jframe.java:225) @ font2dtest.main(font2dtest.java:1032) any experiments display values didn't help. in jdk8 can use awt_force_headful env variable overcome this: awt_force_headful=true java -jar demo/jfc/font2dtest/font2dtest.jar unfortunately there no easy way in jdk7. the problem hidden in mac headless mode detection. next code checks app being in "aqua" session , forces headless otherwise. // jdk/src/solaris/native/java/lang/java_props_macosx.c int isinaqua...

php - How to decode password save with md5() in mysql db -

this question has answer here: encrypt , decrypt md5 5 answers i have simple query . i fetching user name , password mysql db using php. the password in md5() encoded. can 1 me out script while($rfg=mysql_fetch_array($rc)){ //print_r($rfg); echo $_post['im_password'] = $rfg['password']; echo $_post['im_user'] = $rfg['nombre']; } how can decode md5 password real text in php ?? thanks in advance the point of using md5 cant decrypt easely. example use compare md5(user_input) hash in database (login system). if need plain-text (which dont support) try using dictionary-attacks. beside (bruteforcing) wouldnt worth according needed calculation power.

jquery - How we get all ids of sibling div? -

the design this <div id="cat-11">apple<span class='qty'>(12)</span></div> <div id="cat-12">samsung<span class='qty'>(22)</span></div> <div id="cat-13">moto g<span class='qty'>(55)</span></div> <div id="cat-14">google<span class='qty'>(16)</span></div> <div id="cat-15">nokia<span class='qty'>(100)</span></div> i have span value of id cat-13. want span value of siblings div? plz assist assist me. i tried this: $("#cat-13").sibling().find('span').val(); i know return single value unable vaules? to ids in array may do var arr = $("#cat-13").siblings().map(function(){ return this.id }).get();

wpf - Editing CodePlex Source Code -

i new wpf - , visual studio - , using modern ui (metro) charts in application great effect. problem have, however, need change part of source code implement particular chart project. specifically, need change hard-coded height , width of radial gauge piece (part of radial gauge chart) can scaled. have found example of code (see below) can't figure out implement it. original in generic.xaml part of download. <style x:key="radialgaugechartchartareastyle" targettype="chart:chartarea"> <setter property="template"> <setter.value> <controltemplate targettype="chart:chartarea"> <grid> <viewbox height="auto" width="auto"> <contentcontrol content="{templatebinding content}" verticalalignment="stretch" horizontalalignment="stretch" verticalcontental...

php - fsockopen unable to connect error with remote css file -

i'm trying http response headers of images/css/js files used in remote web page.when use fsockopen('mydomain.com',80,$errsno,$errstr,20) it works.but when try same css link in webpage, like, fsockopen('mydomain.com/style.css',80,$errno,$errstr,20) it returns error warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: no such host known warning: fsockopen(): unable connect mydomain.com/style.css isn't possible connect remote file css or image files? but file there in server.i hoping response headers,file size,response time etc.can't way? hint please? fsockopen() doesn't speak http, you'd have write valid http request socket after opening in first example yourself. minimal form be: get /style.css http/1.1 host: mydomain.com followed empty line. or use pear http_request2 package if don't want speak raw http: http://pear.php.net/manual/en/package.http.http-request2.php

java - XML Signature Reference digest uses parent namespace -

i need sign xml-file in java, needs contain 3 reference s. while 2 of them valid (expected digest == actual digest), 1 invalid. relevant part of xml looks like: <qualifyingproperties xmlns="http://uri.etsi.org/01903/v1.3.2#" target="signature1"> <signedproperties id="signedproperties_1"> <signedsignatureproperties> <signingtime>2014-11-27t13:49:36</signingtime> </signedsignatureproperties> </signedproperties> </qualifyingproperties> the reference references element "signedproperties" , children. can see "qualifyingproperties" element defines namespace ( xmlns="http://uri.etsi.org/01903/v1.3.2#" ) , guess thats problem: after having @ log found, "pre-digest" value looks like: <signedproperties xmlns="http://uri.etsi.org/01903/v1.3.2#" id="signedproperties_1"> <signedsignatureproperti...

java - Regex and find in text file -

i have code : package ggg; import java.util.regex.matcher; import java.util.regex.pattern; import java.io.*; public class regex { public static void main( string args[] ){ // string scanned find pattern. string line = "this order placed fro-dda-6666666 %10.25 %10.12 fro-dda-8888888 qt3000! ok?"; string pattern = "\\d+\\.\\d{2}"; string pattern2 = "\\d{7}"; // create pattern object pattern r = pattern.compile(pattern); pattern t = pattern.compile(pattern2); // create matcher object. matcher m = r.matcher(line); matcher g = t.matcher(line); try { printwriter writer = new printwriter("c:\\users\\john\\workspace\\ggg\\src\\ggg\\text.txt", "utf-8"); (int = 1; m.find() && g.find(); i++) { writer.println(g.group(0)+"->"+m.group(0)); } writer.close...

Replacement for Objective-C "lazy-getter-as-dependency-injection" pattern in Swift? -

short of typhoon , told way (or @ least simulate) dependency injection in objective-c lazy-getter pattern: - (foo)foo { if (!_foo) { _foo = [foo sharedinstance]; } return _foo; } i detested this, ended multiple instances of seven-line chunk of boilerplate code polluting each view controller. couldn't hide in category since can't define properties on category. until swift gets annotations , introspection features , can write like: @injected foo: foo! ... patterns people using in swift obtain reference shared model objects multiple storyboard-instantiated view controllers?

How to combine Python context managers in a new function? -

let's have 2 context managers : @contextmanager def foo(): [...] @contextmanager def bar(): [...] in python 2.7 can use both of them around code block this: def do_something(): foo(), bar(): [...] but how can combine both of them single context manager (for dry/clarity): @contextmanager def foobar(): [???] def do_something(): foobar(): [...] i don't think can call other 2 context managers , expect work: @contextmanager def foobar(): # wrong(?) foo() bar() since context manager have __enter__ , __exit__ called @ points, combine of foo , bar appropriately. if insist on using contextlib.contextmanager - again, replicate the logic described in docs : the function being decorated must return generator-iterator when called. iterator must yield 1 value, bound targets in statement’s clause, if any. at point generator yields, block nested in statement executed. generator resumed after block...

android - EditText not increasing width when adding BulletSpan -

when adding bulletspan edittext, size of edittext not increased leading space added bullet. leads wrapping or scrolling of text out of sight. sofar have not been able force edittext remeasure width correctly. unfortunately have not enough reputation illustrate situation. let me try describe situation. when adding bulletspan underlying editable of edittext, resulting larger paragraph scrolls behind right edge. |0123456789| -> | • 0123456|789 the last characters scrolled behind right edge. when altered editable assigned edittext, width of field remains same , wider text wraps. |0123456789| -> | • 0123456| | 789 | in both cases edittext not compensate width leading space. adding characters @ end of paragraph | • 0123456789xxx| | xxx | when adding characters edittext, size of field increases expected, not take added space of bullet , margin account , keeps wrapping. several questions on bulletspans have been asked, not be...

objective c - IOS Stop active queue -

i have queue responsible download images table view, , want stop queue when table view reloaded or segue new view controller. have tried sort of verification inside block none seem work. if(!imagequeue){ imagequeue = dispatch_queue_create("com.loadimages", null); } dispatch_async(imagequeue, ^{ uiimage * image = [uiimage imagewithdata:[nsdata datawithcontentsofurl: [nsurl urlwithstring: urlstring]]]; });

Android send lat/lang of one device to other App -

hello have 2 different apps 'a' , 'b' installed on different devices. want send lat/lang of 1 device other using apps. how it? don't want use own server communication. how can this? in advance. it not easy without own server, since ip address of clients not globally reachable , suggestions are: send email or sms use google cloud messaging give firebase try

openshift - How do I debug an Open Shift 503 Service Unavailable error -

i have node app i'm trying deploy open shift. it's basic express, pretty vanilla express generator. runs locally. when push openshift following error: 503 service unavailable no server available handle request. now i'm not surprised there errors because i've pushed whole new application on open shift in 1 go, want know how go finding them? how go debugging this? how crack open server , see what's going on? you can try following things: rhc tail <app_name> view log files on server connect server ssh @ logs in ~/app-root/logs if scaled application, go http://<app_name>-<your_namespace>.rhcloud.com/haproxy-status view status of scaled gears

HTTP Error 403.14 - Forbidden while using master page in asp.net -

i created new project asp.net empty web application , added master page, when executed program gives me following error http error 403.14 - forbidden web server configured not list contents of directory. i have tried enable directory browsing internet information manager (iis) thanks

Ignore sub-projects in gradle -

i have gradle multi-project , i'm trying create task root build.gradle file,  need run task once after checkout or every-time need generate jars file(from war) project depend on.    problem when run "gradle mytask", gradle try compile projects in file setting.gradle don't have yet jars fails.  is there way run task ignoring setting.gradle? i have tried "gradle -c fake-setting.gradle mytask" , works hope there better way it... task postcheckout << { println "<<<<<< postcheckout" delete filetree(dir: "${rootproject.projectdir}/libs/fineos", include: ".") copy{ ziptree("${rootproject.projectdir}/fineos-war/fineos6/fineos.war/") include "web-inf/lib/*.jar" eachfile { fcp-> fcp.path = fcp.name } "${rootproject.projectdir}/libs/fineos" includeemptydirs = false } }

c# - Xamarin Dependency Service Issue -

in xamarin forms have solution this: solution |- libraries | |- iinterface.cs | |- etc. | |- libraries.ios | |- interface.cs | |- etc. | |- forms.app | |- app.cs | |- etc. | |- forms.app.ios | |- etc. forms.app.ios references libraries.ios forms.app references libraries libraries.ios references libraries forms.app.ios references forms.app iinterface.cs namespace { public interface iinterface { void function (); } } interface.cs [assembly: xamarin.forms.dependency(typeof(a.interface))] namespace { public class interface : iinterface { public void function () { return; } } } app.cs namespace { public class app { public static page getmainpage () { var inter = dependencyservice.get<iinterface> (); // null. return new contentpage { content = new label { text = "hello, forms!", verticaloptions = layoutoptions.centerandexpand, horizon...

javascript - Click outside element without using event.stopPropagation -

i know there lots of ways detect click outside of element. of them use event.stoppropagation . since event.stoppropagation break other stuff, wondering if there way achieve same effect. created simple test this: html: <div class="click">click me</div> javascript: $(function() { var $click = $('.click'), $html = $('html'); $click.on( 'click', function( e ) { $click.addclass('is-clicked').text('click outside'); // wait click outside $html.on( 'click', clickoutside ); // there other way except using .stoppropagation / return false event.stoppropagation(); }); function clickoutside( e ) { if ( $click.has( e.target ).length === 0 ) { $click.removeclass('is-clicked').text('click me'); // remove event listener $html.off( 'click', clickoutside ); } } }); http://js...

Inputting and validating the email address in JAVA -

i have written below code unable make loop if input entered false.kindly me. system.out.println("please enter email address ex:xyz@gmail.com"); string emailaddress=name.nextline(); string email_regex = "[a-z]+[a-za-z_]+@\b([a-za-z]+.){2}\b?.[a-za-z]+"; string teststring = emailaddress; boolean b = teststring.matches(email_regex); system.out.println("string: " + teststring + " :valid = " + b); system.out.println("email address " +emailaddress); here goes 3 functions : public class abc{ public static void main(string[] args){ inputemail(); } public boolean checkemailvalidity(string emailaddress){ string email_regex = "[a-z]+[a-za-z_]+@\b([a-za-z]+.){2}\b?.[a-za-z]+"; boolean b = teststring.matches(email_regex); return b; } public void inputemail(){ system.out.println("please enter email address ex:xyz@gmail.com"); string e...

javascript - storing user input in arrays for a log in site? -

i trying make mock site allow create username , password send array of usernames , passwords on log in page put in username or password , go threw process of checking weather wright or wrong , there. have realized when hit button send information on not register on other page. may please me find out screwed on. here code create username , password: <!doctype html> <html> <head> <title> create account </title> <script> function createlogin() { var usernamearray = document.getelementbyid("usernamemake").value; var paswordarray = document.getelementbyid("pwordmake").value; unarray.push("usernamearray"); pwarray.push("paswordarray"); localstorage.setitem("unarray", json.stringify([])); localstorage.setitem("pwarray", json.stringify([])); } </script> </head> <body> <form name = "makelogin"> <p class="log_on"> enter new us...

asp.net mvc - multiple select list c# mvc -

i trying create multiple select single select drop down menu. model had: public int country_id { get; set; } and view had: @html.dropdownlist("country_id", string.empty) to change multiple select changed model to: public list<country> country_id { get; set; } and view to: @html.listboxfor(model => model.country_id, viewbag.actionslist multiselectlist, new { @class = "multiselect", @style = "width: 450px;height:200px" }) the problem having updating databse using migration since changing int list , however, keeps saying "cannot drop index 'dbo.people.ix_country_id', because not exist or not have permission." i have permission not sure if missing something? my list of countries coming straight country database. thanks inputs. you need populate selectlist in controller & pass view, this: var countries = d in db.countries select new { ...

java - Eclipse warns about a potential resource leak although I have a finally block which closes the outermost stream, what am I missing? -

is there reason eclipse gives me following resource leak warning: resource leak: 'br' never closed" ? code talking @ bottom of post. i thought block had covered, reasoning: res null if fileinputstream constructor threw , therefore nothing has closed res inputstream if inputstreamreader constructor throws (malformed encoding string example) , inputstream must closed ok etc... so missing? or eclipse bug? kind regards! s. public static string filetostring(string filename, string encoding) throws ioexception { inputstream is; inputstreamreader isr; bufferedreader br; closeable res = null; try { = new fileinputstream(filename); res = is; isr = new inputstreamreader(is, encoding); res = isr; br = new bufferedreader(isr); res = br; stringbuilder builder = new stringbuilder(); string line = null; while ((line = br.readline()) != null) { builder.append(line)...