Posts

Showing posts from August, 2013

ios - React Native Stateless component saying undefined -

i'm trying create component using react native so: export class indicatoroverlay extends component { render() { return ( <view> <text>text</text> </view> ); } }; the above works, when try make stateless so... export default ({ text = 'text' }) => { return ( <view> <text>{text}</text> </view> ); }; i following error: element type invalid: expected string (for built-in components) or class/function (for composite components) got: undefined. forgot export component file it's defined in. i'm sure i'm missing basic, can't see it. use similar stateless component in react web app , it's fine. using react 16.0.0-alpha.6 , react-native 0.43.2, , seeing error in iphone simulator. hope can :) this because first example named export, while second 1 default 1 therefore way need import them different. assuming import module this:

android - MediaPlayer not playing live stream for some audio file -

some audio file url not playing in mediaplayer here code mediaplayer = new mediaplayer(); if (mediaplayer != null) { try { string audiourl = constants.audiolink.tostring().replace(" ", "%20"); mediaplayer.setdatasource(audiourl); mediaplayer.prepareasync(); mediaplayer.setonerrorlistener(new mediaplayer.onerrorlistener() { @override public boolean onerror(mediaplayer mediaplayer, int i, int i1) { progressdialogs.getinstance().closedialog(); toast.maketext(audioplayactivity.this, "failed load audio", toast.length_short).show(); return false; } }); mediaplayer.setonpreparedlistener(new mediaplayer.onpreparedlistener() { @override public void onprepared(mediaplayer mediaplayer) { progressdialogs.getinstance().

Why is there a need for both Assignee and Assignees in GitHub? -

currently experiment github api, , noticed following: if request issue, has both assignee , set of assignees - same properties user above. feature introduced year ago , seems. while see reason having assignees , don't understand why have both properties, if, in case of having assignees set, first 1 assignee. why isn't set of assignees enough store information? 1 thing can imagine keeping assignee legacy reasons, other explanation can be? here example, right on official github page. can see, assignee octocat, , after calling post /repos/:owner/:repo/issues/:number/assignees , assignees octocat , 2 new users. i haven't seen official rationale github, think it's safe has maintaining api compatibility. they couldn't change assignee field being single user object being list of user objects since break existing api clients assume single object. they didn't want bump api version v4 small change that. so solution add new assignees field,

c# - Issue in Enabling CORS for Web API 1, .net 4.0 -

i need enable cors web api , can't upgrade framework 4.5. i've tried add following web.config see if worked, didn't: <add name="access-control-allow-origin" value="*" /> <add name="access-control-allow-headers" value="accept,content-type,x-requested-with"/> i accessing url http://localhost:8484/api/values/ ajax call and getting bellow error xmlhttprequest cannot load http://localhost:8484/api/values . response preflight request doesn't pass access control check: no 'access-control-allow-origin' header present on requested resource. origin 'null' therefore not allowed access. response had http status code 405. i found simple solution charanjit singh. worked nicely if stuck older visual studio 2010 , on .net 4.0 , of course web api 1. add function global.asax.cs protected void application_beginrequest(object sender, eventargs e) { httpcontext.current.response.addheader(&q

Trying draw circles in PyQt5 -

i want implement following: when press left mouse button in part of main window the circles having concrete radius must appear. unfortunately nothing occurs. to avoid displaying of source code can show important event part of it: def pressleftmousebutton(self, event): leftmousebutton=qtcore.qt.leftbutton if event.button() == leftmousebutton: painter=qtgui.qpainter(self) centerx=event.x() centery=event.y() painter.setpen(qtcore.qt.black) painter.drawellipse(centerx, centery, 40, 40) thank you! luck!

php - How can I redirect after a form submission? -

this question has answer here: how make redirect in php? 21 answers currently coding post command php pushes data e-mail. i'm looking find way redirect afterward server has sent e-mail url. <?php $email_from = 'my@e-mail.co.uk'; $email_subject = "new form submission"; $email_body = "you have received new insurance enquiry $firstname $lastname $gender born on $dobday $dobmonth $dobyear $smoker after $insurtype want cover $cover,000 $years years $meandpartner contact information: mobile: $mobile telephone: $landline e-mail: $email street: $street city: $city postcode: $postcode partner details: $pfirstname $plastname $pgender $pdobday $pdobmonth $pdobyear $psmoker " ?> <?php $to = "my@email.co.uk"; $headers = "from: $email_from \r\n"; $headers .= "reply-to: my@email.co.uk"; mail($to,$email_sub

Getting JSON response with 400 bad request in Angular 2 -

Image
im trying call rest api of magento 2 angular 2. facing issue long , need fix on same or atleast suggestion on issue is? below how im calling rest angualar: @injectable() export class productservice { public _producturl = 'http://10..../mage_ang2/index.php/rest/v1/customers/1'; constructor(private _http: http) { } getproducts(): observable<iproduct[]> { let headers = new headers({ 'content-type': 'application/json; charset=utf-8' }); headers.append('authorization', 'bearer ntthnrbj1uam2tuv1ekva7n8jh18mcnkby3'); let options = new requestoptions( {method: requestmethod.get, headers: headers }); console.log(headers); return this._http.get(this._producturl,options) .map((response: response) => <iproduct[]> response.json()) .do(data => console.log('all: ' + json.stringify(data))) .catch(this.handleerror); } when post same in postman, response. when run through angular2, same heade

memory - GC and java heap analysis in Android Studio -

i'm playing around in android studio learn more memory leaks. what noticed that, after rotating screen couple of times, see multiple instances of activity (after clicking on "initiate gc" , "dump java heap"). but when click 2 times on "initiate gc", , click after on "dump java heap", see activity , inner classes have 1 instance. why have click twice on "initiate gc" clear activity instances? leaking memory or not? edit: noticed happens when creating new project blank activity. i'm not leaking memory, i'd still know why instances aren't destroyed on first gc the "initiate gc" button signal gc run. when java gc runs, not guaranteed memory references can cleared, cleared @ gc run. this trigger gc run. when gc runs has same behavior. so have click multiple times "initiate gc" until verify object afraid leaking has been cleared gc. there plenty info out there, example thread ho

cannot create a list from list template in sharepoint online -

i not able create list list template,things have done saved list template in 2013 site , downloaded template list template gallery uploaded template list template gallery in sharepoint online site after these steps when clicked on add app option not able see template list needs created any regarding appreciated

c# - Sendgrid- unble to concatinate plaintext along with html hyperlink -

i using sendgrid send email when try concatinate plaintext , html hyperlink seems constructed correct in email email html tag. my code: string myhtml = string.format(@"<a href='{0}'>here</a>", activationlink); string message = string.format("dear {0} {1}\n", firstname, lastname) + "to verify email address click "; sendmail(email, subject, message, myhtml); below sendmail method: public bool sendmail(string to, string subject, string message, string htmlcontent) { try { var client = new sendgridclient(configurationmanager.appsettings["key"].tostring()); emailaddress = new emailaddress(configurationmanager.appsettings["from"].tostring()); var subject = subject; emailaddress = new emailaddress(to); string content = message; //var htmlcontent = "<strong&

Kendo Grid for Angular 2 virtual scroll -

faced virtual scrolling issue grid angular 2. grid scroll on first page , pagechangeevent not fires. can scroll down empty space. can affect pagechangeevent? how ever when scroll on top, pagechangeevent being fired fields {scroll: nan, take: undefined}. ideas? i guess may because of dependencies? here pachage.json: "dependencies": { "@angular/animations": "^4.0.2", "@angular/common": "^4.0.0", "@angular/compiler": "^4.0.0", "@angular/core": "^4.0.0", "@angular/flex-layout": "^2.0.0-beta.7", "@angular/forms": "^4.0.0", "@angular/http": "^4.0.0", "@angular/material": "^2.0.0-beta.3", "@angular/platform-browser": "^4.0.0", "@angular/platform-browser-dynamic": "^4.0.0", "@angular/router": "^4.0.0", "@ng-idle/keepalive": "^2.0.0

Navbar changing colour on scroll, how does this jQuery work? -

so i've copied code question here navbar changes color on scroll. it: $(document).ready(function(){ var scroll_start = 0; var startchange = $('#startchange'); var offset = startchange.offset(); if (startchange.length){ $(document).scroll(function() { scroll_start = $(this).scrolltop(); if(scroll_start > offset.top) { $(".navbar-default").css('background-color', '#f0f0f0'); } else { $('.navbar-default').css('background-color', 'transparent'); } }); } }); it's working , (with necessary id/classes changed ofcourse), want know how works since have no idea. understand code saying change colour of navbar once top of screen scroll past top of #startchange. that's really, im not sure offsets , scrtolltop doing. obviously, im new js/jquery. in advance. in summary offset() , scrolltop() jquery functions. jquery library of javascript functions. js language browser

javascript - JQuery get value out of json by key -

i generate json looks this: { "attendees": [ { "datum": "tue, 11 apr 2017 00:00:00 gmt", "name": " muylaert-geleir", "prename": "alexander" }, { "datum": "wed, 12 apr 2017 00:00:00 gmt", "name": " obolina", "prename": "angelina" }, { "datum": "thu, 13 apr 2017 00:00:00 gmt", "name": " obolina", "prename": "angelina" }, ] } how value keys , place tables? got... $.ajax(settings).done(function (response) { (i = 0; < response.attendees.length; i++){ console.log(i); $('tbody').append('<tr><td>'+ response.attendees["name"] + '</td><td>'+ response.attendees["prename"] + '</td><td>' + response.attendees["datu

inheritance - c++, cannot instantiate abstract class -

i have class called enemy , 1 called groundenemy1. keep getting same error cannot "instantiate abstract class", these 2 classes, searched on internet couldn't fix it. hope can me.` #pragma once #include "vector2f.h" #include "collisionmanager.h" class enemy { public: enemy(collisionmanager &collmanager); virtual ~enemy(); void move(vector2f move); void update(float elapsedsec); virtual void draw() =0; protected: bool m_jump; rectf m_shape; vector2f m_velocity,m_inputvelocity; collisionmanager m_collmanager; float m_jumpspeed, m_acceleration,m_jumpcooldown,m_walkspeed; }; class groundenemie1 :public enemy { public: groundenemie1(collisionmanager &collmanager,sprite &sprite,rectf shape); virtual ~groundenemie1(); void draw() override; protected: sprite m_sprite; }; you can't declare object abstract class because of virtual void draw() = 0 function enemy class abstr

c# - Is there something akin to SetupGetSequence in Moq -

in moq , know there setupsequence setting sequential usage of function , there setupget setting value property. however need set property in sequential way. is there way setting sequential in moq ? note: did not write interface or service mocking, therefore cannot change it. sequencing return values setupsequence works property getters : mock.setupsequence(m => m.propertyname).returns(1).returns(2).returns(3); note: can use setup instead of setupget , because moq checks whether body of given lambda expression property , calls setupget internally [source code] . benefit have skipping internal check.

mysql - How to merge two rows and get single array in Codeigniter/PHP? -

Image
i working on codeigniter assigning multiple roles single user. have created table following values. array ( [id] => 1 [store_address_id] => [customer_ref_id] => 193 [role_ref_id] => 1 [email_alert] => 0 [sms_alert] => 0 [admin_view] => 0 [admin_save] => 0 [admin_delete] => 0 [master_view] => 1 [master_save] => 1 [master_delete] => 1 [business_view] => 0 [business_save] => 0 [business_delete] => 0 [analytics_view] => 1 [analytics_delete] => 1 [analytics_save] => 1 [promotion_view] => 1 [promotion_save] => 1 [promotion_delete] => 1 ) but, in database having multiple rows need value validation +----+----+----+ | i/p|i/p | o/p| +----+----+----+ | 0 | 0 | 0 | +----+----+----+ | 1 | 1 | 1 | +----+----+----+ | 1 | 0 | 1 | +----+----+----+ | 0 | 1 | 1 | +----+----+----+ my table this i need validate , fetch single ar

Elasticsearch scroll getting same results -

using elasticsearch 5.3.0, getting same results using srcoll api. both results , scroll_id returns remains same first call curl -xpost 'localhost:9200/myindex/mytype/_search?scroll=1m&pretty' -h 'content-type: application/json' -d' { "size": 5, query: { "match_all": {} } } ' curl -xpost 'localhost:9200/_search/scroll?pretty' -h 'content- type: application/json' -d' { "scroll" : "1m", "scroll_id" : "copy _scroll_id" } '

Asymptotic costs confusion -

Image
so i'm trying head around different asymptotic costs, can tell faster can't grips when occur /why, can explain me when of examples below occur? or other complexities knowing how complexity occurs largely matter of understanding factors arise , putting them in way. if operations being performed done in correlated manner other operations, complexities multiplied; if performed in series complexities added. list traversals, example, each order n; might know right off bat o(n²) complexities arise doubly nested loop algorithm, o(n³) triply nested one. now writing complexities multiple terms not, in experience, common practice - o(n² + 2n + 1) example. because typically care complexities large n , in such case, lower order terms become negligible. however, can visualize such thing nested loop algorithm in 2 separate steps performed in outer loop that's o(1) (maybe adding collection), plus single o(1) operation outside of loops. similarly, tree structures yield

vsts - visual studio team services load test is not using new machines in load balancer -

we have azure web application, configured auto-scaling. , load-testing using visual studio team services. autoscaling working fine , kicks in @ 1 moment, our load test users remain on original (first 2 maschines in load-balancer-cluster) chocking under load , cpu usage of 100% , new machines not request. we assume tcp connections load-agents sticking first 2 machines , new machines ignored our tests. there way tell load tests in cloud re-establish tcp connection new servers can utilised ? this config settings using: https://drive.google.com/file/d/0b8cmpwlrdss0cjdumkdwbgv2qjq/view?usp=sharing https://drive.google.com/file/d/0b8cmpwlrdss0qlq4r3jpnnj3mkk/view?usp=sharing almir try changing "use multiple ips" "false" in loadtest settings.

haskell - Pattern matching for return values -

i know can use pattern matching function parameters this: fn :: (integral a) => (a,a) -> (a, a) fn (x,y) = (y,x) but how can match return value? expect this: g :: (integral a) => -> g z = (x, y) = fn (z, z + 5) x `mod` y this results in syntax error. there way match return values? basically, want split returned tuple 2 variables. the do used syntactical sugar monads . function not monad. what can use let -clause , like: g :: (integral a) => -> g z = let (x,y) = fn (z,(z+5)) in x `mod` y or where -clause : g :: (integral a) => -> g z = x `mod` y where (x,y) = fn (z,(z+5)) you can define pattern in lambda-expression , like: g :: (integral a) => -> g z = (\ (x,y) -> x `mod` y) $ fn (z,(z+5)) along these lines, can define helper function pattern matching, like: g :: (integral a) => -> g z = h $ fn (z,(z+5)) h (x,y) = x `mod` y this can useful if there several patterns need handled differently (

html - JavaScript CSS animation only works once -

Image
i have bank application has super cool hand come down , drop coin piggy bank. problem is, hand drops coin once stops working. here code: * { margin:0px; padding:0px; } body { background-image:url('../images/bg.png'); } @keyframes movedown { 0% {} 100% {margin-top:-220px;} } @keyframes fadein { 0% {opacity:0;} 90%{opacity:1} 100%{opacity:0;} } #hand { height:300px; width:300px; position:absolute; left:50%; margin-left:-120px; margin-top:-350px; background-image:url("../images/hand.png"); opacity:0; } #pigbox { margin-left:auto; margin-right:auto; height:600px; width:500px; margin-top:250px; position:relative; img { margin:0px 50px; } } input[type=text] { float:left; display:block; font-size:2em; width:500px; border-radius:10px; border:solid 2px pink; margin-top:10px; font-family: 'gochi hand', cursive; text-align:center; padding:2px; } #deposit { float:left; display:blo

jquery - Parse nested json into ajax -

i have sample json structured as, { key : { "data1":data1, "data2":data2 }} i want parsed 'data', $.ajax({ type: 'post', url: 'url', data: <--- here , success: function() { ***** } }); how do it? try use json.stringify var data= { "key" : {"data1":"data1", "data2":"data2" }}; new request.json({ url: '/echo/json/', type: "post", data: json.stringify(data), contenttype: "application/json", onsuccess: function(res) { document.write(data.key.data1); console.log(data.key.data1); } }).send(); here working jsfiddle: http://jsfiddle.net/dk5dl/87/

android - GUI won't update till the end of function execution -

i working on simple log in activity. have button , rotation animation. when button clicked should run animation , call login method takes few seconds finish. the problem animation starts when login function execution finished (just before layout changed). this tried: private void btnpprijava_click(object sender, eventargs e) { this.runonuithread(() => { string username = edttxtkorisnicko.text; string password = edttxtsifra.text; var rotateaboutcorneranimation = animationutils.loadanimation(this, resource.layout.rotationanimation); imageviewforrotation.visibility = viewstates.visible; imageviewforrotation.startanimation(rotateaboutcorneranimation); success = logincontroller.instance.login(username, password); if (success) { startactivity(typeof(mainactivity)); } }} i tried put these 3 lines of code in runonuithread

c - cross compilation for ARM: error no such file or directory/command not found -

i have written simple hello world program , compiled gcc-arm-linux-gnueabi compiler. compiles when try execute on arm machine complains "no such file or directory". think gcc-arm-linux-gnueabi embedded linux due e(mbedded)abi. different arm linux abi? please me solve problem code here #include "stdio.h" int main(void) { printf("hello world !\n"); return 0; } compiled as arm-linux-gnueabi-gcc -wall -o crosscomp hello.c when execute crosscomp on target arm machine error crosscomp no such file or dir edit when using arm-linux-gnueabi-gcc entry point not matching target machine entry point (readelf -l crosscom) when compiled aarch64-linux-gnu-gcc entry point matched target machine. error becomes permission denied on ./crosscomp. tried sudo says crosscomp: no such command. note posted same question on askubuntu https://askubuntu.com/questions/904685/cross-compilation-for-arm-error-no-such-file-or-directory got no response. th

mysql - Update table using dynamically determined values -

i'm using mysql server in current project , need provide migration. have table 'patterns' field 'title' , new field named 'alias',which value null rows. need write in field using next algorithm: 1) if title field unique: write it's value in alias 2) if title not unique: alias = title +'-'+ n , n number of occurrence for example: ________________ |id|title|alias |1 |smile|null |2 |smile|null |3 |smile|null ________________ should transformed to: ________________ |id|title|alias |1 |smile|smile |2 |smile|smile-1 |3 |smile|smile-2 ________________ is possible achieve such result using sql, thank in advance help this pain in mysql. can using variables. select t.*, (case when tt.cnt > 1 concat(t.title, '-', rn) else t.title end) new_title (select t.*, (@rn := if(@t = title, @rn + 1, if(@t := title, 1, 1) ) ) rn t cross

css - How to send image to email as position absolute with html text -

i'm trying send image position absolute html text behind image when send gmail or other email show image in bottom html text. absolute css not working. below template <template name="welcome"> <html> <head> </head> <body style="font-family: 'roboto slab', serif;"> <div class='container-fluid'> <img src="http://qa.couchfashion.com/images/mailer.png" style=" position: relative;width: 100%;left: 0;"> <div style="top: -44px;position: absolute;z-index: 999999;"> <div class='mailer-name text-center' > <h3 style=" font-size: 80px;"> hey {{receivername}} </h3> </div> <div class="mailer-content" style="margin-top: 120px; text-align: center; text-align: justify; padding-left: 10%; padding-right: 10%;">

python - Integrating hl7 2.x with openemr -

are there guides out there learn more how integrate hl7 2.x protocol openemr? any sample programs helpful. i presume have looked @ https://sourceforge.net/p/openemr/discussion/202506/thread/e00ef571/ there reference there "mith" should "mirth", open source interface engine. basic understanding of hl7 v2 necessary. see https://en.wikipedia.org/wiki/mirth_connect . user guide available @ https://bridge.nextgen.com/media/3244/mirth-data-sheet-mirth-connect-3-4-user-guide.pdf if looking basic information on hl7, of information available free nonmembers @ hl7.org. version 2 specs free, although license not strictly open source. organization offers tutorial classes, although not free.

vim 7.4 saving substitution pattern and replacement -

i have function in .vimrc file remove whitespace @ end of lines: " remove trailing space on write function! <sid>striptrailingwhitespaces() let _s=@/ let l = line(".") let c = col(".") %s/\s\+$//e let @/=_s call cursor(l, c) endfu with function, search pattern @/ saved , restored, can continue search ( n ) previous pattern. if in middle of search , replace, using & , search correctly replace empty string. i read vim 8 has :keeppatterns option might me (i didn't check yet) i'm stuck vim 7.4 time being. is possible save , restore 'replacement' part of :s command ? as mentioned :s command not search, if want retrieve need access command history: : , up ( according vim help :keeppatterns {command} allows execute command without adding search pattern, don't believe useful if understand correctly use case) if want still use "column command" :@: still work after function run

Rails blog - is it a reasonable solution to store posts in partials? -

i'm looking code blog using rails , i'm trying figure out best approach storing posts themselves. plan use lot of styling, formatting , images , of course comes few challenges. i've considered using wysiwyg html editor , storing posts html don't using them , find them quite restrictive. plus, editing content poses problems , i'd work within text editor. i've considered using markdown, make storage element simpler, don't particularly want have write in markdown either. i've absolutely no interest in storing xml , parsing display. so solution came store content of each post in partial , have database column called content_partial references it. way can write them in way i'm comfortable , don't have persist huge amounts of text/html/css etc. of course means potentially having lot of partial files doesn't bother me. is reasonable solution? or there pitfalls haven't thought of? alternative suggestions welcome. thanks!

angularjs - Download pdf file on client side -

i beginner mean stack. want download , display pdf file client. server side script under: app.get("/pdf", function(req, res) { var file = __dirname + '/try.pdf'; res.download(file, function (err) { if (err) { console.log("error " + err); } else { console.log("success"); // server shows success file not downloaded client } res.end(); } ); } ); after starting server when give command localhost/pdf in browser file downloaded. but, when connect server through index page , attach module ng-click event of button, server shows success file not downloaded client. angularjs code under displays both success , clause message: app.controller('showpdf', function($scope, $http) { $scope.pdfshow = function() { alert(&

material design - how to build an angular 2 application with npm into output directory, and prevent webpack or any bundling? -

we have software production line (spl) , updated our client platform use angular 2, because of lot of problems couldn't go typescript, had migrated es5 version of angular 2. we're not @ typescript , npm , stuff, here we're stuck. say you've downloaded/purchased admin template angular 2 (material 2), , it's ordinary , routine angular 2 application. you can npm install install dependencies , modules, , npm start make appear in browser. however, npm start happens npm builds (i don't know puts build's output) , bundles everything, , in browser see 9mb of vendor.js , else bundled. that's not want. we want able compile/transpile typescript in given template output folder, , disable bundling of webpack, or other bundling mechansim. what should do? this template we've purchased: https://themeforest.net/item/fury-angular-2-material-design-admin-template/19325966

c# - Need to figure out how to pull a name along with the timespan out of a list -

i've list pulls timespans , selects , displays largest timespan in list. need figure out way display name matches timespan. not sure start this. able me started. of code i've below. code: can see create list of timespans item workmodedirectiondescription = avail-in. need agname = avail-in = , match agent has max time listoftimespans.max , display name of agent has max time. hope makes sense. biggest issue i'm having can create separate list of agname don't know how match times of agent display name has largest time. can't add agname list listoftimespans because agname of type string not timespan. var listoftimespans = new list<timespan>(); list<newagent> newagentlist = new list<newagent>(); foreach (var item in e.cmsdata.agents) { newagent newagents = new newagent(); newagents.agentname = item.agname; newagents.agentextension = item.extension; newagents.agentdateti

c# - Raycast returns null -

Image
code generates error: void update() { if (input.touchcount > 0) { raycasthit2d hit = physics2d.raycast(camera.main.screentoworldpoint(input.gettouch(0).position), vector2.zero); if (hit && hit.collider != null && hit.collider.name == "lefttaparea") { hit.transform.name = "hit"; } } } it says wrong string: raycasthit2d hit = physics2d.raycast(camera.main.screentoworldpoint(input.gettouch(0).position), vector2.zero); error: nullreferenceexception: object reference not set instance of object leftscript.update () (at assets/leftscript.cs:16) the thing can return null in code camera.main.screentoworldpoint . means camera.main null . camera.main initialized, camera must have maincamera tag. select camera gameobject change tag maincamera. if don't want camera in maincamera tag, can find wit directly gameobject.find camera component it. camera cam; v

python - SQLAlchemy: transitive unique constraint -

i'm working on simple document management system each document can have number of versions , optionally number of tags point towards specific versions. users employ tags indicate version of document ready qa, production use, etc. each document, there should @ 1 tag of given name. i'm having trouble describing transitive relationship documents have versions , tags point versions, tag names never occur more once each document. here declarative tables far: class document(base): __tablename__ = 'documents' id = column(integer, primary_key=true) name = column(string, nullable=false) versions = relationship('version', back_populates='document') tags = relationship('tag', secondary='versions') class version(base): __tablename__ = 'versions' id = column(integer, primary_key=true) document_id = column(integer, foreignkey('document.id')) name = column(string, nullable=false) content

android - Unfortunately, <appname> has stopped. Why is it happening? The complete code is given below -

i have written complete code in android studio. have used sqlite backend. app stops click on "add data" button. please help. //databasehelper.java (file name) code package com.example.android.sqlite; import android.content.contentvalues; import android.content.context; import android.database.sqlite.sqlitedatabase; import android.database.sqlite.sqliteopenhelper; /** * created lenovo on 14-04-2017. */ public class databasehelper extends sqliteopenhelper { public static final string database_name = "user.db"; public static final string table_name = "user_info.db"; public static final string col_1 = "id"; public static final string col_2 = "name"; public static final string col_3 = "surname"; public static final string col_4 = "marks"; public databasehelper(context context) { super(context, database_name, null, 1); } @override public void oncreate(sqlite

list - python new dict if value matching key value inside dict -

i try manipulate data , face problem, guess of know how so. first arrange data list of dict : data = [{'compound' : 'molecule1', 'time' : 18, 'temp' : 20, 'orientation' : 'top', 'n' : 1, 'result' : 2.5} , {'compound' : 'molecule1', 'time' : 18, 'temp' : 20, 'orientation' : 'top', 'n' : 2, 'result' : 3.8}, {'compound' : 'molecule1', 'time' : 18, 'temp' : 20, 'orientation' : 'top', 'n' : 3, 'result' : 2.7}, {'compound' : 'molecule1', 'time' : 18, 'temp' : 20, 'orientation' : 'bottom', 'n' : 1, 'result' : 34.2} , {'compound' : 'molecule1', 'time' : 18, 'temp' : 20, 'orientation' : 'bottom', 'n' : 2, 'result' : 38.6}, {'compound' : 'molecule1', 'ti

ios - Excel - Systematically Referring to Sheets on iPad-version -

i have excel document in refer previous sheet in present sheet systematically. of course, type name of previous sheet directly formula in every sheet of document, way impractical. have tried using vba/macros create function refers previous sheet on pc, not work on ipad. that leads actual question: there smart way systematically , automatically refer previous sheet (in sheets except first one) on ipad-version of excel? note: excuse if have been asked before, have searched thoroughly without worthful answers.

c# - Linq order by random without GUID -

need order random using linq , can't use guid.newguid(), need this: .orderby(x => "somestring"). a mobile app suppose generate random string , call webapi , because maintained paging mobile app sends same random string different page number every time sends random string ordering should same different skip ... . how possible? if not string maybe number or fixed every linq query. edit: this webapi [route("getchannels/{id}/{word}/{page}/{randomstring}")] public ienumerable<channels> getchannels(int id, string word, int page, string randomstring) { ... if (canpage) { var channels = db.channels.where(x => (id == 0) || (x.categoryid == id)) .where(q => word == "0" || (q.title.contains(word) || q.desc.contains(word))) .orderby(x => randomstring).skip(skip).take(pagesize).tolist(); } ... if want return results in random order,

javascript - Are there, currently, noticeable performance advantages in using Buffer / Uint8Array instead of plain arrays? -

i believe, nowadays, javascript engines such v8 able detect when array has numeric values in 0-255 range and, thus, store unboxed uint8 array. such, 1 expect they're efficient typed counterparts. having single array type across codebase is, though, more convenient having many. in 2017, there still noticeable performance advantage in using buffer / uint8array s rather plain arrays? see below code used performance testing using runkit . indicates buffer slower, consistent other historic data. other related data points: this jsperf this other jsperf this older thread . //setup //const inumtests = 1000; const inumtests = 1000; let arrresults = []; function randomchar() { var chars = '0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'; return chars[math.round(math.random() * (chars.length - 1))]; } function singletest() { //buffer const t0 = process.hrtime(); let buf = buffer.from(randomchar()); //recommended initialize .from

multithreading - Inconsistent output with Ruby threads and puts -

i writing program perform number of checks , output results via puts . want speed process using threads. however, output includes inconsistent new lines. how can cleanup output? ex. > (1..99).each_with_object([]) {|i, threads| threads << thread.new {sleep(rand 2) && puts(i)} }.each(&:join) 7 202535 36605562 7882 8959958 2826 29 433941 445258 69728063 777975 85496 22 14 24 3850 9712 9892 47 40 71 84 94 49 1 2 152187131627234218194531535759 305417 34647448 735111 66684676 838137 6133 679093 917099 3 56 32 10 6 88 86 65 updated tin man's comment use print / printf or puts , provide new-line char \n explicitly (since puts may write new-line separately rest , other threads may jumping in). (1..99).each_with_object([]) {|i, threads| threads << thread.new {sleep(rand 2) && print("#{i}\n") } }.each(&:join)

ios - Find custom Object index in array -

i have array of custom object called service , in didselectrow populate selected array of object: func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) { if let cell = tableview.cellforrowatindexpath(indexpath) { let services:[service] = self.menu[indexpath.section].services self.selectedservices.append(services[indexpath.row]) } } the problem can't figure out how retrieve diddeselectrow: func tableview(tableview: uitableview, diddeselectrowatindexpath indexpath: nsindexpath) { if let cell = tableview.cellforrowatindexpath(indexpath) { cell.accessorytype = .none let services = self.menu[indexpath.section].services let service = services[indexpath.row] //how can found index position of service inside selectedservices? } } i suggest don't store selectedservices , rely on uitableview.indexpathsforselectedrows . var selectedservices: [service] { let indexpat

database mail - SQL Server 2014 event alerts don't notify but performance condition alerts do -

i sql server event alerts via e-mail. have set database mail , operators, along several severity alerts , few alerts specific error numbers. test alerts have run query in ssms missing '*/' on comment (error 113, severity level 15). i've tried select statement on non-existent table (error 208, severity level 16). interestingly, mail when set performance condition alert (i used tempdb > 0 kb). tells me database mail set correctly. have verified alert enabled, , notify operators box , operator e-mail box both checked. thoughts?

database - Oracle (ORA-02270) : no matching unique or primary key for this column-list error -

i have 2 tables, table job , table user , here structure create table job ( id number not null , userid number, constraint b_pk primary key ( id ) enable ); create table user ( id number not null , constraint u_pk primary key ( id ) enable ); now, want add foreign key constraint job referencing user table, alter table job add constraint fk_userid foreign key(userid) references user(id); this throws oracle (ora-02270) : no matching unique or primary key column-list error , doing investigation appears need have either unique key or primary key constraint on userid cannot have 1 userid can have multiple jobs associated him, thoughts or suggestions on how fix issue? researched ora-02270 , so related question the ora-2270 error quite simple: happens when columns reference in foreign key not match primary key or unique constraint on parent table. common reasons are the parent lacks constraint altogether the parent table&

Python: vlookup on complex arrays searching through multiple columns for each row -

i have following problem python code doesn't work. hoping suggestions on why , how resolve. here's example dataframe: cust_id max_nibt nibt_0 nibt_1 nibt_10 line_0 line_1 line_10 11 200 -5 200 500 100 200 300 22 300 -10 100 300 100 200 300 33 400 -20 0 400 100 200 300 for in range (0,11): if (df4['nibt_%s' % i] == df4['max_nibt']): df4['model_line'] = df4['line_%s' % i] the code gives me following error: valueerror: truth value of series ambiguous. use a.empty, a.bool(), a.item(), a.any() or a.all() however, when use .any() , gives me last range assigning model_line = line_10. when use .all() , answer same cust_ids. thoughts? in advance. i have guess @ want, not using pd.series correctly... see here better explanation. iiuc : want fill in values line_x when nibt_x equals max_nibt # filter `nibt` columns , find first column equals max nibt_maxes = df.filter(regex='nibt_\d+').eq(d

get - Return exact value in Rust Hashmap -

i can't find suitable way return exact value of key in hashmap in rust . existing get methods return in different format rather exact format. there 2 basic methods of obtaining value given key: get() , get_mut() . use first 1 if want read value, , second 1 if need modify value: fn get(&self, k: &q) -> option<&v> fn get_mut(&mut self, k: &q) -> option<&mut v> as can see signatures, both of these methods return option rather direct value. reason there may no value associated given key: use std::collections::hashmap; let mut map = hashmap::new(); map.insert(1, "a"); assert_eq!(map.get(&1), some(&"a")); // key exists assert_eq!(map.get(&2), none); // key not exist if sure map contains given key, can use unwrap() value out of option: assert_eq!(map.get(&1).unwrap(), &"a"); however, in general, better (and safer) consider case when key might not exist. example,

android - My app gets stopped unfortunately when I use Sugar ORM -

Image
using these configurations did add sugar orm project, application stopped unfortunately error : fatal exception: main process: gigacycle.geoaudiotag, pid: 22760 java.lang.runtimeexception: unable instantiate application com.orm.sugarapp: java.lang.classnotfoundexception: didn't find class "com.orm.sugarapp" on path: dexpathlist[[zip file "/data/app/gigacycle.geoaudiotag-1/base.apk"],nativelibrarydirectories=[/data/app/gigacycle.geoaudiotag-1/lib/arm, /vendor/lib, /system/lib]] @ android.app.loadedapk.makeapplication(loadedapk.java:676) @ android.app.activitythread.handlebindapplication(activitythread.java:6289) @ android.app.activitythread.access$1800(activitythread.java:221) @ android.app.activitythread$h.handlemessage(activitythread.java:1860) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:158) @ android.app.activitythread.main(activitythread.java:7224) @ java.lang.reflect.

javascript - How do I return list/value from ionic2/3 storage -

i know isn't 100% right way this, advice cleanup welcome. just learning/getting used ionic2 , i'm having trouble returning storage item. service: import { injectable } "@angular/core"; import { storage } '@ionic/storage'; @injectable() export class locationitemservice { locationitems: locationitem[] = []; constructor( private storage: storage ) {} getlistitems(id): promise<locationitem[]> { this.storage.get("location_items_" + id).then((val) => { // console out proper value. console.log(val); // promise contains proper value. return promise.resolve(val); }); } } however, when run application in development, error: "a function declared type neither 'void' nor 'any' must return value." even if set this.locationitems, still need return promise next function not run until promise resolved. i figured had scope being inside of storage.get, instead of direct

PySpark in Eclipse: using PyDev ----> ImportError: Module use of python35.dll conflicts with this version of Python -

i have python version 3.6.0 installed on windows machine , trying run pyspark job on eclipse. eclipse version: neon pydev: 5.7 spark version:2.1.0 i getting python version conflict. below error: using spark's default log4j profile: org/apache/spark/log4j-defaults.properties setting default log level "warn". adjust logging level use sc.setloglevel(newlevel). sparkr, use setloglevel(newlevel). 17/04/14 23:18:46 error shell: failed locate winutils binary in hadoop binary path java.io.ioexception: not locate executable null\bin\winutils.exe in hadoop binaries. @ org.apache.hadoop.util.shell.getqualifiedbinpath(shell.java:379) @ org.apache.hadoop.util.shell.getwinutilspath(shell.java:394) @ org.apache.hadoop.util.shell.<clinit>(shell.java:387) @ org.apache.hadoop.util.stringutils.<clinit>(stringutils.java:80) @ org.apache.hadoop.security.securityutil.getauthenticationmethod(securityutil.java:611) @ org.apache.hadoop.security.usergr