Posts

Showing posts from July, 2010

List Jasmine test results at bottom of console without other output -

is there reporter jasmine 2.5 can list results of tests without clutter of other console logs? i know can suppress logs more difficult (and can useful too) rather not if can use reporter can still list tests , descriptions @ bottom. right because of logs need scroll lot see descriptions of tests passed.

php - The mbstring extension is missing -

i'm new linux. installed apache2, mysql-server, php 7.0 , phpmyadmin on linux mint 18.1. installation went fine, localhost/phpmyadmin gives error (see title). tried: uncommenting "extension_dir" in php.ini uncommenting mbstring.dll extension in php.ini making link /var/www/html/phpmyadmin /usr/share/phpmyadmin reinstalling php7.0-mbstring but neither worked. i've been restarting apache well. if have apache , php running correctly, should install mbstring extension on php , restart apache: sudo apt-get install php7.0-mbstring sudo service httpd restart restarting apache step people forget about. distributions restart apache when install php extension, other don't.

How to define function in class properly in Python? -

this question has answer here: python: nameerror:global name '…‘ not defined [duplicate] 1 answer i want define function sumofleftleaves recursively: class node(object): def __init__(self,x): self.val = x self.left = none self.right = none class solution(object): def sumofleftleaves(self,root): if root.val == none: return 0 elif (root.left.left == none , root.left.right == none): return root.left.val + sumofleftleaves(root.right) else: return sumofleftleaves(root.left)+sumofleftleaves(root.right) but gives error "nameerror: global name 'sumofleftleaves' not defined", think it's defined recursively, what's wrong? sumofleftleaves still method on class , not globally defined function. can access bound method on self , you'd access other method: self.sumofleftleaves(...) you sh

php - Invalid argument supplied for foreach() in web service API -

i'm using php code call json api, i'm having issues loading. php code $response[$i]['id']=$datafriend[$i]['id']; $response[$i]['name']=$datafriend[$i]['name']; $response[$i]['id']=$id; $response[$i]['lastmsgfrom']=$msg_from; $response[$i]['lastmsgtype']=$type; $response[$i]['lastmsg']=$msg; $response[$i]['lastmsgtime']=$time; $response[$i]['lastseen']=$datafriend[$i]['date']; $response[$i]['status']=$datafriend[$i]['status']; } } foreach ($response $key => $row) { $volume[$key] = $row['lastmsgtime']; } array_multisort($volume, sort_desc, $response); array_unshift($response, $userdata); error log php warning: invalid argument supplied foreach() php

c# - Getting The connection does not support MultipleActiveResultSets when using Dapper.SimpleCRUD in a forEach -

i have following code: var test = new fallenvironmentalcondition[] { new fallenvironmentalcondition {id=40,fallid=3,environmentalconditionid=1}, new fallenvironmentalcondition {id=41,fallid=3,environmentalconditionid=2}, new fallenvironmentalcondition {id=42,fallid=3,environmentalconditionid=3} }; test.tolist().foreach(async x => await conn.updateasync(x)); i getting invalidoperationexception: connection not support multipleactiveresultsets i don't understand await ing each update why getting error. note: have no control on connection string can't turn mars on. that code starts task each item in list, not wait each task complete before starting next one. inside each task waits update complete. try enumerable.range(1, 10).tolist().foreach(async => await task.delay(1000).continuewith(t => console.writeline(datetime.now))); which equivalent foreach (var in enumerable.range(1, 10).tolist() ) { var task = task

json - 765: unexpected token at 'Mailgun Magnificent API' (Ruby on Rails, mailgun_rails) -

i've been trying set mailgun api rails app (in development) , i'm using mailgun_rails gem, when trying send message action controller gives me error: json::parsererror in userscontroller#create 765: unexpected token @ 'mailgun magnificent api' the extracted source follows: @user = user.create(user_params) if @user.save usermailer.account_activation(@user).deliver_now flash[:info] = "please check email activate account." redirect_to root_url my development.rb has following lines concerning action mailer: config.action_mailer.raise_delivery_errors = true config.action_mailer.delivery_method = :mailgun config.action_mailer.default_url_options = { :host => 'localhost:3000' } config.action_mailer.perform_deliveries = true config.action_mailer.mailgun_settings = { api_key: env['mailgun_api_key'], domain: env['mailgun_domain'] } config.action_mailer.perform_caching = false the environments in .rbenv-vars file

wpf - c# Bluetooth LE - write configuration error - ValueChanged never called -

so try connect c# wpf program ble device , code connect device: private async task connecttowatcher(deviceinformation deviceinfo) { try { // device bluetoothledevice device = await bluetoothledevice.fromidasync(deviceinfo.id); // gatt service thread.sleep(150); var gattservicesresult = await device.getgattservicesforuuidasync(new guid(rx_service_uuid)); service = gattservicesresult.services[0]; // gatt characteristic thread.sleep(150); var gattcharacteristicsresult = await service.getcharacteristicsforuuidasync(new guid(rx_char_uuid)); characteristic = gattcharacteristicsresult.characteristics[0]; // register notifications thread.sleep(150); characteristic.valuechanged += (sender, args) => { debug.writeline($"[{device.name}] received notification containing {args.characteristicvalue.length}

asp.net - GridView OnRowUpdating Event not firing on pop-up form -

Image
i'm having trouble calling onrowupdating event on gridview. gridview has auto-generated edit button working event handler. i've been looking @ other related questions , cannot seem find solution. the common, popular issue i've come across attempting bind grid on postback during page_load. attempted follow general advice , bind grid when !ispostback, page always in postback-mode leads me believe has default pop-up state. the form gridview dialog-window (pop-up?) , think has postback behavior , why updating event not firing: gridview definition: <saleslogix:slxgridview runat="server" id="oppprodgrdview" gridlines="none" allowpaging="false" selectedrowstyle lightcyan="backcolor" autogeneratecolumns="false" autogenerateeditbutton="true" autogeneratedeletebutton="true" onrowupdating="grdoppproducts_rowupdating" onrowupdated="grdoppproducts_rowupdate

autohotkey - ahk error else with no matching if, what's wrong? -

hi autohotkey script seems wrong , checked brackets , think okay, keep getting error else no matching if, there missed? loot1() { imagesearch,violetx, violety, 266, 141, 579, 527, c:\image\loot.png if errorlevel { mobs1() } else if errorlevel=0 { mousemove(%violetx%,%violety%) mouseclick, left return } else { sleep, 100 return } } you should use if , because there no previous if match else if . example: if (condition1) { // executed if "condition1" equals true } else if (condition2) { // executed if "condition1" false , "condition2" equals true } else { // executed if both "condition1" , "condition3" equals false } edit, perhaps right answer: loot1() { imagesearch,violetx, violety, 266, 141, 579, 527, c:\image\loot.png if errorlevel { mobs1() } else if errorlevel=0 {

mysql - Dynamically connect to different DB if one fails in Flask-SQLAlchemy -

i want find way can dynamically connected secondary db if primary db timed out. i've reserarched extensively , found solutions uses sqlalchemy not flask-sqlalchemy. recommended solution below. engine1 = create_engine(...) engine2 = create_engine(...) session1 = sessionmaker(bind=engine1) session2 = sessionmaker(bind=engine2) session1 = scoped_session(session1, scopefunc=...) session2 = scoped_session(session2, scopefunc=...) and want build fail safe below.. synthax in psuedo code. if not request_has_connection: db = sqlalchemy(app) # instantiate db different config has different db uri. the problem that, flask-sqlalchemy not allow users separately instantiate engine, db used every model instantiated 1 line db=sqlalchemy(app) how can dynamically change uri of database secondary if primary has timedout or if lost connection? thanks maybe application factories (here) ? if bind app instance db using lazy method can load different configuration object / file

hibernate - Received object of type org.postgresql.util.PGobject -

i can insert geometry data database code, can query data using sql editor, pgadmin iii. can't retrieve geometry data code. every attempt ends with: "received object of type org.postgresql.util.pgobject". running simple query test if 2 geometry values equal, error. 2017-09-11 19:04:47,771 warning [javax.enterprise.resource.webcontainer.jsf.lifecycle] (default task-37) /welcomeprimefaces.xhtml @46,106 actionlistener="#{controlador.testar()}": java.lang.illegalstateexception: received object of type org.postgresql.util.pgobject: javax.el.elexception: /welcomeprimefaces.xhtml @46,106 actionlistener="#{controlador.testar()}": java.lang.illegalstateexception: received object of type org.postgresql.util.pgobject @ com.sun.faces.facelets.el.tagmethodexpression.invoke(tagmethodexpression.java:111) @ javax.faces.event.methodexpressionactionlistener.processaction(methodexpressionactionlistener.java:147) @ javax.faces.event.actionevent.processlis

javascript - Chart.js : Controller for Scatter chart doesn't work for draw function -

following link extend scatter type draw() function print "no data found" in center y axis scale. here's code: chart.defaults.derivedscatter = chart.defaults.scatter; var ctx = canvas.getcontext("2d"); var custom = chart.controllers.scatter.extend({ draw: function() { chart.controllers.scatter.prototype.draw.call(this); this.chart.chart.ctx.textalign = "center"; this.chart.chart.ctx.font = "11px arial"; this.chart.chart.ctx.filltext("no data found", 45, 100); } }); chart.controllers.derivedscatter = custom; chart = new chart(ctx, { type: "derivedscatter", options: { scales: { yaxes: [{ ticks: { beginatzero:true, max:0.10, stepsize:0.001, callback: function(label, index, labels) { var n = parsefloat(label);

Using Jinja2 contextfunction like django inclusion tag -

i trying add contextfunction rendering menu html, jinja2 environment globals. i have written: @contextfunction def main_menu(context, parent, calling_page=none): menuitems = parent.get_children().live().in_menu() menuitem in menuitems: menuitem.show_dropdown = has_menu_children(menuitem) # don't directly check if calling_page none since template # engine can pass empty string calling_page # if variable passed calling_page not exist. menuitem.active = (calling_page.path.startswith(menuitem.path) if calling_page else false) return render ( context['request'], 'personal_web/tags/main_menu.html', { 'calling_page': calling_page, 'menuitems': menuitems, }) but when use {{ main_menu( parent=site_root, calling_page=self) }} in template , call function renders '' what doing wrong?

python - Pandas pd.read_csv - has anything changed? -

i have piece of code wrote jupyter ~1 year ago used dg = pd.read_csv(f10,sep=';') to read data a;w 83;88,0 64;70,1 94;94,2 today get: oserror: initializing file failed and somewhere inbetween: c:\anaconda3\lib\site-packages\pandas\io\parsers.py in _make_engine(self, engine) 964 def _make_engine(self, engine='c'): 965 if engine == 'c': --> 966 self._engine = cparserwrapper(self.f, **self.options) 967 else: 968 if engine == 'python': this, however, works today: with open(f10, newline='') csvfile: data = csv.reader(csvfile, delimiter=';') since prefere pandas-way, has idea should change ? tx hints ! edit : i've found out, works too: with open(f10, newline='') csvfile: dg = pd.read_csv(csvfile, delimiter=';') but necessary ? i guess problem comes newline expected \n pandas . you can pass buffer directly pd.r

forms - access calculated field misbehave -

i have strange issue ms access 2010, problem invoice form includes subform datasheet holds items bought, , in footer sums price of items sum() function ! in invoice form have 3 text boxes, 1 invoice cost sum of elements costs in invoice, other discount user input, , third net cost total cost minus discount the strange behavior comes when change example number of bought items of element @ top of invoice while bottom of not visible on screen, net becomes 0! however, if changed same element while bottom of invoice visible net calculated correctly ! any way in order figure out, uploaded small video showing problem https://drive.google.com/open?id=0byhmj2iqibv0z3vmuvj5lvqymfe any ideas?

Custom authorizer context variable in API Gateway HTTP integration URL -

Image
i use api gateway http integration towards endpoint, parts of url provided custom authorizer (e.g., user id or user grants). i use lambda integration introduces quite significant response time overhead. unfortunately syntax works stagevariables not seem work custom authorizer context - ${context.authorizer.variablename} . note: answer comments, yes, warning sign there bacause used dummy url string. has nothing fact replacement of authorizer context variables not work me, no matter url is. the url needs valid, meaning https://example.com/foo protocol , hostname. starting url/ never going valid.

r - Assign value to row if row and previous row meet requirement -

these events , x , y coordinates of each event. looking assign value of "1" event if event = 0 < x < 4 & 0 < y < 4 , previous event = x > 4 & y > 4, , assign value of "0" if criteria not met. here initial table: event locx locy 1 6 6 2 3 2 3 3 7 4 1 4 5 7 4 6 1 2 7 8 5 8 1 1 my final table like: event locx locy value 1 6 6 0 2 3 2 1 3 3 7 0 4 1 4 0 5 7 4 0 6 1 2 1 7 8 5 0 8 1 1 1 any appreciated! another data.table approach. translation of neilfws's dplyr approach while using shift function compare values previous one. library(data.table) setdt(dt)[ ,value := ifelse(locx < 4 & locy <

vst - How to send blocks of audio to be processed by synthesizer -- without discontinuities -

Image
i using juce framework build vst/au audio plugin. audio plugin accepts midi, , renders midi audio samples — sending midi messages processed fluidsynth (a soundfont synthesizer). this working. midi messages sent fluidsynth correctly. indeed, if audio plugin tells fluidsynth render midi messages directly audio driver — using sine wave soundfont — achieve perfect result: but shouldn't ask fluidsynth render directly audio driver. because vst host won't receive audio. to properly: need implement renderer . vst host ask me (44100÷512) times per second render 512 samples of audio. i tried rendering blocks of audio samples on-demand, , outputting vst host's audio buffer, kind of waveform got: here's same file, markers every 512 samples (i.e. every block of audio): so, i'm doing wrong. not getting continuous waveform. discontinuities visible between each blocks of audio process. here's important part of code: implementation of juce's sy

Rails - Can't get only a few of the attributes for all objects in an array? -

i have service puts array of answer objects, each containing string answer text, boolean indicating whether it's correct answer or not , it's id. code far: @quiz.questions[current_question_index].answers it works. take array of answer objects , send on actioncable channel displayed buttons - works. but i'm thinking better not send entire answer objects (including information of answers correct), id , title tried change code according this post : @quiz.questions[current_question_index].answers.pluck(:id, :title) this not work me - buttons read "undefined". tried way according this post : @quiz.questions[current_question_index].answers.attributes.slice('id', 'title') now buttons don't displayed anymore... what want array of objects contain attributes 'id' , 'title' retrieved answers . can give me pointers fix this? i'm rails beginner , appreciate help. as said answers array, , pluck method no

Dependency injection w/ smart pointers in C++ -

i'm trying implement dependency injection pattern in c++ project, performing injection manually (no framework). i'm using factory function manually create dependencies , pass them classes use them. problem when root of dependency graph (itself class instance managed smart pointer) goes out of scope, dependencies (smart pointers referenced within class) don't destroyed (valgrind shows lost blocks of memory). i'm seeing basic example this, class depends on class b: class b{ public: b() {} ~b() {} }; class a{ std::unique_ptr<b> b_; public: a(std::unique_ptr<b> b) : b_(std::move(b)) { } ~a(){} }; namespace a_factory { std::unique_ptr<a> getinstance(){ return std::make_unique<a>(std::make_unique<b>()); } } int main(void){ auto = a_factory::getinstance(); //do stuff } //a goes out of scope , gets deleted? so in example use a_factory::getinstance a, whatever using doesn't know how cr

pandas - Python Data Frame Time Delta -

i stuck on problem , figured time ask help/advice. have data frame has column named created_on consists of datetime. goal figure out how time in seconds has passed since previous row. i have run code below reason, seconds giving me way off. code below outputs data frame additional column named timediff consisting of difference in seconds if any. created_on 1. 2014-12-08 03:29:08 2. 2014-12-08 03:29:08 3. 2015-02-09 00:10:01 output time_diff 1. 0.0 2. 0.0 3. 74453.0 code: golden['timediff'] = golden.created_on.diff().dt.seconds iiuc looking series.dt.total_seconds() : in [45]: golden['timediff'] = golden.created_on.diff().dt.total_seconds() in [46]: golden out[46]: created_on timediff 0 2014-12-08 03:29:08 nan 1 2014-12-08 03:29:08 0.0 2 2015-02-09 00:10:01 5431253.0

reactjs - How to enable proxy in react-slingshot (by coryhouse) so I can call my Django REST APIs? -

i have django development server running on port 8050 several rest apis serve react app, composed react-slingshot , running on localhost:3002. what want javascript code, such fetch('api/v1/employees') , call localhost:8050 instead of localhost:3002. i see raythree in github discussion able find solution question, however, unable solution work. implemented advice has it, code acts if made no changes @ all. here code in tools/srcserver.js looks right now: // file configures development web server // supports hot reloading , synchronized testing. // require browsersync along webpack , middleware import browsersync 'browser-sync'; // required react-router browserhistory // see https://github.com/browsersync/browser-sync/issues/204#issuecomment-102623643 import historyapifallback 'connect-history-api-fallback'; import webpack 'webpack'; import webpackdevmiddleware 'webpack-dev-middleware'; import webpackhotmiddleware 'webpack-hot-mi

javascript - Counting transitions (rising edges) of boolean metric in Druid query -

i'm getting feet wet nosql queries , druid , came across interesting query case i'm not sure how solve. how write druid timeseries query count rising-edge transitions granularity of 1 second? two issues i'm aware of: aggregations stateless. have input of current floating point aggregation value, , can return updated floating point aggregation value. see "javascript aggregator" in druid aggregation docs queries aware of current segment , must have separate aggregations formula on different segments. see "sharding-the-data" in druid docs . simplified data looks like: seconds metric 0.0 0 0.3 1 0.6 1 1.0 1 1.3 1 1.6 0 2.0 1 2.3 0 2.6 1 3.0 0 3.3 0 desired output: seconds rising-edge-count 0.0 1 1.0 0 2.0 2 3.0 0 here's best shot using floating point's negativity store previous-value's state, it's super hacky , doesn't seem give desired r

python 3.x - Image from pyqt GUI does not appear in my executable -

i have gui created using pyqt , when trying make executable using cx_freeze images not appear. have try include_files command, else can do? in python program, call images in next way (used pushbuttons , labels): self.pushbutton_3.setstylesheet('border-image: url("image.jpg")') my setup.py follow: import sys cx_freeze import setup, executable setup(name ='tt2_cdv', options ={'build_exe': {'include_files':['image.jpg']}}, executables = [executable ("tt2_prueba.py")])

javascript - JQuery overlay image onclick without preloading -

i have basic image gallery shows thumbnails prev / next links, , when thumbnail clicked opens full size image: // slider catalog images var images = $("#slider img"); var prevbtn = $("#prev"); var nextbtn = $("#next"); var total = images.length; var last = total - 1; var first = 0; var current = first; function showimage(index) { index = (index > last) ? last : index; index = (index < first) ? first : index; images.hide(); images.eq(index).show(); if (total == 1) { prevbtn.addclass('disabled'); nextbtn.addclass('disabled'); } else if (index <= first) { prevbtn.addclass('disabled'); if (index == first && nextbtn.hasclass('disabled')) { nextbtn.removeclass('disabled'); } } else if (index >= last) { nextbtn.addclass('disabled'); if (index == last && prevbtn.hasclass('disabled')) { prevbtn

how to add an external repository to svn, and commit changes of the external to current repository, not to external repository -

how add external repository svn , , commit changes of external current repository, not commit external. current repository: external repository: b make changes of b, , commit changes of b a. i know svn:external can make reference external repository, changes of external committed external repository when committed current repository. in work, there many repositories, each of them has copy base repository repository. make management of repository hard.

java - JVM has incorrect timezone after installation of jdk 8 -

i have tomcat service on centos server, , time sensitive service. jvm has gotten timezone correctly until installed jdk 8 yesterday. to fix have add "-duser.timezone=gmt+8" after java command, feel inconvenient. i use date command on server , gives correct timezone. curious: 1. cause problem 2. , how solve neatly? thank in advance. here comes test info: [chiming1@localhost test]$ date +'%y%m%d %h:%m:%s %z' 20170920 15:01:20 +0800 [chiming1@localhost test]$ java -duser.timezone=gmt+08 javatest/test 2017-09-20 15:01:34 gmt+08:00 gmt+08:00 [chiming1@localhost test]$ java javatest/test 2017-09-20 07:01:48 greenwich mean time gmt [chiming1@localhost test]$ java -version java version "1.8.0_144" java(tm) se runtime environment (build 1.8.0_144-b01) java hotspot(tm) 64-bit server vm (build 25.144-b01, mixed mode) and java test code is: simpledateformat sdf = new simpledateformat("yyyy-mm-dd hh:mm:ss"); d

python - Django models.DateTimeField django.db.utils.IntegrityError: NOT NULL constraint failed -

what problem? have googled , have not found thing gets close have. saving profile continue next page produces error. i working on development server using sqlite. thank you. models.py class schoolprofile(models.model): create_date = models.datetimefield( null=false, blank=false, **auto_now_add=true,** verbose_name=u'fecha de creación') modification_date = models.datetimefield( null=false, blank=false, **auto_now=true,** verbose_name=u'fecha de última modificación') cycle = models.charfield( null=false, blank=false, max_length=9, verbose_name='ciclo escolar') name = models.charfield( null=false, blank=false, max_length=100, verbose_name='nombre de la escuela') def __unicode__(self): return '{} {}'.format(self.cycle, self.name) class meta: db_table = 'perfil escolar' ordering = ['id', 'name']

python - Docker connection refused on all ports except 5000 -

i have started docker. have installed docker toolbox windows. trying out sample flask app understand how things work. stuck!. trying access app http://docker-machine-ip : port number every time do, '{docker-machine ip} refused connect.' i no exceptions during building , deploying stages. did docker ps see container running. tried access via kitematic still no luck. below details related app app.py from flask import flask app = flask(__name__) @app.route("/") def hello(): return "flask inside docker shakel!!" if __name__ == "__main__": app.run(debug=true,host='0.0.0.0') requirements.txt flask dockerfile from python:2.7 maintainer shekhar gulati "shekhargulati84@gmail.com" copy . /app workdir /app run pip install -r requirements.txt entrypoint ["python"] cmd ["app.py"] the docker commands used building , running are: docker-machine ip default //to docker machine ip docker build

javascript - what does these expression mean ? `${server Path}/**/!(*.spec|*.integration).js` -

`${server path}/**/!(*.spec|*.integration).js`, may ask above code, ** , * , | , * stand ? can search read ? that looks glob syntax me: https://www.npmjs.com/package/glob https://en.wikipedia.org/wiki/glob_(programming) * matches apart slashes, match file won't match subfolders. ** matches including slashes, subfolders can searched. | or. ! means not.