Posts

Showing posts from April, 2010

php - Why does Instagram's pagination return the same page over and over? -

the code i've created php class communicate instagram's api. using private function called api_request (shown below) communicate instagram's api: private function api_request( $request = null ) { if ( is_null( $request ) ) { $request = $this->request["httprequest"]; } $body = wp_remote_retrieve_body( wp_remote_get( $request, array( "timeout" => 10, "content-type" => "application/json" ) ) ); try { $response = json_decode( $body, true ); $this->data["pagination"] = $response["pagination"]["next_url"]; $this->data["response"] = $response["data"]; $this->setup_data( $this->data ); } catch ( exception $ex ) { $this->data = null; } } these 2 lines of code... $this->data["pagination"] = $response["pagination...

django-autocomplete-light django 1.8 custom modelform for admin -

i want add autocomplete onetoone field django-admin class banner(models.model): product = models.onetoonefield(product, null=true) class banneradmin(admin.modeladmin): form = bannerform stucked on https://django-autocomplete-light.readthedocs.org/en/stable-2.x.x/tutorial.html?highlight=tutorial#tutorial - anything changed after following steps (same list widget 'product' ...): what have done: installed :d added 'autocomplete_light', installed_apps overrided admin/base_site.html (using custom loader) url(r'^autocomplete/', include('autocomplete_light.urls')), urlpatterns autocomplete_light_registry.py model banner , search_fields=['product'], updated modelform: class bannerform(autocomplete_light.modelform): class meta: model = banner fields = ['product', 'priority', 'image'] autocomplete_fields = ['product'] what i've missed? following re...

apache spark - SparkMLlib MultiClassMetrics.confusionMatrix() and precision() seems giving contradictory results -

hi new machine learning , spark mllib. have created randomforest classifier model using randomforest.trainclassifier() training data set categorical in nature , have response/target variables actionable/noactionable. have created predictionandlables rdd using test data , model.predict() trying following validate model accuracy. multiclassmetrics metrics = new multiclassmetrics(predictionandlables.rdd()) system.out.println(metrics.precision()); //prints 0.94334140435 system.out.println(metrics.confusionmatrix()); //prints following 1948.0 0.0 117.0 0.0 now if see model accuracy printed using precision() method seems around 94% if see above confusion matrix seems wrong have 1948 nonactionable target variables , 117 actionable target variable in test data set. according confusion matrix predict nonactionable correctly , not predict @ actionable variables. please me understanding confusion matrix , why precision 94% . results contradicting. please guide in advance...

Multidimensional array calculations in PHP -

i have 2 arrays: array ( [0] => stdclass object ( [id] => 1 [values] => array ( [0] => stdclass object ( [id] => 2 [field_value] => green [ordering] => 0 [count] => 0 ) [1] => stdclass object ( [id] => 1 [field_value] => red [ordering] => 1 [count] => 0 ) ... ) ) [1] => stdclass object ( [id] => 2 [values] => array ( [0] => stdclass object ( [id] => 2 ...

c++ - Singleton class and thread safety -

class numberstorage { public: static numberstorage& instance(); double getnumber(); void setnumber(double d); private: numberstorage() { number = 0.0; }; double number; }; colorramps& colorramps::instance() { static colorramps instance; return instance; } i think have read somewhere instance() method implemented way thread safe. correct? guess must lock member variable number in getnumber() , setnumber()? how do (c++11)? c++11 compiler makes thread safe. static variables can created 1 single thread. other questions locks both depend on how threads should work methods. if have multiple threads can 1 same piece of memory - use locks. simple lock can used std::unique_lock , std::mutex : void setnumber(double number) { static std::mutex _setnumberlock; std::unique_lock _lock(&_setnumberlock); // code }

jquery - Bootstrap modal and multiple vimeo videos -

i have page has multiple videos embedded. each link opens video in bootstraps modal. problem have if close modal video still playing. i found script force stop next issue page has multiple videos. have tried capture id of each video variable when clicked. independently 2 scripts have work, bit missing them combined? html <ul> <li><a class="video" href="#" data-toggle="modal" data-target="#video1">video 1</a></li> <li><a class="video" href="#" data-toggle="modal" data-target="#video2">video 2</a></li> <li><a class="video" href="#" data-toggle="modal" data-target="#video3">video 3</a></li> <li><a class="video" href="#" data-toggle="modal" data-target="#video4">video 4</a></li> </ul> this jquery ...

javascript - How to call the function, if the count reaches the limit -

i using google maps , placing map markers using array locations , want call function clearmarkers() if i==26 how can this? code: var markers = []; var map; var india = new google.maps.latlng(21.9200,77.9000); var image = 'images/pushpins/set1.png'; function initialize() { var mapoptions = { zoom: 5, center: india }; map = new google.maps.map(document.getelementbyid('map-canvas'), mapoptions); drop(); } function drop() { clearmarkers(); (var = 0; < locations.length; i++) { var city = locations[i][0]; var pro_cat = locations[i][1]; addmarkerwithtimeout(locations[i][2], * 500); getcity(city,pro_cat, * 500); } if (i==26){ clearmarkers(); } } function addmarkerwithtimeout(position, timeout) { window.settimeout(function() { markers.push(new google.maps.marker({ position: position, map: map, icon: image, optimized: false, //animation: google.maps.animation.bounce })...

Requirements eclipse update site -

Image
i'd know how add th required plugins eclipse update site. in other words, i've packed plugins in feature project, , i've created update site. when try install plugin machine, got this: cannot complete install because 1 or more required items not found. software being installed: x-man tool 2.0.0 (xman.eclipse.feature.feature.group 2.0.0) missing requirement: x-man tool 2.0.0 (xman.eclipse.feature.feature.group 2.0.0) requires 'org.eclipselabs.spray.runtime.graphiti 0.5.1' not found where should add depencies? i'd highlitght fact plugin org.eclipselabs.spray.runtime.graphiti 0.5.1 alredy listed in dpeencies list (see picture). many attention simone

NSIS MessageBox jump offset -

i'm not able understand what's wrong below code jumping particular offset if messagebox returns idno. below code quit installer while idno selected, jumping goto endcurrentblock line messagebox mb_yesno|mb_iconexclamation "would continue installation?" idno +3 !insertmacro showstatus "failed install software" goto endcurrentblock quit if use absoule label jump it's working good. reason? jumping offset skips x number of nsis instructions !insertmacro preprocessor instruction might expand zero, 1 or several nsis instructions. it not recommended combine offset jumps , !insertmacro because can break code changing macro...

What does Swift 2.0 being released to linux mean for developing iOS apps? -

https://developer.apple.com/swift/blog/?id=29 does mean should able develop ios / osx apps on linux? yes, no or maybe? does mean should able develop ios / osx apps on linux. no , not mean able develop ios or os x applications using linux. compiler 1 of tools required produce application given platform.

javascript - Node js - How to correctly use make async network calls within a module -

so part of project working on have created module uses facebook graph api make calls , return json data. can console.log() data within method out fine , it's good. but can not return values methods, tried use 'async' npm module. have followed examples on website, still struggling working, spent day on far , still things arn't looking clearer. so asking is: firstly need call method sets authentication_token fbgraph api before can else then need call each of functions (in order) , json result each , add 1 big json result finally need 1 big json result origional javascript page (even though it's in module), how invoke it? here snippit of original module (only works console.log, can't return) module.exports = { /** * pass access token fbgraph module * , call other methods populate */ setup: function (access_token) { graph.setaccesstoken(access_token); }, /** * fetch...

microsoft access report export to excel -

i have table following structure: maincat subcat name description main cat 1 sub cat 1 name 1 description 1 main cat 1 sub cat 1 name 2 description 2 main cat 1 sub cat 2 name 3 description 3 main cat 1 sub cat 2 name 4 description 4 main cat 2 sub cat 3 name 5 description 5 main cat 2 sub cat 3 name 6 description 6 i have created report works fine use "group on" @ column maincat , subcat. have possibility export contend excel, , should structured this: main cat 1 sub cat 1 name 1 description 1 name 2 description 2 sub cat 2 name 3 description 3 name 4 description 4 main cat 2 sub cat 3 name 5 description 5 name 6 description 6 any idea how create report or else there can in ms access? maybe missed reporting desired structure shouldn't big problem. put name , description on detail-layer , configure 2 grouping-layers mentioned in post. exporting reports access excel little tricky. although build-in-f...

c++ - How can I have a multi-line item in a ListControl MFC? -

Image
i have mfc list control in visual studio 2013 (c++) list of items (report view) lvcolumn lvcolumn; lvcolumn.mask = lvcf_fmt | lvcf_text | lvcf_width; lvcolumn.fmt = lvcfmt_left; lvcolumn.cx = 120; lvcolumn.psztext = "full name"; ((clistctrl*)getdlgitem(idc_list1))->insertcolumn(0, &lvcolumn); lvcolumn.mask = lvcf_fmt | lvcf_text | lvcf_width; lvcolumn.fmt = lvcfmt_left; lvcolumn.cx = 75; lvcolumn.psztext = "profession"; ((clistctrl*)getdlgitem(idc_list1))->insertcolumn(1, &lvcolumn); lvcolumn.mask = lvcf_fmt | lvcf_text | lvcf_width; lvcolumn.fmt = lvcfmt_left; lvcolumn.cx = 80; lvcolumn.psztext = "fav sport"; ((clistctrl*)getdlgitem(idc_list1))->insertcolumn(2, &lvcolumn); lvcolumn.mask = lvcf_fmt | lvcf_text | lvcf_width; lvcolumn.fmt = lvcfmt_left; lvcolumn.cx = 75; lvco...

android scroll and see details like whatsup -

Image
place icon down arrow user can know there details shown below in android. after scrolled page end, scroll arrow gone. scrollview1.getviewtreeobserver().addonscrollchangedlistener(new onscrollchangedlistener() { public void onscrollchanged() { int scrollviewheight = scrollview1.getchildat(0).getheight(); log.e("scrollview_height", "scroll" + scrollviewheight); double size = 0; displaymetrics dm = mcontext.getresources().getdisplaymetrics(); float screenwidth = dm.widthpixels / dm.xdpi; float screenheight = dm.heightpixels / dm.ydpi; float = dm.heightpixels; log.e("height in i", "" + i); double heightininch = math.sqrt(math.pow(screenheight, 2)); log.e("height in inch", "" + heightininch); size = math.sqrt(math.pow(screenwidth, 2) + math.pow(screenheight, 2)); ...

multithreading - Java 8 parallelStream for concurrent Database / REST call -

here using javaparallel stream iterate through list , calling rest call each list element input. need add results of rest call collection using arraylist . code given below working fine except non-thread-safety of arraylist cause incorrect results, , adding needed synchronization cause contention, undermining benefit of parallelism. can please suggest me proper way of using parallel stream case. public void mymethod() { list<list<string>> partitions = getinputdata(); final list<string> allresult = new arraylist<string>(); partitions.parallelstream().foreach(serverlist -> callrestapi(serverlist, allresult); } private void callrestapi(list<string> serverlist, list<string> allresult) { list<string> result = //do rest call. allresult.addall(result); } you can operation map instead of foreach - guarantee thread safety (and cleaner functional programming perspective): list<string> allresult = partiti...

sql - Convert date into varchar with sas -

i hope can assist. when run code: libname odbc ### user='abc' password='****' dsn='bleh' schema='dbo'; %let date=%sysfunc(intnx(day,%sysfunc(today()),-1,b),yymmddd10.); %put &date.; run; it works! but if run call execute error – reads sql – yet date in sql varchar: data _null_; set odbc.sqltablename; if ((date= &date.) , (datecomplete ne .))then call execute("%include 'path';"); run; datecomplete=jun 10 2015 1:54pm _error_=1 _n_=1 i looking way convert date. so reads today()-1 (technically yesterday’s date) your appreciated!!! shouldn't using single quotes instead of double quotes? don't want macro executed before data step ends? call execute("%include 'path';"); try: call execute('%include "path";');

html - linear-gradient background with color issue -

i have textbox linear gradient background text color not appearing 100% white. some kind of opacity working behind text have not declared opacity anywhere. css code: input[type="search"] { color: #ffffff; height: 35px; margin: 0; padding: 10px; border: none; box-shadow: none; background: rgba(0, 0, 0, 0) linear-gradient(0deg, #820462 0%, #992478 100%); font-size:1rem; } input[type="search"]:focus { background: transparent; } here demo . any highly appreciated. in advance. your color:white ; affect text typed input field... search text placeholder - need target placeholder , add color - described here in more detail . here code. input[type="search"] { color: white; height: 35px; margin: 0; padding: 10px; border: none; box-shadow: none; background: rgba(0, 0, 0, 0) linear-gradient(0deg, #820462 0%, #992478 100%); font-size: 1rem; } input[type="search"]:...

android - Default "beep beep" alarm ringtone -

is there default, safe use, "beep beep"-styled ringtone on andrid phones? i have following code final ringtone alarm = ringtonemanager.getringtone(getactivity(), ringtonemanager.getdefaulturi(ringtonemanager.type_alarm)); alarm.setstreamtype(audiomanager.stream_alarm); alarm.play(); it plays alarm ringtone wakes me @ morning, soothing music. need more alarming . sure, can pack sound file apk, i'd prefer use sounds available on devices. check answer here: how access android's default beep sound? try { uri notification = ringtonemanager.getdefaulturi(ringtonemanager.type_notification); ringtone r = ringtonemanager.getringtone(getapplicationcontext(), notification); r.play(); } catch (exception e) { e.printstacktrace(); } here way list notifications sound have in device public map<string, string> getnotifications() { ringtonemanager manager = new ringtonemanager(this); manager.settype(ringtonemanager.type_notif...

php variable $_SERVER['SERVER_ADDR'] is blank when using crontab -

i have small script gets basic information server ip-, , mac-address of server script running on, posting results mysql database, works fine , code shown below. when use cronjob execute script ip address being stored, reason $_server['server_addr'] blank when being executed cronjob. this script runs every min, , run on multi raspberry pi's can tell connected share job requests. $mac_address = getmaclinux(); $server_ip = $config['server_ip']; $client_ip = $_server['server_addr']; $client_name = $config['client_name']; $ch = curl_init(); $url = "{$server_ip}/checkin0.php"; echo "url = {$url}"."<br>"; curl_setopt($ch, curlopt_url,$url); curl_setopt($ch, curlopt_post, true); curl_setopt($ch, curlopt_postfields, "client_ip={$client_ip}&client_name={$client_name}&client_mac={$mac_address}"); curl_setopt($ch, curlopt_returntransfer, true); $output = curl_exec ($ch); // execute...

asp classic - ASP Error 0223 - TypeLib Not Found, intermittent, resolved after IIS restart -

i'm in process of migrating asp platform windows 2003 r2 iis 6 web servers windows 2012 r2 iis 8.5 web servers. i'm @ stage i've migrated number of sites across 2 separate 2012 web servers, looked great, clients , developers happy... following error has presented after few days hosting on 1 of new servers. active server pages error 'asp 0223' typelib not found /jobboard/conf/constants.vbs.inc, line 1 metadata tag contains type library specification not match registry entry. the metadata tag below: <!--metadata type="typelib" name="microsoft activex data objects 2.8 library" uuid="{2a75196c-d9eb-4129-b803-931327f72d5c}" version="2.8"--> restarting iis on server resolved issue (albeit temporarily). subsequently other 2012 web server in production presented same error couple of days later, again, restarted iis , works now. i've checked registry , relevant tag exists right uuid , correct permissions. ...

capistrano3 - How to ignore files with Capistrano 3 without copy_exlude -

in capistrano 2 possible exclude files live in git repository copy_exclude: set :copy_exclude, %w{.git .ds_store web concept config lib} this isn't possible anymore in capistrano 3. how can exclude files want in git repository not on server? the way achieve add .gitattributes root of repo. works similar .gitignore . add paths files want in repository not on staging / production server followed export-ignore , commit+push changes. sample .gitattributes file: # folders /config export-ignore /lib export-ignore # files license.txt export-ignore readme.html export-ignore then deploy usual. more info here

linux - lpsolve library dynamically linking -

the lpsolve library has script build demo.c file. #this script expects located in subdirectory of subdirectory of base lpsolve files cc -dexplicit -i../.. -o3 demo.c explicit.c -lm -ldl -o demoe ../../lpsolve55/liblpsolve55.so opts='-o3' opts='' cc -i../.. $opts demo.c implicit.c -lm -ldl -o demoi ../../lpsolve55/liblpsolve55.a the name of file ccc , content displayed above. terminal how call script? you should call script using sh ccc this information contained in file demo/readme.txt : to build program under linux/unix, use sh ccc

PHP Comment Tag -

in wonderful world of java/jsp, can use form of commenting: <%-- in here ignored , not sent client can span multiple lines , useful commenting out blocks of jsp, including tags , html: <c:if test="${some.condition}"> <p>all inside comment</p> </c:if> <!-- html comment commented out of jsp not sent client --!> --%> <!-- html comment , sent client --> in in less wonderful world of php, reference comments can find these: /* multi-line comment */ and these: // single line comment but these won't comment out chucks of html , php tags: /* <? do_something() ?> */ results in /* , */ being rendered browser, , do_something() still called. is there equivalent of jsp comment shown above in php? the reason not comment out block: /* <? do_something() ?> */ is not in php in html , /* */ not valid comment structure in html. if had <?php /* some_php(); ?...

css - Strange SASS output when using extends -

i have following sass files _android.scss: $width: 111px; @import 'child'; .android .child { @extend %child; } _ios.scss: $width: 999px; @import 'child'; .ios .child { @extend %child; } _child.scss: %child { width: $width; } app.scss: @import 'ios'; @import 'android'; now when run sass get: $> sass app.scss .ios .child, .android .child { width: 999px; } .ios .child, .android .child { width: 111px; } not expected, is .ios .child { width: 999px; } .android .child { width: 111px; } what wrong here ? it's because @extends processed first found in sass, selectors in used grouped @ point ( @extends bit greedy) , you're including @extends placeholder twice. let's step through happens: ios.sass loaded, sets $width , includes %child sass encounters placeholder because of includes, looks through code, get's instances of placeholder, groups selectors , uses current val...

c# - Turning Textbox Red with a timer when serial port stops outputting data -

i building gui reads in serial data textbox. if there problem , instrument stops working, want textbox turn red. trying timer, timer read data every 30 seconds, if there no data, timer turn textbox red. however, nothing happens when unplug instrument. how can turn textbox red when instrument stops working? here relevant code: private void timer1_tick(object sender, eventargs e) { datetime timenow = datetime.now; timespan span = gpslastdatatime - timenow; timespan = convert.todouble(span.totalseconds); if (timespan > 30) { textbox1.backcolor = color.red; } } i assume "gpslastdatatime" set whenever data comes in? as is, "timespan" value going negative . switch order of subtraction line: timespan span = timenow - gpslastdatatime; by way, in 1 line this: timespan = (datetime.now - gpslastdatatime).totalseconds;

javascript - How to write big array to .txt file using node.js? -

the obvious solution fs.writefile, assume. but answer of this question suggests should using stream technique. i'm trying code in order remove line text file converting array: var index = randomintfrominterval(1, unfinished_searches.length-1); // remove index unfinished_searches.splice(index, 1); fs.truncate('unfinished_searches.txt', 0, function() { var file = fs.createwritestream('unfinished_searches.txt'); file.on('error', function(err) { /* error handling */ }); unfinished_searches.foreach(function(v) { file.write(v.join(', ') + '\n'); }); file.end(); }) which returns following error: typeerror: undefined not function at join in line: unfinished_searches.foreach(function(v) { file.write(v.join(', ') + '\n'); }); if want remove line big text file, consider use pipes . create read stream , pipe "checking function", , pipe write stream . this way don't have load wh...

spring - How to know if my CSRF is working? -

i trying implement csrf using spring , freemarker template. due restrictions of freemarker had add javascript function make work, saw here: http://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#csrf-include-csrf-token so, added code: $(function () { var token = $("meta[name='_csrf']").attr("content"); var header = $("meta[name='_csrf_header']").attr("content"); $(document).ajaxsend(function(e, xhr, options) { xhr.setrequestheader(header, token); }); }); as far see, not adding anything, metatags no content... , ajaxsend cannot 100% sure working, there way know working? i read default csrf enabled. , have correct chain filters (as far check). i using spring 3.2.8 , security 3.2.5 freemarker 2.3.2 is there way verify this? thanks if want check csrf filter preventing malicious requests, use tool firefox-plugin "tamper-data" able manipulate request before send. such t...

python - Figuring out how to web scrape with BeautifulSoup -

i trying scrape data in table "periods" , "percent per annum" (table 4) columns in url : my code follows, think getting confused how refer row above first date , corresponding number , hence error attributeerror: 'nonetype' object has no attribute 'gettext' in line row_name = row.findnext('td.header_units').gettext() . from bs4 import beautifulsoup import urllib2 url = "http://sdw.ecb.europa.eu/browsetable.do?node=qview&series_key=165.yc.b.u2.eur.4f.g_n_a.sv_c_ym.sr_30y" content = urllib2.urlopen(url).read() soup = beautifulsoup(content) desired_table = soup.findall('table')[4] # find columns want data headers1 = desired_table.findall('td.header_units') headers2 = desired_table.findall('td.header') desired_columns = [] th in headers1: #i'm working `headers1` see if have right idea desired_columns.append([headers1.index(th), th.gettext()]) # iterate through each row grabbing data des...

ruby - To obtain random pair from Hash -

part of class keyserver @generated_keys = hash.new def generate_key key = securerandom.urlsafe_base64 while(purged_keys.include?(key)) key = securerandom.urlsafe_base64 end #add new key hashes maintain records @generated_keys.merge!({key => time.now}) @all_keys.merge!(@generated_keys) { |key, v1, v2| v1 } return key end and use generated keys here: (i need random pair selected , allotted user) def get_available_key if(generated_keys.empty?) return "404. no keys available" else new_key = @generated_keys.to_a.sample(1) @generated_keys.delete(new_key[0][0].to_s) @blocked_keys.merge!({new_key[0][0].to_s => time.now}) end end this how use in sinatra api = keyserver.new '/block_key' api.get_available_key end i tried solution mentioned in question when run part of sinatra server obtain internal server error: no implicit conversion array string how make work? other method ...

php - prepared statement not executing but msqli_stmt_execute returning true -

i have insert query below , checking if insert successful using: mysqli_stmt_execute . query not executing values not being entered db. however, getting if condition. cannot understand this. have wrapped stmt_prepare in if condition , returning true tht preparing successfully. did same bind statement , have on final execute statement. return true query not executing. structure of table correct. preformed insert in phpmyadmin , pasted generated query addtoken variable. $con = 'my login credentials' $stmt = mysqli_stmt_init($con); $addtoken = "insert `auth` values ('',?, ?)"; mysqli_stmt_prepare($stmt, $addtoken); mysqli_stmt_bind_param($stmt, "si", $token, $id); if (mysqli_stmt_execute($stmt)){ $message2 = "here"; // worked } else{ //didn't work $message2 = "here 2"; } echo $message2; edit have no idea problem deleted auth table , recreated...

python - Why do numbers in a string become "x0n" when a backslash precedes them? -

i doing few experiments escape backslashes in python 3.4 shell , noticed quite strange. >>> string = "\test\test\1\2\3" >>> string '\test\test\x01\x02\x03' >>> string = "5" >>> string '5' >>> string = "5\6\7" >>> string '5\x06\x07' as can see in above code, defined variable string "\test\test\1\2\3" . however, when entered string in console, instead of printing "\test\test\1\2\3" , printed "\test\test\x01\x02\x03" . why occur, , used for? in python string literals, \ character starts escape sequences. \n translates newline character, \t tab, etc. \xhh hex sequences let produce codepoints hex values instead, \uhhhh produce codepoints 4-digit hex values, , \uhhhhhhhh produce codepoints 8-digit hex values. see string , bytes literals documentation , contains table of possible escape sequences. when python echoes string objec...

php - Why my mysql transaction is not working properly? -

i've been reading , gathering information 2 days , give up. have no clue why piece of simple code not succeeding. i want insert data 1 form 2 tables , yes know there same problems described here , there, said i'm familiar them , need ask more questions. the problem in query somewhere, @ least believe is. here goes: unset($err); //variables $host = 'my.server.com'; $user = '123'; $pass = 'password'; $dbname = '123'; $err = array(); $error_form = false; $img = "sth/sth.jpg"; //connecting database using mysqli application programming interface $con = mysqli_connect($host, $user, $pass, $dbname); if (!validate()) { if (!$con) { echo "connection failed : <br />" . $new_con->connect_errno . "<br />" . $new_con->connect_error; exit; } else { echo "connected! <br />"; } var_dump($name); echo "...

Python Convert None to a Decimal -

how convert none object decimal object in python. code: c['suspended_amount'] = sum([owned_license.charge_amount owned_license in log.owned_licenses.all()]) error: typeerror: unsupported operand type(s) +: 'decimal.decimal' , 'nonetype' just skip values: c['suspended_amount'] = sum(owned_license.charge_amount owned_license in log.owned_licenses.all() if owned_license.charge_amount) i removed [..] square brackets; sum() takes iterable, supplied using generator expression . square brackets list comprehension instead, needlessly build full list of values first. sum needs values 1 one, don't need exist @ once front. better yet, ask database include rows charge_amount not null : c['suspended_amount'] = sum( owned_license.charge_amount owned_license in log.owned_licenses.exclude(charge_amount__isnull=true).all()) best still, ask database summing you:...

How can I add custom XML tags in a BPMN file? -

in bpmn file there 2 main components, process , diagram. <?xml version="1.0" encoding="utf-8"?> <definitions id="definition" targetnamespace="http://www.example.org/minimalexample" typelanguage="http://www.java.com/javatypes" expressionlanguage="http://www.mvel.org/2.0" xmlns="http://www.omg.org/spec/bpmn/20100524/model" xmlns:xs="http://www.w3.org/2001/xmlschema-instance" xs:schemalocation="http://www.omg.org/spec/bpmn/20100524/model bpmn20.xsd" xmlns:bpmndi="http://www.omg.org/spec/bpmn/20100524/di" xmlns:dc="http://www.omg.org/spec/dd/20100524/dc" xmlns:di="http://www.omg.org/spec/dd/20100524/di" xmlns:tns="http://www.jboss.org/drools"> <process processtype="private" isexecutable="true...

c++ - Erasing from vector -

i'm tried erase elements vector. in fact, wrote that: #include<iostream> #include<vector> std::vector<int> foo(std::vector<int> v) { std::vector<int> result; std::cout << "initial size = " << v.size() << std::endl; for(int = 0; < v.size(); i++) { std::cout << "size = " << v.size() << std::endl; v.erase(v.begin() + i); } return result; } int main() { int a[] = {1 ,2, 5, 8, 213, 2}; std::vector<int> v; v.assign(a, a+6); foo(v); } demo why program prints initial size = 6 size = 6 size = 5 size = 4 where size = 3 size = 2 size = 1 ? after third erasure have == 3 , v.size() == 3 , exits

c# - solution architecture for an OData / Web API based .Net project -

so far in office have developed number of small , medium sized .net web based applications used architect them - web layer (.net web apis) controllers, filters services (contains business logic) iservices repository (gets data database using entity framework / ado.net) irepository viewmodel model i used have different projects each of listed above in solution. but moving towards odata web apis , trying away entity framework. bit confused how solution architecture should like. question 1 - should dbcontext file located? question 2 - how going query using odata controller -> service -> repository question 3 - can still follow architectural model given above , have odata instead of entity framework getting data database? question 4 - still need separate business logic layer (service layer) between data source , controllers can keep controllers thin possible please excuse if asking wrong/silly question since first effort trying figure out how can use odat...

php - What are the PHPMailer requirement for sending mail and receiving mail in IIS 7 -

i'm running windows 2008r2 server php , iis 7.0 installed, , want add phpmailer iis 7, i'm not sure roles or features need installed from understanding run phpmailer have unzip phpmailer folder , drop files in project file have website , edit commands. but if have send email. need have smtp feature installed on iis 7? or php send without smtp installed? need other features installed make sure works? i'm asking because havent been able install smtp successful or run phpmailer successfully, know requirements. you have have form of mail server installed , preferably configured in php.ini . doesn't mean has run on windows server, has running somewhere , accessible said server. have linux box running sendmail , tell windows php use send mail through.

c++ - How to use the BFS algorithm to keep only the outer points? -

let's have 500x500 2d grid (from -250 250). each cell of grid has value, 0 100. what i've been trying keep list of cell value lower 50 starting @ point (0, 0), not keep points, outer points (perimeter, bounds, cell value lower 50 not have 4 adjacent cells value lower 50). the way implemented algorithm, keep list of points. how should modify it? optimize code if possible (i can have bigger grids), prefer not iterate again. pointlist pointswithvaluebelow50; // list of points value below 50 map<point, bool> pointdiscovered; // map of points passed through point = {0,0}; point b; int value; queue q; q.enqueue(a); pointdiscovered[a] = true; while(!q.isempty()) { = q.dequeue(a) value = calculatevalue(a); // random method verify if points has value below 50 in grid if (value < 50) { pointswithvaluebelow50.add(a); b[0] = a[0]+1; b[1] = a[1]; if(pointdiscovered[b] == false) { q.enqueue(b) ...

android - permission excpetion on lolipop only and pre-lolipop NOT -

anyone have worked ringtonemanger ? im facing wired problem :/ i have method ringtones names , uri availabe on mobile device http://pastebin.com/kgtw3kab its work on pre-lolipop devices (kitkat) , perfect when run on lolipop device gives exception "requires android.permission.read_external_storage" -please don't tell me add read_external_storage permission because added , app works on pre-lolipop devices , that's problem . <uses-permission android:name="android.permission.read_external_storage" /> android case-sensitive in places. please change to: <uses-permission android:name="android.permission.read_external_storage" /> with respect change in behavior on android 5.0, require able read external storage access stuff mediastore resides on external storage. not unique ringtones.

What frameworks are available in ASP.NET Core (ASP.NET 5) applications? -

i have seen various frameworks targeted in project.json files, using names such netcore50 , dotnet , dnx451 , net45 , , others. documentation "framework" section project.json not (yet) specify how use section different frameworks. what frameworks available , name should used in project.json target each? update 3 full list see target frameworks . the common tfms asp.net app developers need know are: netcoreappx.y = application targets .net core x.y (e.g. netcoreapp1.0 = .net core 1.0) netstandardx.y = library targets .net standard x.y . (e.g. netstandard2.0 = .net standard 2.0). .net standard libraries can work on desktop .net, windows phone, mono, , others. net4xy = library or console app targets desktop .net framework 4.x.y (e.g. net452 or net46 ) update 2 (dec 9, 2015) somewhat official docs available dotnet. see .net platform standard → nuget for libraries targeting multiple platforms adhere .net standard , these tfms (target fram...

matlab - Loading mixed numeric and string data -

Image
i'm new matlab. have file named iris.data , i'm trying load it's contents variables. file have folowing contents: 5.1,3.5,1.4,0.2,iris-setosa 4.9,3.0,1.4,0.2,iris-setosa 4.7,3.2,1.3,0.2,iris-setosa 4.6,3.1,1.5,0.2,iris-setosa 5.0,3.6,1.4,0.2,iris-setosa 5.4,3.9,1.7,0.4,iris-setosa 4.6,3.4,1.4,0.3,iris-setosa 5.0,3.4,1.5,0.2,iris-setosa 4.4,2.9,1.4,0.2,iris-setosa 4.9,3.1,1.5,0.1,iris-setosa 5.4,3.7,1.5,0.2,iris-setosa 4.8,3.4,1.6,0.2,iris-setosa 4.8,3.0,1.4,0.1,iris-setosa i tried: load iris.data but got: error using load unknown text on line number 1 of ascii file iris.data "iris-setosa". why it's giving me error, or i'm totally went on wrong direction, , there better way it. thanks!! in cases absolutely don't know how import data, use import data gui , generate script. this case: %% initialize variables. filename = 'c:\users\robert seifert\desktop\so\data.txt'; delimiter = ','; %% format string each ...

java - paintComponent method not being called by repaint -

i'm trying call paintcomponent method using repaint never being called. first class: public class start { public static void main(string[] args){ frame f = new frame(); f.createframe(); } } and class want paintcomponent method called happens blank frame appears: import javax.swing.jbutton; import javax.swing.jcomponent; import java.awt.graphics; import javax.swing.jframe; import java.awt.image.*; import javax.swing.icon; import javax.swing.imageicon; import java.awt.event.*; import java.awt.*; import javax.swing.*; import javax.swing.timer; public class frame implements runnable,actionlistener { jframe window = new jframe("frame"); int = 0; canvas mycanvas = new canvas(); public void createframe(){ window.setdefaultcloseoperation(jframe.exit_on_close); window.setbounds(30, 30, 700, 500); window.setfocusable(true); window.setfocustraversalkeysenabled(false); window.setvisible(true); (new thread(new frame())).star...

io - Fortran runtime error "bad integer for item 11 in list input" -

i receive runtime error "bad integer item 11 in list input" referencing following line of code. read(2,*)a,b,c,d,e,f,g,h,theta1,phi1,k,l,m,n,o, $ p,theta2,phi2,s,theta3,phi3, $ r1,x1,y1,r2,x2,y2,r3,x3,y3,z1,z2,z3 the line reading 1 255.11211 0.2876 165.11404 90 4 8 0.19173 90 165.11404 0.09587 90 345.11404 4 4 0.0764 89.99915 -64.51149 0.11131 90.0015 24.23892 470.10565 -454.32263 120.7902 264.91144 114.00389 -239.12589 322.2894 293.87778 132.3114 0.01236 0.00697 0.00006 0.42619 -0.19278 so mix of integers , reals, thought okay since used * format descriptor rather specified format. i'm using gcc compiler. item 11 in list 0.09587 , real. using list directed input, real interpreted numeric value using f edit descriptor (fortran 2008 cl. 10.10.3 paragraph 4). input list item corresponding f edit descriptor must real or complex (fortran 2008 cl. 10.7.2.3.1 paragraph 1). ...

genexus - Time to expire a token in GAM for SD -

i'm using gam create authentication system sd app, wish user login once , never again (unless user logout). i checked my security policies , field "token expires (minutes)" 0. this mean user session last "forever"? if not, how can done? you're right, can check link see meaning of property: http://wiki.genexus.com/commwiki/servlet/hwikibypageid?18577