Posts

Showing posts from June, 2015

arrays - Objective-C: Comparing user input with object's instance variable -

i have been learning objective-c while, , decided try , take on little bigger project without real "guidelines" in learning books have got stuck. what i'm trying helping friend digitalising few documents have, creating searchable commandline-tool these documents. i think have gotten pretty far, have created custom class documents 3 variable; name of author, number of article , path file on computer (which of course change place have documents stored on computer). have created 2 example documents variables filled in. since documents have 2 properties, numbers , name of author, user may search 1 of these properties. therefore separated input of user either string or int (with of stack overflow post: how determine if first character of nsstring letter ) created array 'author'-variable's of different documents. this have hit bump: want run through array of 'author' , if author's name match user have put in, open document @ path given @ '

linux - Docker fails at first run after install. Error Post http://..... permission denied. Are you trying to connect to a TLS-enabled daemon without TLS? -

i'm following step 1 of this docker tutorial. have installed ubuntu version 14.04 on virtual box vm. intentionally downgraded docker version when type "docker version" client version: 1.5.0. because server intend communicate on 1.5.0. when trying command " docker run hello-world " response: "post http:///var/run/docker.sock/v1.17/containers/create: dial unix /var/run/docker.sock: permission denied. trying connect tls-enabled daemon without tls?" when running " sudo docker run hello-world " response: cannot connect docker daemon. 'docker -d' running on host? can please explain me what's happening , how can fix it? thanks. edit: tried follow solution linux here however, i had tried follow el mesa's instructions in post. however, when got running sudo docker -d got error running devicecreate (createpool) dm_task_run failed. don't think need start since following tutorial , tutorial did docker run hello-wo

java - What is the effect of storing a larger value in a grayscale png image? -

i trying perform dct on image block size 8x8 in java. after performing dct on first block, first value "372". after performing dct on entire image, wrote values png-grayscale image.values inside image automatically changed. grayscale image not store value greater 255. happen value greater 255 (for eg., 372) ? you can not original image after loss of information need to: perform dct or ever find min,max values whole image change range pixel(x,y)=(255*(pixel(x,y)-min))/(max-min) +/-1 or if clamp right range after lose absolute values relative changes stays there for purposes enough if need restore original image then need encode min,max values png somewhere so add dummy scanline(s) , encode min,max first few pixels ... restoration easy: read png image decode min,max restore original dynamic range pixel(x,y)=min+(((max-min)*pixel(x,y))/255) +/-1 or if clamp right range perform idct or ever

c++ - Is auto as a parameter in a regular function a GCC 4.9 extension? -

gcc 4.9 allows following code, gcc 4.8 , clang 3.5.0 reject it. void foo(auto c) { std::cout << c.c_str(); } i warning: iso c++ forbids use of 'auto' in parameter declaration [-wpedantic] in 4.9 in 4.8 , clang error: parameter declared 'auto' . yes, extension. it's added c++17 part of 'concepts' proposal, believe.

sql - SSRS Percentage display -

i'm not @ skilled when comes sql i'm trying reflect data percentage. example times called on enquiry | contractnumber | enquiry | percentage display 1 101 claim 14.28% 1 101 complaint 85.71% 2 101 complaint 85.71% 3 101 complaint 85.71% 4 101 complaint 85.71% 5 101 complaint 85.71% 6 101 complaint 85.71% so formula work out percentage goes follows [total enquiries contract number / maxrows(contractnumber)] how achieve this? appreciated hmmm. assuming using sql server. and, goal percentage. seem ratio of "enquiry" total "contract number". if so, can use window functions: select e.*, (count(*) on (partition contractnumber, enquiry) * 1.0 /

hadoop - Not able to start Hbase shell in standalone mode -

i installed hbase on ubuntu 64-bit system. run hbase start script without issues , below result. hduser@vignesh-ubuntu:/usr/local/hbase$ ./bin/start-hbase.sh starting master, logging /usr/local/hbase/bin/../logs/hbase-hduser-master-vignesh-ubuntu.out java hotspot(tm) 64-bit server vm warning: ignoring option permsize=128m; support removed in 8.0 java hotspot(tm) 64-bit server vm warning: ignoring option maxpermsize=128m; support removed in 8.0 but when start hbase shell throws me below error. hduser@vignesh-ubuntu:/usr/local/hbase$ ./bin/hbase shell nativeexception: java.lang.runtimeexception: java.lang.reflect.invocationtargetexception initialize @ /usr/local/hbase/bin/../lib/ruby/hbase/hbase.rb:42 (root) @ /usr/local/hbase/bin/../bin/hirb.rb:118 the jdk version using 1.8. path: /usr/lib/java/jdk1.8.0_31 i tried googling no luck. 1 me in resolving this. it compile version different runtime java version. you'd best @ hbase java version help .

android - How to create vertically nested scrollviews with viewpager content -

Image
this in lot of apps, there header content view pager , pager content. header content can scroll off top pager content docks , continues able scroll. i've tried couple ways of doing this, had success using nestedscrollview, never able fling , few other use cases working right. far can tell apps spin own solution. i'm looking suggestions on how go building type of ui. below google+ uses ui. this not answer (the question quite open-ended) found cheesesquare implementation chris banes (he's android team think) helpful you're asking. https://github.com/chrisbanes/cheesesquare

Floating point to 16 bit Twos Complement Binary, Python -

so think questions have been asked before i'm having quite bit of trouble getting implemented. i'm dealing csv files contain floating points between -1 , 1. of these floating points have converted 16 bit 2s complement without leading '0b'. there, convert number string representation of 2s complement, , of csv written written .dat file no space in between. example, if read in csv file , has 2 entries [0.006534, -.1232], convert each entry respective 2s complement , write them 1 after onto .dat file. the problem i'm getting stuck in code on how convert floating point 16 bit 2s complement. i've been looking @ other posts this , i've been told use .float() function i've had no luck. can me write script take in floating point number, , return 16 bit 2s complement string of it? has 16 bits because i'm dealing mit 16 standard. i using python 3.4 btw to answer question in title: convert python float ieee 754 half-precision binary float

view - CouchDB query multiple keys startkey endkey -

hey guys i'm trying point within specific location couchdb database. have absolutely no idea how build query , view. in document, there value latitude , value longitude. i building quadratic bound latmin, longmin, latmax, longmax. view should return documents where: latitude between latmin , latmax and longitude between longmin , longmax thank in advance edit: project forced use iriscouch i'm not able install extension. have solve key, startkey , endkey. you may use extension " geocouch " specialized spatial queries.

google app engine - Does it cost anything to list gs://? -

if example run scandir on google cloud storage bucket folder on app engine application, billed? i know costs connect bucket via json , xml api, cannot find info gs://. if costs anything, scandir count 1 class operation? if @ the pricing page , storage.buckets.list (listing buckets within project) , storage.objects.list (listing objects within bucket) both class operations, which, of today (july 16th, 2015) cost $0.01 per 1000 operations.

jquery - How do I add click events to a tinyMCE 4 file_picker_callback window? -

Image
i'm trying add jquery click event listeners custom file browser window file_picker_callback i'm not having success. i'm able add click events first popup window using : setup : function(ed) { ed.on('click', function(e) { console.log('editor clicked'); }); } my first window insert/edit image window that's built tinymce 4.2 however, not desired target. desired target window launched when click file browser button pictured below. when invoke file_picker_callback , file browser icon (circled). when click on file browser button, have second window appear i'll using file browser, this window want add events. below code i'm using invoke file_picker_callback ... init: tinymce.init({ //... file_picker_callback: function (callback, value, meta) { imagefilepicker(callback, value, meta); } }); code second window: var imagefilepicker = function (callback, value, meta) { tinymce.activ

convert minutes to hh/mi/ss format in oracle query -

i want know query converts minutes format of hh/mi/ss in oracle.i 've seen lot of same questions many forums nothing helped me exact result. the query used -select to_char(to_date(mod(100,60),'mi'),'hh/mi/ss') dual; don't know how hour value.because mod function returns remainder don't know how take quotient part , substitute hour field. i suppose there 2 ways of storing "minutes" in oracle database - can either store them in field datatype interval day second , or can store them in number . simplest case handle interval - in case, to_char function converts value string of form sdd hh:mm:ss.ffffff , 's' sign ('+' or '-' intervals can positive or negative), dd = days, hh = hours, 'mm' = minutes, 'ss' = seconds, , 'ffffff' = fractions; thus, hh:mi:ss need use substr function, in substr(to_char(i_val), 5, 8) where i_val interval day second value. if value converted in numeric

django - How to install cffi package on AWS Beanstalk -

this question looks same this post , since there no answer, re-asking here. i have django project deployed on aws beanstalk, using package cffi . when run eb deploy , error logs looks like: ...... installing collected packages: cffi, characteristic, idna, pyasn1, enum34, ipaddress, cryptography, cssselect, django, django-bower, django-celery, sqlparse, django-debug-toolbar, django-devserver, django-extensions, django-filter, django-model-utils, futures, django-pipeline, djangorestframework, html5lib, ipython, ipdb, librabbitmq, lxml, markdown, openxmllib, pillow, psycopg2, py, pyasn1-modules, pydocx, pyopenssl, pytest, python-docx, python-magic, queuelib, w3lib, zope.interface, twisted, scrapy, service-identity, south, uwsgi, werkzeug running setup.py install cffi complete output command /opt/python/run/venv/bin/python2.7 -c "import setuptools, tokenize;__file__='/tmp/pip-build-wwakyn/cffi/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file_

java - Navigating back to a viewpager fragment in a nested fragment -

i have viewpagercontainer fragment loads when app starts. viewpagercontainer fragment adds 2 tabs(tab , tab b) actionbar. tab b has listview of 2 items. what have done: attached click listener list view item in tab b fragment such when user clicks on item opens fragment (child fragment) inside first fragment i.e under tab b. where got stuck: i'd go tab b when user presses button. tried implementing adding child fragment backstack, unfortunately not go tab b fragment. kindly me out have done alot of research on including implementing backstack hacks no success. i using v4 , v7 appcompat libraries. any me appreciated. in advance. edited: managed navigate child fragment actionbar tabs. achieved through following code: //used getchildfragmentmanager() instead of getsupportfragmentmanager() fragmentmanager fm = getchildfragmentmanager(); myfragmentpageradapter fragadapter = new myfragmentpageradapter(fm); viewpager.setadapter(fragadapter); however, on navigation n

android - Null Pointer Exception on drawer Layout -

i getting null pointer exception @ drawerlayout=(drawerlayout) findviewbyid(r.layout.drawer_layout); please me out. why returning null pointer exception? don't know doing wrong. package com.example.prototype; import android.app.actionbar; import android.app.activity; import android.os.bundle; import android.support.v4.app.actionbardrawertoggle; import android.support.v4.widget.drawerlayout; import android.support.v4.widget.drawerlayout.drawerlistener; import android.view.menu; import android.view.menuitem; import android.view.view; import android.widget.arrayadapter; import android.widget.listview; import android.widget.toast; public class mainactivity extends activity { drawerlayout drawerlayout; actionbar action_bar; listview navigation_list; actionbardrawertoggle drawertoggle; string items[]; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.drawer_layout);

What happens if I move a local Git repo that has already been pushed? -

suppose have local git repo has been pushed remote repository. happens if move local repo local directory? absolutely nothing. remote still tracked, , still work. you can safely move git-tracked directories (as long .git directory inside moves along else)

python - variable in range function -

i trying write script creates new file names (the content of files same). result should follows: file_10_11.txt , file_10_12.txt , ..., file_10_100.txt (resulting 90 files , first batch of files). file_10_11.txt , file_10_12.txt , ..., file_10_99.txt (resulting 89 files , second batch of files). then file_10_11.txt , file_10_12.txt , ..., file_10_98.txt . and @ last way until file_10_ 10 .txt. see last number drops 100 10 step of 1. what doing first batch of files following: for x in range(9,100): initial_file = 'c:\users\alex\desktop\test\x_y.txt' dest_file = 'c:\users\alex\desktop\test\file_' + str(x+1) + '_100.idf' shutil.copy2(initial_file, dest_file) how can put in loop rest batches of file renaming? not sure why need because generating same file name multiple times. instance, file_10_10.txt generated 91 times. want can accomplish 2 backwards loops: for x in range(100, 9, -1): y in range(x, 9, -1): p

linux - Postgres: psql: FATAL: role "postgres" does not exist -

i have been using postgresql couple of days , has been working fine. have been using through both default postgres database user user permissions. in middle of day today (after had been working fine) stopped working , no longer database. try: psql , come psql: fatal: role "postgres" not exist . similarly, if tried other user, psql -d postgres come psql: fatal: role "otheruser" not exist . (note have database named postgres , has been working until now). update it appears 1 of computers accessing server crashed , may have somehow deleted of users of database. try fresh reinstall. to check users exist without being able log in psql , can use following method: stop postgres restart in single user mode (specifying data directory) query pg_user global table restart postgres normally example: $ sudo -i -u postgres ... postgres@u64:/usr/local/pg95a1$ bin/postgres --single -d $pwd/data postgresql stand-alone backend 9.5alpha1 backend&g

html - display: -webkit-box; property disappear few seconds after loading to the browser -

Image
i'm using multi line ellipsis concept ending text dots when exceeds 2 rows. i'm using "display: -webkit-box;" property , disappears in few seconds after loading browser. ellipsis property not there anymore. please refer image. /i.stack.imgur.com/uwqcb.png any comments on ? what web browser use? webkit running on webkit browser, try 1 @ class ul wrapping: display: -webkit-box; display: -moz-box; display: box;

python - Flask-webage background image doesnt work -

below simple html code index.html <html> <head> <title>webpage</title> <link href="http://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet" > <link href="http://getbootstrap.com/examples/jumbotron-narrow/jumbotron-narrow.css" rel="sylesheet"> </head> <body> <style type=text/css> background-image: url("static/images/back.png"); </style> <p>does image work? </p> </body> </html> this flask code: app.py from flask import flask, render_template app = flask(__name__, static_url_path="static", static_folder="static") @app.route("/") def main(): return render_template("index.html") if __name__ == '__main__': app.run() i error when tried inspect page: get http://127.0.0.1:5000/static/images/back.png-404(not found) i read through couple of other forums, couldn't fin

Delphi How to get default value for property using RTTI -

if have class this: tserversettings = class(tsettings) strict private fhttpport : integer; published property httpport : integer read fhttpport write fhttpport default 80; end; how can default attribute of httpport property using rtti? like this: {$apptype console} uses system.typinfo; type tmyclass = class strict private fmyvalue: integer; published property myvalue: integer read fmyvalue default 42; end; var obj: tmyclass; propinfo: ppropinfo; begin obj := tmyclass.create; propinfo := getpropinfo(obj, 'myvalue'); writeln(propinfo.default); end. note class stands, in question, broken. system not automatically initialise properties default value when instance created. need add constructor class that.

php - my ajax response only works in first table row -

im new ajax , need one. dont have idea how solve this, here problem: want ajax response show made changes on select box inside table. solved how pop out select box whenever select in first select box problem happens in first table row of table. ajax code: <script type="text/javascript"> function guest() { var rooms = document.getelementbyid("select_rooms").value; var = document.getelementbyid("room_type").value; var url = "guest.php?rooms="+rooms+"&id="+some; var method = "get"; if (window.xmlhttprequest) { xmlhttp=new xmlhttprequest(); } else { xmlhttp=new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate==4 && xmlhttp.status==200) { document.getelementbyid("guest").innerhtml = xmlhttp.responsetext;

php - Page Freezes When Redirecting User After Form Submit -

in php, collect information form , build email. have following code redirect user page after 200 response code. // send email. if (mail($recipient, $subject, $email_content, $email_headers)) { // set 200 (okay) response code. header('location: https://my.website.com/wp-content/uploads/2015/07/a.pdf'); exit; } else { // set 500 (internal server error) response code. header("http/1.1 500 internal sever error"); echo "oops! went wrong , couldn't send message."; } unfortunately, when attempt sumbit form, chrome freezes , have close tab. explanation cause , fix of issue?

java - How to replace click button with hold? -

hi want make button work buy holding set number of seconds instead of clicking on it, button in question opens new jframe, button.addactionlistener(new actionlistener() { public void actionperformed(actionevent ae) { frame.dispose(); new secondframe(); } }); thanks, as suggested codebender, can use mouselistener instead.which have mousepressed() , mousereleased() methods.i have calculated time currenttimemillis() between each successive press/release. jframe f = new jframe(); jbutton b = new jbutton(); f.add(b); f.pack(); f.setvisible(true); b.addmouselistener(new mouselistener() { long start_time, stop_time; @override public void mouseclicked(mouseevent e) {} @override public void mousepressed(mouseevent e) { start_time = system.currenttimemillis(); system.out.println("" + start_time); } @override public void mousereleased(mouseevent e) {

javascript - Angular Jasmine's spyOn has no effect on functions in the factory -

first have controller this: login.controller.js: angular.module('app').controller('logincontroller', function($scope,userservice,$location) { $scope.submit = function() { userservice.login(email,password).then(function(data){ if(data.result=='success'){ $location.path('/home'); else{ $scope.loginerror='login failed'; } },function(error){ $scope.loginerror='login failed'; }); }; and factory service:userservice.js angular.module('app').factory('userservice', function($http,$q,const) { login: function(username, password) { var defer =$q.defer(); $http({ method:'post', url:const.baseurl+'rest/login', data:{

java - Program Terminates without running in eclipse -

when run code ( having simple buttons , login button action listener), terminates without running , without showing screen. i have tried system.exit(0); in main function overcome terminating issue in vain public class home extends jframe{ dimension screensize = toolkit.getdefaulttoolkit().getscreensize(); int width = (int) screensize.getwidth(); int height = (int) screensize.getheight(); color cardinal = new color(194, 35, 38); int w=155; int h=50; public home(string title) { super(title); getcontentpane().setsize(width,height); getcontentpane().setbackground(color.white); getcontentpane().setlayout(null); final jpanel panel2 = new jpanel(); panel2.setbounds(364, 33, 664, 344); getcontentpane().add(panel2); jpanel panel3 = new jpanel(); panel3.setbackground(color.white); panel3.setbounds(81, 382, 947, 243); getcontentpane().add(panel3); panel3.setlayout(null); jbutton btnhome = new jbutton("home"); btnh

rest - What API response should I send when a consumer asks for a collection of resources related to a resource that doesn't exist? -

let's have resource /providers/123 when consumer sends that, receives 200 ok , record provider identified 123, or 404 not found if there no provider id 123. fine. now let's have resource /providers/123/publications which represents collection of publications authored provider 123. when consumer sends that: if provider exists , has publications, 200 ok collection of publications. if provider exists , has no publications, 200 ok collection empty. but if provider doesn't exist? 404? 200 empty set? 200 empty set , warning? else? 404 sure. url refers resource not exist. don't give more information required.

sql server - What could be wrong with my RODBC configuration? -

i have been working several hours @ getting rodbc connected sql server 2012 on osx yosemite using rodbc , unixodbc. error receive in r quite generic: > odbcdriverconnect("dsn=istsql;uid=sa;pwd=***") [1] -1 warning messages: 1: in odbcdriverconnect("dsn=istsql;uid=sa;pwd=***") : [rodbc] error: state ±6s, code 20013, message 2: in odbcdriverconnect("dsn=istsql;uid=sa;pwd=***") : [rodbc] error: state ±6s, code 0, message 3: in odbcdriverconnect("dsn=istsql;uid=sa;pwd=***") : odbc connection failed warning messages: 1: in strsplit(msgs[i], "\n") : input string 1 invalid in locale 2: in strsplit(msgs[i], "\n") : input string 1 invalid in locale my /etc/freetds.conf file includes following: [istsql] host = ip.address port = 1433 tds version = 8.0 my /etc/odbcinst.ini file follows: [mssql] description = microsoft sql server driver driver = /usr/local/cellar/freetds/0.95.8/lib/libtdsodbc.so usag

How do I programatically find what symbols were imported with Python import * command? -

i have system collects classes derive base classes , stores them in dictionary. want avoid having specify classes available (i discover them programatically), have used from modulename import * statement. user directed place tests collected in modulename module. however, cannot find way programatically determine symbols imported import statement. have tried using dir() , __dict__ indicated in following example, no avail. how 1 programatically find symbols imported in manner (with import * )? unable find them above methods. testtypefigureouterrer.py: from testtype1 import * testtype2 import * class testfigureouterrer(object): def __init__(self): self.existingtests = {'type1':{},'type2':{}} def findandsorttests(self): symbol in dir(): # tried: dir(self) , __dict__ try: thing = self.__getattribute__(symbol) except attributeerror: continue if issubclass(thing,testt

loopbackjs - LoopBack Vs Breeze.JS to use with Node.JS -

are both loopback , breeze.js same persist data node.js client applications database mssql, oracle etc...? loopback exciting company smart people. i don't know loopback's data management offerings and, 1 of principals behind breeze, don't feel comfortable making comparisons anyway. i think it's wise consider every technology choice in context of broad business , application needs. let me suggest areas investigate: what database(s) care about? how product work databases? do need/want support on server for transactions validation during save batch save requests (mix of entity types , insert/update/delete) batch query requests do need/want support on client for client-side caching , events tracking entity change state property change notification property , entity validation automated entity graphs (e.g. just-in-time population , maintenance of entity navigation properties) typed representation of sub-documents ("complex types&

netty - How to set the length adjustment bytes mentioned in the LengthFieldBasedFrameDecoder class -

from lengthfieldbasedframedecoder 's documentation, allow user decode header field header 1 . encoder class allow user define such header field? * advanced example shows case there * header between length field , message body. have specify * positive <tt>lengthadjustment</tt> decoder counts * header frame length calculation. * <pre> * lengthfieldoffset = 0 * lengthfieldlength = 3 * <b>lengthadjustment</b> = <b>2</b> (= length of header 1) * initialbytestostrip = 0 * * before decode (17 bytes) after decode (17 bytes) * +----------+----------+----------------+ +----------+----------+----------------+ * | length | header 1 | actual content |----->| length | header 1 | actual content | * | 0x00000c | 0xcafe | "hello, world" | | 0x00000c | 0xcafe | "hello, world" | * +----------+----------+----------------+ +----------+----------+----------------+

sql - Query for parents and top two children of a hierarchyID table -

i'm trying parent , top left , top right children single table uses hiearchyid. been banging head on weeks , appreciate help. it's single table stores 'facts' school debate team, each fact has child facts can either 'for' or 'against' parent fact. i'd parent , recent 'for' , recent 'against' fact summary page. instead i'm getting cross-union every combination of those. here's table: factid (key) nodeid (hierarchyid) nodelevel(computed column) text side(1=for, 2=against) timestamp ======= ====== ========= ==== ===== ========= 1 /1/2/ 2 "kirk rules" 1 08:00 3 /1/2/1/ 3 "great actor!" 1 08:01 5

javascript - Sum Up for each element of Collection.find() -

i try sum specific column of datapoints collection fits specific query. getclickstotalcampaign: function () { var docs = datapoints.find({campaign: this._id, influencer: meteor.userid()}); var clicks = 0; for(var = 0; i< docs.length; i++) { clicks += parseint(docs[i].clicks); } return clicks; }, i wrong return of datapoints.find beeing array of objects? length of null, when query on mongo entrys back. @edit here data schema: schemas.datapoints = new simpleschema({ influencer: { type: string, label: "influencer id" }, advertiser: { type: string, label: "advertiser id" }, campaign: { type: string, label: "campaign id" }, amount: { type: number, label: "amount" } }); use aggregation framework can use $match pipeline operator filter collection on campaign ,

javascript - dynamically remove an element's required attribute in ASP MVC? -

is there way, in asp mvc project using unobtrusive validation, dynamically remove required attribute element? the element decorated required annotation in view model. thought remove removing html attribute, "data-val-required," jquery client validation still treats element required. impossible manipulate element's validation manipulating unobtrusive validation attributes? this tried, didn't work. wanted remove required attribute if check box unchecked. $("#chktemphire").click(function () { var checked = $(this).attr("checked"); var attr = $("#txttemphireenddate").attr("data-val-required"); var hasattr = false; if (typeof attr !== typeof undefined && attr !== false) hasattr = true; if (!checked && hasattr) $("#txttemphireenddate").removeattr("data-val-required"); }); am missing something, or not possible? thank you! you can use .r

python - incorrect answers for quadratic equations -

i wondering if tell me why python code solving quadratic equations isn't working. have looked through , haven't found errors. print("this program solve quadratic equations you") print("it uses system 'ax**2 + bx + c'") print("a, b , c numbers or without decimal \ points") print("firstly, value of a?") = float(input("\n\ntype in coefficient of x squared")) b = float(input("\n\nnow b. type in coefficient of x")) c = float(input("\n\ngreat. c value? number alone?")) print("the first value x " ,(-b+(((b**2)-(4*a* c))* * 0.5)/(2*a))) print("\n\nthe second value x " ,(-b-(((b * * 2)-(4*a*c))** 0.5)/(2*a))) when a=1 b=-4 , c=-3 expecting -1 , 4 5.5 , 0.5 your trouble in part tries quadratic formula: (-b+(((b**2)-(4*a* c))* * 0.5)/2*a) the trouble * has same precedence / you're dividing 2 , multiplying a . parentheses off, reduced unnecessary ones , moved

class - C++: Deriving with variables. Something is wrong with a small section of code -

classes dog , cat derive animal , in turn derives creature . pdog , pcat , panimal , , pcreature pointers class. animal , creature both abstract classes. what wrong code? panimal = new dog(); pdog = panimal; you can convert up hierarchy (i.e., derived base) implicitly. converting down hierarchy (from base derived) has done explicitly. in cases, want use dynamic_cast conversion succeed if correct: animal *panimal = new dog(); dog *pdog = dynamic_cast<dog *>(panimal); note classes need contain @ least 1 virtual function work (but if don't have virtual functions, hierarchy doesn't make sense @ all).

c# - how to use data annotations to convert int ID to string ID -

i using entity framework code first approach , have class string increments id. have following code in sql server me cannot update-database in package manager, if erase class attribute incrementing string. here sql code: create table [dbo].[school]( [schoolid] [int] identity(1,1) not null, emp_id 'emp_' + cast(schoolid nvarchar(10))persisted, [dayevent] [nvarchar](100) null, [daynote] [nvarchar](250) null, constraint [pk_dbo.school] primary key clustered ( [schoolid] asc )with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on) on [primary] ) on [primary] go first, if post code first class give better answer. presumption have have created true way, think missed databasegenerated attribute specifies how database generates values property. it takes databasegeneratedoption sets pattern used generate values property in database , has identity options marks related

django - Database structure to handle similar/same object at varying business levels -

scenario a well-known taco establishment wants build django app models combo , comboitem , ingredient , , order . headquarters wants create various combos included items , layout original item ingredients , price. each franchise can select combos sell on menu , allowed adjust price , ingredients of combo items store. when order comes in, combo , item details should show on log , should not change in future if hq renames combo or franchise changes price/ingredients. use case hq creates "hot taco combo". has 3 related combo items a taco (price: $.99, ingredients: shell, beef, cheese, hot sauce) churro-spirals (price: $.79) drink (price: $1.29) the ny franchise adds hot taco combo menu. adjust price of taco $1.49 , add lettuce taco. a customer orders combo no cheese on taco. hq changes name of combo fiery taco combo - ny's combo name updates taco remains same custom price , still includes lettuce. a manager @ ny franchise views orders , see's 1