Posts

Showing posts from September, 2015

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....

java - Passing values from pages to components in magnolia -

if have variable assign in page: <#assign myvar = "testing"> <@cms.area name="area-name"/> and i'd able use variable in nested area or component, how pass around application? <#list components component> ${myvar} </#list> [@cms.area name="main" contextattributes={"myvar":myvar}/] ${ctx.myvar} enjoy! :)

jsf - Primefaces autocomplete multiple with forceSelection false -

i'm using primefaces 6.0, in <p:autocomplete> doesn't work multiple=true , forceselection=false . you can find component below: <p:autocomplete value="#{bean.value} multiple="true" completemethod="#{bean.completetheme}" forceselection="false"/> how can insert custom value not listed? you can add inserted custom value in complete method, this: public list<string> completemethod(string query) { list<string> suggestions = new arraylist(); suggestions.add(query); //... add more suggestions return suggestions; }

javascript - Pass result from a function to another function on nodejs -

i have function connect db , consult in it. function conn (text){ var mysql = require("mysql"); var connection = mysql.createconnection({ connectionlimit : 100, //important host : 'xxx.xxx.xxx.xxx', user : 'xxxxxx', password : 'xxxxxxx', database : 'xxxxxxxx' }); connection.connect(); var querystring = 'select usuario.idusuario usuario usuario.nickname = ' + '"' + text + '"'; function getid(text, callback){ connection.query(querystring, function(err, rows, fields) { var id; if (err){ callback(err, null); }else{ (var in rows) { id = rows[i].idusuario; } callback(null, id); } }); } var result; getid(text, function(err, content) { if (err) { console.log(err); } else { result = content; } }); connection.end(); }; now, need result in other variable use in other functions inside js file. how ...

How to reduce Physical Memory usage in SQL Server -

i have 32 gb physical memory server. when starting server taking 18gb memory when server , sql server 2008 r2 up. after few hours sql server taking 23gb or more cached size going 4939 or more. cause of problem , how can see queries making problem?` sql loves memory, it'll use needs to, when caching data. nature of caching data using memory. if concerned leaving little memory server or other processes running on server, set max memory amount sql.

javascript - Track and count firebase calls -

i looking way can count user firebase calls made user node in firebase or it's child nodes. firebase structure looks below: users/uid1/xyz - user 1 users/uid2/abc - user 2 is there way count calls made web app access uid1 node or it's below child nodes done read , write operation user 1. there no public api count number of firebase api calls. wrap api own function counting. var ref = firebase.database().ref(); function updateuser(uid, userobj) { ref.child('users').child(uid).set(userobj); ref.child('userupdatecount').transaction(function(currentvalue) { return (currentvalue || 0) + 1; }); }

java - Multiple Instances of Android Application open - ONLY on Touchwiz -

i have been working on application android devices - , have noticed perplexing issue occurs on devices running samsung touchwiz! when application running on touchwiz device bug occurs. bug can reproduced pressing "back" button while application in foreground - , launching again home screen (or anywhere else icon may be). looking in multi-tasking menu clear system launches second instance of application! second instances totally independent first instance , 2 not seem connected in way. i thought prevent behavior adding singleinstance applications manifest, did not appear trick. manifest: <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsrtl="true" android:theme="@style/apptheme" android:launchmode="singleinstance"> <activity android:name=".mainactivity" android:screenor...

vba - Cell's formula not acting as a formula in excel? -

i have set cell's formula equal sum, yet cell displays equation, instead of result of equation... value not calculated, nor displayed. can copy contents of formula cell , paste 1 , cell display result, need initial 1 display it. here code: set sumrangebegin = cells(sumrow, beginsumcolumn) set sumrangeend = cells(sumrow, endsumcolumn) set sumrangetotal = range(sumrangebegin, sumrangeend) activecell.formula = "=sum(" & sumrangetotal.address & ")" the cell literally display =sum($aa$854: $av$854) (resulting had set variables initially... sumrow , sumcolumn's), won't display result. not sure why is. try -most cause cell set text- activecell.numberformat = "general"

Bootstrap help two forms -

please me understand if did correct code image. didn't finished because wasn't sure right. two forms bootstrap image boostrap: <div class="home-top-selects container-fluid"> <div class="row"> <div class="consulter-form col-sm-5 col-md-5 col-lg-5"> <h2>consulter les petites annonces</h2> <div class="form-group container"> <h4>par mot-cle les petites annonces<h4> <div class="row"> <div class="col-md-3"> <input type="text" class="form-control" id="usr"> </div> <div class="col-md-2"> <select class="form-control" id="sel1"> <option>toutes categories</option> ...

javascript - Default image's display doesn't change despite the source of the image changing. -

var allimages = [imagedata, imagedata1, imagedata2, imagedata3, imagedata4]; var count = 0; $("#right").click(function() { if (count < 5){ document.getelementbyid("hello").src = allimages[count]; count++; } }); to explain code, array allimages contains base64 versions of 5 images. #hello id of default image. #right id of button. so when click #right, #hello's source supposed change 1 of images inside allimages array. however, nothing happens display when click #right. i've tried changing source outside of right click function , when that, display of #hello correctly change. in addition that, #right click function work cause i've stuck alert inside of before activated upon click. probably need check value of count . quite possible count being global variable other block of code might have been updating value leading (count < 5) = false . suggestion : try after renaming variable or rem...

javascript - Transpiling jsx using babel for react app -

i trying transpile jsx file using babel , giving error. the content of file follows, ( src/app.js ) class channel extends react.component{ render() { return( <li> </li> ) } } i used following commands transpile , watch file changes. 1) babel src/app.js --watch --out-file js/app.js 2) babel src/app.js --presets es2015 --watch --out-file js/app.js in both cases recieved following error, syntaxerror: src/app.js: unexpected token (4:12) 2 | render() { 3 | return( > 4 | <li> </li> | ^ 5 | ) 6 | } 7 | } it shows error @ start of html tags embedded in javascript file (jsx). babel expected know html tags , treat , compile it, don't know why behave that. note: installed babel using babel documentation official website. you'll need react preset well. to install it: npm babel-preset-react to use it: babel src/app.js --presets es...

c# - windows service doesn't write files remote server via vpn connection -

i'm writing windows service must write log files in remote server, part of network via secure vpn connection (p2p), can write log files in directory ( like "\10.10.10.10\mylogfolder\log.txt ") via console application, use test business classes. via console app, works correctly when try inject business class service, doesn't work... i believe it's installation/privilege issue, i've put winservice install using localsystem privileges didn't work well. can me? thanks in advance! localsystem limited account network access. you'll need set service account has required privileges on remote machine.

c++ - How to avoid waitForStarted with QProcess to stop GUI from freezing? -

i running wscript qprocess run vb script converts excel files tab delimited text files. script runs fine , everything, gui freezes , user unable interact significant amount of time. here code: /* create txt files , store paths */ (int = 0; < excelfilepaths.size(); ++i) { wscript->start("wscript.exe", qstringlist() << vbs.filename() << excelfilepaths.at(i) << newdir.absolutepath() + "/" + qstring::number(i + 1)); wscript->waitforfinished(); payloadpaths.push_back(newdir.absolutepath() + "/" + qstring::number(i + 1)); } so whats going on have multiple excel file paths , qprocess allocated on heap. qprocess runs vb script converts excel files text files , stores path of new text file. takes long time (about 20 seconds 4 excel files). during time gui frozen. user able use parts of gui don't interfere process. now suspect cause of issue is qprocess::waitforfinished() and i've read online connectin...

javascript - One button, mulitple links. Link changes depending on which div is open -

so asked question got overly complicated , think it's buried because i'm not getting new answers. to see i'm trying change you'll have google red ink themeforest. i'm using portfolio page of template. when click 1 of portfolio items "true gangsters" info pulled div , plugged previous section formatting. all want add button links youtube videos these portfolio items , able pull link div , have formatted button. in jsfiddle included formatted div , "true gangsters" section formatted div gets info from. i included of portfolio part javascript i'm pretty sure important part: //update text info function updatetext(current) { var title = current.attr('data-title'); var desc = current.attr('data-description'); var date = current.attr('data-date'); controls.find('h2').html(title); controls.find('p').html(desc); controls.find('.dat...

reactjs - React — nested onClick handlers? -

i have button component inside parent component , need button component handle button style onclick of button element , while parent handles click of btn component . i've got clickhandler working in btn component, not parent. what's best way this? fiddle // button component class btnfav extends react.component { constructor(props) { super(props); this.state = {favorited: false}; this.handleclick = this.handleclick.bind(this); } handleclick() { this.setstate({favorited: !this.state.favorited}); } render() { var btnstyle = this.state.favorited ? 'btn-fav' : 'btn-notfav'; var btntext = this.state.favorited ? 'favorited' : 'not favorited'; return ( <button classname={btnstyle} onclick={this.handleclick}>{btntext}</button> ); } }; // parent class btnparent extends react.component { constructor(props) { super(props); this.alsodothis = this.alsodothis.bind(this); } also...

unity5 - unity android - build and run game on pc -

i new unity, , trying make simple product, in meanwhile tutorials found in web. though faceing problem - can't figure out why can't build , run game on pc. when hit build , run button, android, tells me there no device connected, can't compile, though, want test game on pc, don't want connect phone device, want test on pc. isn't possible? can't check game on pc? thank help pressing play button above scene should run locally. otherwise, check file -> build settings , change platform pc. if you're trying test android code on local machine, you'll still need connect device or spin android emulator.

How to do line continuation with quotes in Livecode? -

in livecode script have put "create table containers ( `id` integer not null, `name` text not null, `description` text, `location` text, `kind` text not null, `capacity` integer not null, primary key(id) )" tsql it read better if use line continuation in put "create table containers (\ `id` integer not null,\ `name` text not null,\ `description` text,\ `location` text,\ `kind` text not null,\ `capacity` integer not null,\ primary key(id)\ )" tsql but \ not seem work when line contains double quotes. there other way accomplist his? unfortunately can't use line continuation character inside quoted string, since treated literal value. have close string , concatenate, this: put "create table containers (" & \ "`id` integer not null," & \ "`name` text not null," & \ "`description` text," & \ "`location` text,...

javascript - Using Webpack to include React from CDN, but not ReactDOM -

in webpack build, load react cdn, not reactdom, requires roundtrip small file. my webpack configuration has following block of code declaring "externals" not build these files (i instead include cdns). webpack.config.js ... externals: { react: 'react' }, ... the problem only including react in externals still builds react because reactdom depends on it. node_modules/react-dom/index.js module.exports = require('react/lib/reactdom'); adding 'react-dom': 'reactdom' externals removes them both bundle, don't want have include reactdom cdn... how can configure webpack load react cdn, include reactdom in main bundle? note: i'm using webpack 2.1.0-beta17 , react 15.1.0. update tried adding react/lib/reactdom externals. ... externals: { react: 'react', 'react/lib/reactdom': 'commonjs react-dom' }, ... but following error. require not defined [not answer,...

Scala instantiate a Concrete Class From Generic Type -

i have trait generic , goes this: trait mytrait[t] { def dosomething(elems: seq[t]) } i have object factory definition goes this: object mytraitfactory { def apply[t](param1: boolean, param2: boolean): mytrait[t] = { // based on type of t, instantiate sub types } } i have come concrete implementations example: class mystringtrait extends mytrait[string] class myinttrait extends mytrait[int] i need magic bit type in object factory , instantiate corresponding implementations. suggestions? this can solved in scala using implicit typeclass. create factory trait concrete implementations each of types: object mytraitfactory { def apply[t](param1: boolean, param2: boolean)(implicit factory: mytraitcreator[t]): mytrait[t] = { // call typeclass create method factory.create(param1, param2) } // factory trait trait mytraitcreator[t] { def create(param1: boolean, param2: boolean): mytrait[t] } // provide implicit factory object speci...

javascript - Div only fixed between two divs -

i want use following code ( demo here ). there way not have fixed div scroll between points set in pixels top, between 2 divs above , below fixed div? $(window).scroll(function(){ $("#thefixed").css("top",math.max(0,250-$(this).scrolltop())); }); not sure understand question long modify math.max(0,250-$(this).scrolltop()) there should no specification. (20,250...) 20 px top. and if want specify div can use $('thediv').offset() like : var offset = $("#thefixed").offset() $(window).scroll(function(){ $("#thefixed").css("top",math.max(offset.top,250-$(this).scrolltop())); }); live exemple there

javascript - Why does sinon fakeserver not reply to request from Vue component -

i chasing race condition since days now. glad help. both sinon fakeserver , vue.js related question. here setup of my little project : the project based on awesome vue webpack template . i have rather elaborate vue component called doogietable shows table. can load data remote rest endpoint. (using vue-resource) i have mocha test case doogietable . second test loading remote data table problem. the test mocks xhhtmlrequest sinon.fakeserver , responds canned data. this works long set fakeserver.autorespond = true; according sinon doc, not suitable production ready unit tests. when/where in code of test case have call fakeserver.respond() ? things tried: calling right after the vue component doogietable became ready => seems to early. @ point in time, request load data has not been send component. (i think. not quite sure) calling in vm.$nexttick callback => same problem. no request yet.

javascript - Cant execute an html file that includes AJAX -

i'm new @ html , want run code includes script demonstrates ajax.this file saved html file. when try run in localhost script doesnt execute. dont understand why. can explain this? <!doctype html> <html> <head> </head> <body> <p id="demo">let ajax change text.</p> <button type="button" onclick="loaddoc()">change content</button> <script type="text/javascript"> function loaddoc() { var xhttp; if (window.xmlhttprequest) { // code modern browsers xhttp = new xmlhttprequest(); } else { // code ie6, ie5 xhttp = new activexobject("microsoft.xmlhttp"); } xhttp.onreadystatechange = function() { if (xhttp.readystate == 4 && xhttp.status == 200) { document.getelementbyid("demo").innerhtml = xhttp.responsetext; } }; xhttp.open("get", "ajax_info.txt", true); ...

c++ - What are the differences between the following codes -

given code: #include <iostream> using namespace std; int main() { typedef struct node { int data; node* left; node* right; } *nodeptr; nodeptr root, curr, temp; } and second code: #include <iostream> using namespace std; int main() { struct node { int data; node *left; node *right; } node *root, *curr, *temp; } i have few questions: do both codes represent same thing? does int* a , int *a represent same thing? in first code when declared: queue < nodeptr >q worked in second code when declared queue < node >q didn't work. why? are both codes represents same thing ? they represent same thing, except first 1 defines nodeptr typedef ed name. is int* , int *a represents same thing? yes. for first code when declared: queue < nodeptr >q worked second code when declared in code: queue < node >q did not worked. why? queue<nodeptr> q same...

Split a git branch or commit by file type -

i have branch containing html , javascript code. cross cutting reasons, need submit mass change html first @ later date js. @ moment have single branch both kinds of changes it. how can sort commit 2 smaller commits (or branches) file type? you can't change existing commit, can make new commits parent same commit existing "committed much" commit. before start, make sure have clean work tree ("nothing commit"). way no git reset or whatever can lose anything. if necessary can make new commit might need zorg~2 instead of zorg~1 (see diagrams below). able retrieve saved items commit later. draw have right now as usual git, start drawing (at least part(s) of) commit graph. on branch now, means have branch name pointing tip-most commit, , commit pointing parent commit, , on: ...--a--b--c--d <-- zorg where zorg current branch , presumably d too-big-commit , c commit before has neither set of changes. (if had make more commits,...

google cloud sql - Is there a way to upgrade to a different v2 instance type without downtime? -

is possible create read replica/failover, shut down master , switch slave instance master, upgrade old master , make new master again - upgrading or down instance types without downtime? i took @ failovers, appear activate when master shut down maintenance , not when master shut down. if not, feature in works? thanks. you cannot upgrade 1st generation 2nd generation, have create new instance. can use import , export function transfer data (storing them temporary in cloud storage). for transfer period use read-only replica avoid changes. note might need make small or bigger changes code access different in many ways.

jOOQ update returning clause with Oracle -

according http://www.jooq.org/doc/3.8/manual/sql-building/sql-statements/update-statement/ jooq doesn't support returning clause in update statements databases except firebird , postgres. does know, still correct oracle jooq? according oracle's documentation, oracle db supports returning clase delete, insert, or update statements. incorrect manual you're right - manual wrong , should fixed: https://github.com/jooq/jooq/issues/5470 single row update returning jooq 3.8 added support single row update .. returning statements. internally, uses callablestatement , pl/sql block of form: begin update "my_table" set "my_table"."column" = 'xyz' "my_table"."id" = 1 returning "my_table"."id", "my_table"."column" ?, ?; ? := sql%rowcount; end; the relevant issue is: https://github.com/jooq/jooq/issues/5190 multi row update returning a...

android - SD-Card-> Missing value -

really need help. 1 week i'am trying save (raw-)data(-bytes) correctly sd-card of android phone. the mobile data via bluetooth microcontroller. data printed out correctly terminal, java-code incorrect. for testing this, variable (8bit) incrementing , after step value of variable sending phone. when read out created file hex-view, there lot of zeros between guilty values ( in case: µc not sending anything) , reason there lot of values missing / maybe chronology wrong. the saving part: h=new handler() { public void handlemessage (android.os.message msg) { switch (msg.what) { case recieve_message: byte[] readbuf = (byte[]) msg.obj; string path = "/sdcard/" + dateipfad.gettext().tostring() + ".txt"; environment.getexternalstoragedirectory().getpath(); try { file myfile = new file(path); myfile.createnewfile(); fileoutputstream fout = new ...

Swift What is the model file use for and how does it work? -

i saw developer using user.swift or post.swift. use , why seems every developer had it. some code find online https://github.com/dasoga/chat-firebase/blob/master/chatrealtime/model/user.swift import uikit class user: nsobject { var id: string? var name: string? var email: string? var profileimageurl: string? } the idea of model class encapsulate data used app in own class, offering cleaner separation of model controller , view. see model-view-controller in apple's cocoa core competencies. or see model object . but setting aside these broader design principles, let's consider user class: class encapsulates series of properties, namely identifier, name, email address, , image url. so, why use user type, rather individual properties and/or standard collections? let's consider alternatives, illustrative of why model object user can powerful: consider app maintained list of users. array of user objects far more convenient than, say, separate arrays...