Posts

Showing posts from June, 2013

gaps and islands - SQL interview question -

gaps and islands - SQL interview question - i got next question on interview: given table of natural numbers missing ones, provide output of 2 tables, origin of number gap in first table , ending in second. example: ____ ________ | | | | | | 1 | | 3 | 3 | | 2 | | 6 | 7 | | 4 | | 10| 12| | 5 | |___|___| | 8 | | 9 | | 13 | |____| while pretty much same phil sandler's answer, should homecoming 2 separate tables (and think looks cleaner) (it works in sql server, @ least): declare @temp table (num int) insert @temp values (1),(2),(4),(5),(8),(9),(13) declare @min int, @max int select @min = min(num), @max = max(num) @temp select t.num + 1 range_start @temp t left bring together @temp t2 on t.num + 1 = t2.num t.num < @max , t2.num null select t.num - 1 range_end @temp t left bring together @temp t2 on t.num - 1 = t2.num t.num > @min , t2.num null sql gaps-and-islands

parallel processing - Port old X10 Example to version 2.5 -

parallel processing - Port old X10 Example to version 2.5 - i have old x10 illustration in class i'm trying compile. import x10.array.array; import x10.io.console; ... public static def main(args: array[string](1)) { val regiontest = 1..12; val testarray = new array[int](1..12, (point)=>0); ([i] in testarray) { testarray(i) = i; console.out.println("testarray("+i+") = " + testarray(i)); } } unfortunately seems outdated. figure out myself have write public static def main(args:rail[string]) now. definition of val regiontest = 1..12 seems ok. syntax array must wrong, next lines maybe too. tried prepare this guide, did not succeed. my setup working, initial class in new x10 eclipse ide project runs. could help me port version 2.5.x? there number of non-backward-compatible changes in x10 version 2.4, require code changes - see guide "porting x10 2.4". your illustration updated follows: ...

javascript - How to use Angular-fullstack without server components? -

javascript - How to use Angular-fullstack without server components? - i way angular-fullstack scaffolds project. have info served through restful api. don't need server components. there way, can utilize client part , remove server components ? update: aware of generator-angular scaffolding way fullstack scaffolds. thanks. using angular generator improve choice. deals front-end (such case). update the guys behind angular-fullstack started part of de-coupling. check ng-component generator. javascript angularjs node.js yeoman angular-fullstack

ssl - Nginx self-signed certificate isn't working on a Vagrant VM -

ssl - Nginx self-signed certificate isn't working on a Vagrant VM - we're running vagrant vms here. on vm, installed nginx. created self-signed certificate. when @ certificate's innards, see: subject= /c=us/st=in/l=mycity/o=my company/ou=myproduct/cn=silly.com/emailaddress=info@silly.com this sanitized. believe certificate supposed work silly.com . interpret correctly? on laptop, added hostfile entry map silly.com appropriate ip address. on vm, added next configuration /etc/nginx/conf.d/default.conf # https server server { hear 443; server_name silly.com; ssl on; ssl_certificate /etc/nginx/ssl/silly.crt; ssl_certificate_key /etc/nginx/ssl/silly.key; } when browse site, port 80 http screen displayed properly. when browse https://silly.com , however, https portion rejected , non-ssl screen displayed. (i think clicked 'proceed' while experimenting...) i commented nginx.conf file lines relating port 80. restarted nginx. s...

c# - Why does the source code for the Guid constructor contain the line "this = Guid.Empty"? -

c# - Why does the source code for the Guid constructor contain the line "this = Guid.Empty"? - if source code constructor of guid(string) in .net 4.5.2 source code follows: public guid(string g) { if (g==null) { throw new argumentnullexception("g"); } contract.endcontractblock(); = guid.empty; guidresult result = new guidresult(); result.init(guidparsethrowstyle.all); if (tryparseguid(g, guidstyles.any, ref result)) { = result.parsedguid; } else { throw result.getguidparseexception(); } } the question purpose of line this = guid.empty; ? from can see if string g can parsed in tryparseguid method this assigned. if can't exception thrown. suppose wrote: var guid = new guid("invalidguid"); this cause exception , value of guid undefined assume. why need assign this guid.empty ? this more matter of style else - functionally it's superfluous , compiler may o...

c# - Problems rendering image from database byte field using WebImage -

c# - Problems rendering image from database byte field using WebImage - i have asp.net mvc 5 app database stores photos. i'm trying read photo , resize display in staff profile. i'm new both asp.net mvc , c# i setup next controller not getting image display when utilize link controller in img tag. any help appreciated. public actionresult index(int id) { staff staff = db.stafflist.find(id); if (staff.photo != null) { var img = new webimage(staff.photo); img.resize(100, 100, true, true); var imgbytes = img.getbytes(); homecoming file(imgbytes, "image/" + img.imageformat); } else { homecoming null; } } looking around seems there's lot of dissatisfaction webimage class , has few prominent bugs. settled on using nuget bundle called imageprocessor rather trying write own. seems inefficient me don't have improve ...

python - How to add workers to django celery scheduler -

python - How to add workers to django celery scheduler - i have celery running in django , several periodic tasks added. tasks (task-a) take long time run, maybe 30 minutes , 1 of other tasks (task-b), must run each 5 minutes. the problem have task-b, must run each 5 minutes, doesn't start until task-a has finished. i can't find misconfigured. is there way tell celery scheduler allow several tasks in parallel? thanks further investigation, concluded problem have 1 worker django scheduler, not find how add together more workers django celery scheduler. there way add together more workers? python celery django-celery celerybeat djcelery

jboss - Different result in operating Tomcat between development & actual environment -

jboss - Different result in operating Tomcat between development & actual environment - i compile web application war file in test environment (windows 7 32bit/ eclipse). works in test environment when set war files tomcat server in test environment. however, when set war files real server, tomcat boots successfully, error below when seek log in web application. error come jboss library (db script same, should no problem on source code or connected database). wondering if 1 can help me figure out wrong.... advice appreciated. the test environment & actual environment win7 32bit. the java oracle jdk/jre 1.8.x the business relationship authorization administrator. development environment ox eng version, , tranditional chinese =================================================================== 2015-04-09 13:03:57,622 info [http-bio-8080-exec-4] (configreader.java:49) - loading module configuration from:d:\program files\tomcat\apache-tomcat-7.0.59\webapps\colibri...

Zend Framework 2 ZF tool creating controller -

Zend Framework 2 ZF tool creating controller - when seek create new controller in zend framework 2.4 application, using next zf tool command: zf create controller author index-action-included=1 author c:\wamp\www\zendapp i next error: reason failure: invalid arguments or no arguments provided but when remove index-action-included=1 , zf tool creates controller without problems. what i'm missing? if want create index action, created default. if don't want create think should this: zf create controller author author c:\wamp\www\zendapp 0 zend-framework2 zend-tool

android - Customize ActionBar tabs -

android - Customize ActionBar tabs - the traditional way implement actionbar tabs has been deprecated. have implemented tabs guide github tabs. however have problem styling tabs guide. seems can style tabs through java code this: slidingtablayout .setcustomtabcolorizer(new slidingtablayout.tabcolorizer() { @override public int getindicatorcolor(int position) { homecoming color.red; } }); this alter color of indicator, want alter background of tabs in both selected, deselected , pressed states. tradional way alter theme , create xml file this: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- states when button not pressed --> <!-- non focused states --> <item android:state_focused="false" android:state_selected="false" android:state_pressed="false...

java - Why does j8583 Configparser fails with no default value to template fields? -

java - Why does j8583 Configparser fails with no default value to template fields? - i using j8583 build , parse iso messages. have template , parse config.xml in place, when there no default values specified template fields fails nullpointerexception. below template fails nullpointerexception. field 3 doesn't have default value. <template type="0200"> <field num="3" type="numeric" length="6"></field> <field num="32" type="llvar">456</field> <field num="35" type="llvar">4591700012340000=</field> <field num="43" type="alpha" length="40">solabtest test-3 df mx</field> <field num="49" type="alpha" length="3">484</field> <field num="60" type="lllvar">b456pro1+000</field> <field num="61" type="lllvar...

android - CheckBox OnCheckedChangeListener() called after recycled? -

android - CheckBox OnCheckedChangeListener() called after recycled? - problem i created custom expandablelistadapter handle checkboxes correctly when childrow clicked. added oncheckedchangelistener checkbox , passed item wanted operate on tag. weird things start happen when view clicking on got recycled(i beleive). expand parent, mark child, works fine, , when collapse parent , expand parent oncheckedchangelistener kid clicked before fired. isnt consistant, works not. question what making checkboxes alter state , how can avoid it? works fine exept these "random" changes of state. very simplified code @override public view getchildview(int groupposition, int childposition, boolean islastchild, view convertview, viewgroup parent) { convertview = mlayoutinflater.inflate(r.layout.site_picker_list_item_child1, null); checkbox checkbox = (checkbox) convertview.findviewbyid(r.id.site_test_child_selected); final objecta obj = getchild(groupposition, chil...

ruby on rails - Extract column names dynamically without having to hardcode -

ruby on rails - Extract column names dynamically without having to hardcode - i building admin page displays tables database. want without hardcoding column names. right now, hardcoding values in view display values database table. how can extract column names db without having hardcode column names , print them in table format. way if have 10 tables, can phone call table , print column names extracting information. here code: model: class product < activerecord::base end controller: class admincontroller < applicationcontroller def index @products = products.all end end view: <h3 class="sub-header">product</h3> <table border='1' class="table table-striped" width="200"> <tr class="success"> <th>id</th> <th>url</th> <th>url id</th> <th>price id</th> </tr> <% @products.eac...

Android - Run application on SDK 2.1 -

Android - Run application on SDK 2.1 - basically, have purchased htc hero (android sdk 1.5) , got notification of "system software update" , agreed update sdk 2.1-update1 . i developing application android sdk 1.5 successfully, have created hello world application android sdk 2.1 , when trying run on updated phone, @ time below screen showing up: where can see ?????? in serial number , taget shown "unknown". on console window, showing error: "automatic target mode: unable observe device compatibility." (1st question): need run application(sdk 2.1) developing ? pls allow me know and ya, when trying connect phone using usb cable, showing alert dialog regarding "choose connection type:" showing below options: charge only htc sync disk drive internet sharing (2dn question): mode should select development of application , running on phone. maybe udev rules have modified. read this guide prepare them. don't know why ...

pid - Stop cron job from starting while it's already running (even across servers) -

pid - Stop cron job from starting while it's already running (even across servers) - i don't think exact duplicate of other questions, sense free point me somewhere if it's been answered. i'm looking way have cron job start running if isn't running. example, if job runs every 15 minutes takes hr run, don't want duplicate processes start , overlap original job doing. in other questions others have talked making pid file stops job starting duplicates (or similar strategies), case little different. have multiple machines run cron jobs, , want currently-running process on of them stop new instances of job starting. pid file wouldn't enough, since local 1 machine. what best way of dealing situation? a pid file on shared folder? cron pid

excel 2007 - IF Cell A1 = Yes then Fill Red Color in B1 -

excel 2007 - IF Cell A1 = Yes then Fill Red Color in B1 - i have worksheet in excel-2007 if cell a1 has value of 'yes' in want cell b1 filled in reddish color (irrespective of content in cell b1). about conditional formats. expand formulas formatting criteria, expand example 3. example workbook available. excel-2007

emacs - How can I get a variable's initial value in Elisp? -

emacs - How can I get a variable's initial value in Elisp? - in emacs lisp, there function initial value of symbol initilized defvar ? some-function shown below: (defvar var "initial value") (setq var "changed value") (some-function 'var) => "inital value" emacs doesn't remember initial value. if evaluate (defvar var "initial value") (setq var "changed value") in *scratch* buffer, "initial value" no longer available, total stop. if defvar performed in loaded file, emacs remembers it's loaded from; (symbol-file var 'defvar) returns file name, , can original look variable initialized (but not original value), assuming file still around. available via command m-x find-variable. emacs elisp

Weka, dataset for twitter has error when open the file -

Weka, dataset for twitter has error when open the file - i want utilize dataset test, when open file via weka, show this:wrong number of values.read 3,expected 2,read token[eof],line 3 the sec , 3rd line info this: 2: ham || go until jurong point, crazy.. available in bugis n great world la e buffet... cine there got amore wat... 3: ham || ok lar... joking wif u oni... "||" means limit different rows so how can prepare it? hope help, give thanks you twitter dataset weka

itunes - Why does Apple require podcasts to use both new-feed-url and a redirect? -

itunes - Why does Apple require podcasts to use both new-feed-url and a redirect? - why apple require podcasts utilize both <itunes:new-feed-url> tag , redirect? seems redirect gives exact same info less info required. should podcast client's behavior when location header , tag's value differ? here current best guess: itunes wants allow podcast owners create redirects part of actual fetching process. instance, podcast's feed url be http://example.com/crawl/step1 if redirect /crawl/step2 , , itunes considered redirect same feed move, never go /crawl/step1 again. but tag, redirects can part of crawling process. itunes podcast

text file: how to remove line break if line does not start with number? (in emacs or sed) -

text file: how to remove line break if line does not start with number? (in emacs or sed) - i have text file (data base of operations output) many line breaks, i have remove of line breaks (but not of them). i managed hand, there many lines (thousands), automated solution helpful. the aim in end have lines in text file start number, other lines shall appended previous line (the lastly started number) what code should do: go each line if not start number [0-9] go origin of line (c-a) , remove linebreak before (like hitting backspace ) (the lines numbers not have leading spaces!) then go next line , same this should quite easy, don't know hot it. a solution emacs helpful, can within cygwin helpful. so, goal remove newlines not followed number. 1 way sed: sed -i ':a $!{n; ba}; s/\n\+/\n/g; s/\n\([^0-9]\)/\1/g' filename this reads whole line pattern space, replaces sequences of multiple newlines one, , removes newlines aren't followed numb...

html - Searching an Array with the user input using javascript -

html - Searching an Array with the user input using javascript - i want search value in array. array predefined values. there html text box come in value. user need come in value. if value entered user there in array. should display "valued found" or else not found. should utilize ajax. below code not working. <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> </head> <body> <p>enter value: <input type="text" id="carinput" onchange="textchanged()"></p> <p id="onlisttext"></p> <script> var cars = ["abc", "def", "ghi","jkl"]; var textchanged = function(){ var inputtext = $("#carinput").text(); if($.inarray(inputtext, cars) !== -1){ $("#onlisttext").text("value found"); return; } } </script> </body> </html...

ruby on rails - Where are ActionMailer log entries when using delayed_job? -

ruby on rails - Where are ActionMailer log entries when using delayed_job? - i've deployed rails 3.2.16 app aws elastic beanstalk running passenger standalone. i'm using delayed_job 4.0.6 deliver actionmailer mail. mails going out fine, can't figure out mail service send gets logged. thought log_level info, should @ to the lowest degree seeing "sent mail service to..." entry either in delayed_job log or in main passenger log (where see web requests), they're not there. i've modified config/initializers/delayed_job.rb follows force delayed_job log custom folder (the same 1 used passenger under elastic beanstalk): require 'delayed/command' delayed::worker.destroy_failed_jobs = false # default true # delayed::worker.sleep_delay = 60 # polling frequency; default 5 seconds delayed::worker.max_attempts = 3 # default 25 delayed::worker.max_run_time = 5.minutes # default 4.hours # delayed::worke...

python 3.x - using while loop to count how many doublings happen between two numbers -

python 3.x - using while loop to count how many doublings happen between two numbers - my task write function uses while loop count how many days(how many doublings) takes population go given initial size value greater or equal given final size. in addition, reply should 0 if final populations less or equal initial population. my approach: def num_doublings(initial_population, final_population): days = 0 if final_population <= initial_population: homecoming 0 else: while initial_population < final_population: initial_population * 2 days = days + 1 homecoming days testing: ans = num_doublings(1, 8) print(ans) when press enter, tells me "executing command. please wait results." , don't think it'll ever homecoming discontinue code running. so doing wrong? you calling initial_population * 2 , not modify in-place variable. instead try: initial_population *= 2 which equ...

Cocos2d-js: Custom TTF font won't display in Android -

Cocos2d-js: Custom TTF font won't display in Android - i define font resources with var res = { indieflower_ttf: {type:"font", name:"indieflower", srcs:["res/fonts/indieflower.ttf"]}, } and create ttf label with: var text = cc.labelttf.create(text, "indieflower", bubble.fontsize, cc.size(60,0),cc.text_alignment_left, cc.vertical_text_alignment_top); and display ok in firefox , chrome, show default font (arial) on android. what else do? checked thread cocos2d-js: how utilize custom ttf font on android devices?, doesn't help. the problem is, native platforms need total path of ttf font, while html platform needs font name. got 2 solutions cocos2d-x forum: use bitmap fonts. (yes ... wanted have ttf) code it: in resource file have now: var res = { indieflower_ttf: {type:"font", name:"indieflower", srcs:["res/fonts/indieflower.ttf"]}, } then helper function: var _...

android - Get rid of this line separator between my action-bar and pagertabview: -

android - Get rid of this line separator between my action-bar and pagertabview: - i'm trying rid of line separator between action-bar , pagertabview: how did google accomplish this? that isn't line separator, shadow indicating action bar @ higher elevation tab bar. assuming using appcompat, can utilize viewcompat.setelevation() set elevation on tabs devices back upwards (those running api 21+). your code might this: view tabs = findviewbyid(r.id.the_tabs_id) viewcompat.setelevation(tabs, getresources().getdimension(r.dimen.action_bar_elevation)); i using 4dp action_bar_elevation dimension. pre 5.0: <style name="apptheme" parent="@android:style/theme.holo.light"> <item name="android:windowcontentoverlay">@null</item> </style> android android-actionbar styles

java - Finding pairs in strings -

java - Finding pairs in strings - i wondering if can help problem. suppose had string 34342 i find number of pairs in string, two. how go doing that? edit: ok wanted match occurrences of characters same in string. you can utilize backreferences find pairs of things appear in row: (\d+)\1 this match 1 or more digit character followed same sequence again. \1 backreference refers contents of first capturing group. if want match numbers appear multiple times in string, utilize pattern like (\d)(?=\d*\1) again we're using backreference, time utilize lookahead well. lookahead zero-width assertion specifies must matched (or not matched, if using negative lookahead) after current position in string, doesn't consume characters or move position regex engine @ in string. in case, assert contents of first capture grouping must found again, though not straight beside first one. specifying \d* within lookahead, considered pair if within same numbe...

exception - Programmatically check if a COM port exists in C# -

exception - Programmatically check if a COM port exists in C# - i got myself using serialport object in c# , realised throws exception saying "com1" not exist. checked device manager see com ports can use, there way find out com ports available , programmatically select 1 of them? yes, utilize serialport.getportnames() , returns array of strings of available port names. then create serialport object specifying 1 of names in constructor. string[] ports = serialport.getportnames(); serialport port = new serialport(ports[0]); // create using first existing serial port, illustration c# exception serial-port

coordinates - php draw arc with start point, end point and center point -

coordinates - php draw arc with start point, end point and center point - after long search in php, java , c, have not found useful answers want do. my problem 'simple', want draw arc using start, end , center coordinates (not using angle x , y). this type of function exist since in utilize in cad software can't found source code. does have base of operations start? thanks in advance php coordinates draw

R : Map a column to column using key-value list -

R : Map a column to column using key-value list - in r, want utilize key-value list convert column of keys values. it's similar to: how map column through dictionary in r, want utilize list not data.frame. i've tried using list , columns: d = list('a'=1, 'b'=2, 'c'=3) d[c('a', 'a', 'c', 'b')] # want homecoming c(1,1,3,2) doesn't however, above returns list: list('a'=1, 'a'=1, 'c'=3, 'b'=2) unlist useful function in situation unlist(d[c('a', 'a', 'c', 'b')], use.names=false) #[1] 1 1 3 2 or alternative stack returns 'key/value' columns in 'data.frame'. subsetting values column, get stack( d[c('a', 'a', 'c', 'b')])[,1] #[1] 1 1 3 2 r list

java - JList item deselected after clicking a JButton -

java - JList item deselected after clicking a JButton - what tried select item jlist , click jbutton (optionally click jradiobutton ), , value of selected item added jlist . the problem after clicked jbutton or jradiobutton , item in original jlist deselected, , added destination jlist "null". first jlists. items specified selection jcombobox, , generate values arraylist in class. @override public void actionperformed(actionevent e) { // todo auto-generated method stub channellist cl = new channellist(); cl.createlist(); //determine jlist jcombobox selecton string genre = (string)c.getselecteditem(); switch(genre){ case "please select genre of channel": vt1.clear(); lchannels.setlistdata(vt1); break; case "all genres": vt1.clear(); for(int =0; < cl.chlist.length; i++){ char chgenre = cl.chlist[i].getchgenre(); vt1.add(cl.chlist[i].getchtitle()...

matlab - Finding a basis of the null space with a specific structure -

matlab - Finding a basis of the null space with a specific structure - let a nxm matrix , rank(a) = r . allow n matrix columns span right null space of a . how can find n n has next construction (as matlab code): n = [eye(m-r); p] where eye(m-r) (m-r) x (m-r) identity matrix , p remaining piece of a . matlab matrix

c++ - invalid new-expression of abstract class type error -

c++ - invalid new-expression of abstract class type error - homework i'm getting type of error merge sort function. think error has merge() method, thought took care of using in mergesort() . help appreciated. sort.h #ifndef sort_h_ #define sort_h_ class sort { protected: unsigned long num_cmps; // number of comparisons performed in sort function public: virtual void sort(int a[], int size)= 0; // main entry point bool testifsorted(int a[], int size); // returns false if not sorted // true otherwise unsigned long getnumcmps() { homecoming num_cmps; } // returns # of comparisons void resetnumcmps() { num_cmps = 0; } }; class mergesort:public sort { // mergesort class public: void sort(int a[], int size, int low, int high); // main entry point }; #endif sort.cpp sort* s; switch(op.getalg()) { case 's': s=new selectionsort(); break; ...

Scala Play session value not saving -

Scala Play session value not saving - so working on webapp in scala play 2.3 using intellij 14.1.1. the problem storing values in session. have this: def authcredentials = action { implicit request => loginform.bindfromrequest.fold( formwitherrors => badrequest(views.html.login(formwitherrors.witherror("badlogin","username or password incorrect."))), goodform => redirect(routes.accountcontroller.display).withsession(request.session + ("username" -> goodform._1)) ) } and in accountcontroller: def display = action { implicit request => request.session.get("username").map { username => ok(views.html.account(user.getuser(username))).withsession(request.session + ("username" -> username)) }.getorelse(redirect(routes.logincontroller.login)).withnewsession } now in the above function finding username , rendering business relationship page once. problem after when ...

matlab - Filling missing data in a data set -

matlab - Filling missing data in a data set - i have info set following: x= [1, 4, 10] y= [10, 20, 30] ( x , y value pairs, i.e. (1,10), (4,20), (10,30) ) i fill x values gaps , linear interpolated values y . linear interpolation should done between each value pair, i.e. between (1,10) , (4,20) , 1 time again between (4,20) , (10,30) . x= [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] y= [10,?, ?, 20, ?, ?, ?, ?, ?, 30] how can solve matlab? regards, dennis p.s. original info set has on 300 value pairs... using interp1 code: x= [1, 4, 10]; y= [10, 20, 30]; xi = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; yi = interp1(x,y,xi); results: >> yi yi = 10 13.333 16.667 20 21.667 23.333 25 26.667 28.333 30 graphical output using plot(xi,yi,'-*') matlab dataset interpolation

jquery - Find offset relative to parent scrolling div instead of window -

jquery - Find offset relative to parent scrolling div instead of window - i have scrolling element within window. say partition having class "currentcontainer" overflow auto , partition contains huge amount of text big plenty scrolling. now have calculations based on how much "currentcontainer" has scrolled downwards + offset of specific element parent scrolling div (that "currentcoantainer"). but while calculating offset offset of inner kid element regard window not "currentcontainer". js fiddle @shikkediel tried using position().top instead of offset().top is giving same result. have @ : js fiddle 2 please not suggest using : $("<reference of scrolling element").scrolltop() + $("<reference of kid element offset want calculate>").offset().top because going complicate actual calculations beyond this. reason why not want utilize above mentioned approach trying modify existing cod...

python - function without args that uses elements precreated -

python - function without args that uses elements precreated - this question has reply here: function not changing global variable 3 answers i'm making programme uses variable called "lev" must used in functions, doesn't need argument of function. mean, function makes things , changes "lev" value, need this: >>> lev=8 >>> def t(): >>> print 1+1 >>> lev = lev+1 >>> t() >>> lev 9 that first idea, in practice, doing this, doesn't work. i can't utilize "return" new "lev" variable, because there functions need homecoming true or false them , edits value of "lev" too, can't utilize "return" command. has idea? thanks define global lev in function ... >>> lev=8 >>> def t(): >>> glob...

cross validation - Scikit Learn import error: 'cross_val_predict' is not defined -

cross validation - Scikit Learn import error: 'cross_val_predict' is not defined - i trying run simple codes of scikit-learn in python, , while executing this, encountered error: from sklearn.cross_validation import cross_val_predict traceback (most recent phone call last): file "", line 1, in sklearn.cross_validation import cross_val_predict importerror: cannot import name cross_val_predict i have downloaded scikit larn page: http://sourceforge.net/projects/scikit-learn/?source=typ_redirect , other modules sklearn.linear_model works well. seems can import module cross_validation.. cannot understand! yes ! seems works ! in fact, instead of using .exe files downloaded net (which turned out perhaps incompatible), successed install many modules standard "pip install". thing not utilize "pip install" bundle "scipy", had replace .exe file. give thanks help ! scikit-learn cross-validation

c# - Visual Studio IIS HTTP 503 Service Unavailable -

c# - Visual Studio IIS HTTP 503 Service Unavailable - i have searched every topic , seems got there problem solved , have tried possible solution have provided or still missing something. -firewall turned off. ok trying access iis server application run vs 2013. update 2. when seek access http://localhost:29790/ <- http://192.168.1.3:29790 current ip on local. gives me 503 error. i have searched solution , gives tons of. applicationhost.config file <site name="smapplication(4)" id="10"> <application path="/" applicationpool="clr4integratedapppool"> <virtualdirectory path="/" physicalpath="c:\users\danze3\documents\visual studio 2013\projects\smapplication\smapplication" /> </application> <bindings> <binding protocol="http" bindinginformation="*:29790:localhost" /> ...

javascript - Expanding table in html cannot be displaying in a table format -

javascript - Expanding table in html cannot be displaying in a table format - i trying expanding/growing table in html page.. created expanding table , able insert , retrieve info in table.. when tried view table shows first line of growing table. i want show table whatever rows there in table.. please help me code.. //html <table id="1.1.2"> <td>1.1.2 board members-overview<td></tr> <tr> <th>s.no.</th> <th>name</th> <th>area of specification</th> <th>committees involved in</th> <td></td> </tr> <tr> <td> 1 </td> <td> <input type="text" id="1.1.2_1_1" maxlength="50"><br> </td> <td> <input type="text" id="1.1.2_1_2" maxlength="50"><br> </td> <td> <input type="text" id="1.1.2_1_3" m...

c# - Dapper for Table Valued parameter in generic implementation -

c# - Dapper for Table Valued parameter in generic implementation - following post using dapper.tvp tablevalueparameter other parameters have been able execute table valued parameter question regarding part of implementation. procedure seems working how can create implementation more generic? adding parameters in dynamicparameters 'new {}' specialized implementation according requirement. want able specify parameter name well.. example public ienumerable<tcustomentity> sqlquery<tcustomentity>(string query, idictionary<string, object> parameters, commandtype commandtype) tcustomentity : class { datatable dt; dynamicparameters dp; var sqlconnection = _context.database.connection; seek { if (sqlconnection.state == connectionstate.closed) { sqlconnection.open(); } var dynamicparameters = new...

jdbc - ExecuteUpdate() hangs and not able to run my program -

jdbc - ExecuteUpdate() hangs and not able to run my program - i trying jdbc run code servlet .jsp file in netbeans derby database. problem doesn't run beyond "stmt.addbatch(query);" doens't print "hello". have used derby.jar,derbyclient.jar , derbynet.jar in library. looking forwards hear others. import java.io.ioexception; import java.io.printwriter; import javax.servlet.servletexception; import javax.servlet.annotation.webservlet; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import java.sql.*; import java.io.*; import javax.sql.*; protected void processrequest(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { response.setcontenttype("text/html;charset=utf-8"); printwriter out = response.getwriter(); seek { /* todo output page here. may utilize next sample code. */ ...

c# - Creating a dynamic font style across a label -

c# - Creating a dynamic font style across a label - i have label uses special characters, , want special characters oblique , , rest of label regular. oblique font style i've been changing in label properties. i thought of using \n key adds line messagebox didn't found it. hints? because on properties not achievable either. i think impossible on regular label. far know, can set font style hole text of label. however, can create own label, override it's onpaint method, , whatever want there. need calculate locations of characters in text, possible do. c# text fonts

pass html form data to json php string -

pass html form data to json php string - i've been able perform parse post info api using format: working sample: <?php $appid = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'; $private_token = 'xxxxxxxxxxxxxxxxxxx'; $geo_post = "/api/v1/geofence/"; $name = "home"; $latitude = 38.646322; $longitude = -121.185837; $radius = 50; $data = array( "name" => $name, "location" => array( "latitude" => $latitude, "longitude" => $longitude), "matchrange" => $radius ); $data_string = json_encode($data); $ch = curl_init(); $headers = array( 'content-type:application/json', 'authorization: basic '. base64_encode($appid.":".$private_token) // <--- ); curl_setopt($ch, curlopt_httpheader, $headers); curl_setopt($ch, curlopt_url, 'https://admin.plotprojects.com' . ...

python - Division by Zero Errors -

python - Division by Zero Errors - mann have problem question professor. here question: write definition of function typing_speed , receives 2 parameters. first number of words person has typed (an int greater or equal zero) in particular time interval. sec length of time interval in seconds (an int greater zero). function returns typing speed of person in words per min (a float ). here code: def typing_speed(num_words,time_interval): if(num_words >= 0 , time_interval > 0): factor = float(60 / time_interval) print factor homecoming float(num_words/(factor)) i know "factor" getting assigned 0 because not beingness rounded or something. dont know how handle these decimals properly. float isnt doing apparently. any help appreciated, thankyou. when phone call float on partition result, it's after fact partition treated integer partition (note: python 2, assume). doesn't help, help specify partition f...

smo - SQL Server 2008 - script data using Scripter.EnumScript fails with "Login failed for user" error -

smo - SQL Server 2008 - script data using Scripter.EnumScript fails with "Login failed for user" error - i trying script info of table. if utilize windows authentication (integrated security=true), code works. if switch sql authentication existing user , password, fails trying access returned scripts enumerable. user sql login , admin. simplified version of code here: //string connectionstring = "data source=myserver; initial catalog=mydb; integrated security=true"; string connectionstring = "data source=myserver; initial catalog=mydb; integrated security=false; user id=user1; password=1234;"; using (sqlconnection connection = new sqlconnection(connectionstring)) { connection.open(); serverconnection serverconnection = new serverconnection(connection); server server = new server(serverconnection); database database = server.databases["mydb"]; collection<sql...

winbugs14 - Multiple definitions of node ell[1,2] error in Winbugs -

winbugs14 - Multiple definitions of node ell[1,2] error in Winbugs - this post related previous post (how code matrix in winbugs?). apologize new 1 new problem. error multiple definitions of node ell[1,2] . i'm not sure how prepare it. here code , info set reproducibility. model { #likelihood for(j in 1 : nf){ p1[j, 1:2 ] ~ dmnorm(gamma[1:2], t[1:2 ,1:2]) (i in 1:2){ logit(p[j,i]) <- p1[j,i] y[j,i] ~ dbin(p[j,i],n) } x_mu[j,1]<-p[j,1]-mean(p[,1]) x_mu[j,2]<-p[j,2]-mean(p[,2]) v1<-sd(p[,1])*sd(p[,1]) v2<-sd(p[,2])*sd(p[,2]) v12<-(inprod(x_mu[j,1],x_mu[j,2]))/(sd(p[,1])*sd(p[,2])) sigma[1,1]<-v1 sigma[1,2]<-v12 sigma[2,1]<-v12 sigma[2,2]<-v2 sigmainv[1:2, 1:2] <- inverse(sigma[,]) t1[j,1]<-inprod(sigmainv[1,],x_mu[j,1]) t1[j,2]<-inprod(sigmainv[2,],x_mu[j,2]) ell[j,1]<-inprod(x_mu[j,1],t1[j,1]) ell[j,2]<-inprod(x_mu[j,2],t1[j,2]) } ...

c++ - Qt: receive serial port data as unsigned char -

c++ - Qt: receive serial port data as unsigned char - with main app i'm sending bytes , i'm sending them unsigned chars (0x80 , above). created 1 little supporting app receives these data, writes them terminal , sends them confirmation of successful transfer. code in back upwards app: switch(c) // c beingness byte received qbytearray { case 0xff: cout << "header 1" << endl; break; case -1: cout << "0xff = 255 = -1" << endl; break; } //other case statements , default omitted if send 0xff through serial port, "0xff = 255 = -1" on cout. understand number represented 1111 1111 (and in fact 255 equals -1 in case) post here on sof. how supposed receive code "header 1" on terminal? c++ qt qtserialport

javascript - How to use ng-repeat to define a table's td colspan? (AngularJS) -

javascript - How to use ng-repeat to define a table's td colspan? (AngularJS) - given next code, how define colspan of first td match number of other "td"s in table can take total width of table? <table ng-repeat="product in products"> <tr> <td colspan=""> {{product.name}} </td> </tr> <tr ng-repeat="item in product.items"> <td ng-repeat="element in item"> {{element}} </td> </tr> </table> live code here: http://jsfiddle.net/z37uofqk/ i think you're trying column span whole table. way that: <td colspan="100%"> {{product.name}} </td> javascript angularjs angularjs-directive angularjs-scope angularjs-ng-repeat

Python Empty File Leaving 10,000 Lines -

Python Empty File Leaving 10,000 Lines - so have text file total of ids know not them again. every sec seems i'm adding 1,000. i want empty file while keeping lastly 10,000 lines. i know can empty file open(file, 'w').close() won't work. what can do? i'm open ideas. your question operating scheme or file scheme specific. all files (on posix systems linux, , on windows) can truncated @ tail: file scheme layer of os not allow removing bytes @ front end (or in middle) of file (viewed sequence of bytes). so need re-create n lastly lines elsewhere (in other temporary file) rename temporary file appropriately. (btw, reply not python specific. same in c++ or ocaml ...) python file file-io

asp.net - Dropdown list inside gridview binding for alternate rows on Rowdatabound -

asp.net - Dropdown list inside gridview binding for alternate rows on Rowdatabound - i have dropdownlist within gridview in edittemmplate binding on rowdatabound . dropdlownlist binding alternate rows only. example, first row binding, not 2nd, 3rd is, , on. below code: protected sub grvtdsmaster_rowdatabound(byval sender object, byval e system.web.ui.webcontrols.gridviewroweventargs) handles grvtdsmaster.rowdatabound seek lblerrormsg.visible = false lblerrormsg.innertext = "" if (e.row.rowtype = datacontrolrowtype.datarow) if ((e.row.rowstate = datacontrolrowstate.edit)) dim ddlsection dropdownlist = e.row.findcontrol("ddlsection") dim objtds new tdsmasterdl dim dt new datatable dt = objtds.gettdssectionname() ddlsection.datasource = dt ddlsection.datavaluefield = "tds_section_id" ddlsection...