Posts

Showing posts from May, 2011

sql server - Show Sale Data By Salesman By Region -

i need sql server query show grid of sales region sales person this: region mitchell mark manny moe ----------------------------------------- west 0 0 0 0 north 0 1 1 1 east 1 0 0 0 south 0 0 0 0 how can have sql query output data this? know use return data not in correct breakdown or format. select region, salesperson, count(sales) salesdatabase group region, salesperson you can pivot table. try this: ;with data ( select region, salesperson, sales salesdatabase ) select region ,[mitchell] ,[mark] ,[manny] ,[moe] data d pivot (count(sales) salesperson in ([mitchell], [mark], [manny], [moe])) p; you can find more information here .

java - Isn't notifyDataSetChanged enough to force an adapter to redisplay the items it holds? -

in direct subclass of pageradapter in construction pass in empty list<string> list use functionality. in background task fetch/create strings should passed derived adapter , fragment do: derivedadapter.notifydatasetchanged() . inside derivedadapter have overriden method follows: @override public void notifydatasetchanged() { items.clear(); items.addall(getcurrentcreatedlist()); super.notifydatasetchanged(); } but view pager, have set adapter not display anything. misunderstanding adapters , notifydatasetchanged()? note: if start adapter full list, works perfectly update: if recreate adaptor @ point , reset it works fine. updating via notifydatasetchanged not seem work. perhaps misunderstanding supposed do?

java - What does Heads cannot be resolved to a variable mean? -

sorry bother you. have been trying create simple java cointoss simulator recently. here code import java.util.random; import java.util.scanner; public class cointoss { static string choice; static string answer; static scanner user_input = new scanner( system.in ); public static void main(string[] args){ system.out.print("heads or tails?"); choice = user_input.nextline(); random rand = new random(); int side = rand.nextint(2); if (side == 0){ answer = heads; system.out.println("heads"); if (answer == choice) { system.out.println("you win!"); } else { system.out.println("you lose!"); } } else if (side == 1){ answer = tails; system.out.println("tails"); if (answer == choice) { system.out.println("you win!"); } else { system.out.println("you lose!");

python - convex programming with cvxopt or cvxpy -

i need optimize problem cvxopt or cvxpy in python , it's being kind of dificult: obj function: minimize sum(a*x^2+b/x) st: 5 <= x < 40; sum(v/d)<=t where x variable (vector); , b know vectors , t constant. the following code solves problem in cvxpy. assumed meant sum(x/d) <= t . # replace these values. n = 2 = 2 b = 2 d = 2 t = 1000 import cvxpy cvx x = cvx.variable(n) obj = cvx.sum_entries(a*x**2 + b*cvx.inv_pos(x)) constr = [5 <= x, x <= 40, cvx.sum_entries(x/d) <= t] prob = cvx.problem(cvx.minimize(obj), constr) prob.solve()

angularjs - Compiling a directive inside another directive -

Image
i have directive can output plain html or directive. i'm having trouble getting inner directive compile, right angular sticking actual directive tag html without compiling it. here's screenshot of chrome inspector showing un-compiled directive basically, using $sce.trustashtml("<html-string-here>") allow html, not compile directive. if wrap in $compile($sce.trustashtml("<html-string-here>"))($scope) throws errors. what missing here? full demo here: http://jsfiddle.net/chrismbarr/nozaulzo/3/ simplified demo explained below i have list $scope.list = [{ id:1, content: "some plain text" },{ id:2, content: "<strong>some html!</strong>" },{ id:3, content: "<inner-directive text='a directive!'></inner-directive>" }]; i bind list this: <outer-directive ng-repeat="item in list" data="item"></outer-directive> a

Upgrade Mobilefirst CLI 6.3.0 to 7.0 -

are there known issues in upgrading mobilefirst 6.3 cli mobilefirst 7.0 cli ? auto-upgrade fails following error in ubuntu 14.0.x, working fine 6.3.0. error when running mfp build -dd mobilefirst-cli verb cli process.argv=["/opt/ibm/mobilefirst-cli/ibmnode/bin/node","/opt/ibm/mobilefirst-cli/mobilefirst-cli/bin/mobilefirst-cli.js","build","-dd"] mobilefirst-cli verb cli opts={"ddebug":true,"argv":{"remain":["build"],"cooked":["build","--ddebug"],"original":["build","-dd"]}} mobilefirst-cli verb cli mobilefirst@7.0.0.00.20150312-0738 mobilefirst-cli verb cli node@v0.10.30 mobilefirst-cli verb ant variables -dbasedir=/home/ubuntu/xxxxxxxxx mobilefirst-cli verb ant variables -dworklight.jars.dir=/opt/ibm/mobilefirst-cli/mobilefirst-cli/node_modules/generator-worklight-server/lib mobilefirst-cli verb ant variables -dworklight.ant.tools.dir=/o

Sed to replace variable length string between 2 known patterns -

i'd able replace string between 2 known patterns. catch want replace string of same length composed of 'x'. let's have file containing: hello.stringtobereplaced.secondstring hello.shortstring.secondstring i'd output this: hello.xxxxxxxxxxxxxxxxxx.secondstring hello.xxxxxxxxxxx.secondstring using sed loops you can use sed , though thinking required not wholly obvious: sed ':a;s/^\(hello\.x*\)[^x]\(.*\.secondstring\)/\1x\2/;t a' this gnu sed ; bsd (mac os x) sed , other versions may fussier , require: sed -e ':a' -e 's/^\(hello\.x*\)[^x]\(.*\.secondstring\)/\1x\2/' -e 't a' the logic identical in both: create label a substitute lead string , sequence of x 's (capture 1), followed non- x , , arbitrary other data plus second string (capture 2), , replace contents of capture 1, x , content of capture 2. if s/// command made change, go label a . it stops substituting when there no non- x 's

jms - Spring CachingConnectionFactory not reaping when idle -

i using spring cachingconnectionfactory in below configuration cache mq sessions. can see caching working expected: it opens single mq connection creates new sessions needed , reuses them my application has short lived peaks in message traffic. when there peak, session size bloats , remains there long after peak. looking way of reaping these idle sessions after specific period of inactivity. there anyway achieve this? <jee:jndi-lookup id="mqqueueconnectionfactory" jndi-name="java:comp/env/jms/myjmsqueueconnectionfactory" /> <bean id="userconnectionfactory" class="org.springframework.jms.connection.usercredentialsconnectionfactoryadapter"> <property name="targetconnectionfactory" ref="mqqueueconnectionfactory"></property> </bean> <bean id="queueconnectionfactory" class="org.springframework.jms.connection.cachingconnectionfactory"> <property name=&

sql server 2008 - Visual Studio version mismatch -

i working on ssrs project running sql 2008 (entity data model, dll, ssis, ssas cubes) team going need source control, have visual studio 2012 set up. upon check in visual studio updates project files 2012. when pull down project files no longer run on original 2008 environment. has had issues this? please me if there solutions. thank you two ways can this. right click on solution , open vs 2012 create new rs project in 2012 , add everything. the easiest thing recreate solution in 2012. i have number of solutions manage , had spend time , every single 1 of them.

python - pickle error on spark filter -

when filter rdd using closure refers object, pickle error. without object: >>> mappartitionsrdd[369] @ mappartitions @ serdeutil.scala:143 >>> b = a.filter(lambda row: row.foo == 1) >>> b pythonrdd[374] @ rdd @ pythonrdd.scala:43 with object: >>> z.foo 1 >>> b = a.filter(lambda row: row.foo == z.foo) >>> type(b) <class 'pyspark.rdd.pipelinedrdd'> >>> b traceback (most recent call last): file "<stdin>", line 1, in <module> file "/opt/cloudera/parcels/cdh-5.3.1-1.cdh5.3.1.p0.5/lib/spark/python/pyspark/rdd.py", line 142, in __repr__ return self._jrdd.tostring() file "/opt/cloudera/parcels/cdh-5.3.1-1.cdh5.3.1.p0.5/lib/spark/python/pyspark/rdd.py", line 2107, in _jrdd pickled_command = ser.dumps(command) file "/opt/cloudera/parcels/cdh-5.3.1-1.cdh5.3.1.p0.5/lib/spark/python/pyspark/serializers.py", line 402, in dumps return cloudpi

c - Incomprehensible result of a multithread code -

i start c programming project used multithread. before start project, have written code practice. purpose see how mutex , threads works. not work properly. here code: #include <stdio.h> #include <pthread.h> #include <stdlib.h> #include <string.h> pthread_mutex_t mymutex; char mystrings[100][30]; int i=0; void *printthread1() { printf("this initial of first thread\n"); (int j=0; j<33; j++) { pthread_mutex_lock(&mymutex); strcpy(mystrings[i], "this first thread"); i++; pthread_mutex_unlock(&mymutex); } pthread_exit(null); } void *printthread2() { printf("this initial of second thread\n"); (int j=0; j<33; j++) { pthread_mutex_lock(&mymutex); strcpy(mystrings[i], "this second thread"); i++; pthread_mutex_unlock(&mymutex); } pthread_exit(null); } void *printthread3() { printf("this initial o

c++ - Losing Part of Image When Using DrawImage on Panel -

i making winforms app hd images (1920 x 1080) displayed on panel control. images hd webcam. panels smaller (240 x 135) images , having problem getting images resize , display in panels. crash outright , other times image not resized. the images bitmaps , redrawing them in paint event control. here code paint event handler. void cam0panel_paint( object^ /*sender*/, system::windows::forms::painteventargs^ e ) { system::drawing::bitmap^ b = imagewinarray[channel_select0]; graphics^ g = e->graphics; g->interpolationmode = system::drawing::drawing2d::interpolationmode::bilinear; g->compositingmode = system::drawing::drawing2d::compositingmode::sourcecopy; g->drawimage(b,system::drawing::rectangle(0,0,cam0panel->right,cam0panel->bottom)); } i specifying top, left point in panel (0,0) , image resized panel size. reason not working. any appreciated.

casting - Python cast string to type if string is not none -

this question has answer here: python idiom applying function when value not none 2 answers i have long list of values cast , assign. each value has possibility of being none. if value none, i'd leave none, otherwise casting. reason being these values end in database , have convert none's null's later. so far simplest way i've found adding inline if statements each assignment. self.number = decimal(input.number) if input.number else none i don't find code appealing, it's lacking in readability , tedious write statements on every input value. prefer decimal(input.number) return none if input.number none doesn't appear case. there simpler way this? suppose make own decimal_ function , call instead? update: i've heeded words of advice hear , come this def dec_(string): if string none: return none else:

javascript - Prevent reloading certain parts of page -

i'm new web development don't have experience of this. have navbar @ top of website (made foundation), don't want reload every time page reloads. i've noticed on several websites parts of page kept in place when links clicked , url changes. how can achieve this? thanks there several ways achieve this. using ajax calls 1 of them, iframe another. create 1 page application , show/hide elements when buttons clicked. force load data @ once won't recommend (depending on website). a small article how can use iframe option. a small article ajax option, include small demo show how works.

asp.net mvc - List of registered users with details on MVC 5 -

i know if possible how list of registered users , details in mvc 5? i'm sort of trying users outputted tabular form when creating controllers , views other data sets can edited , forth. i'm using asp .net identity store user details. try following: right-click controllers , add new controller choose mvc 5 controller views, using entity framework choose user object model class (typically called applicationuser if project created standard vs/mvc template) you'll find (as did) scaffolding adds new dbset dbcontext called applicationusers. can delete because imagine context should include set of users called users. finally find , replace applicationusers property users in new controller. you should able run app , navigate /applicationusers see list of users, usual edit/details/delete action links.

sockets - How can server determine whether client is local or remote? -

i'm trying create server able determine whether each accepted connection local or remote. server this: call socket() create tcp srvsock bind() srvsock inaddr_any|server_port listen() on svrsock accept() connection on svrsock local client this: call socket() create clisock connect() clisock 127.0.0.1|server_port remote client this: call socket() create clisock connect() clisock server_public_ip|server_port when accept() returns, how can server determine whether client local or remote? the server can use getpeername() address of connected client. or use address accept() outputs. either way, if address among addresses returned getifaddrs() (or equivalent function, depending on platform) client local; otherwise, remote.

Displaying custom dataset properties in tooltip in chart.js -

what easiest way possible display custom properties in pie chart tooltip? var piedata = [ { value: 40, color:"#f7464a", highlight: "#ff5a5e", label: "label 1", description: "this description label 1" }, { value: 60, color: "#46bfbd", highlight: "#5ad3d1", label: "label 2", description: "this description label 2" } ]; var options = { tooltiptemplate: "<%= label %> - <%= description %>" }; window.onload = function(){ var ctx = document.getelementbyid("chart-area").getcontext("2d"); window.mypie = new chart(ctx).doughnut(piedata, options); }; i tried adding "decription" property , printing it, without luck. gives me error saying description not defined. saw there custom tooltip functionality, seemed lot of work trivial. there easier way?

javascript - Jquery - check column checkboxes then do something with those rows -

i've been trying find match question, nothing concrete. i'm still learning , don't know i'm missing. so code can found here: fiddle this simplified version of i'm working with. in final version, upload csv file html table see there (id="dvcsv"). upon uploading, table shown (with added dropdowns , column of checkboxes). checkboxes come "pre-chcecked" when generate them want user able turn "off" rows not want calculate on. i'll run through process: function reads columns user designates. don't know column upload data into. function checklocations() { //checks uploaded data locations of lat/lon data based on user dropdowns collocs[0] = ($('#value_0 :selected').text()); collocs[1] = ($('#value_1 :selected').text()); collocs[2] = ($('#value_2 :selected').text()); collocs[3] = ($('#value_3 :selected').text()); latcolumn = collocs.indexof("lat"); longcolumn = collocs.indexof(&quo

Android Accessibilty Service: onAccessibilityEvent() Method isn't fired all the time -

preface : device: nexus 5, android lollipop put simply, app capture accessibility events capture rate around 93%. this might unacceptable kind of functionality app designed for. my code: @override public void onserviceconnected() { accessibilityserviceinfo info = new accessibilityserviceinfo(); info.notificationtimeout = 0; info.eventtypes = accessibilityevent.type_window_state_changed; info.feedbacktype = accessibilityserviceinfo.feedback_generic; info.packagenames = new string[] { "com.android.phone" }; setserviceinfo(info); } public void onaccessibilityevent(accessibilityevent x) { log.e("event", "occurred"); } question: if have worked accessibility services before have observed similar? if missing events norm, capture rate poor ? if overcame issue, please please answer this, i'll buy pizza anywhere on earth ......seriously !

Submit form data within a table via Ajax always sends first row PHP -

this table has many rows each few columns completed own mini-form. variable $y auto-incremented , identifies row should submitted. old form pre-ajax looked this: <tr> <form id='form$y' action=".htmlspecialchars($_server["php_self"])." method='post''/> <input type='hidden' form='form$y' name='id' value='$id' /> <td> <input style='height:18px' form='form$y' type='date' name='date value='$date'/> </td> <td> <select name='status' form='form$y' required/> <option>$status</option> <option value='option1'>option1</option> <option value='option2'>option2</option> </select> </td&g

sql - MySQL Statement Displaying Values Even If NULL -

i have 2 tables, employee & dependent . employee pk ssn , foreign key dependent table essn . trying retrieve name of employees , names of dependent. if employee not have dependent, need display blank value in dependent column. to retrieve name of employees have dependents, statement use: select firstname "first name", lastname "last name", dependent_name "dependent name" employee,dependent ssn=essn; if guide me in right direction, appreciated. use left join rows first table if there no matching in second: select firstname "first name", lastname "last name", dependent_name "dependent name" employee left join dependent on dependent.essn = employee.ssn; i changed implicit old-style join ansi compliant explicit join too.

angularjs - Multiple states on one page with ui-router -

Image
currently investigating possibility configure ui-router following scenario. great, if have idea how achieve this. i have simple 1 pager layout navigation. each navigation item have div box content. how can define several states on 1 page (for each navigation item 1 state separate controller , template)? afterwards implement solution, when click on navigation item scroll corresponding div container. made html anchors, how can solve ui-router? or isn't possible , have create 1 state separate views? below example image show wanted layout: hopefully have solution that. thanks in advance, xynnn with ui-router can have multiple views on 1 page. able this: $stateprovider .state('main',{ views: { 'contentsite1': { templateurl: 'site1.html', controller: function($scope){} }, 'contentsite2': { templateurl: 'site2.html', controller: function($scope){} }, 'contentsite3': {

Android Lollipop 5.0.1 Call Duration bug -

if @ this , there bug in lollipop 5.0.1 incorrectly calculates duration of call time of call arrival or call start , not when start talking . the version 5.1 came in, has has installed can verify bug has been corrected or not? this issue has been corrected, had 5.1 update , our apps work again.

node.js - Longer Nodemailer Html/Text -

every example of nodemailer along these lines: var mailoptions = { from: "fred foo ✔ <foo@blurdybloop.com>", // sender address to: "bar@blurdybloop.com, baz@blurdybloop.com", // list of receivers subject: "hello ✔", // subject line text: "hello world ✔", // plaintext body html: "<b>hello world ✔</b>" // html body} i want make longer message 1 liner when signs up. is there way write , source html place within application, maybe series of line breaks. tl;dr i want have nodemailer send longer email 1 liner put content in file , load it. fs = require('fs'); fs.readfile('/wwwroot/includes/email.html', 'utf8', function (err,data) { if (err) { return console.log(err); } var html = data; });

objective c - What is the best way to rename a class in an iOS library? -

if wanted rename class used within ios library , api publicly exposed, best way that? ideally, i'd have old name still around, marked deprecation warning people can switch using new syntax gracefully. because can't keep both classes around want developer still able use deprecated api internally calls renamed version of itself. i playing around #define , __attribute__((deprecated)) , @compatibility_alias didn't find way accomplish of trying do. first, use refactor rename class new name. then, want support old name depreciate, can use typedef statement: __attribute__((deprecated)) typedef newclassname oldclassname;

php - Sql query with punctuation marks -

i have webserver between sql database , android app. on database want put sentence question marks when webserver catches query, echo null. happen when use question marks, dots or commas in phrase. code of webserver is: <?php $hostname_localhost ="*****"; $database_localhost ="*****"; $username_localhost ="*****"; $password_localhost ="*****"; $localhost = mysql_connect($hostname_localhost,$username_localhost,$password_localhost) or trigger_error(mysql_error(),e_user_error); mysql_select_db($database_localhost, $localhost); $resultado = mysql_query('select pregunta,respuesta,intentos,frase frases'); if (!$resultado) { die('consulta no válida: ' . mysql_error()); } while ($fila = mysql_fetch_assoc($resultado)) { $pregunta = $fila['pregunta']; $respuesta = $fila['respuesta']; $intentos = $fila['intentos']; $frase = $fila['frase']; } mysql_close($localhost); $data = a

Android: Dynamically replacing fragments on a custom layout -

i trying programatically add fragments activity custom layout, want change them on button clicks. i read tutorials , managed add them when activity has linearlayout. however, when use mine fragment not show up. it not begin laid out, not know how this. laying out framelayout want put them, not know fragments have laid out. here code (i want display blogfragment framelayout placed): main_activity.xml <com.example.myfirstapp.mainlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/main_window" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".mainactivity" > <fragment android:name = "com.example.myfirstapp.buttonsfragment" android:id = "@+id/buttons" android:layout_width="match_parent" android:layout_height="30dp" android:layout_weight=&q

Selenium code to wait until CSS class is available and extract text in Python -

i have looked @ questions on here related none of them concerned finding class , extracting text part of class. my goal automate process of entry website finds emails, given name , domain names. far have code automate entry of name , domain, , click on "search", issue waiting result load. want code wot wait until css class "one" present , extract text related class, e.g. following snippet: <h3 class="one">success</h3> extract text "success". you need explicitly wait element become visible : from selenium.webdriver.common.by import selenium.webdriver.support.ui import webdriverwait selenium.webdriver.support import expected_conditions ec wait = webdriverwait(driver, 10) h3 = wait.until(ec.visibility_of_element_located((by.css_selector, "h3.one"))) print h3.text

ios - Custom Callout View like MKAnnotationView's Callout -

Image
i have custom mkannotationview have customised according documentation of apple docs . so far it's been nice follow because neat , clean code , haven't used third party it. here's screenshot of it. now stuck @ ui part of it, making callout native callout. don't want use other third party in have redo work or have abandoned guidelines of apple. so guess looking simple solution can make in callout view's xib or similar. thanks, attiqe ok have figured out way. loading callout view nib , have made changing in mimic native look. have embedded icons/uiimageview's uiview. parent view transparent , child view(that contains icons now) have uiimageview(with callout arrow) @ it's centre bottom. this solved problem. thanks, attiqe

php - upload file using ajax temporary save in table -

in project insert data files , other info using ajax, saving of file want insert many files did have table store file content as var file = $('#file')[0].files[0]; //var file = document.getelementbyid('file').files[0]; var name = file.name; var size = file.size; var type = file.type; var newname = $('#filename').val(); var newrow = "<tr>" + "<td id=''>" + file.name + "</td>" + "<td id=''>" + file.size + "</td>" + "<td id=''>" + file.type + "</td>" + "<td id=''>" + newname + "</td>" + "<td>" + "<a href='#' id='" + id + "' class='deletefile'>delete</a>" + "</td>" + "</tr>"; $("#filetable > tbody > tr:last").after(newrow); this how save file c

C++ Test if map element exists -

this question has answer here: how find whether element exists in std::map? 9 answers i have "array" of strings defined such: typedef map<int, string> strarr; whenever this: strarr args; if(!args[1]) { /*do stuff*/ } the compiler tells me there's no match 'operator!' why so, , how can fix this? edit: there way of making work bool operator! ()! with !args[1] , you're trying call operator! on std::string , , indeed, error message right: std::string has no operator! . to check whether element exists in std::map , use find . return std::map::end if specified key not in map: if (args.find(1) == args.end()) { ... }

android - issue with permission in /system/bin files after updating the images built with security keys -

i built android secuirity keys taking reference below link: http://www.kandroid.org/online-pdk/guide/release_keys.html i got signed-img.zip. updated zip using fatboot. after rebooting getting errors in debug tool: init: cannot execve('/system/bin/servicemanager'): permission denied init: cannot execve('/system/bin/mediaserver'): permission denied init: cannot execve('/system/bin/surfaceflinger'): permission denied init: cannot execve('/system/bin/dbus-daemon'): permission denied init: cannot execve('/system/bin/keystore'): permission denied like files in system/bin getting permissions issue. i debugged issue stage. found command: make -j4 product-<product_name>-user dist the command above creates file under out/dist called -target_files.zip. file need pass sign_target_files_apks script. when extract zip file there system folder contain system image data. files under /bin didnt have executable permision. executable

Ruby on Rails error message is very long -

i purposely made mistake in migration file show kind of error get. == 20150321034322 alterusers: migrating ======================================= -- rename_table("users", "admin_users") -> 0.0023s -- add_column("admin_users", "username", :string, {:limit=>25, :after=>"email"}) -> 0.0198s -- change_column("admin_users", "email", :string, {:limit=>100}) -> 0.0162s -- rename_column("admin_users", "broken", "hashed_password") rake aborted! standarderror: error has occurred, later migrations canceled: no such column: admin_users.broken/library/ruby/gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract_adapter.rb:483:in `column_for' /library/ruby/gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:759:in `rename_column_sql' /library/ruby/gems/2.0.0/gems/activerecord-4.2.0/lib/a

javascript - How to wait for a click on canvas -

i put "pause" in program. basically, every time call wait() function, nothing should happen until click canvas. drawrectangle(a,b,c,d) waitforclick() drawrectangle(e,f,g,h) the first rectangle drawn, , second 1 not drawn until click on canvas. thank help. you may looking @ problem wrong way. it's not best idea halt program since want execution happen possible. 1 of big advantages javascript has awesome event api baked in it. instead of making program wait/sleep, try using events: drawrectangle(a, b, c, d); let's make function run when detect click events: function customclickeventhandler(event) { drawrectangle(e, f, g, h); } and finally, bind new function window's 'click' event. can choose dom element, not window. window.addeventlistener('click', customonclickevent); documentation events api: https://developer.mozilla.org/en/docs/web/api/event follow link find out more 'addeventlistener' function

Unable to make Smarty tag meaning -

i have below code in smarty template. unable interpret paging does. calc, total, current, per_page, url variable paging {paging calc=$pinfo.calc total=$dealers|@count current=$pinfo.current per_page=$config.dealers_per_page url=$search_results_url} {paging} seems custom smarty plugin.

python - scipy quad uses only 1 subdivision and gives wrong result -

i want use quad mean of gaussian distribution. first try , 2nd try gets different result. , 2nd try of quad uses 1 subdivision. mu =1 sigma =2 import scipy sp import scipy.integrate si import scipy.stats ss f = lambda x: x * ss.norm(loc=mu, scale=sigma).pdf(x) = si.quad(f, -999., 1001., full_output=true) print a[0] #print sum(a[2]["rlist"][:a[2]["last"]]) print a[2]["last"] b = si.quad(f, -1001., 1001., full_output=true) print b[0] #print sum(b[2]["rlist"][:b[2]["last"]]) print b[2]["last"] print sorted(a[2]["alist"][:a[2]["last"]]) print sorted(b[2]["alist"][:b[2]["last"]]) here output: 1.0 16 0.0 1 [-999.0, -499.0, -249.0, -124.0, -61.5, -30.25, -14.625, -6.8125, 1.0, 8.8125, 16.625, 32.25, 63.5, 126.0, 251.0, 501.0] [-1001.0] do make mistake? because limits of integration far out in tails of gaussian, you've fooled quad thinking function identically 0:

Eliminate numbers from a sentence in Python -

i parsing xml file , trying build dictionary every context in xml. have done parsing successfully, , need rid of stopwords, punctuations , numbers string get. however, reason, couldn't rid of numbers, have been debugging night, hope me it... def is_number(s): try: float(s) return true except valueerror: return false i have been checking method 'is_number' working, don't why still pass if statement: if (words[headindex + index] not in cachedstopwords) , ~isnumber: thanks in advance! the problem is: ~isnumber ~ bitwise not operator . want not boolean operator : >>> ~true -2 >>> ~false -1 >>> not true false >>> not false true the bitwise operator lead ~isnumber being truthy value ( -1 or -2 ), , if statement entered.

php - Can I disable mysql protection allowing access without any authentication in phpmyadmin (XAMPP)? -

i tried run application on localhost, stuck problem. someone told me need give password users , privileges. result, have tried giving permissions users in users , privileges. don't know username , password (due problem). can disable mysql protection allowing access without authentication in phpmyadmin (xampp)? this error (during execution @ localhost): cdbconnection failed open db connection: sqlstate[hy000] [1045] access denied user 'root'@'localhost' (using password: yes) first, authentication not done @ phpmyadmin level @ mysql level. disable mysql server's "protection" (authentication) have restart mysql server special option. have find, depending on xampp version, my.ini file located, edit described in how start mysql --skip-grant-tables? (in answer tonycoupland) , restart mysql service.

php - How to insert data into MongoDB with Laravel -

first i've set default setting database connection mongodb. 'mongodb' => [ 'driver' => 'mongodb', 'host' => 'localhost', 'username' => 'dofuser', 'password' => 'dofpass', 'database' => 'dof', ], apps/models/user <?php use jenssegers\mongodb\model eloquent; class user extends eloquent { protected $collection = 'user'; //$user = user::all(); } and router route::post('/register', function() { $user->model('user', 'app\models\user'); $user = new user; $user = user::create(array( 'username' => input::get('username'), 'fullname' => input::get('fullname'), 'password' => hash::make(input::get('password')), 'gender' => input::get('gender'), 'month' => input::get('month'), '

android - IntelliJ compiles successfully but no signed apk is generated -

Image
i updated android sdk platform, since update when try generate signed apk in intellij idea no error in compilation , packaging process (even proguard works fine) no apk file generated in destination. able run app on emulator , devices, means debug apk generated correctly. i tried cleaning , rebuilding, no luck. thought might problem project settings, tried generate apks other android projects or empty hello world project, problem still exists. is there log files or other things can post here clarify problem? well, irrelevant (to android sdk) problem struggling last 2 days. the problem solved removing following directory: %home%\.intellijidea14\system\caches

Looking for example of Javapackager gradle integration for a JavaFX app -

i looking sensible way integrate packaging of javafx application gradle build. the plugin @ https://bitbucket.org/shemnon/javafx-gradle not it's maintained , wondering if there better way manually hacking command line invocation of javapackager have manually resolve dependency stuff myself. thanks i've been facing similar situations, started pure gradle sample project on github https://github.com/moxi/javafx-gradle-multiproject-setup i'll try update code basic stuff generating dmg mac apps, it's starter. you're right plugin looking no longer supported, can see in last comment author posted of issue: https://bitbucket.org/shemnon/javafx-gradle/issues/49/documentation-and-a-working-sample i found following project , it's kinda working, needs tweaks multiple modules project, generates binaries correctly: https://github.com/fibrefox/javafx-gradle-plugin this guy seems active on project nowadays, lack of documentation issue still can d

objective c - Use a not active application (background) -

is there way work minimized or not active applications? can open application, open , use another, , press button activate program? for example, open application, open safari, press button (f1 or other), program copies nsstring , pastes text field using in safari. know how make program need (copy , paste message when button pressed) when it's active somehow has done in background. yes. application should provide "service". accessible contextual menus, services submenu of application menu, , can have hot key assigned. designed (optionally) receive selected data app invokes , (optionally) return new data replace selection or inserted @ insertion point if there's no selection. see description of services os x human interface guidelines. see services implementation guide .

c++ - i want exit my code after tokenizing -

i want tokenize string space delimeter using following code: int main(){ string str; string s; cout<<getcwd(null,0)<<endl; cout<<"enter command"<<endl; cin>>str; while (getline(cin, str, ' ') && str.size() != 100) cin>>str; return 0; } but want terminate code after taking input continuously taking inputs , not executing return 0 line ,what should user able give 100 characters input , after taking input user should terminate program.

ios - How can I call a method from another swift file in GameViewController? -

i have button have created in storyboard lives on game game screen. has ib action in gameviewcontroller() follows: @ibaction func buttonpressed(sender: anyobject) { gamescene().mycustommethod() } in gamescene lives mycustommethod() spawn enemies, code above doesn't work properly. if add println("button pressed") in ibaction, print out in console mycustommethod won't execute , spawn enemies expected. can me or explain how resolve issue? thanks in method, create new gamescene object each time. should create once (at initialization), , call mycustommethod on object. var gamescene: gamescene! override func viewdidload() { gamescene = gamescene() } @ibaction func buttonpressed(sender: anyobject) { gamescene.mycustommethod() }

c# - Populating one dataset overwrites another dataset result -

its been 2-3 hours , can't still understand why happening. need help. i populating datagridview using dataset. there 2 tables master , detail. using 2 datasets fetch both tables datasets (also i've implemented class fetch database call class's function return dataset containing result , assign local datasets). now happening 1st fetch detail table , check whether null etc , if not fetch second. here problem arises second gets populated 1st 1 overwrites. out of mind can't understand happening. here's code: private void txtinvnumber_textchanged(object sender, eventargs e) { if (txtinvnumber.text != "") { try { dataset dsdetail = new dataset(); datatable dtdetail = new datatable(); string query = "select sell.itemid 'item id',item 'item name' ,sell.quantity ,status ,credit_limit 'credit limit'," + "total_a

delphi - Detect help button click in MessageBox? -

in delphi xe7, need use button in messagebox. msdn states: mb_help 0x00004000l adds button message box. when user clicks button or presses f1, system sends wm_help message owner. however, when click button in messagebox, no wm_help message seems sent application: procedure tform1.applicationevents1message(var msg: tagmsg; var handled: boolean); begin if msg.message = wm_help codesite.send('applicationevents1message wm_help'); end; procedure tform1.btnshowmessageboxclick(sender: tobject); begin messagebox(self.handle, 'let''s test button.', 'test', mb_iconinformation or mb_ok or mb_help); end; so how can messagebox button click , how can detect messagebox did come from? the documentation says, emphasis: the system sends wm_help message owner. that msdn code fact message delivered synchronously directly window procedure. in other words, has been sent using sendmessage , or equivalent api. you've attempte

MySQL- Select and Update at the same time -

i have query select * outbox status=0 ; then need update selected records status should equal 1 i.e ( update outbox(selected records select query) set status =1 ) any ? you can that, outbox table: update outbox set status = 1 status = 0

sorting - Ampscript: desc sort field values from data extension and pass them to another variable -

i have data extensions 6 fields: emailadress (type: emailadress, unique) field1 (type: number, not nullable) field2 (type: number, not nullable) field3 (type: number, not nullable) field4 (type: number, not nullable) field5 (type: number, not nullable) i have 3 objectives: 1. pass values of each field ampscript variables (the easy part) %%[ set @var1 = field1 set @var2 = field2 set @var3 = field3 set @var4 = field4 set @var5 = field5 ]%% 2. sort variables descending based on values , (3) pass them on 1 of 5 contentareas. %%=contentareabyname("my contents\campaigns\mainitem\@maxvar1")=%% %%=contentareabyname("my contents\campaigns\subitem1\@maxvar2")=%% %%=contentareabyname("my contents\campaigns\subitem2\@maxvar3")=%% %%=contentareabyname("my contents\campaigns\subitem3\@maxvar4")=%% %%=contentareabyname("my contents\campaigns\subitem4\@maxvar5")=%% if, example values of fields are: field1: 10 field2: 15 field3: 5 fie

ios - 'ld: file not found' after changing product name in Xcode -

Image
i working on application , started out bad name. decided change it. did this. at top right corner changed name want. , started getting error can see there. reveal in log shows these details: the main error says: ld: file not found: /users/.../xcode/deriveddata/... go edit scheme shown below. then uncheck other targets except main target under build tab.

python - Calculator code problems: 10 + 5 results in 105 -

i'm new forum , new python after c++. i have problem python calculator. when run , + example : 10 + 5 gives 105 , wanted 15 . other operations don't work (i error). print("\ncalculator in python") print("\nchose operation :") print("\na)+\n\nb)-\n\nc)/\n\nd)*") answer = input("\n\n: ") result = int if answer == 'a': = input("\n\nfirst number : ") b = input("\n\nsecond number : ") print(a, "+", b, "=", a+b) elif answer == 'b': = input("\n\nfirst number : ") b = input("\n\nsecond number : ") print(a, "-", b, "=", a-b) elif answer == 'c': = input("\n\nfirst number : ") b = input("\n\nsecond number : ") print(a, "/", b, "=", a/b) elif answer == 'd': = input("\n\nfirst number : ") b = input("\n\nsecond number : ")

xml - Append at a specific position using PHP files -

i trying add <?xml-stylesheet type='text/xsl' href='soap.xslt'?> after <?xml version="1.0" encoding="utf-8"?> xml file, in fact soap response replacing data found after <?xml version="1.0" encoding="utf-8"?> link stylesheet. here's part of code client.php writes soap response file , appends part want. <?php if(isset($_post['search_input'])) { try { $input = $_post['search_input']; $wsdl = "http://localhost/webservice/uddi/90210store.wsdl"; //$options = array('cache_wsdl'=>wsdl_cache_none, 'features'=>soap_single_element_arrays); //$client = new soapclient($wsdl, $options); $debugoption = array('trace'=>true, 'cache_wsdl'=>wsdl_cache_none, 'features'=>soap_single_element_arrays); $client = new soapclient($wsdl, $debugoption); $response = $client->viewdressperprice($input); $s