Posts

Showing posts from April, 2010

xaml - Xamarin.Forms - x:Reference 2nd level -

i'm working in new contentpage application , have controls datatemplates. i use command in contentpage's viewmodel in 1 of datatemplates, i'm not sure how right reference work properly. here's xaml code: <?xml version="1.0" encoding="utf-8"?> <contentpage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:class="maverickmobileonline.imageslistingpage" --many namespace references-- > <contentpage.resources> <resourcedictionary> <c:itemtappedeventargsconverter x:key="itemtappedconverter" /> <c:itemappearingeventargsconverter x:key="itemappearingconverter" /> <c:booleannegationconverter x:key="not" /> </resourcedictionary> </contentpage.resources> <stacklayout spacing="0"> ...

regex - Get multiple matches from text in curly braces -

i have sample file: authoritative; subnet x.x.x.x netmask x.x.x.x { range x.x.x.x x.x.x.x; deny unknown-clients; default-lease-time 86400; max-lease-time 86400; option domain-name "bla"; option domain-name-servers x.x.x.x; option broadcast-address x.x.x.x; option subnet-mask x.x.x.x; option routers x.x.x.x; host host1 { hardware ethernet 00:e1:4c:68:00:53; fixed-address 1.1.1.1; } host host2 { hardware ethernet 01:e2:4d:69:01:54; fixed-address 2.2.2.2; } host host3 { hardware ethernet 02:e3:4e:70:02:55; fixed-address 3.3.3.3; } host host4 { hardware ethernet 03:e4:4f:71:03:56; fixed-address 4.4.4.4; } host host5 { hardware ethernet 04:e5:5f:72:04:57; fixed-address 5.5.5.5; } } now i'm trying extract mac address , ip address parts within host x blocks. when use file structure (that includes newlines) doesn...

javascript - Regular expression for inserting span tags -

i need regular expression replacement of string below wrapper format. example input: c# regular expression combination of space, alpha , special-character. delta output: <span>c# <span>regular <span>expression <span>for <span>combination <span>of </span><span>space<span>,</span> </span><span>alpha </span><span>and </span><span>special</span><span>-</span><span>character</span>. </span><span>also </span><span>for </span><span>delta</span> you use replace call: var txt = "c# regular expression combination of space, alpha , special-character. delta"; var result = txt.replace(/[\w#]+\s*|[^\w#]+\s*/g, "<span>$&</span>\n"); console.log(result); .as-console-wrapper { max-height: 100% !important; top: 0; }

logging - Druid.io (imply): log level settings -

during druid.io work found out log files located in /druid_dir/var/sv/ takes gigabytes of space. to fix problem want set log level error i put in common.runtime.properties druid.emitter.logging.loglevel=error and in log4j2.xml : configuration status="error" but .log files still grow huge sizes (and includes info messages). what else should added config? need update root logger level in log4j2.xml: <root level="error">

javascript - JQuery - $ is not defined -

i have simple jquery click event <script type="text/javascript"> $(function() { $('#post').click(function() { alert("test"); }); }); </script> and jquery reference defined in site.master <script src="<%=resolveurl("~/scripts/jquery-1.3.2.js")%>" type="text/javascript"></script> i have checked script being resolved correctly, i'm able see markup , view script directly in firebug, must being found. still getting: $ not defined and non of jquery works. i've tried various variations of $(document).ready , jquery etc. it's mvc 2 app on .net 3.5, i'm sure i'm being dense, everywhere on google says check file reference correctly, have checked , checked again, please advise! :/ that error can caused 1 of 3 things: your javascript file not being loaded page you have botched version of jquery. happen because edited co...

SSL Failure on GET request with Groovy HttpBuilder -

i can not make request on following link using groovy's httpbuilder: https://system.planassist.mpu.mp.br/production/login.aspx i tested method below: ignoresslissues() but exception returns: error: javax.net.ssl.sslhandshakeexception: received fatal alert: handshake_failure code example: import groovyx.net.http.httpbuilder import groovyx.net.http.method def http = new httpbuilder("https://sistema.planassiste.mpu.mp.br/producao/login.aspx") http.ignoresslissues() http.request(method.get) { req -> } result: javax.net.ssl.sslhandshakeexception: received fatal alert: handshake_failure @ sun.security.ssl.alerts.getsslexception(alerts.java:192) @ sun.security.ssl.alerts.getsslexception(alerts.java:154) @ sun.security.ssl.sslsocketimpl.recvalert(sslsocketimpl.java:1979) @ sun.security.ssl.sslsocketimpl.readrecord(sslsocketimpl.java:1086) @ sun.security.ssl.sslsocketimpl.performinitialhandshake(sslsocketimpl.java:1332) @ sun.securi...

javascript - Nav menu won't open or close on click -

i've been trying make hamburger menu work longest time , i've tried lot, keep going in circles reason menu won't open( menu not opening problem :( ), i got menu learning how create tutorial -> youtube link please let me know how fix or refer me similar post, thanks! $(document).ready(function() { $(".burger-nav").on("click", function() { $("header nav ul").toggleclass("open"); }); }); header nav ul { height: 0; overflow: hidden; background: #6134a3; } header nav ul.open { height: auto; } .burger-nav { padding: 0px; margin: 0px; display: block; height: 40px; width: 100%; cursor: pointer; background-image: url(images/nav.png); background-repeat: no-repeat; background-size: 10%; background-position: 97%; background-color: #502196; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <h...

Google Spreadsheet conditional borderline -

how can script in google spreadsheet when cell a1:d > 0 f1:i stay black borderline? this can done script. see reply posted in automatically add borders around nonempty cells thread more information including script may after, may restrictive desires.

java - Removing EMF dependencies -

i trying clean java project emf dependencies. set option "suppress emf types" in .genmodel file in eclipse true , regenerated code. converted emf types java types such elist list. there section in project uses emf classes follows: vulnerabilitydb db = nvdfactory.einstance.createvulnerabilitydb(); xmiresource resource = new xmiresourceimpl(uri.createfileuri("target/test.vdb")); resource.getcontents().add(db); resource.save(collections.emptymap()); i think need reimplement using java libraries not familiar emf , didn't exact objective of section. how can fix part? that minimum bottleneck/requirement have encountered. suggest create facade hide remaining emf apis. example: interface vdbservice { void createdb(vulnerabilitydb db, string uri); vulnerabilitydb loaddb(string uri); }

Inject inline script in cordova wkwebview IOS -

alright, i've seen threads can't seem work. <meta http-equiv="content-security-policy" content="default-src * 'unsafe-inline'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; media-src *; img-src *"> if directly add: <script type="text/javascript"> alert('hello world'); </script> this works. ..but.. if inject localstorage crashes app. can inject html , css fine though. i have these npms installed: <plugin name="cordova-plugin-wkwebview-engine" spec="git+https://github.com/apache/cordova-plugin-wkwebview-engine.git#1.0.0" /> <plugin name="cordova-plugin-wkwebview-file-xhr" spec="^1.0.0" /> i use small function load it. works uiwebview nate.createscript = function(input){ var head = document.getelementsbytagname('head')[0] var el = document...

PHP Concatenate many variables and store them into one variable? -

i know if correct way concatenate many dynamic variables , store them 1 variable? dynamic variables contain html. of them may, depending on earlier code, contain nothing. or there alternatives? $specialproductmsg = $garminmsg .= $studdybuddymsg .= $baroncoursemsg .= $fircoursemsg .= $pilotworkshopmsg .= $cfirenewalmsg .= $flightsimmsg .= $xplane11msg .= $ltfcoursemsg; you shall do $specialproductmsg = $garminmsg . $studdybuddymsg . $baroncoursemsg . $fircoursemsg . $pilotworkshopmsg . $cfirenewalmsg . $flightsimmsg . $xplane11msg . $ltfcoursemsg; and stored on $specialproductmsg to concatenate don't use .= in between variables. you can see more here

java - onServiceConnected not called after enable my AccessibilityService -

after open app, jumps accessibility settings. onserviceconnected not called after have turned on accessibilityservice (which called voiceservice ). could please tell me should do? seems voiceservice fails start although enable in xml. or need bind mainactivity voiceservice in different way? androidmanifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.wang.hearexpr"> <uses-permission android:enabled="true" android:name="android.permission.bind_accessibility_service"/> <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsrtl="true" android:theme="@style/apptheme"> <activity android:name=".mainactivity"> <intent-filter> ...

C# Driver- LINQ - Aggragate - Contains in Int[] -

mongo driver version: 2.2.4.26 i have following query performs aggregations. if remove contains predicate clause, query executes successfully. i reduce , perform aggregation on server before realizing data client memory. issue encountering when use contains in clause, following exception: $project or $group not support sum({document}{forecastquantity}). i prefer stay in linq implementation vs. native if possible: public class forecast { public int markdowngroupid { get; set; } public list<forecastdata> forecastarray { get; set; } ... } public class forecastdata { public int markdownnumber { get; set; } public double forecastquantity { get; set; } ... } public class flat { public int markdowngroupid { get; set; } public int markdownnumber { get; set; } public double salesquantity { get; set; } ... } public class flatprojection { public int markdowngroupid { get; set; } public int markdownnumber { get; set; } public double s...

c# - Unity Google Cardboard Button not working -

i have google cardboard v2 touchscreen button (not magnet) , use it. info found outdated. de sdk has changed lot on time. , no don't want use daydream controller.i want use touchscreen button. i have tried following no luck int fingercount = 0; foreach (touch touch in input.touches) { if (touch.phase != touchphase.ended && touch.phase != touchphase.canceled) fingercount++; } if (fingercount > 0){ print("user has " + fingercount + " finger(s) touching screen"); transform.translate(0.0f, 0.0f, 2f * time.deltatime); } if (input.touches [0].pressure > 0f){ transform.translate(0.0f, 0.0f, 2f * time.deltatime); print ("user hasdfsf"); } if (input.getmousebutton(0)){ transform.translate(0.0f, 0.0f, 2f * time.deltatime); } // if(gvrcontroller.appbutton){ // transform.transl...

oop - Can method overloading be considered a way of describing polymorphism in Java? -

so, studying head first java , there read - an overloaded method different method happens have same method name, has nothing inheritance , polymorphism. however, have famous book named java - complete reference herbert schildt , in book, read: method overloading 1 of ways java supports polymorphism. method overloading supports polymorphism because 1 way java implements “one interface, multiple methods” paradigm. which 1 of them correct? can method overloading considered way of describing polymorphism in java? no these 2 different concepts. i think incorrectly understood author means. i stressed in bold important part : method overloading 1 of ways java supports polymorphism. method overloading supports polymorphism because 1 way java implements “one interface, multiple methods” paradigm. it means overloading , polymorphism not incompatible. for example, may have interface defines overloaded method : public interface doable{ ...

javascript - How to detect current width and height of monitor it's displayed on for 100vh -

i want create element containing video responsively changes height , width based on current height , width of monitor displayed on. should equal 100vh (both width , height). problem said element lies under navigation bar position: relative set. script i'm looking week should change width , height of element , video fit in 100vh , width under navbar end of viewed screen. when scrolling down element (or better said section) should behave every other, normal section: supposed scroll , giving next section opportunity catch daylight. i appreciate concepts of realizing in javascript, jquery or other script based language feel familiar with. thank in advance!

html - SVG curved text inside path -

hello guys created circle 5 segments svg, im trying add text inside segments can't work right. this im trying text curved , centered inside path this im getting: enter image description here this code far, suggestions? <svg viewbox='0 0 110 110' style="margin-top: 10px;transform: rotate(18deg);"> <a xlink:href=""> <path class="frag logoa" id="f1" data-link="1" d='m55,55 l14.54915028125263,25.61073738537635 a50,50 0 0,1 70.45084971874736,7.447174185242318z' > </path> <text font-family="verdana" font-size="15" stroke="red";> <textpath xlink:href="#f1"> go up, go down, again </textpath> </text> </a> <a xlink:href="" > <path class="frag logoa" data-link="2" d='m55,55 l70.45084971874736,7.447174185242318 a...

Installing fftw-2.1.5 with openMPI -

trying install fftw use gadget2 , , after running following command: ./configure --enable-mpi --enable-type-prefix --enable-float i message: checking mpicc... mpicc checking mpi_init... no checking mpi_init in -lmpi... no checking mpi_init in -lmpich... no configure: error: couldn't find mpi library --enable-mpi now have installed openmpi already, seems case can't find it. there similar question posted while ago different mpi software. think problem openmpi , other compilers might in different folders? brings me more general question (i have tried googling can't find explains well): if extract tar , use ./configure without prefix, program install to? , issue openmpi has reason installed different place? thanks! edit: found solution this question , running sudo ldconfig seemed fix , compiles fine.

vert.x - Putting 2 millions objects in Hazelcast cluster of 5 nodes - what optimization we should do -

we have 2 millions objects coming rest api in chunks of 500 objects in each api call (apprx 750 mb of data in total). when put these objects in hazelcast cache following takes around 10 minutes – cpu 5-6% - makes sense because there 2 million blocking n/w calls. vertx.executeblocking { for(2 million times) { hazelcast.put(mapname, key, value) } } when don’t use vertx’s “executeblocking” , rather following whole process finish in 10-15 seconds cpu reaches 80% . using hazelcast mancenter, see 2 millions objects reflected in cache within 10-15 seconds. for(2 million times) { hazelcast.putasync(mapname, key, value) } when used #putall following cpu reaches 60% , better second approach . approach finishes in apprx 10 seconds. for(2 million objects in chunks of 500) { hazelcast.putall(mapname, collection-of-500-objects) } any optimization guys recommend? wonder why hazelcast spiking cpu much. fyi - think vertx.executeblocking executing piece of ...

html - Replace and modify String using regex in java -

i have part of html website in below string format: srcset=" /tesla_theme/assets/img/homepage/mobile/homepage-models--touch@200w.jpg?20170808 200w, /tesla_theme/assets/img/homepage/mobile/homepage-models--touch@338w.jpg?20170808 338w, /tesla_theme/assets/img/homepage/mobile/homepage-models--touch@445w.jpg?20170808 445w, tesla_theme/assets/img/homepage/mobile/homepage-models--touch@542w.jpg?20170808 542w, /tesla_theme/assets/img/homepage/mobile/homepage-models--touch@750w.jpg?20170808 750w" i want add http://tesla.com in front of urls in srcset element http://tesla_theme/assets/img/homepage/mobile/homepage-models--touch@750w.jpg?20170808 750w i believe done using regex, not sure. how do using java if have multiple srcset elements in html string variable, , want replace of srcset url.'s , add server url in front? note: /tesla_theme not consistent, cannot use repl...

Angular Custom Input with Custom Validators -

i have custom input component created. looks this: const input_value_accessor = { provide: ng_value_accessor, useexisting: forwardref(() => inputcomponent), multi: true }; @component({ selector: 'my-input', providers: [input_value_accessor], template: ` <div> <input #inputmodel="ngmodel" [required]="required" [(ngmodel)]="value" /> </div> ` }) export class mycustominput { @input() required: boolean; } when use built-in validators required, input marked invalid state, so: <my-input required="true"> <div> <input required="true" class="ng-invalid" /> </div> </my-input> problem when have custom validators bind my-input like: <my-input checkpassword></my-input> the parent component gets invalid state like: <my-input checkpassword class="ng-invalid">...

Android Studio cannot find SDK -

i using android studio 2.3.3 in previous hard disk, android studio working fine, when change hard disk, , again install android studio in new hard disk, installed cannot find sdk, error messege please specify android sdk location, gave location going in configure> project defaults> project structure gave location sdk exist c:\users\username\appdata\local\android\sdk but still checking availability , nothing happens please help this snap of project structure window

hidden markov models - Learn characters sequences using hmmlearn in Python -

here problem, i'm trying teach hidden markov models using hmmlearn. i'm new language, , have difficulties understand differences between lists , arrays. here code: from hmmlearn import hmm babel import lists import numpy np import unidecode u numpy import char l = [] data = [] gods_egypt = ["amon","anat","anouket","anubis","apis","atoum","bastet","bès","gheb","hâpy","harmachis","hathor","heh","héket","horus","isis","ka","khepri","khonsou","khnoum","maât","meresger","mout","nefertoum","neith","nekhbet","nephtys","nout","onouris","osiris","ouadjet","oupaout","ptah","rê","rechef","renenoutet","satet","sebe...

javascript - How to generate React view from JSON response -

starting out react.js, have endpoint api backend returns json response. how access json inside of react component , loop through creating copies of other elements: example: ... class books extends react.component { constructor() { super(); // have access json here api } render() { const books = jsonresponse.map((val) => { <img src={jsonresponse.imgsrc} /> ... }); return( {books} ); } so var books should render based on results json response major problem: how data inside of class component, , possibly best way render it. thanks probably easiest (not best) way fetch data in componentdidmount or componentwillmount component lifecycle method. can choose wide range of libraries able fetch data. jquery, fetch, axios mention some. you can find many tutorials simple google search. e.g.: https://daveceddia.com/ajax-requests-in-react/

python 3.x - Can't create gcloud cloudsql instance through Google sql library. (not authorized to make this request) -

i'm able create cloudsql instance though use of google's sdk, i'm not able create through google's sqladmin library. i keep getting googleapiclient.errors.httperror: <httperror 403 when requesting https://www.googleapis.com/sql/v1beta4/projects/kentik-testing-175821/instances?alt=json returned "the client not authorized make request."> i've followed these instructions https://cloud.google.com/compute/docs/tutorials/python-guide . any appreciated. been stuck @ weekend. this history believe. hard tell i've tired many things. 625 gcloud auth application-default login 626 gcloud auth application-default login 627 unset google_application_credentials 628 pip3 install --upgrade google-api-python-client 629 gcloud auth application-default login 630 env 631 env | grep google 632 ls 633 kentik 634 cd intern-test-suite/ 635 ls 636 chmod +x test.py 637 ./test.py 638 gcloud projects status 639 gclo...

unity3d - Unity Facebook/Twitter SDK access token storage -

want make sure our users safe when signing in , using facebook/twitter through our app. where/how facebook + twitter official unity sdk's store user access token? i'm looking answer both/either of these if happens know. i've looked through source code , done googling , nothing obvious popped out.

facebook - this.state.text.split() is undefined error when using onSubmitEditing -

according facebook's official documentation: onchangetext takes function called every time text changes and onsubmitediting takes function called when text submitted i'm following official facebook tutorial on text input handling , code: export default class pizzatranslator extends component { constructor(props) { super(props); this.state = {text: ''}; } render() { return ( <view style={{padding: 10}}> <textinput style={{height: 40}} placeholder="type here translate!" onchangetext={(text) => this.setstate({text})} /> <text style={{padding: 10, fontsize: 42}}> {this.state.text.split(' ').map((word) => word && '🍕').join(' ')} </text> </view> ); } } takes sentence , change of words 🍕 emojis, if change onchangetext onsubmitediting , error saying this.state.text.split no...

ExtractYear and ExtractMonth returning None in Django -

i trying group data on basis of year, month , column value. query is feedbackdata.objects.annotate(year=extractyear('created'), month=extractmonth('created')).values('year','month','start_operator_alias').annotate(dcount=count('*')).values('year', 'month','start_operator_alias','dcount') the result getting is: <queryset [{'year': none, 'start_operator_alias': 7, 'dcount': 12858, 'month': none}, {'year': none, 'start_operator_alias': 2, 'dcount': 185042, 'month': none}, {'year': none, 'start_operator_alias': 5, 'dcount': 13963, 'month': none}, {'year': none, 'start_operator_alias': 3, 'dcount': 127819, 'month': none}, {'year': none, 'start_operator_alias': 0, 'dcount': 566040, 'month': none}, {'year': none, 'start_operator_al...

Firebase and Mysql usage together -

i trying create messaging app. using firebase store messages this toid: "4" message: "hello" fromid: "5" my users stored in mysql database how can join between 2 in realtime can access users's name , profile picture mysql database using toid , fromid in firebase? thanks you can use guuids generate unique keys independent of database generated auto keys. using can access both mysql , firebase. can read domain driven development , event sourcing.

Paypal Chained Payments PHP - Receiver needs to pay a percentage -

i'm having trouble locating helpful tutorials or articles explaining if there's way extract percentage each receiver. not pay paypal fees fee selling item through website. took @ chained payments don't want take percentage full transaction can unfair if selling item cheaper other. any input appreciated. thank you.

ios - UICollectionView Custom layout header with section headers -

Image
i have been googling , struggling while. need create uicollectionviewflowlayout supports both - main collectionview header (as instance can create in uitableview dragging view tableview) , section headers classic section headers. far able implement sections without main header... the header has scrollable along collectionview please don't want put collectionview view scrollview since not option... the expected result this: the thing have called "collectionview header" header section lacks items, or decoration view . here's screen shot of proof-of-concept doing first way:

JavaScript not working in XHTML -

i trying make xhtml page javascript. javascript not work. i have written simplest file, can not find error. me seems fine. please, give me advice. <!doctype html> <html version="-//w3c//dtd xhtml 1.1//en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.w3.org/1999/xhtml http://www.w3.org/markup/schema/xhtml11.xsd"> <head> <title>xhtml test</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta charset="utf-8" /> <meta name="description" content="xhtml test" /> <meta name="keywords" content="xhtml, test" /> <link rel="stylesheet" type="...

php - Is there a wildcard operator I can use in a WHERE clause? -

i have mysql query benefit wildcard-style operator. unfortunately, internet searches proving difficult can't figure out how narrow down search keys. i have, example... $my_color = "red"; $a = $pdo->prepare("select * my_table color=:color"); $a->bindparam('color', $my_color); $a->execute(); $data = fetchall(pdo::fetch_assoc); this works great. i'd give customers ability search color. yes, (basically) if-then around entire pdo block create multiple queries, i'm hoping there's more elegant solution. does mysql have ability set condition translates to, "accept anything"? assuming fictional mysql command, any , ability set variable... $my_color = "any"; and rows of color. use like instead of = . if value doesn't contain wildcard characters, like performs exact equivalence check. can use % wildcard match anything. so: $color = '%'; $a = $pdo->prepare("select * my_ta...

javascript - getElementById not finding element -

i using jquery count dynamically generated list items , in array - getting initial values of objects like: $(document).ready(function () { $("<div></div>").load("/stats/contents #stats", function () { statcount = $(".list-group-item", this).length; (var j = 0; j < statcount; j++) { statlist.push(stat); } (var = 0; < statcount; i++) { statlist[i].statid = document.getelementbyid("statid-" + (i + 1) ).value; statlist[i].productdescription = document.getelementbyid("producttype-" + (i + 1)).value; statlist[i].lastmeasuredinventoryamount = document.getelementbyid ("statlastmeasureamount-" + (i + 1)).value; } )} )} i got 2 issues here: 1) when using $('').load("/stats/contents #stats", function () { above, doesn't find element unless browser...

java - Printing out text when space bar is pressed -

this example of taking place main program. want call method when spacebar pressed want call method example wrote prints out text , changes boolean value isn't working. not sure doing causing not work. import java.awt.flowlayout; import java.awt.event.keyevent; import java.awt.event.keylistener; import javax.swing.jbutton; import javax.swing.jframe; import javax.swing.jlabel; import javax.swing.jpanel; import javax.swing.jtextfield; public class test implements keylistener { static boolean spacedpressed = false; static jtextfield text = new jtextfield(); public static void main(string s[]) { jframe frame = new jframe("jframe test"); jpanel panel = new jpanel(); panel.setlayout(new flowlayout()); jlabel label = new jlabel("test label"); jbutton button = new jbutton(); button.settext("press me"); panel.add(label); panel.add(button); frame.add(panel); ...

R dplyr: mutate specific values with a reference value found in the same column -

how can mutate specific values in column reference value found in same column? data frame looks this: a ref 20 s1 12 s2 76 s3 12 s4 12 xy 89 b ref 02 b s1 12 b s2 42 b s3 21 b s4 12 b xy 56 i mutate having s values divided ref value, not values xy. basically s1/ref, s2/ref, ... s4/ref , b excluding values xy. thanks in advance. here 1 way dplyr . after grouping first column, 'v1', dvide 'v3' divided 'v3' 'v2' 'ref' (assuming there 1 'ref' per each unique 'v1' , replace 'newcol' 'v2' column have values not "s\d+"i.e. "s" followed numbers 'v3' values. library(dplyr) df1 %>% group_by(v1) %>% mutate(newcol = v3/v3[v2 == "ref"], newcol = ifelse(!grepl("^s\\d+", v2), v3, newcol)) # tibble: 12 x 4 # groups: v1 [2] # v1 v2 v3 newcol # <chr> <chr> <int> <dbl> ...

unit testing - httptest.NewRequest vs http.NewRequest: which one to use in tests and why? -

golang has these 2 similar libs http , httptest , both have newrequest func. why need httptest.newrequest if http.newrequest all? if need create multipart/multiform request tests, 1 need use? as indicated in documentation, httptest.newrequest "returns new incoming server request, suitable passing http.handler testing", while http.newrequest "returns request suitable use client.do or transport.roundtrip." so, if you're passing request directly handler in unit test, use httptest.newrequest , , if you're executing full round-trip using http.client , use http.newrequest .

echoing an AVG value from a virtual value with mysql and php -

i have following query , gives me percentage. works great , echo in table. in table want echo avg % total.i.e have 12 months of year , want avg. % year @ bottom of table. have worked out how valuations , instructions stored in database. but.. how do 'virtual' column %..as has been created query , not physical column in database. iam starting think need combine total valuations total instructions %. ideas how can this? $query= "select *, concat(round(( instructions/valuations * 100 ),0),'%') percentage office_figures2016"; $result = mysqli_query($conn, $query); while($office_figures2016=mysqli_fetch_assoc($result)){ it echos : echo"".$office_figures2016['percentage'].""; and here php totals each column...the third part of code wrong have far: <?php $sql = "select round(avg(valuations),0) value_sum office_figures2016"; $result = $conn->query($sql); if ($result->num_rows ...

python - With for loop, run a model across multiple pandas columns and create new columns with model output -

for 4 columns in dataframe, i'd run model on each of these , append results 4 new columns original dataframe. i have below: materials = ['var1', 'var2', 'var3', 'var4'] materials_new= ['found_new', 'walls_new', 'roof_new', 'floor_new'] i, j in zip(materials, materials_new): df["%s"]=mlb.inverse_transform(grid_search_rf.predict(df[i])) % j however produced error, "typeerror: unsupported operand type(s) %: 'list' , 'str'". any advice on how create new dataframe column names loop , list, great. side note: i'm able run model individually on 4 columns create new columns in df, don't believe error related model. @ point i'll repeating exercise 12+ columns, i'm trying pursue loop method. thanks! try this: for i, j in zip(materials, materials_new): df[j]=mlb.inverse_transform(grid_search_rf.predict(df[i]))

c# - RollBack all executed query -

how can rollback executed query on 1 transaction in mysql query executed in c# if (cn0.state != system.data.connectionstate.open) cn0.open(); cm0.connection = cn0; cm0.commandtext = "set autocommit=0 "; cm0.executenonquery(); cm0.commandtimeout = 0;//unlimited tr = cn0.begintransaction(system.data.isolationlevel.serializable); cm0.transaction = tr; try { cm0.commandtext = "create table if not exists i2019.produkh i2019.karyawanh "; cm0.executenonquery(); cm0.commandtext = "create table if not exists i2019.profileh i2019.karyawanh "; cm0.executenonquery(); cm0.commandtext = "create table if not exists i2019.customerh i2019.karyawanh "; cm0.executenonquery(); cm0.commandtext = "create table if not exists i2019.supplierh i2019.ka...

java - JPanel How to create an instance/object -

i keep mixing jframe , jpanel. have code compiles nothings happens , program ends. this homework assignment requires draw triangle. add button, when button pressed triangle flip upside down. press again return first location. any assistance great. countless rough draft , i'm trying initiate object view. import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.awt.geom.line2d; import java.awt.color; public class triangle extends jpanel implements actionlistener { jbutton button = new jbutton("just flip it"); public triangle() { add(button); button.addactionlistener(this); } public void actionperformed(actionevent e) { } @override public void paintcomponent(graphics g) { super.paintcomponent(g); g.drawline(125,75,100,200); g.drawline(125,75,150,200); g.drawline(100,200,150,200); } public static void main(string[] args) { triangle frame = new triangle();...

r - How to make the points look larger in ggplot -

Image
ggplot(data_exp, aes(x = transaction, y = exp, size = count, colour = class, label = label)) + geom_point(alpha = 0.5) + geom_text(colour = "black", vjust = 0, nudge_y = 0.5, size = 3, fontface = "bold") i want make points in plot larger, try make size becomes count*1000, nothing seems change. use size aesthetic in geom_point an example; library(ggplot2) data(mtcars) # increase point size based on variable value p <- ggplot(mtcars, aes(wt,mpg)) p + geom_point(aes(size=wt*100))

android - How to display markers from sqlite on OpenStreetMap -

i'm creating application sqlite database , openstreetmap. in db i've store data id, type of building, year, function, latitude , longitude. i'm trying display on openstreetmap markers db , 1 marker current gps position. @ moment @ map displaying location , first record db. how can display markers on map? p.s. tried using various examples found in google my mapa class public class mapa extends activity implements locationlistener { private mapview osm; private mapcontroller mc; private locationmanager locationmanager; wywiaddata wywiaddata; int id_marker; double dlugosc; double szerokosc; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.map_view); osm = (mapview) findviewbyid(r.id.mapview); final float scale = getbasecontext().getresources().getdisplaymetrics().density; final int newscale = (int) (256 * scale); string[] osmsource = new string[2]; osmsource[0] = ...

Exclude all records below specific row in R -

the data have contain 3 variable 3 unique ids , each has multiple records. see below id <- c(rep(1,7), rep(2,6), rep(3,5), rep(4,6)) t <- c(seq(1,7), seq(1,6), seq(1,5), rep(2,6)) y <- c(rep(6,7), rep(1,6), rep(6,5), rep(0.2,6)) z <- c(5,0,0,0,1,0,0,0,0,-1,0,0,0,4,2,nan,0,1,0,0,1,inf,inf, inf) dat1 <- data.frame(id, t, y, z) for each id, if value of z below 0 (negative), nan, inf, or -inf, need exclude record , records below it. for data, new processed data like: id <- c(rep(1,7), rep(2,2), rep(3,2), rep(4,3)) t <- c(seq(1,7), seq(1,2), seq(1,2), rep(2,3)) y <- c(rep(6,7), rep(1,2), rep(6,2), rep(0.2,3)) z <- c(5,0,0,0,1,0,0,0,0,4,2,0,0,1) dat2 <- data.frame(id, t, y, z) ave , group-by substitute. using cumsum counter identify subsequent rows deletion: dat1[with(dat1, ave(z < 0 | (!is.finite(z)), id, fun=cumsum) == 0),] quick check see match, exception of rownames not lining up: all.equal( dat2, dat1[with(dat1, ave(z <...

vb.net - Cannot find usb device iot core -

trying connect apc ups via usb , send raw data. package.appxmanifest <devicecapability name="usb"> <device id="vidpid:051d 0002"> <function type="name:vendorspecific"/> </device> </devicecapability> startuptask.vb imports system imports system.collections.generic imports system.linq imports system.text imports system.net.http imports windows.applicationmodel.background ' background application template documented @ http://go.microsoft.com/fwlink/?linkid=533884&clcid=0x409 public notinheritable class startuptask implements ibackgroundtask public async sub mainpage_load(sender object, e routedeventargs) handles mybase.loaded dim vid uint32 = &h51d dim pid uint32 = &h2 dim filter string = windows.devices.usb.usbdevice.getdeviceselector(vid, pid) dim dev windows.devices.enumeration.deviceinformationcollection = await windows.devices.enumeration.deviceinformati...