Posts

php - Symfony3 / Doctrine - function: adding row with foreign key -

i starting adventure symfony3 (and php) , encountered problem. at moment application supposed allow user crud projects. displaying works fine, have problem creating. i have got 2 tables: users , projects. project table contains project data including project owner id of user. symfony docs managed map both tables: part of "project" entity: /** * @orm\manytoone(targetentity="user", inversedby="projects") * @orm\joincolumn(name="uid", referencedcolumnname="id") */ private $uid; /** * set uid * * @param \appbundle\entity\user $uid * * @return project */ public function setuid(\appbundle\entity\user $uid = null) { $this->uid = $uid; return $this; } /** * uid * * @return \appbundle\entity\user */ public function getuid() { return $this->uid; } part of 'user' entity: private $projects; public function __construct() { $this->projects = new arraycollection(); } at point i...

React Native | Firebase authentication | Impossible to trigger navigator -

i’ve been stuck since 3 days problem. i’ve migrated app firebase , react native working charm except user authentication. i’m trying trigger navigator when user logs in. i’m using following method : componentdidmount() { firebase.auth().onauthstatechanged(function(user) { if (user) { global.userid = user.uid alert(‘test’) var naviref = this.refs.navref naviref.push({ ident: ‘home’ }) } else { // no user signed in. } }); } i alert(‘test’) navigator nothing. if put naviref.push outside « onauthstatechanged » working. have no idea can now. there better solution using navigator ? i think should trick: componentdidmount() { firebase.auth().onauthstatechanged((user) => { if (user) { global.userid = user.uid alert(‘test’) var naviref = this.refs.navref naviref.push({ ident: ‘home’ }) } else { // no user signed in...

Django formset error: select fields cause partially filled forms -

i have form utilizes choices argument i've created formset. when page containing formset rendered, fields uses choices argument display drop-down select widgets. forms filled user have no errors. however, forms not filled user have 'this field required' errors other fields fields used select widget. it appears select field's initial values causing form treated half-filled form , form validation process throws errors required fields not filled. # form: class ownerform(forms.form): name = forms.charfield(label = 'name', max_length = 20) owner_entity = forms.choicefield(label = 'owner entity', choices = owner_entities) num_of_shares = forms.decimalfield(label = 'number of shares' , min_value = 0.0, max_digits = 5, decimal_places = 2) share_class = forms.choicefield(label = 'share class', choices = share_classes) joined_date = forms.datefield(label = 'joined date', help_text = 'mm/dd/yyyy') # v...

r - Cannot find function readDICOM, though oro.dicom is installed -

i struggeling reading dicom files in r. have installed oro.dicom package, using: install.packages("oro.dicom", repos="https://cran.cnr.berkeley.edu/") i have set working directory files located. when trying read dicom file, using... slice=readdicom("im-0001-0011.dcm") ... following error message: error: not find function "readdicom" can help? thank you, lena you should load package library(oro.dicom) fisrt before use functions package,

arrays - Javascript - Collection of objects with parent properties in common -

i'd create collection of objects works array. time ago, made this question , came following solution of people helped me: newobj.collection = function(){ array.apply(this); for(var = 0; < arguments.length; i++){ for(var j = 0; j < arguments[i].length; j++){ this.push(arguments[i][j]); } } return } newobj.collection.prototype = object.create(array.prototype); newobj.collection.prototype.push = function(o){ array.prototype.push.call(this, new newobj.element(o)); } however, leaves children unconnected parent. example, imagine collection has render() function, makes children print html onto page. well, i'd able like: newobj.collection.html_container = '#cont'; newobj.collection.render = function(){ $.each(this, function(i, el){ el.render() }) } newobj.element.render = function(){ $(parent.html_container).html('.......') } it should able set different collections in 1 page, m...

excel - On making MATCH function like FIND function -

i'm trying make match function work find function. first of all, generate dummy data use testing. here routine use: sub data_generator() randomize dim data(1 100000, 1 1) dim p single = 1 100000 p = rnd() if p < 0.4 data(i, 1) = "a" elseif p >= 0.4 , p <= 0.7 data(i, 1) = "b" else data(i, 1) = "c" end if next range("a1:a100000") = data end sub now, create sub-routine find string a in range data . there 2 methods use here employ match function. first method reset range of lookup array following code: sub find_match_1() t0 = timer dim long, j long, k long, data range dim output(1 100000, 1 1) on error goto finish set data = range(cells(j + 1, 1), "a100000") 'reset range of lookup array = worksheetfunction.match("a", data, 0) j = j + output(j, 1) = j 'label position of k = k + 1 ...

PHP Combine Associative Arrays If Specific Key Matches Inside For-Loop -

i working combine 2 different arrays based on comparison of key if values match, otherwise combine not occur. here short example of each array begin with, both array 1,000 items: vehicle array ( [vehicle] => 2016 ford transit 250 cargo van [stockno] => 153721 [msrp] => 32195 [price] => 32195 [payment] => 359 [type] => new [bodystyle] => van [mileage] => 6 [year] => 2016 [make] => ford [model] => transit 250 [trim] => cargo van ),( [vehicle] => 2016 ford f150 xlt [stockno] => 153723 [msrp] => 36195 [price] => 36195 [payment] => 429 [type] => new [bodystyle] => truck [mileage] => 6 [year] => 2016 [make] => ford [model] => f150 [trim] => xlt ) special array ( [vehicle] => 2016 ford transit 250 cargo van [store] => baxter ford [offertype] => $ off msrp [offervalue] => $10,000 [disclaimer] => *valid on in-stock models. based on stock #1616...

sql - How to query items that have full match of its children in Child table -

i have 2 tables: parentchild , child. parentchild table has 2 columns pid , cid, 1 pid can map multiple cids. child table contains distinct cids. thing cids in child table doesn't cover cids in parentchild table. now want find pids each pid has cids in child table. examples: p1 has 3 cids, if in child table, p1 selected; p2 has 2 cids, if not in child table, p2 not selected. how write query in clear , performant way? one method uses aggregation: select pc.pid parentchild pc left join child c on pc.cid = c.cid group pc.pid having count(*) = count(c.cid); the last condition checks children match.

web services - Client App with WsHttpBinding gets "no endpoint listening at..." -

i have client application talks our web service hosted on server (we'll call hostserver ). client application can build , connect fine using basichttpbinding . however, i'm trying impliment wshttpbinding security reasons. last week before lunch swear working hardcoded certificate. came lunch, checked in code , won't run. keep getting "there no endpoint listening @ https://hostserver:1234/service.svc/myservicename accept message. caused incorrect address or soap action.". i've tried re-checking settings, retracing steps, can't seem functioning state in. i using servicereference address of "https ://hostserver:1234/service.svc?singlewsdl". can navigate "https ://hostserver:1234/service.svc" without problem , view wsdl. my client code is wshttpbinding wsbinding = new wshttpbinding(securitymode.transport); wsbinding.security.transport.clientcredentialtype = httpclientcredentialtype.certificate; client = new myservicename(wsbi...

android - Setting Margins for EditText in AlertDialog -

Image
i've created alertdialog edittext in android app, default margins off. i've tried specify margins follows: android.support.v7.app.alertdialog.builder builder = new android.support.v7.app.alertdialog.builder(spinactivity.this); builder.settitle("edit spin tags"); builder.setmessage("(separate tags commas)"); // set input int margin = 10; final edittext input = new edittext(spinactivity.this); input.setsingleline(); input.settext(spintags.tostring().replace("[", "").replace("]", "")); builder.setview(input, margin, 0, margin, 0); however, image below, can see not applying desired effect. other options i've tried including placing input in linearlayout , setting margins using layoutparams before setting alertdialog view linearlayout. how set margins edittext in alertdialog? actually solution work...

postgresql - Query the contents of a Django model's JSONField -

i'm trying figure out way query data inside postgres jsonfield on particular instance of model. from i've seen, use cases things equivalent of if had attributes jsonfield, , selecting instances of model attributes ->> color = 'red' or whatever. so let's give more real example, let's have model shoe , has price , quantity , whatever fields, jsonfield called versions , array of objects, each objects having things make each version special. so if 1 instance of shoe model air jordans, attributes jsonfield like: [ { color: black, edition: limited, tonguecolor: red }, { color: black, edition: standard }, { color: gold, edition: fancy, bright: } ] so there's 2 things can do, can: query model shoes have available version color: black (which return our air jordans, plus maybe other shoes), or query instance of model objects inside jsonfield ...

android - isExternalStorageRemovable throws Illegal exception even if SD card is attached with device -

i got paths application using getexternalfilesdirs api. after each file calling isexternalstorageremovable (file_name) check whether storage removable or not. throws exception: java.lang.illegalargumentexception: failed find storage device @ _given_path_ what possible reason this. sd card still inserted in device only.

IntelliJ IDEA: How to open pop-up "New in Current Directory" -

Image
i using intellij idea ultimate 2016.2 (on using os x el capitan 10.11.6), follow video tutorial: https://youtu.be/d3nnjmk1gwe?t=3m39s , don't know how open pop-up "new in current directory". intellij has universal shortcut find other ctrl+shift+a using can find action new... has shortcut ctrl+alt+insert

sql - MS Access "This recordset is not updatable" in a SELECT query -

i'm stumped regarding message ms access giving me. i trying run select query, 2 sub-queries within it. tables local. could please explain me why following code returning error? select s.sku, s.date, s.[order no], p.wsp, p.average_cost, s.[item status] [item detail temp] s, [fd worksheets temp] p [p].[sku]=[s].[sku] , [p].[date use]=(select min(p2.[date use]) [fd worksheets temp] p2 p2.[sku] = s.[sku] , p2.[date use] >= s.[date]); giving google hasn't particularly helped. have macros enabled in security make sure wasnt it, , can tell dont have sort of grouping in code above cause error? additionally, believe code work fine, whole time loading bar message displayed in bottom left corner of screen. runs incredibly slow, , i'm sure have run query in past without message showing up, , quicker currently. many thanks edit: after looking bit more, have found few possible reasons: ...

c# - Detect if a new record is the same as the existing record in database -

suppose there records in database this: id v1 v2 v3 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 and suppose new records this: id v1 v2 v3 1 1 2 1 5 5 5 5 now, want insert new records in way: 1. check if id exists in database; 2. if doesn't exist, insert record directly; 3. if exists, detect if record same new one. if not, update changed values. since real data large , contains 50+ variables , want make inserting fast, ask there general way detect if new record of same id different existing record in entity framework. can't 50+ if see variables have been changed. please make sure solution applicable large data set, thanks. you can use merge perform "upsert" operation: merge #t tgt using ( values (1,1,2,1), (5,5,5,5) ) src (id, v1, v2, v3) on tgt.id = src.id when matched update set tgt.v1 = src.v1, tgt.v2 = src.v2, tgt.v3 = src.v3 when not matched target insert (id, v1, v2, v3) ...

xaml - PrepareContainerForItemOverride works different in Desktop than in Mobile UWP -

i wanted change color of item of listview according data value. easy doing: <listview.itemcontainerstyle> <style targettype = "listviewitem" > < setter property="background" value="{binding eventtype, converter={staticresource eventtypetobackcolorconverter}}" /> </listview.itemcontainerstyle> but thing uwp not support binding in setter properties. second attempt overriding preparecontainerforitemoverride of listview: public class eventlistview : listview { protected override void preparecontainerforitemoverride(dependencyobject element, object item) { base.preparecontainerforitemoverride(element, item); var listviewitem = element listviewitem; var ev = item eventtype; if(ev.warning) listviewitem.background = new solidcolorbrush(color.red); } } the above code works fine running in pc windows 10 , uwp. colors in red items according underlying data....

c - Iterate through memory using pointers -

i new c; have more background knowledge java. want try searching value in memory using pointer #include <stdio.h> void main(){ int value = 10; find(value); } void find(int value){ // change return array of long or int depending on better int* intpointer; for(int = 40000; < 40400 ; i+= 32){ /* not sure if or way, * starting value, ending value , condition * testing purpose */ intpointer = (int*)i; if(*intpointer == value){ printf("found value"); //will storing array instead } } } the find method gives me segmentation fault because address not store int value. there way can find out type data stored in memory address. is there better way of achieving similar task? please explain , show. actual program not have int value = ?? instead find method used array of addresses contains value. also best type stor...

c# 4.0 - how to insert current date into access database? -

Image
actually im creating 1 application inserted user sales count, sales count updating fine when edit in query putting current date not updating detail here im putting whole code private void button1_click_1(object sender, eventargs e) { this.txtinput.maxlength = 4; cmd = new oledbcommand("update login set sales_count= iif(isnull(sales_count), 0, sales_count) + 1 [unique_no]=@unique_no , [to_date]='#"+datetime.now.tostring("dd/mm/yyyy")+"#'", con); cmd.parameters.addwithvalue("@unique_no", txtinput.text); con.open(); int n = cmd.executenonquery(); if (n == 0) { messagebox.show("invalid unique no. pls try again later");// **debugger come line if insert [to_date]='#"+datetime.now.tostring("dd/mm/yyyy")+"#'** // if remove above line in code updating fine ...

vim - Saved macro to do substitution without hitting return and remaining in current position -

i'm trying write macro save/configure in .vimrc let . without ^m , have hit return after typing @b . ^m , goes line of last replacement. i'd remain in current position macro executed. what way use let i'm trying accomplish? let @b=':%s/searchterm/blah/g^m' you'll need set macro mark current position can return there after substitutions have finished: let @b='mc:%s/searchterm/blah/g^m`c'

jwt - Auth0 and Angular 2: login and routing failing using the login widget -

i starting develop web applications , chose angular 2 front-end framework. i'm trying out auth0 user authorisation. problem follows: trying implement landing page login -> redirect functionality. after opening website should check if there user's token in localstorage , either show login widget or redirect home page. have ran nasty bug: when i'm logging in, page refreshes , widget appears again: tokennotexpired() reason returns false . press login again same credentials - page refreshes, login widget disappears, logging shows tokennotexpired() returning true now, redirect still doesn't work. if enter base address, http://localhost:4200 , redirects me home , tokennotexpired() returns true . i tried debugging without luck - can't find failing. essentially, sure there problems in way approach coding redirect feature, since lack of experience. kindly appreciate help, been sitting on while. i'm including excerpts of code omitting redundant parts....