Posts

Showing posts from May, 2013

python - Prepopulate 1 form field that is a foreign key -

previously letting user pick drop down of colors rather pick 1 them used following code determine colors valid choice , randomly chose one. i'm trying pre-populate in form , i'm getting name error. scratching head crazy because tested code piping choice template already. know code functioned in context. can not i've done below? the error i'm getting when launch server name error: name 'cur_colors' [at list comprehension line] not defined is... class limitedjobform(forms.modelform): jobnum = forms.charfield(label='job number') #get colorchoice cur_jobs = job.objects.filter(enddate__gte=(datetime.date.today()-timedelta(days=7))) all_colors = color.objects.all() cur_colors = [] in cur_jobs: cur_colors.append(i.color) aval_colors = [x x in all_colors if x not in cur_colors] choice = random.choice(aval_colors) color = forms.charfield(initial=choice) you haven't defined init method code go in

Directive That Injects a Modal $on Event in AngularJS -

how create directive injects fixed position modal or directly underneath element directive attached to? in directive want scope.$on trigger injecting directly below element. here's code far: angular.module('mobiledashboardapp') .directive('httperrormessage', function (httperrors) { return { template: '<div></div>', link: function(scope, element, attrs) { console.log("hello"); scope.$on(httperrors.badrequest, function (event, args) { // inject template directly below 'element' <-- part i'm not sure how }); } }; });

objective c - Binding to NSComboBox -

i new cocoa , developing 1 normal cocoa desktop application in xcode 4.5. have requirement display values in nscombobox , have retrieve nscombobox , restriction should not bindings iboutlet . if want need use of array controllers can use nsarraycontroller s not iboutlet s. will 1 suggest me how perform task without using iboutlet s. i don't want use iboutlet s because of: it reduces code: assume have 15 text fields in ui, need have 15 iboutlet s (if working on small project can have when implement bigger size project, may end creating tons of iboutlet s, nothing other helping access value text fields. if use binding rather iboutlet , handling ui easy, let's assume have 1 table linked arraycontroller. when array modified linked array controller, automatically changes reflect in tableview, no need bother updating tabelview, if use iboutlet , have scratch out head update content. whenever data modified display in tableview. makes developer's life easy:

sapui5 - Convert JS coding to xml -

i working sapui5 , new, have js view, need convert xml view, there way convert it? thanks you can make use of sapui5 diagnostics tool convert js view xml. https://help.sap.com/saphelp_uiaddon10/helpdata/en/6e/c18e80b0ce47f290bc2645b0cc86e6/content.htm

node.js - Elasticsearch: Searching for fields with mapping not_analyzed get no hits -

i have elasticsearch running , requests nodejs. have following mapping applied index "mastert4": { "mappings": { "mastert4": { "properties": { "s": { "type": "string", "index": "not_analyzed" } } } } } i added 1 document index looks pretty this: { "master": { "vi": "ff155d9696818dde0627e14c79ba5d344c3ef01d", "s": "anne will" } } now doing of following search queries not return hits: { "index": "mastert4", "body": { "query": { "filtered": { "query": { "match"/"term": { "s": "anne will"/"anne will" } } } } } } but following query return exact document: { "index": &

python 2.7 - How can I use scan/scroll with pagination and sort in ElasticSearch? -

i have es db storing history records process run every day. because want show 20 records per page in history (order date), using pagination (size + from_) combined scroll, worked fine. when wanted used sort in query didn't work. found scroll sort don't work. looking alternative tried es helper scan works fine scrolling , sorting results, solution pagination doesn't seem work, don't understand why since api says scan sends parameters underlying search function. question if there method combine 3 options. thanks, ruben yes, can combine scroll sort, but, when can sort string, need change mapping works fine, documentation here in order sort on string field, field should contain 1 term only: whole not_analyzed string. of course still need field analyzed in order able query full text. the naive approach indexing same string in 2 ways include 2 separate fields in document: 1 analyzed searching, , 1 not_analyzed sorting. "tweet":

c - Bind failed: Address already in use -

i attempting bind socket port below: if( bind(socket_desc,(struct sockaddr *) &server, sizeof(server)) < 0) { perror("bind failed. error"); return 1; } puts("bind done"); but gives: $ ./serve socket created bind failed. error: address in use why error occur? the error means port trying open being used application try using netstat see ports open , use available port. also check if binding right ip address (i assuming localhost)

ruby - Rails: How to access self.method in another controller? -

class foo1 def self.foo1action(cake) # returns user object end end class foo2 def foo2action user = # here want call foo1action end end how call foo1action in foo2action? based on rails framework. know inheriting 1 way go... want know other way of doing this.. class foo1 def self.foo_1_action(cake) end end class foo2 def foo_2_action user = ::foo1.foo_1_action(some_cake) end end

excel - Fails to update on cell change from outside source (OPC) -

i trying use vba store values on spreadsheet plc via rslinx data link. code reads cell has data link inserted , vba used perform analysis of data. wrote code tool aid in troubleshooting problems but, when initiated it, worked appears 'one scan' stopped updating. stripped code down bare bones read-and-relay set analyze how excel 2010 handling requests. set data linked cell, second cell equal data linked cell, , third cell relaying information second cell via vba code below. data link cell updates fine data on plc changes, second cell reads data without problem , can handle data formulas changes, vba cell not displaying anything. when second cell doubleclicked , enter key pressed, vba cell updated , displayed value shown in second cell failed continue update after that. used vba target data linked cell , got same result. not vba expert , usually, program in c++. may have bad interpretation of of commands below. please descriptive , thank you. the data link is =rslinx|dmon

java - Neo4j match... merge cypher syntax for UPSERT is returning (no rows) -

Image
i started learning graphdb neo4j yesterday, now, want perform upsert operation shown below; match (circle:circle {id:3, cycleid:5}) merge (member1:member {id:1}) -[invited:invited_to_join {c:circle, time:timestamp()}]-> (member2:member {id:2}) return member1, member2, invited, circle according docs here http://neo4j.com/docs/stable/query-merge.html if node circle assigned properties not exist node , specified relationship should created, otherwise, update should performed on node , relationships. not happen. rsponse says (no rows) . see below; could please point me i'm not doing correctly? edit: want create circle , member1 , member2 , their relationships on fly without worrying whether nodes exist, if do, update them accordingly edit: make myself clearer after comments , suggestions @davebennet @cybersam, & @michaelhunger ( main aim: ) to create relationship implies member1 invited member2 join circle3 if node(s)/relationship(s) not exist, crea

Docker is in volume in use but no docker containers -

i've been having issues removing docker volumes docker 1.9.1. i've removed stopped containers docker ps -a returns empty. when use docker volume ls , i'm given whole host of docker containers. docker volume ls driver volume name local a94211ea91d66142886d72ec476ece477bb5d2e7e52a5d73b2f2f98f6efa6e66 local 4f673316d690ca2d41abbdc9bf980c7a3f8d67242d76562bbd44079f5f438317 local eb6ab93effc4b90a2162e6fab6eeeb65bd0e4bd8a9290e1bad503d2a47aa8a78 local 91acb0f7644aec16d23a70f63f70027899017a884dab1f33ac8c4cf0dabe5f2c local 4932e2fbad8f7e6246af96208d45a266eae11329f1adf176955f80ca2e874f69 local 68fd38fc78a8f02364a94934e9dd3b5d10e51de5b2546e7497eb21d6a1e7b750 local 7043a9642614dd6e9ca013cdf662451d2b3df6b1dddff97211a65ccf9f4c6d47 #etc x 50 since none of these volumes contain important, try purge volumes docker volume rm $(docker volume ls -q) . in process, majorit

how to do an if else depending type of type in c++ template? -

// template specialization #include <iostream> using namespace std; // class template: template <class t> class mycontainer { t element; public: mycontainer (t arg) {element=arg;} t increase () { //if(t.type==int)//how or similar? //do if int return ++element; //if(t.type==char) //if ((element>='a')&&(element<='z')) //element+='a'-'a'; //return element; } }; i know how write template specialization , separate whole class def char type. but if wanted handle in 1 block of code? how can check if t int or char? you use typeid : if (typeid(t) == typeid(int)) or use std::is_same type trait: if (std::is_same<t, int>::value)

user interface - How to add Richfx in a layout -

i have been trying add inlinestyletextarea , codearea in anylayout both in main method in javafx , in fxml file. receive thread error. please if possible examples how can add these components javafx layout? if possible tutorial link. this simple code public class main extends application { @override public void start(stage primarystage) { textfield mytextfield = new textfield(); inlinecsstextarea textarea = new inlinecsstextarea(); hbox hbox = new hbox(); hbox.getchildren().add(mytextfield); hbox.getchildren().add(textarea); hbox.sethgrow(mytextfield, priority.always); hbox.sethgrow(textarea, priority.always); scene scene = new scene(hbox); primarystage.setscene(scene); primarystage.show();} public static void main(string[] args) { launch(args); } } exception in application start method java.lang.reflect.invocationtargetexception @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect

javascript - Can't assign a string to another string in an onchange = function() -

i have this: <select id="prio" class="w60"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> if select value, onchange = function() called: var prio = document.getelementbyid('prio'); var string1 = "hello"; var string2 = ""; prio.onchange = function () { prioindex = prio.options[prio.selectedindex].text; switch (prioindex) { case '1': prioindex = " friend"; break; case '2': prioindex = " sister , brother"; break; case '3': prioindex = " mom , dad"; break; } alert(prioindex); string2 = prioindex; } alert(string2); the alert inside function works fine not assign new string. alert

asp.net - How can I access the rows in a certain column of a DataTable? -

i need populate rows in specific columns of datatable . have following setup: dim dt datatable = new datatable() dim da sqldataadapter = new sqldataadapter() dt.columns.add("column 0") dt.columns.add("column 1") try sqlconn.conopen() da.selectcommand = sqlcmd_loccodes da.fill(dt) sqlconn.conclose() catch ex exception sqlconn.conclose() end try the sqldataadapter filling table data database. need able store data database specific columns in datatable. i'm trying (i'm populating barchart data, can ignore part): for integer = 0 dt.rows().count - 1 chart.series("series1").points.addy(dt.rows(i)("column 0").tostring()) chart.series("series1").points(i).axislabel = dt.rows(i)("column 0").tostring() next i know i'm doing simple task incorrectly. going accessing particular rows incorrectly? appreciated. you can iterate rows in dat

How to rename property/attribute of resource with jsonapi-resources ruby gem -

i building json api rails using jsonapi-resources gem. library great, lot of job. however column names in our db not meaninful showed in api. so, question: possible rename property/attribute in resource? example: let's have model user attribute login . class user < activerecord::base attr_accessor :login end and want login in api appear username , e.g.: class userresource < jsonapi::resource attribute :username, map_to: :login end thanks! set :username alias :login attribute: class user < activerecord::base attr_accessor :login alias_attribute :username, :login end then in jsonapi::resources (jr) can specify username attribute so: class userresource < jsonapi::resource attribute :username end by setting alias, you've mapped username attribute login attribute, doesn't matter whether use username or login , return same value.

ruby - Stop `until`-loop when condition is met -

i want make sure following test can't stuck in infinite loop. make loop run amount of times. when /^i click settings link$/ footer = @browser.div(:id, 'iwinbottombar') footer.wait_until_present unless footer.html.include?('settings') throw exception.new("expected see settings button not there") end until @browser.div(:id, 'dialogcontainer').div(:class, 'settings_browsebutton button clickable').present? footer.a(:class, 'button_settings').when_present.click end end but i'm not sure how limit code that. think need counter, i'm not sure how implement it. if got correctly, want while / until maximum times of retries: 10.times break if condition_met? do_whatever end

lua - osx - script to get current desktop number -

is there way current desktop/space number on osx programatically? i've found questions seems little bit outdated: osx lion applescript : how current space # mission control? i've found this: http://www.hammerspoon.org/docs/hs.spaces.watcher.html unfortunately not work. since recent os version, no longer possible access via script spaces. thing found how get, via applescript name/path of desktop picture on current space : tell application "finder" set (desktop picture) string except that, since yosemite (at least !) applescript dictionary no longer contain space scriptable elements.

sql - ORA-01427: single-row subquery returns more than one row- multiple values needed -

i have following sql query on oracle select case when (select distinct(trim(z.m_base_acct)) acc_mapping_rep z z.m_dyn_acct=b.m_en_credit , z.m_ref_data =b.m_ref_data) in 'samanos' '7200000888001x' end m_en_crdr acc_journal_rep b , b.m_ref_data = 41091 , b.m_en_date = '21-sep-15' , b.m_entity = 'ln' , b.m_nb_trn = 0 i having oracle error ora-01427. due line have case when condition knowing did put in operator instead of equal. please advise. need have multiple values in case condition. if you've shown have 1 value compare, 'samanos' , can swap terms: select case when 'samanos' in (select distinct(trim(z.m_base_acct)) acc_mapping_rep z z.m_dyn_acct=b.m_en_credit , z.m_ref_data =b.m_ref_data) '7200000888001x' end m_en_crdr ... you left-join acc_mapping_rep table, distinct , trim worrying - if needed becomes litt

xpath - All elements with a following sibling equal to it -

my xml structure: <root> <!-- first --> <a> <b>123</b> <c>456</c> </a> <!-- second --> <a> <b>999</b> <c>456</c> </a> <!-- third --> <a> <b>123</b> <c>456</c> </a> <!-- fourth--> <a> <b>123</b> <c>999</c> </a> <!-- fifth --> <a> <x>123</x> <y>456</y> </a> </root> i want find elements have following siblings equal it. the desired result first element, because equal third element. i've tried this: //a[.= following-sibling::a] but result first , third element. guess third element matches fifth element, because = operator compares string values, right? can me? can compute position of matched element in xpath or have search in xsl loop? i think looki

python - Using regex on Charfield in Django -

i have model with class dbf_att(models.model): name = models.charfield(max_length=50, null=true) and i'd check later object.name match regex: if re.compile('^\d+$').match(att.name): ret = 'integer' elif re.compile('^\d+\.\d+$').match(att.name): ret = 'float' else: ret = 'string' return ret this return 'string' when of att.name should match regex. thanks! regex great, more simpler , readable use other approaches. example, how using builtin types check type try: att_name = float(att.name) ret = "integer" if att_name.is_integer() else "float" except valueerror: ret = "string" fyi, regex code works fine. might want inspect data being checked. demo: >>> import re >>> = re.compile('^\d+$') >>> b = re.compile('^\d+\.\d+$') >>> a.match('10') <_sre.sre_match object @ 0

d3.js - Grouped pie chart segments in d3js using .padAngle() -

Image
how add padding between groups of segments in donut/pie chart using d3? update i using d3.svg.arc shape generator , .padangle(paddingfunction) paddingfunction defined as: var paddingfunction = function(d,i) { return i%1==0 ? 0.1 : 0 }; this image using paddingfunction described above. but if change padding function this: var paddingfunction = function(d,i) { return i%5==0 ? 0.1 : 0 }; i image: shouldn't code return 2 groups of segments gap in-between? complete code: // magic numbers var t = 2 * math.pi; var archeight = 100; var innerradius = 50; var hours = 10; function postion(i,offset) { offset = offset || 0; return i*(t / hours) + offset*(t / hours) } var paddingfunction = function(d,i) { return i%1==0 ? 0.1 : 0 }; // arc generators var arc = d3.svg.arc() .innerradius(function(d,i) { return innerradius; }) .outerradius(function(d,i) { return innerradius + archeight; }) .startangle(function(d, i){ return postion(d.hour);}) .endangle(

"Subsetting" a dictionary in F# -

i'm beginner in f# , i'm trying write function subset dictionary given list, , return result. i tried this, doesn't work. let subset (dict:dictionary<'t,'u>) (sub_list:list<'t>) = let z = dict.clear sub_list |> list.filter (fun k -> dict.containskey k) |> list.map (fun k -> (k, dict.trygetvalue k) ) |> list.iter (fun s -> z.add s) |> list.iter (fun s -> z.add s);; --------------------------------------^^^ stdin(597,39): error fs0039: field, constructor or member 'add' not defined perhaps there native function in f# ? thanks edit @theinnerlight answer below can educate me bit more, , tell me how should adapt function if want return original variable being modified ? (of course possible go call function, call temp variable, , reassign) you have written: let z = dict.clear z of type unit->unit yet calling z.add . i suspect want write let subset (di

imagej - Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [B -

i tried read image loci tools , save filesaver imagej but, got error when running it imageplus[] imps = bf.openimageplus("path/to/my/file"); (imageplus imp : imps)new filesaver(imp).saveasraw("e:/test.raw"); when run code, shows exception in thread "main" java.lang.classcastexception: [ljava.lang.object; cannot cast [b @ ij.io.imagewriter.write(imagewriter.java:272) @ ij.io.filesaver.saveasraw(filesaver.java:494) @ skripsi.dcmtoraw.main(dcmtoraw.java:16) this bug, although it's not trivial whether bug in imagej 1.x, or in bio-formats plugins. in imagej 1.x code , imagewriter assumes (unchecked) pixels array object[] when image stack, , byte[] when it's single image plane. however, seems bio-formats produces imageplus objects pixels object[] single planes. (is image single plane?) you work around issue using bio-formats exporter plugin save data. or use imagej2 api, use scifio under hood: /** * adapted * <a hr

algorithm - 3 max flow prove or disprove small questions -

Image
the questions : for (a) seems not true, can fin example of flow growing without e being saturated. for (b) seems true, yet not sure how prove it. maybe because of min cut max flow theorm, on min cut had grew. for (c) seems false. flow grew because e changed e might have not grew 5. (1) seems true me - if managed increase maximum flow, means found new path source sink (that did not exist before increasing edge e ). e must in new path, if e not saturated before, path have existed in original graph. (2) false. take graph this: s --20-- n --20-- t where s source , t sink, there 2 min-cuts ( {(s, n)} , {(n, t)} ), increasing either (s, n) or (n, t) won't change maximum flow. (3) false. take graph this: s --20-- n --25-- t if increase capacit of e = (s, n) 10 , new maximum flow 25 , did not increase value of e 5 .

javascript - View A Base64 Encoded Page -

might general question anyway. i have link file on server base64 encoded. able view file decoded. in order achieve this, downloading file content inserting like <a href="data:image/png;base64,...(base64-encoded file content goes here)..." width="70" height="38" alt="image embedded using base64 encoding!"></a> then opening link view file. i wondering if there maybe more elegant solution? instance, can view original link decoded passing in parameter link or such? ideally looking way view without having download , decode via javascript. try <img src="data:image/png;base64,...(base64-encoded file content goes here)..." /> live demo: https://jsfiddle.net/anzrrogs/

Fiware: Issue when registering a service through IDAS -

i'm using idas. can register service through iot agent, if try using iota manager, seems can't due issue protocols. when try register it: curl -x post 172.21.0.23:8091/iot/services \ -i \ -h "content-type: application/json" \ -h "fiware-service: sanitysrvm" \ -h "fiware-servicepath: /sanitysspath" \ -d '{"services": [{ "apikey": "apikey", "token": "token", "cbroker": "http://127.0.0.1:1026", "entity_type": "thingsrv", "protocol": ["pdi-iota-ultralight"] }]}' i response: http/1.1 400 bad request connection: close host: 172.21.0.23:8091 content-length: 94 content-type: application/json {"reason":"the request not formed","details":"no exists protocol pdi-iota-ultralight"} i have checked protocols: http://172.21.0.23:8091/iot/protocols but seems there none: { "count"

utf 8 - Replace Special Characters function issue -

i using function found on stackoverflow replace special characters: function toascii( $str ) { return strtr(utf8_decode($str), utf8_decode( 'ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝŐŰßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿőű'), 'sozsozyyuaaaaaaaceeeeiiiidnoooooouuuuyousaaaaaaaceeeeiiiionoooooouuuuyyou'); } however, when try functionality in html not desired result. html code: <?php $test = 'ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝŐŰßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿőű'; $test1 = toascii($test); ?> !doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> </head> <body> <?php echo $test.&quo

javascript - Searching the DOM on click events -

say have following code: $('.some-class a').click(function() { // }); will jquery search dom each time .some-class a clicked? or dom searched once? i'm wondering if improve performance if make $('.some-class a') variable , change to: var $someclass = $('.some-class a'); $someclass.click(function() { // }); in case : $('.some-class a').click(function() { // }); this instruction executed once : jquery search dom once, find requested elements , attach click events them. end. in case : function hidestuff(){ $('.some-class a').hide() } jquery have search dom every time function called. in order avoid that, store objects in variable (it's called caching) : var $elems = $('.some-class a') function hidestuff(){ $elems.hide() } every time hidestuff() function called, jquery won't have search dom, it's got elements stored in memory, it's faster.

python - CSV to text file layout -

i outputting 2 columns of csv file text file , printing on single line in text file. this: product name counter({'descriptions': 1, 'descriptions':3}) but want print out this: product name counter({'descriptions': 1, 'descriptions': 3}) here code have far: import csv import sys collections import defaultdict collections import counter data = defaultdict(list) class dictionary: open ('practice.csv', 'rb') f: reader = csv.reader(f) next(reader, none) row in reader: data[row[2]].append(row[3]) text_file = open("test.txt", "w") data_count = counter() key in data.keys(): sys.stdout = text_file print key, counter(data[key]) text_file.close() how can text file not print out on 1 line? not sure how work. the counter({'descriptions': 1, 'descriptions':3}) stuff output of counter

ASP.NET DateTime object "changes" when passed to Javascript -

i have asp.net webservice whicn runs on local computer in test environment. local computers utc time +1 (denmark). have these methods available javascript client: [webmethod(enablesession=true)] public datetime getdatetime() { return new datetime(2013,3,15,10,0,0); } [webmethod(enablesession=true)] public void setdatetime(datetime dt) { } when call first method javascript , alerts passed datetime, correctly shows 10 time: 'fri mar 15 2013 10:00:00 gmt+0100 (romance standard time)' after alert, pass datetime object webserver. when debug object, datetime 9 am. how come? client , server runs on same machine. i´ve played around datetime.specifykind, overall result same; client subtracts hour when time sent server. hope can me better understanding of subject. thank in advance. @millimoose i´ve tried datetimeoffset solution, didnt help. not sure if used 100% correctly though. works me this: before send datetime(s) server client, dont datetime (such setting

javascript - Debug a New Polymer Element Page -

we have / bower_components index_demo.html mycomponent.html mycomponent.html uses e.g. paper-button , gets imported <link rel="import" href="../paper-button/paper-button.html"> so when mycomponent installed via bower lands in bower_components , works. now best practice debug element locally? index_demo.html should import mycomponent.html , bower_components/paper-fab/paper-fab.html . now mycomponent.html doesn't work, because ../paper-button/paper-button.html not found (as lies in bower_components/paper-button ) for manually add required mycomponent polymer elements index_demo.html , it's unclean solution. platform: win as seems comment helpful, here answer there's guide in polymer website on recommended way of creating new elements polymer, in can find download link seed-element template has structure allows develop, debug, test, deploy element github pages, , put bower quite easily.

javascript - How to autoplay super slider? -

i choose superslider link config on website , it's worked absolutely . have problem it. :( can't start auto play slider. due documentation on mentioned link there options can use start auto play don't know how , there no auto play demo show me how ? code : <section id="slider"> <div class="row"> <div class="col-lg-12 col-md-12"> <div class="slider_area"> <!-- start super slider --> <div id="slides"> <ul class="slides-container"> <li> <img src="img/slider/2.jpg" alt="img"> <div class="slider_caption"> <h2>title</h2> <p>description</p> <a class="slider_btn" href="#">more</

Why would `go get` start to fail in Travis CI build? -

i opened pull request on repository goes through build cycle in travis. job failing here . cannot find reason why job in particular continues fail. i've restarted multiple times see if temporary timeout. core error is: the command "go golang.org/x/tools/cmd/vet" failed , exited 1 during . full log here: https://gist.github.com/mjbrender/79e0343625038bce440a has changed golang's vet package don't see here? or flaky process? if is, there way of improving build process? looks wasn't alone in having vet cause broken build: https://github.com/coreos/etcd/issues/4149 and traces change in imports. team behind package rolled change broke go vet 1.4.2: https://github.com/golang/tools/commit/da91609d887c6b1e28ad4548c47f3ff39a471989 go golang.org/x/tools/cmd/vet works since update package: https://travis-ci.org/intelsdi-x/snap/jobs/100709221

data structures - Programming concept -

i want make program sort mail junkmail using point--system. for couple of words in mail, want program give different points each word have in program categorized "junkwords" have assign different points different words, each word worth amount of points. my pseudocode: read text file look "junk words" for each word comes give point word worth. if total points each junkword 10 print "spam" followed list of words in file , categorized junkwords , points. example (a textfile): hello! have trouble sleeping? need rest? dont hesitate call absolute solution- without charge! so when programs run , analyzes text above should like: spam 14p trouble 6p charge 3p solution 5p so planing write in manners: class junk(object): fil = open("filnamne.txt","r") junkwords = {"trouble":"6p","solution":"3p","virus":"4p"} words = junkwords if words i

Docker: Development environments -

i coding in few different languages/technologies. honest, messing around, playing golang, node.js, ruby on rails, etc. but want jump on docker bandwagon well, not sure benefits , if should put in effort. what best practise in using docker development environments? set separate container each language or technology dabble with? or containers overkill , should set 1 vm (linux vm on windows host) development? how guys use docker development work? you should go ahead , best approach follow, if share volumes between containers, , avoid setting different vms if have necessary hardware-power in workstation , not need distribute environment on different workstations. at current company, i'm guy responsible setting development environments among other things. have few monolithic applications we're decoupling multiple functionalities separate micro-services. how we're starting manage is, every micro-service code repository has self-contained, being docker-compo

python 3.x - pylint generates r:redefined-variable-type when using enums? -

i'm using python 3.4.2 , pylint 1.5.2. pylint printing r:redefined-variable-type warning when use variable of type enum. following script demonstrates problem: enumrepro.py: from enum import enum class myenum(enum): value1 = 1 value2 = 2 myenum = myenum.value1 print("my enum {}".format(myenum)) # huh? line generates # warning r0204: redefinition of myenum type enumrepro.myenum.value1 # enumrepro.myenum.value2 [r:redefined-variable-type] myenum = myenum.value2 # generates print("my enum {}".format(myenum)) any suggestions? currently, i'm spot-disabling r0204 whenever use enums, that's not ideal. thanks! this problem pylint (enums , r0204 in general). multiple issues reported, e.g. https://github.com/pycqa/pylint/issues/781 thus, spot- or disabling r0204 moment fine.

javascript - Refreshing partial, while also changing URL to match -

using partial view , home controller action index of <div id="eventcontroller"> <div class="row event"> <div class=""></div> </div> <div class="row row-top-20-margin"> <div class="col-md-2 sidebar"> <ul class="nav nav-stacked nav-pills" id="eventnavbar"> <li><a href="" data-tab="eventcalendar" id="eventcalendar">event calendar</a></li> <li><a href="#submitnewevent" data-tab="submitnewevents" id="submitnewevent">submit new event</a></li> <li><a href="#myevents" data-tab="myevents" id="myevents">my events</a></li> </ul> </div> <div class="col-md-10 main"> <div class="panel panel-default"&

modelica - How to initialize model with previous simulation solution? -

having run out of ideas again turn you. i'm sure has have been answered before though life of me can't find clear description of it. scenario: you work hard model set initial guesses, etc., , solve 'real' steady state (ss) condition of parameters in model. solution want investigate events effects on system. to perform deviation ss analysis, expedient able load ss solution .mat file model parameters generated dymola . loading solution removes need first simulate model achieve ss solution before performing deviations ss investigations. can conceive possible step @ takes place during 'initialization' phase of simulation. given seem important concept, imagine idea have been considered stage of modelica/dymola development. manual extraction of each individual parameter not seem proper given size of these models become large. question: is possible solve state of model (.mat file) , load simulation 'initial' values of variables? (this overri

ajax - codeigniter: Rest api + Json -

how, implement code igniter rest api outputs ajax outputting json. i'm unsure how use rest api deleting , adding json. how delete item json , database. 1. rest api routing let's start routing of api - if apply best practice api want use http verbs (post/put/get...). ( read more on http verbs , rest here ) if on codeigniter 2.x read question , answer if on codeigniter 3.x read documentation on other side, if planning use api internally , scope of project limited can ignore http verbs , make post , calls controllers. 2. creating json response generally not need use views - can have controllers echo json response. here example of fictional api has api call actor database of actors. /* ---------------------------------------------- | example of api method actor | database of actors: | call: http://example.com/api/getactorbyid | parameter: actor_id | method: post */ public function getactorbyid(){ // let's first actor id post data

javascript - why VScode sometimes don't find the reference? -

it doesn't happen time, visual studio code cannot find variable in other file, , don't know why. for example, have index.html <script src="monitor.js"></script> <script src="notificationmanager.js"></script> notificationmanager.js var notificationmanager = function() { this.attentionrequest = function() { console.log("attention"); }; } var notificationmanager = new notificationmanager(); in monitor.js: notificationmanager.attentionrequest();//vscode don't find it happens you trying access variable/function declared in js file not available @ time of access. hence, need change order of js files update from <script src="monitor.js"></script> <script src="notificationmanager.js"></script> to <script src="notificationmanager.js"></script> <script src="monitor.js"></script>

registry - Create Batch File to Undo Windows 10 New Default Printer Behavior -

yesterday made aware of disruptive update microsoft released. 1 of windows 10 updates, microsoft made default printer dynamically changes whatever last printer used. while understand how useful in many situations, there many situations in problematic. example if printed small label on dedicated label printer , went print out 8.5" x 11" report without selecting printer. result lot of wasted labels. particular situation, unfortunately rather common experience. for reason, need find way , disable new "feature". see there option going settings -> devices -> printers , scanners. purpose, though, need can automated. have couple hundred computers need perform change on. i looked around bit, unable find complete answer elsewhere , decided answer own question. the answer put reg add command in batch file. command is: reg add "hkcu\software\microsoft\windows nt\currentversion\windows" /v "legacydefaultprintermode" /t reg_dword /d

python 2.7 - Openerp asynchronous process -

this similar python asynchronous processing in existing loop ; have time consuming python method needs run (user initiated) asynchronously user can keep working on else while method running on backend. i using threading cursor gets closed , have re-create it, , when writing db getting error 'generatorcontextmanager' object has no attribute 'dbname'. my simplified code: import threading def call_validar(self, cr, uid, ids, context=none): t = threading.thread(target=self.test_threading, args=(cr, uid, ids, context,)) t.start() return true def test_threading(self, cr, uid, ids, context=none): id in ids: my_cr = self.pool.cursor() # cursor needs re-created try: self.write(my_cr, uid, id, {'validation_logs': 'just anything'}) except exception, e: # 'generatorcontextmanager' object has no attribute 'dbname'

Elasticsearch: Query nested object contained within an object -

i'm struggling build query can nested search across sub-object of document. say have following index/mapping: curl -xpost "http://localhost:9200/author/" -d ' { "mappings": { "item": { "properties": { "books": { "type": "object", "properties": { "data": { "type": "nested" } } } } } } } ' and following 2 documents in index: { "id": 1, "name": "robert louis stevenson", "books": { "count": 2, "data": [ { "id": 1, "label": "treasure island" }, { &q

php - validate directly in your if or create a function? -

the question kinda hard put in words hope make sense what's best practice? this if($value < 5) { //do } or this if(validvalue($value)) { //do } function validvalue($value) { if($value < 5) return true; } this best way validate value rather creating function that's not required. if ( $value < 5 ) { #do }

php - QueryBuilder: Sum values of a pivot table -

i'm new on laravel & eloquent. have users, products , votes tables on db. users can vote (0 5) on products, "many many" relationship, votes table acting pivot: users: id, name, email, password products: id, name, model, brand votes: user_id, product_id, vote i mapped schema this: // user model: public function product_votes() { return $this->belongstomany('app\product', 'votes')->withpivot('vote'); } // product model: public function product_votes() { return $this->belongstomany('app\user', 'votes')->withpivot('vote'); } so john can vote 5 on product x , 0 on product y. bob can vote 2 on product x, 3 on product y, , on... i'm trying query products, sum of votes of each 1 of them. like: select p.*, (sum(v.vote) / count(*)) votes products p inner join votes v on v.product_id = p.id group p.id how can querybuilder? mapping right? the following trick: product::select(

node.js - Node, Mongodb, Limiting updatemany to the first 500 entries -

is there way in node using native mongodb driver limit update many operation first 500 entries? right update many line looks col.updatemany({$exists : {available : false}}, {$set : {available : "na"}}, function(){}); is there way limit number of documents searches , updates? thanks!

How to use condition in expression in AngularJS -

i'm making small page show how number filter work: number: <input type="text" ng-model="nomber"><br/> fractionsize: <input type="text" ng-model="fractionsize"><br/> gives: {{ nomber | number:fractionsize }} if write number, work, if decide had nomber in fractionsize, remove it, gives me nan. i have condition in {{ nomber | number:fractionsize }} that tell condition not try use fractionsize if input empty. you should redefine filter using, cause design angular return nan, can see here: number filter should not format nan empty string here custom filter accomplish looking for: angular.module('plunker', []) .controller('mainctrl', function($scope) { $scope.nomber = 0; $scope.fractionsize = 0; }) .filter('textornumber', function ($filter) { return function (input, fractionsize) { if (isnan($filter('number')(input, fractionsize)))

python - Enforce Not Null field in MariaDB using Peewee -

well, i'm trying use peewee small project. need fields text , url (both longtext in mariadb) not null , not null understand not allow null value stored in field , did this: database = mysqldatabase("mydatabase", user="", password="123justkidding", host="localhost") class mytable(model): text = textfield(null = false) url = textfield(null = false, max_length = 100) class meta: database = database and then, of course, created table , started adding values, lots of values. thing there empty values on text , url fields don't want them be. ran query: select `table`.`text`, `table`.`url` `table` `table`.`text`="" , `table`.`url`="" and gave me 4 rows. so, missing guys? also, notice mariadb has text , medium text , longtext data-types , appears me textfield in peewee default longtext in mariadb . way can change that? thanks in advance. "" empty string. nu

c# - Parsing text from HTML formatted email -

i inbound emails html formatting below (probably copy/pasted office , sent outlook) causes formatting issues when html enabled ui displaying email content.so resolve copy html content online html editor or save html file , run in browser can copy text rid of garbage html , styling tags. dont have option of using frames in markup suppress html , css , prevent affecting page styling. is there other way can resolve issue pragmatically , parse text out every time detect 'urn:schemas-microsoft-com:vml' in body of inbound emails? i went far writing code removes tags (e.g. between <head> , </head> ) see if can offer more efficient way of handling or alternate frames suppress bad html in email body content on ui <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns

rest - Cannot add the most basic RESTful web service -

i'm on windows 2008 r2 (64-bit) using cf10 (64-bit) (developer edition?) i trying implement basic tutorial: http://blogs.coldfusion.com/post.cfm/rest-support-in-coldfusion-part-i i created new website through iis on port 8081 , added 2 files: /index.cfm (in theory, since no application.cfc containing app vars needed, have skipped this) <cfset s = "hello world!"> <cfoutput>#s#</cfoutput> /restexample/helloworld.cfc <cfcomponent rest="true" restpath="/hello"> <cffunction name="sayhello" access="remote" returntype="string" httpmethod="get"> <cfset res="hello world"> <cfreturn res> </cffunction> </cfcomponent> in cf admin: root path: c:/websites/test/restexample/ service mapping: example i following error: error registering rest service. please ensure have entered proper mapping