Posts

Showing posts from March, 2015

sql - delete from table with foreign keys to other tables -

i trying delete table( mytable ) has foreign key reference linking 4 other tables. i needed delete data mytable referenced table1 , table2 , not table3 , table4 . have deleted data in table1 , table2 i tried this: delete mytable id not in(select mytableid table1) delete mytable id not in(select mytableid table2) but doesn't work because if did inadvertently delete data table2 references. is there way delete table fks aren't being referenced tables? (rewritten answer sql server syntax after basic research , finding the delete statement in sql server .) use multiple table syntax of delete statement. delete mytable mytable left join table1 on mytable.id = table1.mytableid left join table2 on mytable.id = table2.mytableid left join table3 on mytable.id = table3.mytableid left join table4 on mytable.id = table4.mytableid (table1.mytableid not null or table2.mytableid not null) , table3.mytableid null , table4.mytableid null the

c - Maximum sum in a Subarray -

you're given array of n integer numbers. maximal sum of array maximal sum of elements of nonempty consecutive subarray of array. example, maximal sum of array [1, -2, 3, -2, 5] 6 because sum of subarray [3, -2, 5] 6 , impossible achieve greater subarray sum. you're allowed remove no more 1 element given array. maximal possible maximal sum of resulting array can achieve doing so? i testing code own test cases. getting correct output on dev-c++. when test code online wrong answer. not able find out problem. #include <stdio.h> #include <limits.h> #include <stdlib.h> struct result{ long long int start; long long int end; long long int sum; }res; long long int find_max(long long int a[],long long int n) { long long int max=llong_min; long long int i; for(i=0;i<n;++i) { if(a[i]>max) max=a[i]; } return max; } long long int max_sub(long long int a[],long long int n) { long long int

Python Scraping - Selenium - Element is not clickable at point -

i'm trying click next button on webpage multiple times, need scrape page after each click. following code shortened illustrates situation. able scrape required tag after first click, second click fails. here code from selenium import webdriver selenium.common.exceptions import nosuchelementexception selenium.webdriver.common.keys import keys browser = webdriver.firefox() browser.get('http://www.agoda.com/the-coast-resort-koh-phangan/hotel/koh-phangan-th.html') browser.find_element_by_xpath("//a[@id='next-page']").click() browser.find_element_by_xpath("//a[@id='next-page']").click() browser.quit() i error webdriverexception: message: element not clickable @ point although when use beautifulsoup , source code after first click element trying click again there click. i've read on other answers might need wait time not sure how implement that. the first time click next page starts load, can't click on

java - Docker build hangs during downloads -

mac 10.10.5 here, using docker-machine create virtualbox host vm local docker. have project builds executable jvm located @ build/libs/myapp-snapshot.jar . dockerfile , located in root of project, looks like: from frolvlad/alpine-oraclejdk8:slim volume /tmp add build/libs/myapp-snapshot.jar myapp.jar run sh -c 'touch /myapp.jar' entrypoint ["java","-jar","/myapp.jar"] please note, don't wish push images registry, keep/run them locally (for now). when run: docker build -t myorg/myapp . i following console output: myuser@mymachine:~/sandbox/myapp$docker build -t myorg/myapp . sending build context docker daemon 42.69 mb step 1 : frolvlad/alpine-oraclejdk8:slim slim: pulling frolvlad/alpine-oraclejdk8 d0ca440e8637: downloading [=================================================> ] 2.295 mb/2.32 mb 0f86278f6be1: downloading [=================================================> ] 3.149 mb/3.172 mb c704a6161dca: download complete

LOG4NET Could not create Appender -

i migrated application new server (windows 2008 server r2, sql server 2008 r2, poweshell) , works except error when trying log database. log4net:error xmlhierarchyconfigurator: not create appender [adonetappender] of type [log4net.appender.adonetappender]. reported error follows. system.argumentnullexception: createconverterinstance cannot create instance, convertertype null parameter name: convertertype @ log4net.util.typeconverters.converterregistry.createconverterinstance(type convertertype) @ log4net.util.typeconverters.converterregistry.getconverterfromattribute(type destinationtype) @ log4net.util.typeconverters.converterregistry.getconvertfrom(type destinationtype) @ log4net.util.optionconverter.canconverttypeto(type sourcetype, type targettype) @ log4net.repository.hierarchy.xmlhierarchyconfigurator.createobjectfromxml(xmlelement element, type defaulttargettype, type typeconstraint) @ log4net.repository.hierarchy.xmlhierarchyconfigurator.setparameter(xml

java - how BufferedInputStream.available works? -

fileinputstream in=new fileinputstream("dd.txt"); bufferedinputstream bufi= new bufferedinputstream(in); system.out.println(bufi.available()); int half =bufi.available()/2; bufi.skip(half); system.out.println(bufi.available()); output: 7 4 in "dd.txt" there 1234567 but why bufi can skip before use bufi.read(),i mean when data sent input stream? it works adding number of bytes buffered, possibly zero, value returned available() method of wrapped stream. in case wrapped stream fileinputstream , available() method returns, arguably incorrectly, number of bytes remaining read in file. there no reason why skip() should not possible prior read() . data never 'sent t imoitbstream'. read by input stream.

python - How do I create a list from a column of a file? -

i want create list specific column of file, example csv file. how append each value in column without knowing index? i created loop find index of specific column want append list, not seem correct. need somehow make use of ".split()" method. appreciated :) filename = open(file_name) row = filename.readline() index1 = 0 index2 = 0 list1 = [] list2 = [] i, value in enumerate(row.split(",")): if value "value1": index1 = elif str(value) "value2": index2 = rows = filename.readlines() value in rows: list1.append(int(value.split(",")[index1])) list2.append(int(value.split(",")[index2])) example file: a,b,value1,value2 1,2,3,4 4,5,6,7 1,2,3,4 suppose want add first column value of csv file list, can this: import csv lst=[] open('fl.csv', 'rb') csvfile: ... reader = csv.reader(csvfile) ... row in reader: ... lst.add(row[1]); since have use split, :

javascript - How do I add filtering to a Phanes template? -

a year ago bought template html5 , wanted add filtering part portfolio is, unfortunately can not deal it. i searched many scripts in google, have problems template. link template want add filtering: http://ivang-design.com/phanes/slidermp/work.html i tried add mixitup , close success: html <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script type="text/javascript" src="//cdn.jsdelivr.net/jquery.mixitup/latest/jquery.mixitup.min.js?v=2.1.9"></script> <div class="controls"> <label>filter:</label> <button class="filter" data-filter="all">all</button> <button class="filter" data-filter=".category-1">category 1</button> <button class="filter" data-filter=".category-2">category 2</button> <label>sort:</label&g

javascript - How can I make this request synchronous in node.js -

here asynchronous code snippet working giving website urls asynchronous request want make synchronous request can me here using alchemy api feeds cloud fetching data var urls = [website ur names] for(var j=0;j<urls.length;j++){ alchemyapi.feeds("url",urls[j], {}, function(response) { console.log(response["feeds"]); for(var i=0;i<response["feeds"].length;i++) var feed = response["feeds"][i].feed; getfeed(feed); console.log("title: " +objtostring(response["feeds"][i])); }); } function objtostring (obj) { var str = ''; (var p in obj) { if (obj.hasownproperty(p)) { str += p + '::' + obj[p] + '\n'; } } return str; } var request = require('request'); var getfeed = function(feed){ feeds = e

java - Read only the first 5 characters and discard rest -

i want read first 5 characters system.in , discard rest eol character if stream contains more (in order start reading next line). here's tried: private static final int read_count = 5; public static void main(string[] args) throws ioexception, interruptedexception{ bufferedreader reader = new bufferedreader(new inputstreamreader(system.in)); int readcharacters = 0; int character; do{ character = reader.read(); dojob(); if(++readcharacters >= read_count){ discardrest(reader); break; } } while(character != '\n'); system.out.println((char) reader.read()); } private static void discardrest(bufferedreader reader) throws ioexception { while(true){ int character = reader.read(); if(character == '\n') break; } } public static void dojob() throws interruptedexception{ thread.sleep(1000); } it works, it's pain. , looks ugly hell. not qu

R: Test condition on column of dataframe elements within list; return smaller list -

my goal take list of dataframes, see if specific column of data frames has max value of 0, , if so, remove data frame list. right looping on names of list. given r, there must better way. feel need function applied through lapply() right. i've considered ddply() think maybe overkill. here have far: # make df of first element mycolumn <- rep ("elementa",times=10) values <- seq(1,10) <- data.frame(mycolumn,values) # make df of second element mycolumn <- rep ("elementb",times=10) values <- rep(0,10) b <- data.frame(mycolumn,values) # bind dataframes df <- rbind(a,b) #now split dataframes based on element name mylist <- split(df,df$mycolumn) # loop through element lists , check max of 0 in values (name in names(mylist)) { # loop through list if (max(mylist[[name]]$values) == 0) { # check max 0 mylist <- mylist[[-names]] # if 0, remove element list } # close if } # close loop error in -names : invalid argument u

javascript - Generate child components from ngFor in Angular 2 -

is possible create independent child components ngfor iteration in angular 2? i'm making quiz application structure, 1 quiz component have multiple categories , , 1 category have multiple questions . angular generate form quiz retrieved rest api, user can navigate , forth between different categories of questions , save partial or submit complete form. i sketched following pseudo-structure application template: <html> <form> <category> <question *ngfor="let question of questions" /> <category> <navigate/> </form> </html> quiz component has list of categories , reference active category. category component has input binding reflect active category of quiz. category has list of questions, want encapsulate in distinct component. iterate through list of questions , create question tag. now problem is, how populate question component each tag according question object creating tag? pos

umbraco6 - How to add a custom section in umbraco 6.1.x -

i found few blogs on adding new section umbraco 6.1.x. nothing seems work perfectly. can me ? i think asking creating custom tree dashboard. refer following links you, http://www.robertgray.net.au/posts/2011/5/creating-a-custom-content-tree-in-umbraco.aspx#.ug4fj21yhix http://www.theoutfield.net/blog/2012/07 http://www.richardsoeteman.net/permalink,guid,f470b6cf-40da-4aa9-a0d9-7b984fe9bf59.aspx

scipy - How to fit a poisson distribution with seaborn? -

Image
i try fit data poisson distribution: import seaborn sns import scipy.stats stats sns.distplot(x, kde = false, fit = stats.poisson) but error: attributeerror: 'poisson_gen' object has no attribute 'fit' other distribution (gamma, etc) de work well. the poisson distribution (implemented in scipy scipy.stats.poisson ) discrete distribution . discrete distributions in scipy not have fit method. i'm not familiar seaborn.distplot function, appears assume data comes continuous distribution. if case, if scipy.stats.poisson had fit method, not appropriate distribution pass distplot . the question title "how fit poisson distribution seaborn?", sake of completeness, here's 1 way plot of data , fit. seaborn used bar plot, using @mwaskom's suggestion use seaborn.countplot . fitting trivial, because maximum likelihood estimation poisson distribution mean of data. first, imports: in [136]: import numpy np in [137]: scip

angularjs - Show different html files with md-tab -

i'm new angular material , question how can show different html file each md-tab. example, have 3 tabs: first catalog.html, second manage.html , third orders.html. thanks! edit 1: did this: <md-tabs > <md-tab label="product catalog"> <div ng-include src="#"></div> </md-tab> <md-tab label="workers management"> <div ng-include src="employeespage.html"></div> </md-tab> </md-tabs> inside index.html, nothing shown... <md-tab label="catalog"> <div ng-include src="'catalog.html'"></div> </md-tab>

serenity with jbehave - JBehave reports do not have any style sheet formating -

for test automation using serenity jbehave. when run appropriate maven goal eclipse, creates proper serenity reports. issue - jbehave reports created under "target/jbehave" folder without formatting. there no table boundries, no jbehave title image @ top , failed scenarios not shows in red font. is there way change pom.xml or change code jbehave report (with proper formatting) created along serenity reports.

ibm bluemix - How do two devices communicate on IBM-Watson platform -

on watson mqtt foundation, how publish message 1 device ( publish-"iot-2/evt/xxxxxxxxx" ) device ( subscribe-"iot-2/cmd/xxxxxxxx" )? how possible devices' publish , subscribe topics cannot same? possible without first receiving in application , republish 2nd device, or devices can send/receive data to/from application? is watson implementation or mqtt spec? devices publish events , subscribe commands. application can send commands device. a device can not send commands device. watson iot platform has specific topic strings, refer documentation. if have device such raspberry pi sending commands, have tried connecting application publish command , have other device connect device subscribe , receive commmand?

mysql - Returning most common linked ID for a user -

i have 3 tables. user_sticker holds sent stickers between users. when profile view screen loaded, need display common sticker has been given user. user id_user name sticker id_sticker name user_sticker id_user_sticker id_sticker id_user_from id_user_to so, if user_sticker holds info: 1, 3, 254, 205 2, 2, 362, 205 3, 2, 519, 205 4, 3, 945, 205 5, 3, 199, 205 (which means users 254, 362, 519, 945, 199 sent stickers user 205). result has return both user 205 information (name) , common sticker id (in case #3) in same record. ok, lets see in principal, need use user_sticker table. so: select * user_sticker then, match user table user_to select * user_sticker join user u on us.id_user_to = u.id_user then, want name , stickers user want recieve select us.id_sticker, u.name user_sticker join user u on us.id_user_to = u.id_user u.id_user = "yourwanteduser" now, pick first select top 1 us.id_sticker, u.name user_sticke

Facebook Like Box only visible in Firefox -

i have website 2 boxes on http://www.thebasecamp.com/ one box associated facebook page username thebasecampbillings the other associated facebook page user name thebasecamphelena on sidebar have inserted code in possible formats , lanaguages (html5, xfbml, , iframe). each different piece of code works widget associated thebasecampbillings when add code widget associated thebasecamphelena looks fine in firefox (i using firefox 22.0 on mac osx 10.8.4) the widget not appear in other browsers. any or suggestions appreciated. thanks

Is Android Volley Dead? -

i presently use volley network calls. but, google doesn't seem actively maintaining volley. heard google developed volley use play store app haven't mentioned in list of 3rd party libraries used. uses retrofit(looking @ benchmarks, retrofit seems better option), time quit using volley? p.s: please don't post pros , cons of volley , retrofit google doesn't seem actively maintaining volley that depends entirely on how define "actively maintaining". development ongoing, can see looking @ the volley git repo , shows many commits on past year (as of time of writing). google shipped an official volley artifact earlier year, version 1.0.0. but haven't mentioned in list of 3rd party libraries used google wrote play store app. google wrote volley. hence, google's standpoint, volley not third-party library. other google , volley third-party library. almost uses retrofit retrofit not equivalent volley. triad of square http

knockout.js - Unable to bind to a view with compose containerless code -

this kind of related recent question multiple views within 1 page. started durandal sample knockout shell , attempted extract navigation menu on left own "navlist.html/navlist.js" view/viewmodel. i created navlist.html , navlist.js: <ul class="nav nav-list"> <li class="nav-header">basic examples</li> <!--ko foreach: introsamples--> <li data-bind="css: { active: isactive }"> <a data-bind="attr: { href: hash }, text: title"></a> </li> <!--/ko--> <li class="nav-header">detailed examples</li> <!--ko foreach: detailedsamples--> <li data-bind="css: { active: isactive }"> <a data-bind="attr: { href: hash }, text: title"></a> </li> <!--/ko--> </ul> define(['plugins/router', 'knockout'], function (router, ko) { var childrout

Need to upload file via gcloud to server from localmachine - INSUFFICIENT PERMISSIONS? -

i have tried looking answer problem on month. apparently 1 in world ever had issue... here's console commands giving on ssh. logged account permissions , has full permissions on project... stumped. sudo gcloud compute copy-files /home/lestado/trs.key adminuser@the-real-strategy-vm:/etc/ssl/private/ this response getting: did mean zone [us-central1-f] instances: [['[the-real-strategy-vm]']]? want continue (y/n)? y error: (gcloud.compute.copy-files) not fetch instance: - insufficient permission set project name before start copying files. gcloud config set project <project_name> complete process be: login: gcloud init set project: gcloud config set project <project_name> upload using root user instance: gcloud compute copy-files ./ root@instance:/etc/ssl/pvt

Sharing Video to Facebook - Swift IOS -

i'm writing app try , post video facebook. ideally i'd pull video parse, , convert nsurl. right trying use imagepicker pick photo used share. right have imagepicker showing up, i'm getting 2 errors. 1)only photos showing in roll , 2) i'm getting 'found nil while unwrapping optional value' in didfinishpickingmediawithinfo function. issue 1, have changed uiimagepickercontrollersourcetype .photolibrary still omitted videos. override func viewwillappear(animated: bool) { let profilebutton = uibarbuttonitem(image: img, style: .done, target: self, action: "videobtnclicked") self.navigationitem.setrightbarbuttonitem(profilebutton, animated: true) func videobtnclicked(){ if uiimagepickercontroller.issourcetypeavailable(uiimagepickercontrollersourcetype.savedphotosalbum){ print("video capture") imagepicker.delegate = self imagepicker.sourcetype = uiimagepickercontrollersourcetype.savedphoto

asp.net mvc 4 - Submit button not doing anything from within a fancybox dialog in mvc 4 application -

currently, have edit user dialog (fancybox) has link replaces dialog fancybox dialog changing password. seems behaving correctly until click submit button on change password dialog. nothing happens @ all. checked fiddler , no request being made. check firefox verify change password controls in fact wrapped in correct form tags, , are. gives? i've looked through net find similar problems , there some, none using mvc4 , didn't quite understand them. these fancybox modals being loaded through partial view. instance, link opens first dialog link href="edituserpartialaction". works great. model opened link first model same thing, has href="changepasswordpartialaction". loads perfectly. button doesn't anything. here html being generated. can see form looks right , should work (unless im overlooking something). , again, nothing happening. no request being made let alone error. cancel button works replaces dialog previous edit user dialog. <div clas

javascript - Parallax effect make elements follow scroll with delay -

i trying replicate site: www.adidas.co.uk/climazone. elements seem move after user scrolls. how can achieve this? thank you! here's demo uses debounce/throttle effect . when scroll up/down shouldn't modify/animate dom element directly because scroll event can fire @ high rate in case animation dom element can behave weird avoid can use windowanimationframe or settimeout throttle/debounce event throttle settimeout taken source function.prototype.debounce = function(threshold){ var callback = this; var timeout; return function() { var context = this, params = arguments; window.cleartimeout(timeout); timeout = window.settimeout(function() { callback.apply(context, params); }, threshold); }; }; function animloop(){ .... } var test=animloop.deboune(50); $(window).on('scroll',test); window.requestanimationframe() mdn scource the window.requestanimationframe() method tells browser wish perfo

javascript - base map selector does not work -

i changing default basemap mapbox.streets in code. not update baselayer baselayerpicker widget anymore. var viewer = new cesium.viewer('cesiumcontainer',{ animation : false, homebutton : false, baselayerpicker : true, infobox : true, scenemodepicker : true, timeline : false, navigationinstructionsinitiallyvisible : false, navigationhelpbutton : false, contextoptions: { webgl:{preservedrawingbuffer:true} }, selectionindicator : false, }); var layers = viewer.imagerylayers; var baselayer = layers.get(0); layers.remove(baselayer); layers.addimageryprovider(new cesium.mapboximageryprovider({ url : 'https://api.mapbox.com/v4/', mapid: 'mapbox.streets',

jquery - trunacte cells in datatables but also preview full text in tooltip -

how can truncate comments cells (one column), , in same time, insert tooltip show full text of truncated text? i've tried truncate text, , in tooltip shown truncated text.. <table id="example" class="table table-bordered" cellspacing="0" width="100%"> <thead> <tr> <th> @html.displaynamefor(model => model.shortdate) </th> <th> @html.displaynamefor(model => model.clientname) </th> <th> @html.displayname("type") </th> <th> @html.displaynamefor(model => model.projectvaluehr) </th> <th> @html.displaynamefor(model => model.projectvaluemoney) </th> <th> @html.displaynamefor(model => model.commentpipeline) </th> <th> @html.displayn

java - In Eclipse statusbar is there a way to include a new statusfield (say the file's line delimiters )? -

Image
iam writing eclipse plugin customized text editor. status bar contibutor iam using is default one. , these fields displayed i believe because of following in org.eclipse.ui.part.editoractionbarcontributor /** * status fields set editor * @since 3.0 */ private final static statusfielddef[] status_field_defs= { new statusfielddef(itexteditoractionconstants.status_category_find_field, null, false, editormessages.editor_findincremental_reverse_name.length() + 15), new statusfielddef(itexteditoractionconstants.status_category_element_state, null, true, statuslinecontributionitem.default_width_in_chars + 1), new statusfielddef(itexteditoractionconstants.status_category_input_mode, itexteditoractiondefinitionids.toggle_overwrite, true, statuslinecontributionitem.default_width_in_chars), new statusfielddef(itexteditoractionconstants.status_category_input_position, itexteditoractionconstants.goto_line, true, statuslinecontributionitem.default_width_in_chars) }; my q

php - success message displaying before submit -

i have contact form requires validation. problem success message displaying before hit submit. should display success message once form has passed validation , submitted. <?php $error = ""; $successmessage = ""; $fname = $email = $message = ""; if ($_server["request_method"] == "post") { if (empty($_post["name"])) { $error .= "first name required.<br>"; } else { $fname = test_input($_post["name"]); // check if name contains letters , whitespace if (!preg_match("/^[a-za-z ]*$/",$fname)) { $error .= "only letters , white space allowed.<br>"; } } if (empty($_post["email"])) { $error .= "email required.<br>"; } else { $email = test_input($_post["email"]); // check if e-mail address well-formed if (!filter_var($email, filter_validate_email)) { $error .= "invalid email for

javascript - Bootstrap Carousel slide is not smooth for "NEXT" but smooth for "PREVIOUS" -

i using bootstrap framework website helping with. on front page of website carousel. odd reason, carousel "slide" transition smooth when clicking on left arrow (previous); seems go weird when clicking right arrow (next) i've tried looking online in bootstrap files (css , js) cannot seem find anything. i've tried re-copying code bootstrap website carousels. not sure what's wrong. url: www.acebac.org help? :d here jquery code: var $item = $('.carousel .item'); var $wheight = $(window).height(); $item.eq(0).addclass('active'); $item.height($wheight); $item.addclass('full-screen'); $('.carousel img').each(function() { var $src = $(this).attr('src'); var $color = $(this).attr('data-color'); $(this).parent().css({ 'background-image' : 'url(' + $src + ')', 'background-color' : $color });

javascript - Pass parent directive's controller to a directive controller (like it is done in the "link" function) -

i have several hierarchical directives , in one, need have functions in controller, child elements can interact it. 1 directive needs reference parent directive's controller, don't know how in controller (i know how in "link()" time need controller child interaction). should possible scope: controller: function($scope){}, link: function (scope, ..., parentctrl){ scope.parentctrl = parentctrl; } but seems weird, because link function executed after controller is, or it ok? i'm confused , think might bad design? diagram: parentparentdirective controller: function(service){ this.service = service; } parentdirective controller: function(){ this.callonservice = function(id){ ???parentparentdirective???.service.callsth(id); } } childdirective link(scope, ...,parentdirectivectrl){ scope.makechanges = parentdirectivectrl.callonservice; } you can use $element.controller method th

java - Jersey ServletContainer Hangs when logging errors in Errors.logErrors -

we facing severe problem our jersey container going hang state, when reload resourceconfig. code reloads jersey container container.reload(resourceconfig.forapplication(application)); we not able find out root cause issue , blocking our release. we using jersey version 2.13. the stack trace receive follows thread [defaultmessagelistenercontainer-1] (suspended) owns: bufferedoutputstream (id=3280) owns: printstream (id=3281) owns: loggingconfigurationhelper$2 (id=3282) owns: outputstreamwriter (id=3283) owns: consolehandler (id=3284) owns: restfulconnector (id=2845) fileoutputstream.writebytes(byte[], int, int, boolean) line: not available [native method] fileoutputstream.write(byte[], int, int) line: not available bufferedoutputstream.write(byte[], int, int) line: not available printstream.write(byte[], int, int) line: not available loggingconfigurationhelper$2(printstream).write(byte[], int, int) line: not available streamencoder.writ

Python Mechanize: submit button will not work no attribute 'click' -

there form on webpage: https://www.avanza.se/mina-sidor/kontooversikt.html i trying fill in , submit using this: # -*- coding: utf-8 -*- import cookielib import urllib2 import mechanize bs4 import beautifulsoup lxml import html import urllib2, base64, lxml import numpy np import unicodedata import datetime import re import time url = "https://www.avanza.se/mina-sidor/kontooversikt.html" br = mechanize.browser() cookiejar = cookielib.lwpcookiejar() br.set_cookiejar( cookiejar ) # browser options br.set_handle_equiv(true) br.set_handle_gzip(true) br.set_handle_redirect(true) br.set_handle_referer(true) br.set_handle_robots(false) # follows refresh 0 not hangs on refresh > 0 br.set_handle_refresh(mechanize._http.httprefreshprocessor(), max_time=1) br.addheaders = [('user-agent', 'mozilla/5.0 (x11; u; linux i686; en-us; rv:1.9.0.1) gecko/2008071615 fedora/3.0.1-1.fc9 firefox/3.0.1')] br.open(url) f in br.forms(): if f.attrs['clas

C# MongoDB match any of elements in an array -

i have documents this: /* 1 */ { "_id" : objectid("573f3944a75c951d4d6aa65e"), "source" : "ign", "country" : "us" } /* 2 */ { "_id" : objectid("573f3d41a75c951d4d6aa65f"), "source" : "vg", "country" : "norway" } /* 3 */ { "_id" : objectid("573f4367a75c951d4d6aa660"), "source" : "nrk", "country" : "norway" } /* 4 */ { "_id" : objectid("573f4571a75c951d4d6aa661"), "source" : "vg", "country" : "norway" } /* 5 */ { "_id" : objectid("573f468da75c951d4d6aa662"), "source" : "ign", "country" : "us" } and list of sources this: list = ['vg', 'ign'] i want return documents source equals 'ign' or 'vg&

Python function not returning anything -

def equip(x): global bag_sword global bag_chest global bag_gloves global bag_helmet while x == "iron sword" , "iron sword" in bag: if bag_sword: print "you can't have 2 weapons equipped!" x = "" print "\nyou equip iron sword.\n" bag.remove("iron sword") bag_sword.append("iron sword") when run first time, works fine, when run second time nothing happens. bag_sword list test code: bag.append("iron sword") if input1[:5] == "equip": print input1[:5] equip(input1[6:]) print input1[6:] type console 'equip iron sword' i've tried using variable in place of input[] (it isn't syntax) here how can make function work described: bag_sword = [] def equip(x): global bag_sword if x == "iron sword": if "iron sword" in bag_sword: pr

How to ignore the first line in a csv file when you read the csv file in C# -

i how read csv file in c#. instance, file data consists of 3 columns, can make array has 3 columns , number of rows not matter since can use, instance while loop read csv file until gets null. i want know how not read first line of csv file , read rest of it. data files such .txt, .csv contains different types of data. in csv file, might have "store catalog" in first line title , have phone number, owner name, monthly sale in each line second line. it's going end looking like. reader.readline(); var text = reader.readtoend(); or like: var text = reader.readalllines(); text = text.skip(1); this assuming you're using built-in .net readers, of course.

javascript - Jquery var to php but do not return -

i have html form want send php javascript variables. these js vars not in form. how can both th php class? below code have far. $("#login_form").submit(function() { event.preventdefault(); $.post('../class/login.class.php',{ //.. serialized form data screen:screen.width //...ser //... },function(data){ alert(data); window.location.href = ""; }); }); the screen variable ends in login.class.php when gets end of php file... returns above javascript function. even when using header php returns javascript function. reads page , returns thats returned in there. echo $_post['hash']; header('location: ../index.php'); die(); only if use window.location.href = ""; in javascript can redirect correct page after processing javascript data in login.class.php file (redirecting correct page isn't rea

javascript - My meteor autoform wont submit, but there are no errors, what's wrong? -

i using couple of packages in meteor web app, including aldeed:autoform , aldeed:collection2. made schema , attached database. auto generated form it, includes submit button. submit button worked when first generated it, not when run meteor app not work once press submit. checked git linked folder , doesnt there have been changes made effect this. there way can debug autoform? i'm not sure do, great. here relevant code in main.js file: createlobby = new mongo.collection("createlobby"); createlobbyschema = new simpleschema({ game: { type: string, label: "game" }, console: { type: string, label: "console" }, players: { type: number, label: "players" }, mic: { type: boolean, label: "mic" }, note: { type: string, label: "note" }, gamertag: { type: string, label: "gamertag" } }); createlobby.attachschema( createlobbyschema ); meteor.su

jquery - How to show a URL in Bootstrap Modal dialog: On button click -

i have load page (internal url) in modal window. had been using window.showmodaldialog(url, null, features) not work on safari,chrome. decided use bootstrap's modal dialog instead. i'm unable make work. ideas doing wrong? //imports <script src="http://code.jquery.com/jquery.js"></script> <script src="js/bootstrap.min.js"></script> <link href="css/bootstrap.min.css" rel="stylesheet"> //activate content modal $(document).ready(function(){ $('#test_modal').modal({ }); } ....... ....... $("#btnsubmit").click(function(){ var url = constructrequesturl(); $('#test_modal').modal(data-remote=url,data-show="true"); }); ----- ----- <div class="modal fade" id="test_modal"> </div> if you're going continue down bootstrap path, take h

node.js - How can I set up a node app (ember app kit) on heroku that reads ENV variables and makes the values available to the application? -

okay, i'm new node, , using node server serve static js, can't find info on anywhere. i'm running application ember app kit , gets built node server.js deploy, , heroku runs node server.js . it uses grunt building, testing, etc. i'd know how can specify configuration variables (i.e. authentication tokens) can overridden heroku config variables. the closest i've been able custom task reads environment variables , writes out json file gets built site (and assigned global var). works locally, doesn't take account heroku configs. i wrote deploy script gets heroku's configs, exports them environment variables locally, , build--which works , configs updated on app deploy . if heroku config:add config_test=test_value , app doesn't see value config_test until next time deploy app. i'd app start embedding config value in browser js immediately. any way node way app set up? i not sure understand what's wrong taking config var

networking - IP Header: Total Length vs. Internet Header Length -

i have questions w.r.t. ip header. if correct, total length field shows length of overall packet. internet header length (ihl) shows length of header , whether options set or not. my question why ihl field needed if there total length field shows total length? regards with ipv4, header length variable. ihl pointer start of packet payload. without this, unable know payload starts. ipv6 has fixed header size, ihl unnecessary, , doesn't exist.

ruby - RSpec Raising an Exception - expected exception, but nothing was raised response? -

i doing coding challenge , trying make 1 rspec test pass, unsure why code not passing. error getting after running rspec is: 1) plane#land raises error if landed failure/error: expect { plane.land }.to raise_error 'plane can not land on ground' expected exception "plane can not land on ground" nothing raised # ./spec/plane_spec.rb:22:in `block (3 levels) in ' the rspec test code is: describe plane let(:plane) { plane.new } describe '#land' 'raises error if landed' plane.land expect { plane.land }.to raise_error 'plane can not land on ground' end end end and main code is: class plane def initialize @in_air = true end def land fail "plane can not land on ground" if already_landed? @in_air = false end end i have tried substituting plane plane.new , tried using raise instead of fail , have double checked, can not see why not working. many thanks

java - adding text input to multipart/form-data makes it fail -

this question has answer here: how upload files server using jsp/servlet? 12 answers so want t simple form transfer text , image. now, can't both @ same time ! here simple form code: <%@ page language="java" contenttype="text/html; charset=iso-8859-1" pageencoding="iso-8859-1"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>file upload</title> </head> <body> <center> <h1>file upload</h1> <form action="uploadservlet" method="post" enctype="multipart/form-d

user experience - Should the goal be an identical page rendering for legacy browsers? -

personally, i've thought goal provide good ux every user, regardless of browser's features , modernity. this doesn't equate identical page renderings , functionality , though. at work i'm being asked make sure pages render identically in every browser, means either dumbing down design not use newest features, or loading ton of polyfills in legacy browsers achieve "browser transparency," far see, hurts ux because have longer page loads styles , features don't affect page's usability. taken extreme, result mean design should cater lowest common denominator no js (some people don't use js) , features beyond should excluded in name of uniformity. am wrong in thinking identical ux should not goal, rather good, consistent ux best capabilities of browser? when developing multiple browsers, cannot provide identical experience every browser. after all, try access site via lynx, , you're not going design ux ensure using lynx have ide