Posts

Showing posts from May, 2014

java - TableModel not called in a JScrollPane containing a JTable -

i having unexpected behavior java gui. want create jscrollpane containing jtable add jscrollpane frame . here code : public class urlsscrollpanel extends jscrollpane { private static final long serialversionuid = 1l; public urlsscrollpanel() { //setup urls , collections arraylist<url> urls = url.getall(); arraylist<collection> collections = new arraylist<>(); for(url url : urls) collections.add(new collection(url)); //table string[] columns = { "database", "status", "consumption", "last snapshot date", "last message", "details", "stop collect" }; abstracttablemodel datamodel = new abstracttablemodel() { private static final long serialversionuid = 1l; @override public object getvalueat(int rowindex, int columnindex) { system.out.printf("row: %

pass pointer of struct in c programming -

Image
i need pass pointer function doesn't work output empty. i study pointer 1 week ago @ university it's confused. thank advance. code below , output : #include<stdio.h> #include<string.h> #include<stdlib.h> typedef struct nooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo{ char courseid[10]; char coursename[50]; float score; struct nooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo *next; }course; void getdata(course *newnode,course *root,course *last) { char courseid[10],coursename[50]; float score; file *input; input = fopen("course.txt","r"); fscanf(input,"%s %s %f",&courseid,&coursename,&score); while(!feof(input)) { newnode = (course*)malloc(sizeof(course)); strcpy(newnode->courseid,courseid); strcpy(newnode->coursename,coursename); newnode->score = score; newnode->ne

java - How to round up my BigDecimal to have 2 digits after the decimal point? (scala) -

this question has answer here: scala doubles, , precision 10 answers java bigdecimal: round nearest whole value 6 answers what best solution make bigdecimal have 2 digits after decimal point (while keeping precise possible) in scala? val bigdec1 = bigdecimal(12345.12) val bigdec2 = bigdecimal(1345.12) ((bigdec1/bigdec2)*100) the last row equal 917.7709051980492446770548352563340 want 917.77 .

python - Pandas Dataframe: Accessing via composite index created by groupby operation -

i want calculate group specific ratio gathered 2 datasets. 2 dataframes read database with leases = pd.read_sql_query(sql, connection) sales = pd.read_sql_query(sql, connection) one real estate offered sale, other rented objects. group both of them city , category i'm interested in: leasegroups = leases.groupby(['idconjugate', "city"]) salegroups = sales.groupby(['idconjugate', "city"]) now want know ratio between cheapest rental object per category , city , expensively sold object obtain lower bound possible return: minlease = leasegroups['price'].min() maxsale = salegroups['price'].max() ratios = minlease*12/maxsale i output like: category - city: ratio cannot access ratio object city nor category. tried creating new dataframe with: newframe = pd.dataframe({"minleases" : minlease,"maxsales" : maxsale,"ratios" : ratios}) newframe = newframe.loc[newframe['ratios'].notnull()]

python - PySpark groupByKey finding tuple length -

my questions based upon first answer this question . want count elements key, how that? example = sc.parallelize([(alpha, u'd'), (alpha, u'd'), (beta, u'e'), (gamma, u'f')]) abc=example.groupbykey().map(lambda x : (x[0], list(x[1]))).collect() # gives [(alpha, [u'd', u'd']), (beta, [u'e']), (gamma, [u'f'])] i want output below alpha:2,beta:1, gamma:1 i came know answer below. why complex? there simpler answer? s contain key + values? why cannot len(s)-1 subtracting 1 remove key s[0] map(lambda s: (s[0], len(list(set(s[1]))))) well, not complex. need here yet word count: from operator import add example.map(lambda x: (x[0], 1)).reducebykey(add) if plan collect can countbykey : example.countbykey() you don't want use groupbykey here assuming there hidden reason apply after all: example.groupbykey().mapvalues(len) why len(s) - 1 doesn't work? because example pairwise rdd or in

How do I stop the C# compiler output from wrapping in the Visual Studio 2015 output window? -

when build c# code in visual studio 2015 using default compiler (nothing unusual project), output in output window looks bit this. (the actual width isn't representative, i've replaced rather long path xxx .) 1>xxx(402,13,402,16): error cs1955: non-invocable member 'lo 1>g' cannot used method. 1>xxx(424,25,424,28): error cs1955: non-invocable member 'lo 1>g' cannot used method. presumably compiler printing non-invocable member 'log' cannot used method , , something, somewhere, stepping in , popping newlines in (at column 120 in practice - mentioned, column counts in example output unrepresentative). can stop this? if so, how? i'd prefer messages printed out newlines in natural places, can use output window's word wrap functionality. after open package manager console, build output starts become wrapped above. the fix appears to restart visual studio.

scala - How to retrieve record with min value in spark? -

lets have rdd -> (string, date, int) [("sam", 02-25-2016, 2), ("sam",02-14-2016, 4), ("pam",03-16-2016, 1), ("pam",02-16-2016, 5)] and want convert list -> [("sam", 02-14-2016, 4), ("pam",02-16-2016, 5)] where value record date min each key. best way this? i assume since tagged question being related spark mean rdd opposed list. making record 2 tuple, key first element allow use reducebykey method, this: rdd .map(t => (t._1, (t._2, t._3)) .reducebykey((a, b) => if (a._1 < b._1) else b) .map(t => (t._1, t._2._1, t._2._2)) alternatively, using pattern matching clarity: (i find _* accessors tuples bit confusing read) rdd .map {case (name, date, value) => (name, (date, value))} .reducebykey((a, b) => (a, b) match { case ((adate, aval), (bdate, bval)) => if (adate < bdate) else b }) .map {case (name, (date, value)) => (name, date, value)} re

How to get all string except the first word in Python -

how rid of first word of string? want rid of number , rest whole string. input text is: 1456208278 hello world start what wanted output was: 'hello world start' here approach: if isfile('/directory/text_file'): open('/directory/test_file', 'r') f: lines = f.readlines() try: first = str((lines[0].strip().split())) final = first.split(none, 1)[1].strip("]") print final except exception e: print str(e) the output of code was: 'hello', 'world', 'start' i not want " ' " every single string. if split , join, may lose spaces may relevant application. search first space , slice string next character (i think more efficient). s = '1456208278 hello world start' s[s.index(' ') + 1:] edit your code way complex task: first split line, getting list, convert the list

maven - Allow G zip compression in wildfly-8.2.0.Final -

i running java project on wildfly-8.2.0.final, , want enable g-zip compression web content (js, css ,jsp etc), how achieve it. i got done, need change standalone.xml search , make changes below <subsystem xmlns="urn:jboss:domain:undertow:1.2"> <buffer-cache name="default"/> <server name="default-server"> <http-listener name="default" socket-binding="http"/> <host name="default-host" alias="localhost"> <location name="/" handler="welcome-content"/> **<filter-ref name="gzipfilter" predicate="regex[pattern='(?:application/javascript|text/css|text/html)(;.*)?', value=%{o,content-type}, full-match=true]"/>** <filter-ref name="server-header"/> <filter-ref name="

java - How to impose common constraint on class with javax.validation library? -

i using bean validation constraints validate class instances @ run time. have many dtos each has multiple fields common constraint. want add constraint class applies properties of class. (as lombok @notnull constraint). e.g class person { @notnull private string name; @notnull private string address; @notnull private string contact; } i want make this. @notnull class person { private string name; private string address; private string contact } you cannot plain bean validation. adding @notnull class won't work. one potential approach utilize xml configuration. idea have own annotation mynotnull . framework need scan these annotations , build programmatic configuration class in question. example done via annotation processor during compile time. once have constraint mapping xml files add them jar , reference them in validation.xml . that's basic idea. personally, not sure whether worth effort.

Find the sum in 2d array with pointers in c -

i have tried "sum=6" , wrong. whats wrong code? here code: #include <stdio.h> #define row 2 #define col 3 int sum(int(*array)[3]); int main(void) { int a[row][col] = { {1 , 2, 3} , {4 , 5, 6} }; printf(" sum = %d\n", sum (a)); return 0; } int sum(int(*array)[3]) { int i,j, sum = 0; (i =0; < row ; ++) { (j =0; j < col ; j ++) { sum = sum + *(*( array +i )+j); } } } you forget return value of sum in function int sum(int(*array)[3]) { int i,j, sum = 0; (i =0; < row ; ++) { (j =0; j < col ; j ++) { sum = sum + *(*( array +i )+j); } } return sum; /* here */ } and notice sum = sum + array[i][j]; is more readable sum = sum + *(*( array +i )+j);

javascript - Enter keypress is not detected on keypress function -

i trying detect enter key press inside tinmyce editor , it's working fine keys not working enter key. setup : function (instance) { instance.on("keypress", function(e) { var keycode = (e.keycode ? e.keycode : e.which); alert(keycode); }); } in above code alerting keys except enter. don't know whats issue there. i think work, i've tested , works in fiddle jquery 2.24 $(document).keypress(function(e) { if (e.which == 13) { console.log('you pressed enter!'); } else { console.log('you pressed ' + e.which); } }); body { height: 500px; width:500px; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <body> </body> edit: sorry noticed after tagged tinymce i think can adjusting function //tinymce.init({ setup : function(instance) { instance.onkeydown.add(function(i

python - ImportError when integrating unittesting into bash script -

assume folder ' lib/ ' contains several unittesting files (ending in ' __unittest.py '). conduct unittesting on test files in said folder calling bash script called testing . michael$ python -m unittest discover -s ./lib/ -p '*__unittest.py' ................... ---------------------------------------------------------------------- ran 19 tests in 0.001s ok michael$ bash <(python -m unittest discover -s ./lib/ -p '*__unittest.py') ................... ---------------------------------------------------------------------- ran 19 tests in 0.002s ok michael$ echo "python -m unittest discover -s ./lib/ -p '*__unittest.py'" > testing michael$ bash <(cat testing) eee ====================================================================== error: checkingops__unittest (unittest.loader._failedtest) ---------------------------------------------------------------------- importerror: failed import test module: checkingops__unittest

sql - ERROR: duplicate key value violates unique constraint in postgres -

here slo_order_item_id unique constraint insert shb.sale_order ( slo_order_item_id, slo_order_id, slo_channel, slo_status, slo_channel_status, slo_order_date, slo_dispatch_by_date, slo_sku, slo_quantity, slo_selling_price, slo_shipping_charge, slo_vendor_id ) select distinct vss_order_item_id, vss_order_id, vss_channel_name, vss_sale_order_item_status, vss_sale_order_item_status, case when is_date(vss_order_date) vss_order_date::date else null end, case when is_date(vss_dispatch_date) vss_dispatch_date::date else null end, vss_sku, 1, vss

deployment - GitLab and it's webhook for Build events -

i've set own gitlab ce server ci in it. can create webhook deploy code server pushing it. (many matt jones , little invention ). however, still have 1 issue there. don't find description gitlabs new feature webhook build events. think i'll need this, since wish deploy code only after build succesfull. if set webhook push event, has no problem, inmediatly deploys code. can of provide me proper instruction, have make, achieve goal? thanks lot in advance! i use jenkins these purposes, can set preferences when deploy code , run pre , post build steps. it's useful , has gitlab integration web hooks.

How does home screen work in Kodi(XBMC)? -

Image
i wondering how scrolling through options feature works in kodi.. here, can scroll through videos, music, programs etc options when mouse pointer near bar, if mouse pointer in other part if screen, scrolling through mouse wheel won't work. want add similar button(i.e activated wheel when ponter in region) part of kodi(full screen video). can tell me how can or config files home screen located?? it depends on os. must locate skin folder (the default 1 skin.confluence ) , 720p folder. there find home.xml file contains contents seen on home screen. you can add new item under content group of <control type="fixedlist" id="9000">

unpivot - Dynamic unpivoting in Oracle -

i create view unpivots wide table. this: create view mylongtable select * mywidetable unpivot (value parameter in ( param1, param2, [continues ~200 entries] )); now, list param1, param2, ... should calculated dynamically. easiest way this? inner select won't work, unfortunately. easiest me, because have param s stored in table.

encryption - Java Keystore.getKey() slow while Key store size Increase -

i using java key store store , retrieve encryption key.it works faster while key store size small. once key store size increased key store operation goes slow. i working on linux platform, java version jdk_1.8. , safenet provider. i have been facing same issue related execution speed varies different operation system platform. jvm loads key store in memory. , having hashtable collection internal storage. hashtable synchronized. whenever perform operation key store, return in-memory key store not physical keystore. can confirm using ("top" - %wa section) command in linux base os. key store using hashtable , root cause behind performance decriment. i have solved issue loading keys keystore concurrenthashmap while initializing project. , later on, read operation performed map instead of keystore. , make sure write operation perform on both keystore , map.

html - Add Underline To <img> tag inside <a> tag -

Image
i have <a> tag has both text , image inside. want image , text underlined shown below: what keep getting though: as can see underline not extend under arrow. here code: <a target="_blank" href="http://url.com" style="text-decoration:underline;color:#000001;" >call action <img src="image/path/triangle.png" border="0" /></a> now can't put border-bottom on wrapping container because on mobile need text underlined , put border on bottom of text. you need style a border-bottom , remove text-decoration:underline <a target="_blank" href="http://url.com" style="border-bottom:1px solid red;text-decoration:none;color:#000001;">call action <img src="//lorempixel.com/20/20" border="0" /></a>

node.js - Pomelo app kill and remove servers automatically -

what circumstances kill pomelo app itself? the issue facing that, pomelo kills own application without throwing exception. when try run command 'pomelo list', shows no server running. app gets close after few hours of running , automatically well. have gone through logs generated pomelo on each server there no exception or blockage app. below details might guys: we using distributed server structure of pomelo framework mongodb on different server redis instance on master-server itself pomelo version 1.2.1 we running same architecture our different multi-player games haven't gone through such issues ever. can explain why might happening? if need other info please ask same.

ios - App rotating to landscape left and right, when landscape "right" is explicitly chosen. Xcode 7.2.1 -

Image
can tell me why happening? there anywhere else needs defined? //appdelegate - (nsuinteger)supportedinterfaceorientations { return uiinterfaceorientationmasklandscaperight; } - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation { return (interfaceorientation == uiinterfaceorientationlandscaperight); //return no; } -(bool)shouldautorotate { return no; } i found interface orientation method in app delegate. @matt's comment, made me take harder look. returning landscape, changed landscape right , fine now. - (uiinterfaceorientationmask)application:(uiapplication *)application supportedinterfaceorientationsforwindow:(uiwindow *)window { if (([window.rootviewcontroller.presentedviewcontroller iskindofclass:[uiimagepickercontroller class]]) && (window.rootviewcontroller.presentedviewcontroller.isbeingdismissed == no)) { return uiinterfaceorientationmaskportrait; } //return uiinterfaceorientationmask

docusignapi - Retrieving information from a signed document entered by the signer using DocuSign API -

i have added texttabs signer in envelope using docusign api. request information user has entered texttab. how can that? i found following hint: retrieving information signed document docusign api but when looking rest api documentation stated api retrieves original value (originalvalue) of tab when sent recipient. that behaviour had discovered. there exist other method retrieve data entered signer? here 2 approaches tab values envelope: 1) envelopes/(envelopeid)/recipients?include_tabs=true. return tab values every recipient on envelope. not include originalvalue property of tab though. 2) envelopes/(envelopeid)/recipients/(recipientid)/tabs. need explicitly hit tabs endpoint every recipient. display originalvalue property. example: ../envelopes/5ad452d5-3004-4b8b-b4d1-ef90f02f2c45/recipients/1/tabs

google play - Is the app developer the same as the app owner? -

if ask app development company host app on app store or google play store accounts, make them legal owners of app? i want stay legal owner of app. affect ownership rights means? to ensure ownership of app concept, ip , confidentiality:- - sign ip rights document dev company. - sign nda dev company. you might need more documents depending upon laws of country, step not possible without consulting lawyer. also, need ensure that:- - source code proper documentation. - also, make sure there no encrypted files/libraries present in source code. since, 2013 apps can transferred between accounts if happen create 1 later. ================================ on flip side why want such mess? it easy , cheap create developer account. straighforward paperwork , not more 100$ each platform (compared amount of resources have invested in creating app) once have account, give dev company developer access account. can upload app account it. once done , have ensured have sou

WSO2 API Manager publishing runtime data to DAS, but No Data Available in UI -

i'm using independent wso2 api manager 1.10.0 , wso2 das 3.0.0 have configured rest client publishing statistics published event , i'm able see data in wso2am_stats_db datasource (api_request_summary,...) the strange problem statistics showing in publisher ui interface (api subscriptions,api response times,api last access times) in other pages i'm getting no data available message explication strange message i think setup working fine. see data in am_stats_db means published data being analyzed , stored there. there pages in stats page show message "no data available" if there no relevant data. example "faulty invocation", "throttled out requests" pages. if invoke api wrong token, appear in faulty invocation page. if send requests api until throttled out (high tps), appear in throttled out requests page.

python - Pandas DataFrame - Adding rows to df based on data in df -

apologies not specified title. i've been, unsuccesfully far, trying come way add new 'rows' pandas dataframe based on contents of of columns. hope make clear example. data mock-up data suffices in painting bigger picture. so, lets car dealer has, among others, following 7 customers. in dataframe can see customer-id, gender (because why not), , country live in. in addition, can see whether they've bought of 4 car brands (and type of car) or not (na) (all values in dataframe strings btw). example, customer 4 female russia, , has bought porsche 911 dealer. cust-id sex country audi ferrari porsche jaguar 0 cu1 f fr r8 ff na na 1 cu2 m na na na xf 2 cu3 m uk rs7 na na na 3 cu4 f ru na na 911 na 4 cu5 m na na 918 ford 5 cu6 f s6 na na f-type 6 cu7 m uk a8 na ma

node.js - electron url scheme "open-url" event -

i did following in index.js ; electron.remote.app.on("open-url", function(event, url) { console.log("open url: " + url); }); this gets triggered in mac os, not in windows. there event or different way in windows? this mac-only feature. closest alternative app.makesingleinstance(callback) . you can arrange app launched url argument: myapp my-scheme://stuff then callback called url in whichever app process launched first.

apache karaf - How to install opendaylight restconf -

anybody know how install opendaylight restconf in custom karaf distribution. tried adding rest conf feature repo , tried feature install. fail saying odl-config-persister missing. when try install odl-config-persister error come. there other way install opendaylight restconf in karaf. start karaf , verify if have feature: feature:list | grep 'restconf' if so, can install it, "feature:install feature-name": feature:install odl-restconf-all

javascript - getelementbyid().click not working -

i making website whenever click , x equal range of numbers, plays audio, after click once when x between numbers, play if x not in range. please help. here code. way, not use jquery because not work on chrome. if(x<=1200&&x>=600){ var n=true; }; if(x<=1200&&x>=600&&n==true){ document.getelementbyid('a').onclick = function(){ audio.play(); n=false; } } else{n=false} what code adds click event listener on element, , afterwards click handler trigger regardless of x value because don't have checks inside click handler. the solution create click listener once, , check value of x inside it. this: document.getelementbyid('a').onclick = function(){ if(x <= 1200 && x >= 600 && n == true) { audio.play(); n = false; } } see (i've replaced audio playing div highlighting, it's same principle): var r = document.getelement

handwriting recognition - Is it possible to extract text from handwritten notes in OneNote? -

for project looking ways extract text handwritten notes in onenote. idea 1 can write notes in onenote , application reads notes , saves text file somewhere else. i have read rest api , know there many ways submit content onenote, not sure extracting handwritten ("ink" ?) content it. the onenote apps across multiple platforms have varying degrees of ability analyze ink strokes , recognize text. e.g. in windows desktop app, you can convert handwriting text . but extracted text not supported rest apis today.

excel - Google spreadsheet - Formula does not show negative time -

i have google spreadsheet write down working time. example there following records g9 | 05:05 h9 | 06:30 now want calculate if there time left or not. first try: =if(g9>0;g9-h9;0) second try: =if(g9>0;if(g9<h9;g9-h9;h9-g9);0) unfortunately both ends time 22:35 . because calculation below 0 let system think should start 24:00 . how can display value -1:25 or vice-versa positive times ( 1:05 e.g.) dynamically formula? i have tried change format of field, doesn't work since display times negative ones, when positive. edit: as information if has troubles work text values. @words mentioned have convert value. need function if want work arrays: =sum(arrayformula(value(i2:i32))) one can convert time string text , , prepend "-" when needed: =if(g9>=h9, text(g9-h9, "h:mm"), "-" & text(h9-g9, "h:mm")) the result string, if it's needed in later computations 1 can still recover original valu

beautifulsoup - UnicodeEncodeError when printing beautifulsoup4 get_text() in Python -

i'm running pretty simple script in python data url: import urllib2 bs4 import beautifulsoup def get_data(): response = urllib2.urlopen('http://www.p2016.org/photos15/summit/trump012415spt.html') html = beautifulsoup(response, 'html.parser') text = html.get_text() return text print get_data() i keep getting error message: ps c:\users\ben\pythonlearning\markov_chain> python fetch_data.py traceback (most recent call last): file "fetch_data.py", line 11, in <module> print get_data() file "c:\python27\lib\encodings\cp437.py", line 12, in encode return codecs.charmap_encode(input,errors,encoding_map) unicodeencodeerror: 'charmap' codec can't encode character u'\xa9' in position 22825: character maps <undefined> i've tried: running without print command, , no error having on computer run exact same code, , works. the difference encounter between error , &qu

javascript - How to show only particular number of data and hide remaining with more link -

i want show notes of user on page want show first 200 characters , after there link of more navigate user on page. completed more link part don't know how show 200 characters , hide remaining link. extract first 200 characters text , display in div var smallcontent = divcontent.substr(0, 200) + ".."; https://jsfiddle.net/cmpbehf1/1/

spring - How can I run test by JUnit4, with more threads? -

this question has answer here: running junit tests in parallel in maven build? 9 answers i have unit test class, , execute test spring junit4. tests execute 15 minutes, because test runs 1 one. here problem. test won execute continuing integration. after every commit need wait 15 minutes, , not acceptable. how can execute test more 1 thread, or tests execute in parallel? e.g mean,run @test method in parallel,not 2 different class in parallel. if have 60 test methods in 1 class,execute 60 methods simultaneously. configure maven surefire plugin runs in parallel: <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-surefire-plugin</artifactid> <version>2.19.1</version> <configuration> <parallel>methods</parallel> <threadcount>10</threadcount&

TFS 2015 - XAML build progress inside Visual Studio 2015 -

this question has answer here: stop opening tfs builds in browser instead of ide 3 answers we've upgraded tfs 2015 - working although i've noticed when queue 1 of our xaml builds visual studio , double click build check progress, opens team foundation web ui (in browser) used open status window within visual studio itself. the web based build progress screen missing key information - time taken each step of build (we have part of build a thread.sleep whilst servers drained , there no way see how far through step timestamps not outputted on web build status page). is there way a) open build summary in visual studio tfs 2013 did? or b) tfs show timestamps against each individual step of build in web ui status page? see stop opening tfs builds in browser instead of ide i'm using build explorer tool codeplex in order build details.

How to pass dynamic source to Mapper.CreateMap<source, destination> method in automapper -

i have scenario have pass source class dynamic. tried generic type class not working. public virtual void mapattributefact<t>() { mapper.createmap<t, dto.tabrender.attribute>() .formember(dest => dest.ismultiselect, src => src.mapfrom(opt => opt.multiselect)) } please me how pass dynamic. thanks in advance

matlab - how to make the second gui wait until the first one finishes? -

i have 2 consecutive guis in 1 function. how can make second 1 waits until push exit button on first one. searched in internet , says use uiwait, should use it? should menstion first gui contains 3 buttons 1 of supposed programmed quit gui. thanks in advance uiwait should used in first gui, before launching second. e.g.: uiwait( launch_second_gui );

javascript - Does jQuery have an AJAJ method? -

does jquery have method asynchronous javascript , json (ajaj), jquery.ajax() asynchronous javascript , xml ? also noticed there isn't ajaj tag. the acronym 'ajax' created in day, when xml format used data returned. today, data format returned typically json, still use acronym ajax -- asynchronous http request , response. data format returned can makes sense implementation; technology behind same. use jquery.ajax json. jquery has shorthand method at, getjson .

html - Order column CSS -

i'm working on website , i've code : .container { -webkit-column-count: 4; -webkit-column-gap: 1em; } .container div { background-color: lightblue; display: inline-block; margin: 0 0 1em; width: 100%; } <div class="container"> <div>1 .lorem ipsum dolor sit amet, consectetur adipisicing elit. facere natus amet, architecto maxime cum adipisci, deleniti quasi non sed, totam accusamus placeat quibusdam ipsam?.</div> <div>2. sit ducimus delectus labore veritatis dicta earum fugit cum repellat est perspiciatis impedit, architecto ut officiis placeat quidem aspernatur dolores assumenda nostrum dolorem quo rerum hic? repudiandae facilis, cum dignissimos.</div> <div>3. libero enim saepe magnam eaque ratione odio deleniti, nostrum ullam eum ea eveniet hic voluptatum tempora voluptatibus voluptates asperiores, aut laudantium rem quod minus cum accusantium placeat blanditiis esse. pr

Is it possible to implement a class constructor type converter in Scala -

as example have class import java.sql.timestamp class service(name: string, stime: timestamp, etime:timestamp) how make accept following in implicit way, let called stringtotimestampconverter val s = new aservice("service1", "2015-2-15 07:15:43", "2015-2-15 10:15:43") time have been passed string. how implement such converter? you have 2 ways, first having in scope string => timestamp implicit conversion // have in scope before instantiate object implicit def totimestamp(s: string): timestamp = timestamp.valueof(s) // convert timestamp the other 1 adding constructor class: class service(name: string, stime: timestamp, etime:timestamp) { def this(name: string, stime: string, etime: string) = { this(name, service.totimestamp(stime), service.totimestamp(etime)) } } object service { def totimestamp(s: string): timestamp = timestamp.valueof(s) // convert timestamp }

mvvm - How to save VM back to Server with KnockoutJs -

Image
i have asp.net mvc5 app ef 6 on server. site has dozen or pages, each of has grid displaying business data many columns. certain users not interested in of columns on of pages (views) need way them indicate views make visible. on database, view has many columns , user can designate column of view displayed (and stored in userviewcolumn table): i using following viewmodel pass data selected database view: public class userprefsviewmodel { public icollection<vmuser> users { get; set; } public userprefsviewmodel() { this.users = new list<vmuser>(); } } public class vmuser { public int userid { get; set; } public string adlogondomain { get; set; } public string adlogonid { get; set; } public list<vmview> views { get; set; } } public class vmview { public int viewid { get; set; } public string name { get; set; } public list<vmc

python - How to make django task.py code editable in admin panel? -

i have functions tasks in tasks.py file in django , want able edit code of each task in administration panel. there way of doing this. if possible, able add more tasks in tasks.py file directly through administration panel without having go tasks.py file add new task function. if can point me in right direction, appreciated. as peter saying bad idea. if must it, below 1 might little better: create view render form, user can choose task name, class name, , text area write function or task (or) totally new task.py (as per requirement). once submitted, in backend check pep8 code formatting , (having copy of entire source code in server/somewhere) , copy new file there , run python manage.py shell basic sanitize code. restrict access form based on users model (users). again peter saying totally spectacular security hole.

ruby on rails - "Invalid association": nested_form_for with has_many through -

i trying dynamically add arbitrary number of ingredients shoppping list using nested_form gem. has_many through relationship, , i'm having trouble finding need. i'm getting following error when trying render new action: invalid association. make sure accepts_nested_attributes_for used :ingredients association. here models: class shoppinglist < activerecord::base has_many :shopping_list_ingredients has_many :ingredients, :through => :shopping_list_ingredients accepts_nested_attributes_for :shopping_list_ingredients, allow_destroy: :true end class ingredient < activerecord::base has_many :shopping_list_ingredients has_many :shoping_lists, :through => :shopping_list_ingredients end class shoppinglistingredient < activerecord::base belongs_to :shopping_list belongs_to :ingredient end my shopping_list_controller.rb: class shoppinglistscontroller < applicationcontroller def index @shopping_lists = shoppinglist.all end d

java - How can I use HashMap values to form a String? -

i have following code maps specific string characters letters: string = "94466602777330999666887770223377778077778 883 336687777"; string[] tokens = a.split("(?<=(.))(?!\\1)"); map<string, string> hmap = new hashmap<string, string>(); hmap.put("2", "a"); hmap.put("22", "b"); hmap.put("222", "c"); hmap.put("3", "d"); hmap.put("33", "e"); hmap.put("333", "f"); hmap.put("4", "g"); hmap.put("44", "h"); hmap.put("444", "i"); hmap.put("5", "j"); hmap.put("55", "k"); hmap.put("555", "l"); hmap.put("6", "m"); hmap.put("66", "n"); hmap.put("666", "o"); hmap.put("7", "p&quo

get dns/dhcp address powershell 4.0 -

using powershell return dns servers , dhcp address variables. have tried get-dns cmdlet powershell doesn't recognize it. it should return ex. $dns1 = 1.1.1.1 $dns2 = 2.2.2.2 $dhcp = 3.3.3.3 below command gives properties of network adapter configuration: get-wmiobject win32_networkadapterconfiguration | select * using inside parenthesis give access individual properties of output: (get-wmiobject win32_networkadapterconfiguration | select *)[2].dhcpserver (get-wmiobject win32_networkadapterconfiguration | select *)[2].dnsserversearchorder here [2] index number of network adapter looking @ (if have multiple)

python - secant method rungekutta schrodinger -

so trying use secant method find ground state energy, have tried multiple ways far , of them returning errors. code far : import numpy np import matplotlib.pyplot plt %matplotlib inline ###first importing modules me = 9.1094*10**-31 hbar = 1.0546*10**-34 ec = 1.6022*10**-19 ###defining constants need, electron mass, h bar , electron charge = 5*10**-11 ###halfwidth of n = 1000 xsteps = (2*a)/1000 xpoints = np.arange(-a,a+xsteps,xsteps) ###array of calculation points inside ###using a+xsteps ends @ x=a, , not @ x=a-step def v(x): if abs(x)<a: v=0 else: v=10**15 return v ###can modified add other variables, should return v=0 steps def s(r,x,e): ###where r vector comprised of phi , psi psi=r[0] phi=r[1] fpsi=phi ###function of dpsi/dx fphi=((2*me)/hbar**2)*(v(x)-e)*psi ###function of dphi/dx return np.array([fpsi,fphi]) r=np.array([0,1]) ###initial conditions def rungekuttaschrod1(r,xpoints,e): ps

python - remove symbols from string -

i have file like: @hwi abcde + @hwi7 efsa + ???=af gtey@jf gvtawm i want keep strings ( remove contains symbol ) i tried : import numpy np arr = np.genfromtxt(f, dtype=str) line in np.nditer(arr): if np.core.defchararray.isupper(line) , not '@?=;?+' in line: print line but gives : @hwi abcde @hwi7 efsa ???=af gtey@jf gvtawm and expecting: abcde efsa gvtawm i want use numpy , not commands regex or similar. this solution : import numpy np arr = np.genfromtxt('text.txt', dtype=str) test = np.core.defchararray.isalpha(arr) #create mask : true = str , false = not str print arr[test] #use mask on arr , print values don't use if numpy ! have indexing ;) i : ['abcde' 'efsa' 'gvtawm']

Maintain coldfusion j2ee session using URL parameters with cookies disabled -

i cannot seem session preserve j2ee enabled , browser cookies disabled using session.urltoken append session information link. i need specific solution these exact criteria because of following limitations: we have on 2500 templates , trying avoid adding urlsessionformat() every link. we have internal variable include on every link ( link.cfm?#ourvariable# ) set single login verification template. we'd reuse variable insert session.urltoken when necessary. we'd prefer use j2ee. code works fine cf session management. 1/3 of our users not allow cookies , cannot force them to. in locked down environment old browsers. now, test case..... application.cfc: <cfcomponent> <cfset this.name = "test" /> <cfset this.sessionmanagement = true> <cfset this.sessiontimeout = createtimespan(2,0,0,0)> </cfcomponent> index.cfm: <cfoutput> <cfset session.testme = 123 /> <a href="#url

c++ - Create a map of objects without destroingthe objects -

this question has answer here: why default constructor required when storing in map? 4 answers i trying create map contains objects different arguments. but found after inserting pair, object destroyed. if try use function in object.for example: #include <map> #include <iostream> class test{ public: test(double value) : value_(value){} ~test(){std::cout<< "destroyed";} void plusone() {value_ += 1;} private: double value_; }; int main(){ std::map<long, test> map; map.insert(std::make_pair(1, test(1.2))); map[1].plusone(); return 0; } it show: [error] no matching function call 'class::class()' [note] candidate expects 1 argument, 0 provided how can this? the syntax map[1] can used when mapped type has default constructor. because if key not found

html - How to center and corner flex items in flexbox? -

i trying learn flexbox having trouble getting want. what want: 1 box have 2 labels (a number on top label) second box have 4 labels (1 in top left, 1 in top right, 1 in center , 1 in bottom middle) .flex-container { display: flex; background-color: lightgrey; flex-direction: row; align-items: stretch; align-content: stretch; } .flex-item { display: flex; background-color: cornflowerblue; margin: 10pt; } .flex-item-2 { display: flex; background-color: cornflowerblue; margin: 10pt; flex: 2 0 0; } .flex-qty-container { font-size: 27pt; margin: 0; } .flex-sub-container { display: flex; background-color: yellow; flex-direction: column; flex-wrap: wrap; align-items: flex-start; flex: 2 0 0; } .flex-item-left-corner { background-color: red; } .flex-item-right-corner { background-color: red; align-self: flex-end; font-size: 10pt; }

angular - service (which have dependencies) unit tests with angular2 -

i'm starting angular2 unit tests , running problems. have service accepts parameters applicationref , componentresolver service uses componentresolver load component dynamically. question how can pass in unit tests service above parameters? does example you: import {component, provide} '@angular/core'; import {componentfactory} '@angular/core/src/linker/component_factory'; import {componentresolver, reflectorcomponentresolver} '@angular/core/src/linker/component_resolver'; import {reflectioninfo, reflector} '@angular/core/src/reflection/reflection'; import {aftereach, beforeeach, beforeeachproviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} '@angular/core/testing/testing_internal'; import {asynctestcompleter} '@angular/core/testing/testing_internal'; import {console} '../../src/console'; class dummyconsole implements console { log(message: string) {} warn(message: string) {} } expo

android - setOnClickListener error - cannot resolve symbol -

i want create button which, when clicked, show intent. this code: <button android:text="bine ati venit!" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/button1" android:background="#479fc7" android:textsize="40dp" android:textcolor="@color/colorprimarydark" android:textstyle="normal|bold|italic" android:textallcaps="false" android:fontfamily="casual" android:onclick="next_page"/> and .java class: protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_welcome); } button button = (button) findviewbyid(r.id.button1); button.setonclicklistener( new view.onclicklistener() { public void onclick (view v){ next_page(v); } }); public void next_page(view v) { intent intent = new intent(thi

templates - Excel 2013 - "At startup, open all files in": only works first time -

afternoon all, i've upgraded office 2013 , i'm trying grips it. since excel 2003, through 2007 , 2010 have created , used standard templates new workbooks , sheets store in specific location. use "at startup, open files in" option in advanced excel options reference location each time new workbook or sheet opened, uses templates. in excel 2013 works in first workbook workbook after open opens standard. if create new instance of excel holding down alt when click on it, works correctly. seems if change in excel 2013 open workbooks in same instance behave separate instances has downside of startup files not being accessed. does know how correct or around this? edit: same problem if use default xlstartup folder slidersteve

r - ggplot2 avoid boxes around legend symbols -

Image
consider example plot below. i'd make little boxes around each of symbols in legend go away. how this? ggplot(mtcars, aes(wt, mpg, shape=factor(cyl))) + geom_point() + theme_bw() you're looking for: + opts(legend.key = theme_blank()) you can see lots of examples of sorts of stuff in ?opts . couldn't remember off top of head 1 was, tried few until got right. note : since version 0.9.2 opts has been replaced theme : + theme(legend.key = element_blank())

c# - How do I create a model using AJAX in ASP.NET MVC 5 -

currently can create models regularly (by going settingprofile/create) but when try use ajax send data wrapped in settingprofile js object returns http 500 internal server error error, believe problem in data type. correct way of calling create method in ajax? my code: model: public class settingprofile { [databasegenerated(databasegeneratedoption.identity)] public int id { get; set; } public string name { get; set; } public long? userid { get; set; } public string url { get; set; } } view (js): function savesettingprofile() { var name = prompt("please enter profile name", ""); var url = $("form").serialize(); // not ajax url, variable in model var settingprofile = { name: name, url: url }; jquery.ajax({ url: "@url.action("create", "settingprofile")", contenttype: "a

Meteor authentication and react-router -

how meteor re-render components when sign in using accounts-password package? my react-router routes are: import react, { component } 'react' import reactdom 'react-dom' import { router, route, indexroute, browserhistory } 'react-router' import app './containers/app' import recordings './containers/recordings' import landingpage './containers/landingpage' import { bloodpressure } '../collections/bloodpressure' const routes = ( <router history={browserhistory}> <route path="/" component={app}> <indexroute component={landingpage} /> <route path="dashboard" component={recordings} /> </route> </router> ) meteor.startup( ()=> { reactdom.render(routes, document.queryselector('.render-target')) }) my app component is: import react, { component } 'react' import { createcontainer } 'meteor/react

jquery - Rails 4 Dynamic Collection_Select -

this seems pretty popular question here, though have yet find tutorial or thread works me. have 2 dropdown menus in form, team type , user role, user role dependent on team type. options team type stored in model array, since there 5 choices (artist, venue, promoter, independent, other). source selections user role model well, proper array selected depending on team type. possible, or need create models each team type , pass id join table select proper user role? thank you. model class waitinglist < activerecord::base companies = ['—select—', 'artist team', 'venue team', 'promoter', 'independent', 'other'] artist_team = ['-select-', 'artist', 'manager', 'tour manager', 'production manager', 'agent', 'other'] venue_team = ['-select-', 'artist liason', 'stage manager', 'production manager', 'owner', 'other'] promoter =