Posts

Showing posts from August, 2012

c# - How to launch and run a UWP app in the background -

i developing uwp app want run in background , launch hidden exception of perhaps notification tray icon. i'm not sure start first venture uwp , cannot seem change entry point in manner want. with background tasks app can work in background , wake after conditions for needs can run background task on timer

asp.net mvc - Serilog MVC integration -

i have project utilizes 3rd party software uses serilog. purpose added following startup method in startup.cs file. log.logger = new loggerconfiguration() .minimumlevel.verbose() .readfrom.configurationsection(configuration.getsection("logging:serilog")) .createlogger(); on separate project, have service layer uses logging mechanism based on microsoft.extensions.logging.ilogger. now adding ui initial project , injecting microsoft.extensions.logging.ilogger controller classes through service collection; use (inside controllers) create service layer objects. the challange is; inject existing serilog logger these controllers. couldn't find neat way of adding service collection controllers can fetch through di. suggestions? the solution register instance of already-existing logger object in dependency injection container. single instance passed constructor of controller, instead of new instance being created each time. t...

Creating a form builder, how to implement the backend PHP Laravel MYSQL -

i'm trying create system users able create questionnaires, ways envision cumbersome create , don't seems efficient. when user specifics: one txt field. one multiple choose ( string, string, string ) etc how save data database in efficient way. there tutorials on this? thanks time. this laravel 5 example should best choice. create questionnaire app based on example should easy.

asp.net ImageButton CommandArgument -

so have object playerlist of type list , doing foreach fill table. want add id of each player commandargument when click on imagebutton, know id of player need work with. reason not working. commandargument returning empty string yet collection has id when debug , each player. <% foreach (var player in playerlist) { %> <tr> <td><asp:imagebutton width="32px" height="32px" commandargument='<%#eval("player.id")%>' id="editrecord" imageurl="../images/edit.png" oncommand="editrecord_click" runat="server" /></td> <td><%=player.firstname %></td> <td><%=player.lastname %></td> <td width="15%"><%=player.address %></td> <td><%=player.dob %></td> <td><%=player.parent1 %></td> <td><%=player.parent1phone %></td> <td><...

Meaning of << operator in C -

this question has answer here: c - syntax about? << 6 answers i wondering know meaning of operator << in #define x (10 * (1<<12)); it's bitshift operator . << shift left , >> shift right . 1 << 12 means shift value (the int '1') 12 bits left. '1' 00000000 00000000 00000000 00000001 in binary, if it's 32 bit integer. shift left 12 places, changes to: 00000000 00000000 00010000 00000000 if shift 5 << 8 , '5' 101 in binary, it'll shift: 00000000 00000000 00000000 00000101 into: 00000000 00000000 00000101 00000000 see this question details on other bitwise operators.

How to alias this route in Spring Cloud? -

the code @ this github link defines 3 interconnected spring boot apps using spring cloud , spring oauth2. there ui app loads default @ localhost:8080 , , there authserver authentication app runs on localhost:9999 . when user tries login ui app on localhost:8080 , redirected localhost:9999/uaa/login . this run on apache, ui app @ mydomain.com . imagine create virtualhost mydomain.com/login , map authorization app url pattern. want spring cloud manage urls. what specific changes need make code in these sample apps login page render @ localhost:8080/login instead of localhost:9999/uaa/login ? i tried changing zuul route definition in the ui app's application.yml following, clicking login link ui app still redirects localhost:9999/uaa/login : zuul: routes: resource: path: /resource/** url: http://localhost:9000/resource user: path: /user/** url: http://localhost:9999/uaa/user login: path: /login** url: http:...

android - Skew custom layout -

Image
i've got custom layout , skew this: @override protected void ondraw(canvas canvas) { canvas.skew(0f, 0.2f); super.ondraw(canvas); } and achieve although, want skew other side (i want right higher left) decided flip horizontally this @override protected void ondraw(canvas canvas) { canvas.scale(-1f, 1f, super.getwidth() * 0.5f, super.getheight() * 0.5f); canvas.skew(0f, 0.2f); super.ondraw(canvas); } but button, can see below, flips too. can suggest me how flip layout not children inside?

python - Initializing a command that's failing with popen -

i trying run "repoinitcmd" using popen below , running following error..can provide inputs on wrong? import subprocess branch_name='ab_mr2' repoinitcmd = 'repo init -u git://git.company.com/platform/manifest.git -b ' + branch_name proc = subprocess.popen([repoinitcmd], stderr=subprocess.pipe) out, error = proc.communicate() error:- file "test.py", line 4, in <module> proc = subprocess.popen([repoinitcmd], stderr=subprocess.pipe) file "/usr/lib/python2.7/subprocess.py", line 679, in __init__ errread, errwrite) file "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child raise child_exception oserror: [errno 2] no such file or directory by default, popen expects command line passed list. in particular, actual command run (in case 'repo') should first item of list. rather writing commands strings , using split or shlex pass them popen lists, prefer manage command lines lis...

android detect is gyroscope available -

how can detect whether android device has gyroscope? i'm using following method detect whether gyroscope available. if gyroscope not available, use accelerometer. sensormanager mgr = (sensormanager) getsystemservice(sensor_service); list<sensor> sensors = mgr.getsensorlist(sensor.type_all); (sensor sensor : sensors) { log.i("sensors",sensor.getname()); if(sensor.getname().contains("gyroscope")){ try{ msensormanager.registerlistener(this, msensormanager.getdefaultsensor(sensor.type_rotation_vector), sensormanager.sensor_delay_fastest); return; }catch(exception e){ } } } msensormanager.registerlistener(this, msensormanager.getdefaultsensor(sensor.type_accelerometer), sensormanager.sensor_delay_fastest); however of app users c...

ios - Sending Device Token Safely for APNs -

Image
for ios applications require push notifications, must first request user permission so. after that, device token generated , this, remote server may communicate user through token. i have read similar question here , not feel enough. picture below trusted certificate, allows me view traffic happens on device. with fiddler2 certmaker , can sniff https traffic, means client can know data sending, , where. my question is, knowing ssl not secure protecting clients seeing send remote server, should encypt secret key found within application? such encrypt("device_token","secretkey_a0a0a0a") (pretend objective-c)? couldn't find key within application? read this question, , seems possible secret key. my plan goes this: within ios application, generate random string named activate . encrypt (not hash), token random string and secret key know. (secretkey_a0a0a0) send encrypted string along generated randomly generated string (active). within s...

java - Is there a reliable (proper?) way for code to know if a SQLException was due to a connection error? -

i know exception due connection error has string "connection closed" or similar, that's not way know if connection problem cause sql error instead of data integrity issue. for example, if code executing multiple statements , connection dies between statement 1 , 2? how cna know know it's connection issue , not problem sttement? example: try { conn.createstatement().execute( sql ); //imagine dies here conn.createstatement().execute( sql2 ); } catch (sqlexception e) { //something 1 of these if ( e.geterrorcode() === sqlexception.connection_error ) {} if ( e instance of sqlcoonnectionexception ) {} } i think looking explained here https://docs.oracle.com/javase/tutorial/jdbc/basics/sqlexception.html oracle has given example how can retrieve lot of information error code, sqlstate etc. sqlexception.

c++ - Qt display settings set to grayscale -

how can change display settings of qt application whole application presented in grayscale, 1 byte per pixel? i know how using grab, convert color frame grayscale , paint on paintevent, not need. i'm looking way setup whole screen grayscale without need convert it. the news qt supports rendering grayscale software rasterizer, obvious looking @ qpaintengine_raster_p.h , qpaintengine_raster.cpp , the bad news have implement own platform plugin, start plugin using , override use grayscale qimage pixel storage, won't work qpixmap : case qinternal::pixmap: qwarning("qrasterpaintengine: unsupported pixmaps..."); once platform plugin passes grayscale qimage down chain, should picked , configure rasterizer it. more bad news : there no detailed tutorial documentation writing qpa plugins @ time. however, there 2 example plugins shipped qt5: qtbase/src/plugins/platforms/minimal/ qtbase/src/plugins/platforms/minimalegl/

visual studio 2010 - C++ Compiles fine but cannot debug -

ok, let me clear don't have repeat myself later on. please read carefully, i'll try concise possible. put parts want stress in bold. i pretty c++, not begginer. made alot of projects , think second time happens in 6 months. here's problem, started console project doesn't have console, opengl window launched sdl library. having fun , , built , debugged project several times , it both building , running fine . then, out of blue , built project after addition (shooting bullets, if wanna know) , wanted test addition. it built fine (build succeed) , when try start debugging, says .exe file not found. doesn't seem create .exe file. now here precisions might wanna know: i didn't change project settings , running fine before. it has nothing bullet shooting, mean builds fine. my project has main.cpp , glrect class made , gameconstants.h file made game constants in it. i'm using visual studio 2010, installed sdl-1.2.15 library sdl_image add-on. i...

apache - Unable to Rewrite on htaccess -

i have few rules in htaccess working however, when try add seemingly simple rewriterule won't work. scratching head. want make http://www.sample.com/dev/reference/library/a into http://www.sample.com/dev/library.htm?cat=a the "a" can alphabets z only. i have htaccess this: rewriteengine on rewritecond %{https} off rewriterule ^member/([a-za-z0-9-_\s]+)/?$ member.htm?cid=$1 [nc] rewriterule ..... rewriterule ..... rewriterule ..... rewriterule ^library/([a-za-z])/?$ library.htm?cat=$1 [nc] the library.htm sits on root direct. however, getting "file not found" 404 error. assistance appreciated. in advance. found issue. looking /dev/library , had files in /dev/reference/library.

Android, changing orientation of WebView in fragment -

i have fragment webview , need play video in fullscreen. can't use android:configchanges="orientation|screensize" in androidmanifest mainactivity, because mainactivity has 2 different layout lanscape , portrait mode. calling method setretaininstance on fragment retain fragment (it not destroyed), hence instance variables of fragment preserved, destroy fragment's view hence webview gets destroyed.

node.js - Consuming Magento SOAP API with Node JS -

i'm using soap npm try customer, right i'm getting undefined in user list console log var soap = require('soap'); soap.createclient(url, function (err, client) { client.login(args, function (err, session, client) { console.log(session); session = session.result; client.customercustomerlist(session , function (err, list){ if(!err){ console.log(client); console.log('user list', list); }else{ console.log(err); } }); }); }); i haven't found reliable soap module node.js yet. after spending time trying debug or modify popular ones on npm, took advice offered in answer https://stackoverflow.com/a/22897376 . has worked me far.

android - Getting current view from ViewPager -

i'm trying current page view viewpager viewpager.findviewwithtag . when try current view viewpager returns null; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.viewpager_main); bundle bundle = getintent().getextras(); chapter = bundle.getint("chapter"); viewpageradapter adapter = new viewpageradapter(this, chapter); pager = (viewpager) findviewbyid(r.id.pager); pager.setadapter(adapter); view myview = pager.findviewwithtag(pager.getcurrentitem()); ... , here's viewpageadapter @override public object instantiateitem(viewgroup container, int position) { layoutinflater inflater; if(position != 10){ inflater = (layoutinflater) context .getsystemservice(context.layout_inflater_service); itemview = inflater.inflate(r.layout.viewpager_item, container, false); itemview.settag(position); } else { ...

apache - How to Change Response Headers - Pragma & Cache-Control -

i'm using font awesome in web application none of icons displaying in internet explorer 11. per troubleshooting guide learned behavior can tied no-store cache-control header, or no-cache pragma header. how can change these header values? ideally, there option in ie developer tools can adjust this, not seem possible. have been playing around on web server - apache 2.4 (debian) - , attempted following in sites-enabled configuration: <filesmatch "\.(eot|woff|ttf|svg|otf)$"> <ifmodule mod_headers.c> header unset cache-control header unset pragma </ifmodule> </filesmatch> i reloaded apache , no change, these headers still set, icons still not displayed in internet explorer. i don't have experience apache, use here! in advance.

asp.net - Change CHMOD of a file in PHP for specific user -

i have admin panel coded asp.net (c#). have textarea wordpress (redactor) , trying upload image it. using php file make upload after everytime upload image, encounter iis "401 - unauthorized: access denied due invalid credentials." error while displaying it. add 755 permission iis_iusr every timem after file upload. possible? here php code: $dir = 'assets/images/content/'; $_files['file']['type'] = strtolower($_files['file']['type']); if ($_files['file']['type'] == 'image/png' || $_files['file']['type'] == 'image/jpg' || $_files['file']['type'] == 'image/gif' || $_files['file']['type'] == 'image/jpeg' || $_files['file']['type'] == 'image/pjpeg') { // setting file's mysterious name $filename = md5(date('ymdhis')).'.jpg'; $file = $d...

R version 3.2.4 "very secure dishes" on Ubuntu 14.04 LTS, how can I open a file given by an user in a function? -

i quite new in stackexchange , in r. following course on r, , assignment have series of more 300 files. have create function takes nb of files argument in vector (here id) : myfunction<-function(directory, variable, id=1:332) . files in .csv format , called 001.csv until 332.csv. my question how open given file nb of file number in id. instance, if call myfunction(directory, variable, 1) , open first file (001.csv), etc. if call myfunction(directory, variable, 1:4) , program open 4 first files. here attempt, doesn't work: myfunction<-function(directory, variable, id=1:332) { for(i in id) { data<-read.csv("i.csv") } #data<-read.csv("") } i precise question first step of function have write , not whole assignment ;) ! use paste0() . data <- read.csv(paste0(directory, "/", i, ".csv"))

android - tool bar not removed? -

so im trying remove tool bar on android design page can't reason. xml code: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_parent" android:layout_width="match_parent"> </linearlayout> did set theme of activity in manifest without actionbar ? in styles.xml : <style name="apptheme.noactionbar"> <item name="windowactionbar">false</item> <item name="windownotitle">true</item> </style> and in androidmanifest.xml : <activity android:name=".mainactivity" android:theme="@style/apptheme.noactionbar" /> then in design page, you'll need select theme created in dialog.

c++ - Qt Creator - Getting error D8021 - Invalid numeric argument '/Wextra' -

i'm using qt creator make simple gui. functioning past couple weeks, i'm not sure changed i'll best detail be. windows 10 qt creator 5.5 currently using following lines in .pro file, commenting them out makes no difference: qmake_cxxflags += -std=c++14 -wall -wextra config += c++14 i guessing either has odd flag/exception, or compiler i'm using. in honesty, can't tell compiler i'm using, can tell in compiler options in settings, has 4 "microsoft visual c++ compiler 12.0"s under auto-detected. i'm not sure here, appreciated.

html - Change class style (not individual elements) that's not in stylesheet using Javascript -

this question has answer here: how dynamically create css class in javascript , apply? 13 answers i have series of divs share class assorted reasons (and number of divs created via code @ other points). i've tried find answers, rely on class being in stylesheet (if there one), doesn't happen in case or alters existing elements instead of rules themselves. so need like... var add_to_styles('myclassname'); myclassname.csstext = "color: red;" and have divs created (both before , after script running) have class <div class="myclassname">i should red</div> to come out rule change. haven't found this. you can add new <style></style> new rules (new or existing classes) , append body (so read after other stylesheets). you can target specific parent (and don't modify other existing ele...

php - Prevent a selected <option>-tag from being overwritten by .html() -

i have php file fetches rows of car brands database, echoes these "<option value=\"$brand\">" . $brand . "</option>"; , puts them inside pre-written <select> tags. my issue first item appears in select box not passing value onwards. the value of select box changed event $('select[name=model]').on('change', function() { selectedmodel = $("#select-model").val() }); the <option> -tags generated loop in brands.php : while ($row = mysqli_fetch_array($result)) { $brand = $row['brand']; echo "<option value=\"$brand\">" . $brand . "</option>"; } the brands fetched function: function fetchbrands() { $.ajax({ type: "post", url: "script/rent/brands.php", data: {datefrom: selecteddatefrom, dateto: selecteddateto, destination: selecteddestination}, success: function(data) { $(...

parsing - Parse GUID out of string -

i running issue following using trim. removing of guid. guid out of this. if appreciative.thank in advanced. ((get-adorganizationalunit -filter {name -eq "ouname"} -properties linkedgrouppolicyobjects,gplink) | foreach-object {if($_.gplink){$_.gplink.split(",") | foreach-object {if($_ -like 'dc=dcname*'){if($_.length -gt 10){(((($_).trim('dc=dcname;0][ldap://cn={')).trim('}')) ) }} }}}) my output this: 754ff9f1-078a-4e05-913d-4f36572b2fc6 eddaab18-2ba6-42e6-a5ec-21b0227be71a 7df312db-eb73-418e-8f64-3e391f4639b7 6e3512-4100-48a3-9a65-4da17a0e2d87 72ef89d6-2c57-40ac-a116-2cad89f453ed 2][ldap://cn={31bb7749-f6dc-4098-8f10-9d8b4b0f0c0a 78528b0-f379-4e8f-a166-ace1448af9b2 without input cannot sure, might try this get-adorganizationalunit -filter {name -eq 'ouname'} -properties linkedgrouppolicyobjects, gplink | foreach-object { if ($_.gplink) { $_.gplink.split(',') | foreach-object { if...

spring - Singleton vs prototype JdbcTemplate -

in spring documentation recommended way use jdbctemplate create new template every class use in... public class jdbccorporateeventdao implements corporateeventdao { private jdbctemplate jdbctemplate; public void setdatasource(datasource datasource) { this.jdbctemplate = new jdbctemplate(datasource); } } i wondering, advantage of solution on define jdbctemplate singleton in context , directly inject in dao public class jdbccorporateeventdao implements corporateeventdao { @autowired private jdbctemplate jdbctemplate; public void setjdbctemplate(jdbctemplate jdbctemplate) { this.jdbctemplate = jdbctemplate; } } from class-level documentation of jdbctemplate: * can used within service implementation via direct instantiation * datasource reference, or prepared in application context * , given services bean reference. either ok. here have large application (50 daos, 100 concurrent users) , ...

c++ - Factory methods in derived classes -

i have 2 kinds of messages: messagea , messageb , both derived abstract class imessage containing pure virtual method std::string tostring() . can convert each message string representation pointer base class. that's fine. however, need somehow construct message (concrete type of message) string, example: messagea* msg = [something].fromstring( str ) . null if given string isn't suitable construction of messagea . can see 2 approaches task: a) messagefactory dynamic_cast class messagefactory { imessage* fromstring( const std::string& str ); }; ... messagefactory mf; messagea* msg = dynamic_cast< messagea* >( mf.fromstring( str ) ); if ( msg ) { ... } however, uses dynamic_cast avoid. b) factory method in each derived class static messagea* fromstring( const std::string& str ) { return stringisok( str ) ? new messagea() : null; } is there better solution? should change in general design? thank you. upda...

apache - Starting a service inside of a Dockerfile -

i'm building docker container , in container downloading apache service. possible automatically start apache service @ point? systemctl start httpd not work inside of dockerfile. basically, want apache service started when docker container started. from centos:7 maintainer me <me@me.com> run yum update -y && yum install -y httpd php run (cd /lib/systemd/system/sysinit.target.wants/; in *; [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ rm -f /lib/systemd/system/multi-user.target.wants/*;\ rm -f /etc/systemd/system/*.wants/*;\ rm -f /lib/systemd/system/local-fs.target.wants/*; \ rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ rm -f /lib/systemd/system/basic.target.wants/*;\ rm -f /lib/systemd/system/anaconda.target.wants/*; volume [ "/sys/fs/cgroup" ] expose 80 expose 443 cmd ["/usr/sbin/init"] try using cmd ["/usr/sbin/httpd", "-dfo...

using HtmlAgilityPack how to load encoded html string -

i working on converting html string pdf. using expertpdf process. but int process have clean html string , pass cleaned html string library create pdf. in cleaning process first step remove unwanted html tags (some thing removing tags blacklist. list created me.). remove unwanted tags using htmlagilitypack parse html string , remove nodes second step auto close knows tags if opened .when load html string using htmlagilitypack auto closes tags good. have come across problem here. issue when there text "reading < 5 go , visit doctor". less symbol treats start of tag , close down line. for example : below html > <p style="margin-top: 5px; margin-bottom: 5px; line-height: 16.9px; > background-color: #ffffff;">1. full evaluation , management of > acute coronary syndrome, st-elevation , non-st-elevation myocardial > infarction beyond scope of soc tele-intensivist coverage. 2. > cardiology consultation should recommended in cases of ...

c# - How can I re-run a nunit test programmatically in 3.2? -

in nunit 2.6.4, used below c# code re-run failed test: testexecutioncontext.currentcontext.currenttest.run(new nulllistener(), testfilter.empty); but after upgrading nunit 3.2, testexecutioncontext.currentcontext.currenttest returns null. how can re-run test in 3.2? if trying re-run tests because fail because of transient network errors or like, nunit 3.x introduced retry attribute retry test given number of times.

C++ - Performance of static arrays, with variable size at launch -

i wrote cellular automaton program stores data in matrix (an array of arrays). 300*200 matrix can achieve 60 or more iterations per second using static memory allocation (e.g. std::array ). i produce matrices of different sizes without recompiling program every time, i.e. user enters size , simulation matrix size begins. however, if use dynamic memory allocation, (e.g. std::vector ), simulation drops ~2 iterations per second. how can solve problem? 1 option i've resorted pre-allocate static array larger anticipate user select (e.g. 2000*2000), seems wasteful , still limits user choice degree. i'm wondering if can either a) allocate memory once , somehow "freeze" ordinary static array performance? b) or perform more efficient operations on std::vector ? reference, performing matrix[x][y] == 1 , matrix[x][y] = 1 operations on matrix. according this question/answer , there no difference in performance between std::vector or using pointers. edit: i...

Add custom UserDetailsService to Spring Security OAuth2 app -

how add custom userdetailsservice below this spring oauth2 sample ? the default user default password defined in application.properties file of authserver app. however, add following custom userdetailsservice the demo package of authserver app testing purposes: package demo; import java.util.list; import org.springframework.security.core.grantedauthority; import org.springframework.security.core.authority.authorityutils; import org.springframework.security.core.userdetails.userdetails; import org.springframework.security.core.userdetails.usernamenotfoundexception; import org.springframework.security.provisioning.userdetailsmanager; import org.springframework.stereotype.service; @service class users implements userdetailsmanager { @override public userdetails loaduserbyusername(string username) throws usernamenotfoundexception { string password; list<grantedauthority> auth = authorityutils.commaseparatedstringtoauthoritylist("r...

How to automatically promote an Azure web app to production, if it passes all the integration tests -

i've got asp.net mvc web app set of selenium ui integration tests it. want put in azure, , apply continuous delivery this: i commit change git repository azure notices commit, gets latest code, builds it, , deploys test environment azure runs unit tests on code, , fails build if tests fail azure runs integration tests on test environment, , fails build if tests fail if tests pass, promote code production this seems logical pipeline me i've struggled working. i've managed step 3. creating 2 web apps, e.g. muppet , muppetstaging. muppetstaging environment automatically updated on each commit, that's great start. edited deploy.cmd perform unit tests. fails build when unit tests fail. that's great too. the integration testing hard bit. before deployment has been completed, can't integration test current build - because it's not been deployed yet. best integration test previous version... not pending version. , if could, how promote successful...

css selectors - Targeting Previous Sibling Element CSS -

this question has answer here: is there “previous sibling” css selector? 12 answers i'm using off canvas menu i've been trying work correctly. in order fixed menu , off-canvas play nicely, had take header out of off canvas inner wrapper, header won't move on when menu opened. when off canvas opened, applies .is-open-right inner wrapper has css applied it. i'm trying add line of css header when .is-right-open class added wrapper. -webkit-transform: translatex(-450px); transform: translatex(-450px); i trying target way: .is-open-right, .is-open-right > .header { -webkit-transform: translatex(-$offcanvas-size-large); transform: translatex(-$offcanvas-size-large); } my html looks when menu closed: <div class="off-canvas-wrapper"> <header class="header scrolled" role="banner"></header>...

python 3.x - adding functions to self made calculator -

ok i'm trying make working napier numeral calculator. have gone through of steps need make work. need 2 more steps function , converting napier numbers. i'm stuck on getting functions work. seems skip step. can tell should work , not skipped. tell me if missed step in process of making function. def main(): response = 'y' while response == 'y' or response == 'y': nap1 = getnapier() num1 = naptoint(nap1) print(num1) nap2 = getnapier() num2 = naptoint(nap2) print(num1, num2) operator = getoperator result = domath(num1, num2, operator) response = input("try another[y/n]") def domath(num1, num2, operator): if operator == "+": answer = num1 + num2 elif operator == "-": answer = num1 - num2 elif operator == "*": answer = num1 * num2 else: if operator == "/": ...

java - Ant shortcut for specifying source/version in several different javac tasks -

when using ant, there way specify set of attribute/value pairs can passed different tasks single item/variable? i have ant build file includes several different javac tasks. have same values several attributes (source, version, bootclasspath, debug, etc.) i know can set variable each attribute; but, there way can refer entire group of attributes can this <javac ${standard_attributes} ...> instead of <javac debug="on" includeantruntime="false" source="${java_version}" target="${java_version}" bootclasspath="${bcp}" ... in every javac task? use presetdef <presetdef name="standard-javac"> <javac debug="on" includeantruntime="false" source="${java_version}" target="${java_version}" bootclasspath="${bcp}" ... </javac> </presetdef> and use standard-javac task in places used put javac .

io - Term for an algorithm that works in a distributed or sequential fashion -

i working on algorithm subdivides large data problem , performs work on across many nodes. local solution each subdivision of problem can modified match global solution if each subdivision knows limited amount of information subdivisions around it. this can achieved through fixed number of communications between each subdivision, allowing embarrassingly parallel solution. an up-shot, however, that, problem performed on single core, each piece of data need loaded fixed number of times, regardless of size of problem, reach solution. thus, algorithm parallelizes nicely, allowing fast solutions on supercomputers there sufficient nodes hold of data in memory @ once, permits large datasets processed limited resources loading data disk fixed number of times. is there standard word or phrase denotes such algorithm has property? the theoretical description of problem might complexity lies in nc , , particularly very-low-order subset of nc c = 0 , k = 1

How to get crash logs for React Native app? -

my react native app crashed on tester's phone. what best way logs of crash? i'm using react native 0.14.2 as @abhishek has commented, you'll have use monitoring tools crashlytics such infomation. fabric option in case. comes crashlytics solution. here blogpost explains in-depth on how set app. here's excerpt of features of crashlytics tool of fabric blogpost crash reporting —it record every single crash , stack trace. way better itunes connect crash reports, include info of users opted in share information developers while setting new iphone. it’s not updated in real-time (you can read more here). crash logs  — (a.k.a. cls_log) if you’re familiar objective-c, have been using “nslog” while you’re developing app. should use cls_log instead. there’s no difference @ when you’re debugging (whatever you’re logging still show in console) cool part when user crashes app, information sent crashlytics’s servers next time user launches app, in...

html5 - How to write HTML code of main. -

code necessary place layer "main" left edge 33.3% left edge plus 7 pixels? . im not sure how write code. use css calc function element want position way. left:calc(33.3% + 7px); example div{ width:100px; height:100px; position:absolute; background:blue; left:calc(33.3% + 7px); } <div></div>

Listen when extension popup page closes in Crossrider -

i need know when crossrider's extension closes can throw message in background. easy on other way around appapi.ready(function() { } this i'm using on popup.html determine if extension opened. need appapi.close(function() {}) can't find on crossrider's doc http://docs.crossrider.com/ thanks, kevin so if want monitor "popup page close" event, listen unload event popup page. window.addeventlistener("unload", function() { // logic here }, false); please aware can't use console.log in function, since time unload event fires late. see this post more details.

ruby on rails - Capybara rspec test takes a long time to execute - why? -

i have rails project using rspec 3.4.0 capybara 2.6.2 , capybara-webkit 1.8.0 . i have simple feature test follows: require 'rails_helper' rspec.feature "seller features", type: :feature let!(:sub_category) { factorygirl.create(:sub_category) } #all tests create user - sign them in , land them on homepage background sign_in_as end scenario "buyer creates seller profile", :js => true click_link("sell on site",match: :first) expect(page).to have_text("reach thousands of customers in area") click_link("create activity",match: :first) expect(current_path).to eql (new_seller_profile_path) fill_in "seller_profile[business_name]", :with => "test company" fill_in "seller_profile[business_email]", :with => "test@email.com" fill_in "seller_profile[business_phone_number]", :with => "07771330510" fill_in "selle...

php - Calling query: Notice: Array to string conversion in -

i newbie trying make own web app. got problem. i've tried call query table code find rank $rank="select student_code, led2dt4engavgfinal, find_in_set( led2dt4engavgfinal, (select group_concat(distinct led2dt4engavgfinal order led2dt4engavgfinal desc) led2deng) ) rank led2deng;"; $myqry2 = mysql_query($rank, $koneksidb) or die ("query salah : ".mysql_error()); $mydata2 = mysql_fetch_array($myqry2); and use code call data <?php echo $mydata2; ?> but came out notice: array string conversion in.... how can fix this? iterate result array this: foreach($mydata2 $row){ //now access columns echo $row["student_code"]; echo $row["led2dt4engavgfinal"]; } update: try this <?php $rank="select student_code, led2dt4engavgfinal, find_in_set( led2dt4engavgfinal , (select group_concat( distinct led2dt4engavgfinal order led2dt4engavgfinal desc ) led2deng) ) rank led2deng;"; $myqry2 =...

Google Maps Web API -

is link below valid web api google maps http://cbk0.google.com/ i use link xml values location(lat , long) check if there web view available. for example: http://cbk0.google.com/cbk?output=xml&ll=22.33419,114.145635 if link valid. free use it? mean here if has limit on how many times allowed access web service. saw page https://developers.google.com/places/web-service/usage#usage_limits stating 1000 limit 24 hours. applicable link? usage limits apply following maps apis answered in which google maps apis have usage limits? : google maps javascript api google static maps api google street view image api google maps directions api google maps distance matrix api google maps elevation api google maps geocoding api google maps geolocation api google maps roads api google maps time zone api

sh - Shell script cut returning empty string -

i writing script trying linux distribution. have following code returning empty string. sure missing something os=`cat /etc/os-release | grep -sw name` newos=$os | `cut -d \" -f2` echo $newos like honesty's answer says, have 2 problems. adding answer, i'd address use of backticks in code. the command substitution can done in 2 ways 1 using $(command) , other `command` . both work same, $(command) form modern way , has more clarity , readability. the real advantage of $(...) not readability (that's matter of taste, i'd say), ability nest command substitutions without escaping , , not have worry additionally having escape $ , \ instances. - mklement0 the following code uses modern way: #!/bin/bash os=$(cat /etc/os-release | grep -sw name) newos=$(echo "$os" | cut -d \" -f2) echo $os echo $newos output on computer: name="ubuntu" ubuntu

How can I every 1 second command intentfilter on android? -

i want every 1 second registerreceiver. i try registerreceiver(receiver, new intentfilter(intent.action_time_tick)); but code every 1 minute i want every 1 second. perhaps, android have form ? thanks what trying accomplish? if want have code executed every 1s, don't user broadcastreceiver . receivers result in inter-process communication every time triggered (relatively) expensive. best way use handler, private static final long tick_interval = timeunit.seconds.tomillis(1); private static final handler tickhandler = new handler(looper.getmainlooper()); public void onresume() { super.onresume(); tick(tick_interval); } private void tick(final long interval) { tickhandler.postdelayed( new runnable() { public void run() { tick(interval); ontick(); } }, ); } protected void ontick() { // } ensure stop ticking when activity pauses, public void onpause() { super.onpause(); tickhandler.removecallbacksandme...

cmd - How to run a command on command prompt startup in Windows -

edit if want perform task @ computer startup or based on event helpful http://answers.microsoft.com/en-us/windows/forum/windows_7-performance/how-to-schedule-computer-to-shut-down-at-a-certain/800ed207-f630-480d-8c92-dff2313c193b back question i have 2 questions: i want specific commands executed when start command prompt. e.g. cls clear command prompt. i want execute commands in batch file , wait user enter new commands (if any). e.g. batch file take user specified folder , wait user rename/delete file command prompt. how can it? if want defined set of commands run every time start command prompt, best way achieve specify init script in autorun registry value. create (an expandable string value allows use environment variables %userprofile% ): reg add "hkcu\software\microsoft\command processor" /v autorun ^ /t reg_expand_sz /d "%"userprofile"%\init.cmd" /f then create file init.cmd in profile folder...

javascript - Disable Bootstrap accordion after opening -

i have multiple bootstrap accordion running , disable once clicked. 1 tab has remain open @ times. for example, link1 open link1 should disabled. link2 , link3 should clickable. how should achieve this? here's code: <div id="accordion"> <a class="btn btn-primary" role="button" data-toggle="collapse" href="#collapseexample1"> link 1 </a> <a class="btn btn-primary" role="button" data-toggle="collapse" href="#collapseexample2"> link 2 </a> <a class="btn btn-primary" role="button" data-toggle="collapse" href="#collapseexample3"> link 3 </a> <div class="collapse in" id="collapseexample1"> description 1 </div> <div class="collapse" id="collapseexample2"> description 2 </div> <div class="collapse...

c++ - Boost CRC 16 bit -

using online crc calculator, know 32311e333530 (hex) = e558 (hex) crc-ccitt (0xffff). how can boost crc? std::string crc_str = "32311e333530"; boost::crc_16_type result; result.process_bytes(crc_str.data(), crc_str.length()); std::cout << "checksum = " << result.checksum(); checksum yields 59589 (decimal) = e8c5 (hex), when e558 (hex) = 58712 (decimal). what user manual serial device says: unsigned short calculate_crc16(char *data_ptr, unsigned short data_length) { unsigned short index; unsigned short new_crc = 0xffff; //loop through entire buffer array of data (index = 0; index < data_length; index++) { new_crc = (new_crc << 8) ^ crc_table[(new_crc >> 8) ^ (*data_ptr++)]; } return(new_crc); } static const unsigned short crc_table[256] = { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0...

python - How to switch different config file running flask with uwsgi -

i deploying flask app uwsgi multiple servers. different server should run same app read different config file. there 2 config file used in app. 1 'config.py' read flask: app.config.from_object('config') another 'uwsgi_config.ini' used when starting uwsgi: uwsgi uwsgi_config.ini since have several server, must write several config files like: config.dev.py config.test.py config.prod.py uwsgi_config.dev.py uwsgi_config.dev.py uwsgi_config.prod.py so question how can switch different tiers when starting uwsgi without hacking source code every time ? i think key thing should run uwsgi this: uwsgi uwsgi_config.dev.ini and flask can read 'dev' tier uwsgi_config.dev.ini. there simple way ?

ruby on rails - Devise_token_auth and Devise login with username and email -

i continuously errors when trying add token authentication existing rails application , it's stemming devise authentication_keys. in rails 4 app allow users login either username or email , i'd provide same functionality api. the error i'm getting when logging in api follows started post "/api/v1/auth/sign_in" 127.0.0.1 @ 2016-04-19 23:40:26 -0400 processing devisetokenauth::sessionscontroller#create json parameters: {"login"=>"email@example.com", "password"=>"[filtered]", "session"=>{"login"=>"email@example.com", "password"=>"[filtered]"}} can't verify csrf token authenticity geokit using domain: localhost user load (1.3ms) select "users".* "users" (login = 'email@example.com' , provider='email') order "users"."id" asc limit 1 sqlite3::sqlexception: no such column: login: select "user...