Posts

Showing posts from March, 2015

java - Get X/Y coordinates on ImageView touch -

so, need coordinates of touch on imageview. i have tried coordinates in ontouchlistener event. not need. the problem resolution of screen lower resolution of picture in imageview. how actual coordinates (maybe pixels) of image? android: how x y coordinates within image / imageview? imageview.setonclicklistener(new onclicklistener() { @override public void onclick(view view) { int[] values = new int[2]; view.getlocationonscreen(values); log.d("x & y",values[0]+" "+values[1]); } }); something this?

How to connect to Statistics Canada JSON from R -

i'm trying connect online database through r, can found here: http://open.canada.ca/data/en/dataset/2270e3a4-447c-45f6-8e63-aea9fe94948f how able load data table r , able change table name in code access other tables? i'm not particularly concerned language need use (json, json-ld, xml). thanks in advance! assuming know urls each of datasets similar question can found here: download file https using download.file() for becomes: library(rcurl) url <- "http://www.statcan.gc.ca/cgi-bin/sum-som/fl/cstsaveascsv.cgi?filename=labr71a-eng.htm&lan=eng" x <- geturl(url) urlout <- read.csv(textconnection(x),row.names=null) i obtained url right-clicking access button , copying address. i had declare row.names=null number of columns in first row not equal number of columns elsewhere, read.csv assumes row names as described here . i'm not sure if url these datasets change when updated, isn't convenient way data. json doesn't s

XCode project missing files on other Mac -

i have multiple xcode projects in dropbox can use them on imac , macbook. when open projects on mac of imported images, videos etc... red (missing). files in project root folder. can do? this error because when added files (images, documents, etc) did not tick copy if needed option. that means if deag/drop items desktop project, xcode reference documents desktop. when opening project on computer, xcode not finding documents in desktop of other computer, error. solution: 1- delete red marked items (take note of them) 2- move them again project , make sure check copy items if needed checkbox. 3- re upload project wherever need , run. happy coding!

jhipster - micro-service always connects to localhost for consul -

i have generated microservice configured consul jhipster 4.6.2. i'm running consul docker (with virtualbox). as result, not running on localhost (but e.g. 192.168.99.100). hence modified application-dev.yml of microservice set host : cloud: consul: discovery: prefer-ip-address: true host: 192.168.99.100 port: 8500 ... when start micro-service, still trying connect localhost (i.e. property below not taken account). got exception : com.ecwid.consul.transport.transportexception: org.apache.http.conn.httphostconnectexception: connect localhost:8500 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1, localhost/fe80:0:0:0:0:0:0:1%1] failed: connection refused any idea ? thanks ! my config jhipster: { "generator-jhipster": { "promptvalues": { "packagename": "org.fge.msconsul" }, "jhipsterversion": "4.6.2", "basename": "msconsul", "packagename": "org

How do I stop my turtles from stacking up on NetLogo? -

how stop turtles stacking on netlogo? i need turtles move, not on top of each other , stop piling up. i tried following code: to go ask turtles [ let empty-patches neighbors [not any? turtles-here] if (breed = ricos) [ face one-of patches [ price = 1000 ] if any? empty-patches [ fd 1 ] ] if (breed = pobres) [ face one-of patches [ price = 1000 ] if any? empty-patches [ fd 1 ] ] if (breed = medias)[ if any? empty-patches [ face one-of patches [ price = 1000 ] fd 1] ] ] end move-to-empty-one-of [locations] move-to one-of locations while [any? other turtles-here] [ move-to one-of locations ] end but still piling up. welcome stack overflow! helpful provide minimal complete verifiable example of code reproducible- increase chance useful answer. if have set turtles breeds( breed [ ricos rico ] ), can ask ricos [ ... do call move-to-empty-one-of [locations] procedure somewhere? not called in example code, , procedure, might tur

user interface - Naming conventions for UI component variables? -

i have ui class managing different components in user can interact with. having read design priciples , ui terminoloty guidelines manage: the active component user last clicked on , has keyboard focus, being rendered differently show typing can performed caret appearing in text-field. the pointed component below user's hotspot or mouse pointer, propably being highlighted show available interaction. and component right call handled component , unsure weather or not right way call it. component user performed pressing event on, did not yet release it. component user might initiate drag&drop operation on. how call it? there might more things 1 might need keep track of when writing own ui handling framework. there guidelines have not found yet worth read?

Setting Console Font in C on Windows 10 -

i trying change size of console font in console application during runtime. looking windows documentation, found following functions: getcurrentconsolefont (and getcurrentconsolefontex ) , setcurrentconsolefontex . console_font_info prevfontinfo = {sizeof(prevfontinfo)}; getcurrentconsolefont( getstdhandle(std_output_handle), false, &prevfontinfo ); console_font_info fontinfo = {0}; //fontinfo.cbsize = sizeof(prevfontinfo); fontinfo.dwfontsize.x = 30; fontinfo.dwfontsize.y = 70; //fontinfo.fontweight = 700; setcurrentconsolefontex( getstdhandle(std_output_handle), false, &fontinfo ); ... (some irrelevant code here) setcurrentconsolefontex( getstdhandle(std_output_handle), false, &prevfontinfo ); currently getting following warnings: implicit declaration of function 'getcurrentconsolefont' and implicit declaration of function 'setcurrentconsolefont' i tried using getconsolefontex (the reason fontweight , cbsize commented ou

mongodb - Testing spring boot application with embedded mongo -

my application has spring boot spring data mongo db. i trying unit test case dao layer using embedded mongo.while searching in internet, came across 2 annotations *@springboottest *@testsbmongo.. i confused annotations usage.my question 1.what difference between these annotations 2. getting connection refused error when using @testdbmongo 3.how use embedded mongo test when original mongo server running

regex - <listRel:entityId>(.*?)<\/listRel:entityId> -

good day. my work requires me query , response it. cannot seem remove letters or name on match group. need numbers 917857 i use rubular check if match correct. 917857 james bond here regex number number @ start of string , numbers: \<listrel:entityid\>(\d+)[\s\w]+<\/listrel:entityid\> here working example: regex101 this adjusted match additional input example.

Writing multiple columns into csv files using python -

i python beginner. trying write multiple lists separate columns in csv file. in csv file, have 2.9732676520000001 0.0015852047556142669 1854.1560636319559 4.0732676520000002 0.61902245706737125 2540.1258143280334 4.4032676520000003 1.0 2745.9167395368572 following code wrote. df=[2.9732676520000001, 4.0732676520000002, 4.4032676520000003] cs=[1854.1560636319559, 2540.1258143280334, 2745.9167395368572] int_peak=[0.0015852047556142669, 0.61902245706737125, 1.0] open('output/'+file,'w') f: dt,int_norm,css in zip(df,int_peak,cs): f.write('{0:f},{1:f},{2:f}\n'.format(dt,int_norm,css)) this isn't running properly. i'm getting non-empty format string passed object. format error message. i'm having hard time catch going wrong. spot what's going wrong code? you better off using pandas import pandas pd df=[2.9732676520000001, 4.0732676520000002, 4.4032676520000003] cs=[1854.1560636319559, 2540.12

ios - UIswitch to activate or deactivate an image array in seperate view controller -

Image
overview - making flashcard app. have gotten point user can swipe left , right through array of images. images split 11 different groups , of groups add 1 final array user can swipe through(code below). import uikit class secondviewcontroller: uiviewcontroller , uigesturerecognizerdelegate { @ibaction func home(_ sender: any) { performsegue(withidentifier: "home", sender: self) } @iboutlet weak var imgphoto: uiimageview! struct list { let words: [string] var active: bool } let list1 = list(words:["lake", "lamb", "lamp", "lark", "leaf", "leash", "left", "leg", "lime", "lion", "lips", "list", "lock", "log", "look", "love", "lunch"], active: true) let list2 = list(words: ["ladder", "ladybug", "laughing", "lawnmower", "lemon", "leop

32bit pyodbc for 32bit python (3.6) works with microsoft's 64 bit odbc driver. Why? -

what can observe: i using windows 7 64bit code (establish odbc connection sql server on network, simple reading operations only) written in python 3.6.2 32bit i pip installed pyodbc, assume 32bit well. i downloaded , installed 64bit "microsoft® odbc driver 13.1 sql server®" microsoft website. my python code connects other computers on network, run server2003 32bit , either sql server 2005(32bit) or sql2008(32bit). the setup works. moreover: cursory test shows that, above setup can connect computer microsoft server2008(64bit) running sql2012(64bit) configuration under "sql server network connection (32bit)" being empty (meaing, 32bit dll missing), while default 64 bit network connection configuration contains usual config options ip adress , listening port info. my own explanation: [1] client , server's os , odbc interfaces can of 32/64 bit combination, protocol travels thru network between computer , sql computer identical. [2] 32 bit python+

wso2 - WSO2IS OAuth/OpenId Connect SSO Setup -

i'm trying figure out how setup applications sso using wso2 identity server. use case have 2 applications secured oauth/openid connect using wso2is. if i'm logged application 1, launching application 2 should automatically log me in. should flow be? currently, have created 2 service providers, 1 each application. each service provider inbound authentication configuration configured using oauth/openid connect. else need do? i've followed https://docs.wso2.com/display/is530/configuring+oauth2-openid+connect+single-sign-on . i'm success on being redirected login , each application able obtain access token , jwt. however, i'm being asked login each application separately---no automatic login when access application 2. thank you! wso2is output when login application 1 follow application 2, within same browser , tab. <<< application 1 >>> [2017-07-27 21:30:17,117] debug {org.wso2.carbon.identity.oauth2.oauth2service} - validate client

amp html - AMP IFrame is not working in AMP LightBox -

example:- <amp-lightbox id="my-lightbox" layout="nodisplay"> <div class="lightbox" on="tap:my-lightbox.close" role="button" tabindex="0"> <amp-iframe width="350" height="300" layout="fixed" sandbox="allow-scripts allow-same-origin allow-popups" frameborder="0" src="https://ampbyexample.com/"></amp-iframe> </div> </amp-lightbox> <button class="ampstart-btn caps m2" on="tap:my-lightbox" role="button" tabindex="0">open iframe in lightbox</button> i tried manipulate position of iframe 75% or 600px top it's not working. the amp iframe contains jquery ui calendar want use delivery date selected user in our amp page. is possible , pass value in amp iframe? if having problems iframe displaying, add placeholder image iframe element. allow circumven

html - CSS, box that scrolls but doesn't disappear -

i not sure if wording right. have googled different terms. in plain english want a: box scrolls doesn't disappear. i trying achieve boxes similar linkedin's side boxes. scroll page stop scrolling , never disappear. a mix of: position:fixed , position:absolute ? i have other boxes on box question, positioned in exact same area side box. it's not possible raw css, though is possible if use javascript. need work out how far down page user is, , add content every time scroll number of pixels. this can achieved jquery. can bind $(window).scroll() function, , check height $(window).scrolltop() . append new content .append() . in following example, $(window).scrolltop() + $(window).height() > $(document).height() - 100 checks when user 100 pixels away reaching end of content. new content appended, , scrollbar grows in length. because checks against height of document, every time end of new content reached, loop trigger again, , more content crea

android - Fixing the tabs in PagerTabStrip -

Image
i have pagertabstrip setup, tabs don't good. how make tabs normal? (centered in middle - no double lines) here picture of it thanks if can lead me solution. find wierd how can't seem find answer question here xml - pretty plain. <android.support.v4.view.viewpager xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="visible"> <android.support.v4.view.pagertabstrip android:id="@+id/pager_title_strip" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/primary_blue" android:textcolor="#fff" /> </android.support.v4.view.viewpager> use pagertabstrip in viewpager here picture. you can this. xml code <?xm

Avoid R function paste generating backslash for quotes -

i trying 2 strings contain quotations ("") combined character/string vector or r function paste can plug result in argument x of writeformula in openxlsx package. an example this paste('hyperlink("file)',':///"&path!$c$1&trim(mid(cell("filename",b',sep="") and hope should produce result this hyperlink("file:///"&path!$c$1&trim(mid(cell("filename",b but produces result backslash in front of ": [1] "hyperlink(\"file):///\"&path!$c$1&trim(mid(cell(\"filename\",b" i have searched many potential solutions replace paste cat or add noquote function in front of paste output not character vector. functions tostring or as.character convert these results strings backslash comes well. really appreciate helps this. thanks. there no backslashes in p . backslashes see how r displays quote (so know quote part of string , not ending de

wordpress - Widget form fields displaying just after click on save or refresh the admin page -

Image
when add widget sidebar first time in wordpress admin can't display form fields but if click on save or refresh admin page form fields display can me solve problem?

mysql - Online Gadget Retail Management System -

i designing online gadget retail system. have different gadgets categorized mobiles, laptops, accessories etc. have 2 questions: 1) have single table named " products " or have multiple tables such mobiles, laptops, accessories etc ? 2) how choose product id? thank in advance. it's not seperate products in several tables - you'll have union 3 tables select products, not convenient. you should have 2 tables - products , categories . in products you'll store information on products foreign key - category_id . in categories you'll store, well, categories of products - laptop, mobile etc. now can work 1 table instead of 3 , distinct product categories. "how choose product id" - simplest solution create integer product_id autoincrement in products table.

php - The call to other actions does not work correctly with TYPO3 Extbase -

i have contoller calls socialprofile 1 action profile of twitter, facebook or google+ , save socialprofile object, each one. end of action calls edit action objective of end user add groups of categories (not typo3 category), problem second action not work correctly. i have been using instruction calls editaction @ end of createaction $this->redirect('edit', null, null, array('profileid' => "{$profileid}"),11); now editaction public function editaction( $socialprofile = null) { $arguments = $this->request->getarguments(); var_dump($arguments); $groups = enum\gruposcontenidos::categorygrouplist(); $this->view->assign('categorygroups', $groups); $this->view->assign('socialprofile', $socialprofile); } the error next required argument "socialprofile" not set vendor\extension\controller\socialprofilecontroller->edit. exception code:1298012500

html - TYPO3 laterally border around "Grid Element" -

actually creating border around website in typo3 (version 7.6.14). creating whith 3 border pictures (one top, 1 bottom , 1 left , right side) , still workes fine @ "normal" pages. only border left , right side created css , 2 others in template. whole page surroundet div "website". now added "grid element" main page. in website div included. border not shown @ grid elements part , non of tries workes. my css code following one: div#website { width:1200px; text-align:left; position: relative; background-image:url(images/border_lr.jpg); background-repeat:repeat-y; background-position:left; } i know pixel methode not best way, should not problem, changed , tryed resize other content, did not helped. border not in background, not created @ grid elements part of website. why not use :before , :after pseudo-elements ?

json - python slackclient userslist -

i trying use python slackclient. getting json.decoder.jsondecodeerror: expecting value: line 1 column 1 (char 0) error this, print (slack_client.api_call("users.list")) in below code. tried this, still getting error, print (json.loads(slack_client.api_call("users.list"))) please suggest wrong, first 2 api calls works fine , return result. users list api call giving me error print (slack_client.api_call("api.test")) print (slack_client.api_call("auth.test")) print (slack_client.api_call("users.list")) traceback (most recent call last): file "print_bot_id.py", line 15, in <module> print (slack_client.api_call("users.list")) file "/users/vt/anaconda3/lib/python3.6/site-packages/slackclient/_client.py", line 83, in api_call result = json.loads(self.server.api_call(method, timeout=timeout, **kwargs)) file "/users/vt/anaconda3/lib/python3.6/json/__init__.py", line 354, in l

python 3.x - Pandas: How to analyse data with start and end timestamp? -

Image
i have analyze activity of users uses application during given period, periods start , end timestamp. tried bar chart not know how include hours in interval. ex : user uid=2 use application @ [18, 19, 20, 21] my dataframe like: uid sex start end 1 0 2000-01-28 16:47:00 2000-01-28 17:47:00 2 1 2000-01-28 18:07:00 2000-01-28 21:47:00 3 1 2000-01-28 18:47:00 2000-01-28 20:17:00 4 0 2000-01-28 08:00:00 2000-01-28 10:00:00 5 1 2000-01-28 02:05:00 2000-01-28 02:30:00 6 0 2000-01-28 15:10:00 2000-01-28 18:04:00 7 0 2000-01-28 01:50:00 2000-01-28 03:00:00 df['hour_s'] = pd.to_datetime(df['start']).apply(lambda x: x.hour) df['hour_e'] = pd.to_datetime(df['end']).apply(lambda x: x.hour) uid sex start end hour_s hour_e 1

python - Sprite keeps shaking up and down -

i have implemented gravity game, , keeps pulling down onto player. yet, when player standing on platform, keeps shaking , down. how can fix this? player_acc = 0.65 player_friction = -0.12 player_gravity = 0. class player(pg.sprite.sprite): def __init__(self, game, x, y): self.pos = vec(width / 2, height / 2) self.vel = vec(0, 0) self.acc = vec(0, 0 def collision_with_walls(self): collision = pg.sprite.spritecollide(self, self.game.walls, false) if collision: self.pos.y = collision[0].rect.top self.vel.y = 0 def update(self): self.acc.x += self.vel.x * player_friction self.vel += self.acc self.pos += self.vel + 0.5 * self.acc self.collision_with_walls() self.rect.midbottom = self.pos all/any appreciated!

c++ - How to pass data between preestablished windows in Qt? -

i have wizard class, creates 3 pages in form of qstackedwidget in constructor. each page own class. in page one, have variety of forms , i've implemented slot assigns them when next button clicked. they're assigned respective variables in wizard class. goal pass information pagetwo class appropriate computations. pointers on how this? wizard class class wizard : public qdialog { q_object public: wizard(); qstring nameinput; etc } constructor wizard::wizard() : qdialog() { pages = new qstackedwidget(); pages->addwidget(pageone = new pageone(pages)); pages->addwidget(pagetwo = new pagetwo(pages)); connect(next, signal(clicked(bool)), this, slot(saveforminfo())); } assignment function void wizard::saveforminfo() { nameinput = pageone->nameedit->text(); etc } pagetwo class class pagetwo : public qwidget { public: pagetwo(qwidget *parent = 0); void displayoutput(qhboxlayout *layout); } is right way

nginx - App on a Vagrant box running Laravel Homestead only displays 'It Works' upon fresh install of Laravel App -

i install new laravel app /sites folder called 'blog' using laravel new blog terminal command. the site builds fine, no errors on terminal. then used subl /etc/hosts command open hosts file in sublime text 3. here contents of file. ## # host database # # localhost used configure loopback interface # when system booting. not change entry. ## 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost 127.0.0.1 laraveltest.app 127.0.0.1 makoto.app 127.0.0.1 modelawiki.app 127.0.0.1 fresher.app 127.0.0.1 blog.app right let's focus on blog.app. i use subl homestead.yaml command open , edit homestead.yaml file , update maps. here's contents of file. --- ip: "192.168.10.10" memory: 2048 cpus: 1 provider: virtualbox authorize: ~/.ssh/id_rsa.pub keys: - ~/.ssh/id_rsa folders: - map: ~/www/sites to: /home/vagrant/sites sites: - map: blog.app to: /home/vagrant/sites/blog/public - map: larav

java - Hibernate property update -

when use hibernate property <property name="hibernate.hbm2ddl.auto" value="update"/> , consult doesn't work. the hibernate log is: : jul 27, 2017 8:28:18 pm org.hibernate.resource.transaction.backend.jdbc.internal.ddltransactionisolatornonjtaimpl getisolatedconnection info: hhh10001501: connection obtained jdbcconnectionaccess [org.hibernate.engine.jdbc.env.internal.jdbcenvironmentinitiator$connectionproviderjdbcconnectionaccess@6974a715] (non-jta) ddl execution not in auto-commit mode; connection 'local transaction' committed , connection set auto-commit mode. if remove update property, can consults, generate tables don't. can't generate tables , need this. this persistence.xml : <?xml version="1.0" encoding="utf-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation=&qu

android - Toggle between Application for debug build and MultiDexApplication for release build -

one of test phone not able install app adb when application class extending multidex application. i attempted implement this on build.gradle app application class extending multidexapplication cannot compile. buildtypes { release { multidexenabled false } debug { multidexenabled true } } references: 1. https://developer.android.com/studio/build/multidex.html 2. can enable multidex in android debug build only? 3. conditionally inherit class keep application class extend multidexapplication , add line attachbasecontext if (buildconfig.debug) { multidex.install(this); }

Create a function to change bin size in a histogram with hist in R -

write function accepts vector, vector of integers, main axis label , x axis label. function should iterate on each element in vector of integers , produce histogram each integer value, setting bin count element in input vector, , labeling main , x-axis specified parameters. should label y-axis read frequency, bins = , number of bins. i trying not reading in nclass 3 different bin sizes correctly. doing wrong? plot.historgrams <- function(x,nclass, ...){ (i in 1:length(nclass)) { hist(x,nclass=nclass[i], ...) } } plot.histograms(hidalgo.dat[,1], c(12,36,60), main="1872 hidalgo issue",xlab= "thickness (mm)") it seems working when use breaks , put x= in front of data set. plot.historgrams <- function(x,b, ...){ (i in 1:length(b)){ hist(x=x,breaks=b[i], ylab=paste("frequency, bins= ",b[i]), ...) } } plot.historgrams(x=hidalgo.dat[,1], c(12,36,60), main="1872 hidalgo issue",xlab= "thickness (mm)"

vb.net - Covering Panel with another -

private sub frmitem_load(sender object, e eventargs) handles mybase.load pnldeposit.visible = false pnlwithdraw.visible = false end sub private sub cmdideposit_click(sender object, e eventargs) handles cmdideposit.click pnldeposit.visible = true pnlwithdraw.visible = false end sub private sub cmdiwithdraw_click(sender object, e eventargs) handles cmdiwithdraw.click pnlwithdraw.visible = true pnldeposit.visible = false end sub //i having problem form. want show first panel successful, problem showing second panel. not working, im using buttons btw. me. thank in advance :d here quick example using bringtofront . both panels having same location , being same size. public class form1 private switchpanels boolean private sub btn_click(sender object, e eventargs) handles btn.click switchpanels = not switchpanels if switchpanels panel1.bringtofront() else panel2.bringtofront() end if end sub end class

javascript - Displaying checkbox data when clicked -

i'm trying make multiple select checkbox ... if click checkbox checkbox b follow click too. checkbox appears, b checkbox created in hidden state css .. <button type="button" id="delete" title="delete">delete</button> <input type="checkbox" class="select_data" id="a" name="a[]" value="a" /> <input type="checkbox" class="info_del" id="b" name="b[]" value="b"> $('#delete').click(function() { if($('#a').is(":checked")) { $('#b').attr('checked', true).val(); } var data = $(".select_data:checked, .info_del:checked").serialize(); console.log(data); }); i believe have syntax issue 1 line of jquery. try changing line: $('#b').attr('checked', true).val(); to: $('#b').prop('checked', true)

c# - AutoMapper overrides source properties -

i have following code update student entity: using static automapper.mapper; ... public void update(studentinputdto dto) { student student = _studentrepository.getstudent(); student = map<student>(dto); //student.studentnumer null here :( _studentrepository.update(student); } my student entity: public class student { public guid studentid { get; set; } public string firstname { get; set; } public string lastname { get; set; } public int age { get; set; } public guid genderid { get; set; } public string studentnumber { get; set; } } my studentinputdto: public class studentinputdto { public string firstname { get; set; } public string lastname { get; set; } public int age { get; set; } public guid genderid { get; set; } } the problem student.studentnumber null after mapping. i want configure automapper in such way student.studentnumber preserved after mapping. how ? appreciated. my initial thought configure automapper in f

c++ - How to find maximum(or minimum) in any subarray(of any size) in a given array? -

we given array , queries. each query contains 2 numbers i , j . need find maximum(or minimum) element in subarray starting index i , ending @ index j in given array. for eg. arr = [2 , 3 , 5, 8 , 4 , 9] and query 1: (2 , 4) the subarray corresponding query [5 , 8 , 4] . so, maximum 8 . note: number of queries 10^5 , there 10^6 elements in array. time limit execution of program 1s . so, guess solution needed has complexity of o(log n) or less per query, n number of elements in array. counter = i-1 max = min_integer min = max_integer while counter < j: if arr[counter] > max: max = arr[counter] if arr[counter] < min: min = arr[counter] counter++ return max,min edit: alternatively, insert maxheap , minheap (o(n)), , thereafter queries o(1).

ios - Alamofire failing to upload a file to Google Cloud Storage -

i'm trying upload media file gcs(google cloud storage) via alamofire. below code. let soundurl = url(fileurlwithpath: dirpaths.appending("/audio-file.wav")) let headers: httpheaders = [ "content-type": "audio/wav", "authorization": "bearer <mytoken>" ] alamofire.upload( multipartformdata: { multipartformdata in multipartformdata.append(soundurl, withname: "name") }, to: "https://www.googleapis.com/upload/storage/v1/b/<folder-name>/o?uploadtype=media?&name=audio-file.wav",method: .post, headers: headers, encodingcompletion: { encodingresult in switch encodingresult { case .success(let upload, _, _): upload.responsestring(completionhandler: { (response) in print(response) }) case .failure(let encodingerror): print(encodin

android - Start a new activity from an Imagebutton inside a fragment -

i have fragment class button , want start new activity button . me please? here mainfragment.class : public class mainfragment extends fragment { public mainfragment() { // required empty public constructor } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // inflate layout fragment return inflater.inflate(r.layout.fragment_main, container, false); } } @override public void onviewcreated(view view, bundle savedinstancestate) { view.findviewbyid(r.id.buttonid).setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { startactivity(new intent(...)); } }); } replace buttonid id of button , fill out intent .

c++ - How to get the distance of the object and How to use camera calibration matrix correctly? -

Image
i succesfully calibrate camera using opencv. camera lens using. https://www.baslerweb.com/en/products/vision-components/lenses/basler-lens-c125-0418-5m-f1-8-f4mm/ the internal , external camera parameter given below. cv::mat cameramatrix(3, 3, cv::datatype<double>::type); cameramatrix.at<double>(0) = 1782.80;//fx //432.2 in mm cameramatrix.at<double>(1) = 0; cameramatrix.at<double>(2) = 3.0587694283633488e+002;//cx cameramatrix.at<double>(3) = 0; cameramatrix.at<double>(4) = 1782.80;//fy cameramatrix.at<double>(5) = 3.0535864258476721e+002;//cy cameramatrix.at<double>(6) = 0; cameramatrix.at<double>(7) = 0; cameramatrix.at<double>(8) = 1; cv::mat discoeffs(1, 5, cv::datatype<double>::type); discoeffs.at<double>(0) = -8.1752937039996709e-001;//k1 discoeffs.at<double>(1) = -2.5660653367749450e+001;//k2 discoeffs.at<double>(2) = -1.555692293181

How to convert two's complement binary to decimal in ruby? -

what easiest way convert two's complement binary decimal? example, if convert string such as"1001" decimal i'll 9. i'm trying simple -7. guys suggest?, from question looks using 4 bit system. might work you, got results asking for. here 2 functions, 1 4 bit , 1 16 bit twos' complement. # 4 bit def convert_4bit_to_signed_binary(binary) binary_int = binary.to_i(2) if binary_int >= 2**3 # 4 bit return binary_int - 2**4 else return binary_int end end # 16 bit def convert_16bit_to_signed_binary(binary) binary_int = binary.to_i(2) if binary_int >= 2**15 # 4 bit return binary_int - 2**16 else return binary_int end end = convert_4bit_to_signed_binary('1001') # give -7 j = convert_16bit_to_signed_binary('1001') # give 9 puts puts j let me know if works you?

mysql - Store multiple rows data with multiple columns using table field in backpack for laravel -

i creating form has product , multiple prices @ multiple stores i.e. amazon, ebay, etc. compare price , provide minimum price consumer. i have problem build type of form. unable store data in database using table field of backpack, need it. crud controller: <?php namespace app\http\controllers\admin; use backpack\crud\app\http\controllers\crudcontroller; // validation: change requests match own file names if need form validation use app\http\requests\menrequest storerequest; use app\http\requests\menrequest updaterequest; class mencrudcontroller extends crudcontroller { public function setup() { $this->crud->setmodel('app\models\men'); $this->crud->setroute(config('backpack.base.route_prefix') . '/men'); $this->crud->setentitynamestrings('men', 'mens'); //$this->crud->setfromdb(); // ------ crud fields // $this->crud->addfield($options, 'update/

r - how to find top N descending values in group in dplyr -

i have following dataframe in r serivce codes abs rt abs rt abs ty abs dr abs dr abs dr abs dr def rt def rt def ty def dr def dr def dr def dr def ty def se def se what want service wise code count in descending order serivce codes count abs dr 4 abs rt 2 abs ty 1 def dr 4 def rt 2 def ty 2 i doing following in r df%>% group_by(service,codes) %>% summarise(count = n()) %>% top_n(n=3,wt = count) %>% arrange(desc(count)) %>% as.data.frame() but,it not give me intended. we can try count/arrange/slice df1 %>% count(service, codes) %>% arrange(desc(n)) %>% group_by(service) %>% slice(seq_len(3)) # tibbl

Date formatting in BigQuery -

i have found many date functions cloud bigquery , have specific case , none of available functions seem work. data have date column in 'mmddyy' format , convert 'yyyy-mm-dd' format. how can achieve this? this 1 possibility: #standardsql data as( select '072817' dt union select null union select '' ) select if(dt != '', format_date("%y-%m-%d", parse_date("%m%d%y", dt)), dt) data

How to efficiently use logging in Google App Engine python application? -

how can print log messages debugging purposes in google cloud endpoints frameworks application implemented in python? since cloud endpoints apps deployed on app engine , followed app engine's docs on reading , writing application logs , , tried find log messages on gae console logs . that did not though using available filters, since log entries have hundreds of lines of nested json objects, , log message buried in among metadata , unrelated info in 1 log entry. is there way print , view log messages simple python application running on local machine?

css - Button gets extended when using flexbox to -

i trying put button @ center of div section using flex-box. here code: <div> <a href="#" class="btn btn-outline-primary btn-lg" style="display: flex; justify-content: center;">button</a> </div> however, button extended after compiling. how should modify codes avoid problem of extension? .btn{ padding:0 0; margin:auto; width:20px; } this css fix issue

actionscript 3 - Adobe AIR StageWebView fail to show web page with javascript -

i'm trying write mobile app using adobe air shows web page. want show web page , allow user browse it. the problem when try i'm getting lots of javascript errors , page partially rendered in unreadable way. i've tried pass true usenative ctor parameter didn't seem make difference. is there way display html content web in adobe air without using ane? you don't need ane allow users browse web page adobe air. using webview best, simple, popular way. webview.stage = this.stage; webview.viewport = new rectangle(0, 0, stage.stagewidth, stage.stageheight); webview.loadurl("http://www.example.com"); your problem not actionscript code developed. it's page loading webview element. if page has javascript errors webview , has javascript errors using simple browser on mobile device (or on desktop). thus, passing true usenative not solve problem. to solve problem, run app in debug mode , javascript errors in debug console. me, example