Posts

Showing posts from January, 2013

python - Detect the green lines in this image and calculate their lengths -

Image
sample images the image can more noisy @ times more objects intervene background. right using various techniques using rgb colour space detect lines fails when there change in colour due intervening obstacles background. using opencv , python. have read hsv better colour detection , used haven't been successful yet. not able find generic solution problem. hints or clues in direction of great help. still in progress first of all, rgb image consists of 3 grayscale images. since need green color deal 1 channel. green one. so, can split image, can use b,g,r = cv2.split('your image') . output if showing green channel: after should threshold image using desired way. prefer otsu's thresholding in case. output after thresholding is: it's obvious thresholded image extremley noisy. performing erosion reduce noise little bit. noise reduced image similar following: i tried using closing instead of dilation , closing preserves unwanted noise. s...

Python: How does string.replace("\n", " ") behave in- and outside a function? -

the aim of code put string datastr two-dimensional list matrix . works in code_v1 when put same code function datastr = datastr.replace("\n", " ") doesn't replace \n same way did in code_v1 (form 1 " " several " " ´s; compare output_v1 output_v2). why case , how can fix it? i read through numerous other questions regarding .replace(old, new) wrote string.replace(old, new) instead of string = string.replace(old, new) . thank in advance answers. p.s. don't want use matrix math. why use two-dimensional list , not numpy.matrix . p.p.s. first questions. if 1 has suggestion how improve readability of question or kind of improvements coding, please tell me. code_v1: datastr = """08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 ...

java - The use of servlets and JSP -

i have created small application have problems in running piece of code in tomcat server 7. want create simple login page. have built database using mysql. form appeared correctly in browser, @ time press submit button 404 error. have used servlets , jsp. appreciate if taking in code below. loginklientiservlet.java: package prorent.controllers; import java.io.ioexception; import java.io.printwriter; import java.sql.drivermanager; import java.sql.resultset; import java.sql.sqlexception; import javax.servlet.requestdispatcher; import javax.servlet.servletexception; import javax.servlet.annotation.webservlet; //import javax.servlet.annotation.webservlet; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import javax.servlet.http.httpsession; import com.mysql.jdbc.connection; import com.mysql.jdbc.preparedstatement; import java.io.*; import javax.servlet.http.*; import javax.servlet...

java - pass parameter from jsp to another jsp dynamically -

i working on java application user's login , predict football matches , create admin jsp teams name stored table in database set week matches , set final results later when matches finish compare them users results , calculate points , top users etc ... my admin.jsp choose matches team jstl foreach loop , set final result later compare them user prediction results. <%@page import="pws.daoimp.usersdaoimp"%> <%@page import="java.lang.string"%> <%@page import="java.util.list"%> <%@page import="java.util.arraylist"%> <%@page import="pws.beans.users"%> <%@page contenttype="text/html" pageencoding="utf-8"%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!doctype html> <html> <% request.getattribute("admminresult"); %> <% list<string> teams1 = new arraylist(); usersdaoimp udi ...

android - No resource error while trying to build Heartbeat app -

Image
i'm trying make app gets heartbeat wear watch, , sends server. i'm trying use upost's heartbeat app base ( https://github.com/upost/myheartbeat ), keep getting these errors: what kind of errors these?

c# - (Interop.Word) Range.Copy-Range.Paste work slow -

i use microsoft.office.interop.word create new doc based on doc. there multiple iterations search/replace operations using range.text , work pretty fast. however, in 1 case need copy entire chapter formatting , instead of range.text (which resets formatting) used range.copy , range.paste. work, test chapter 450 words, take 40 sec (vs. less 1 sec when change same code use range.text). question: there way make range.copy/range.paste faster? need find particular piece of text , copy tables, formatting, etc. file. if want copy text formatting in word can use formattedtext property of range like targetrange.formattedtext = sourcerange.formattedtext; avoid using range.copy() , range.paste() approach internally use clipboard may cause security problems or may provide unpredictable results in cases

java - @Element annotation needs to be added on all fields? -

if have class 20 fields, need add @element annotation on each of them? there way tell simple-framework take all? no, can use @default annotation: the default annotation used specify fields or methods should serialized in default manner. allows objects fields or properties serialized without need annotate them. in addition @default can still use custom annotations @element : @root @default public static class example { private int value = 3; private string string = "abc"; @element(name = "some-custom-name") private string customstring = "custom"; // ... } output: <example> <value>3</value> <string>abc</string> <some-custom-name>custom</some-custom-name> </example>

py2neo - Neo4j: Adding nodes and finding relationship taking more time -

here python code, trying insert nodes , find relationships taking more time, appreciated from xml.dom import minidom py2neo import graph, node, relationship, authenticate authenticate("localhost:7474", "neo4j", "neo4j") graph = graph("http://localhost:7474/db/data/") i=0; xml_file = open("sample.xml") xml_doc = minidom.parse(xml_file) archives = xml_doc.getelementsbytagname('archive') class_names=xml_doc.getelementsbytagname('class') label_archive="archive" label="class" 'adding nodes' arch in archives: arc = graph.create(node(label_archive, arc_value=arch.attributes['name'].value)) topic_nodes = arch.getelementsbytagname('class') clas in topic_nodes: cla=graph.create(node(label,class_value=clas.attributes['name'].value)) e'].value)) **adding relationship** 'this section adds relationship' arch in archives: a...

c - How can I make code that concurrently reads and modifies an array well-defined without introducing locking? -

i'm writing program computes endgame tablebase chess variant. algorithm filling tablebase works this: start huge array of unsigned char , each member representing 1 position (we assume it's white's turn). array member if position lost, odd if won, 0xff if invalid, 0xfe if draw. iterate on array, marking each illegal position 0xff , each position white mated 0x00 , other positions 0x0fe . iterate on array, considering positions marked 0xfe . check if there move leads position array member even, if there one, write 1 plus number of position member corresponding curren position. if moves lead positions indicated odd numbers (i.e. loosing position), mark position 1 plus highest of these numbers indicate how long strongest defence takes. repeat step 3 until array doesn't change anymore. for speed, i'd parallelize step three. careful reading yields in each iteration, ever write 1 value (the number of iteration) array. following strategy obtains: split ...

php - How to check if something is fetched , and then to run multiple query -

i've searching quite time no luck. want check if given username , password correct echo something, it's not working. after want run query. <?php require "conn.php"; $status=1; $user_name = $_post["user"]; $user_pass = $_post["pass"]; $sql = "select * tbl_client username = :user , password = :pass"; $sth = $dbl->prepare($sql); $sth->execute(array(':user => $user_name' , ':pass => $user_pass' )); //$sth->execute(':user' => $user_name, ':pass' => $user_pass); $row = $sth->fetch(pdo::fetch_num); if ($row) { echo 'login success , hello'; } else { echo 'login failed'; } $sql = 'insert login_status (username, status) values (:user, :status)'; $sth = $dbl->prepare($sql); $sth->execute(array(':user => $username' , ':status => $status' )); ?> $...

c# - Selenium tests run on local machine but not through jenkins -

when running selenium tests c# in visual studio on local machine tests run fine , pass. when try run them on jenkins fail. if use firefox jenkins runs fine. problem though boss wants use ie because that's our company uses most. here code failing run: [testinitialize] public void openbrowser() { //start opening browser var options = new internetexploreroptions() { initialbrowserurl = baseurl, introduceinstabilitybyignoringprotectedmodesettings = true, ignorezoomlevel = true, enablenativeevents = false }; string ie_driver_path = @"c:\users\eedward7\desktop\selenium"; driver = new internetexplorerdriver(ie_driver_path, options); driver.manage().window.maximize(); driver.navigate().gotourl(this.baseurl); webdriverwait wait = new webdriverwait(driver, timespan.fromseconds(15)); wait.until(expectedconditions.visibilityofallelementslocatedby(by.id("ctl00_contentplaceholder1_login1_userna...

rest - POST Caspio API -

i'm trying post caspio's api - i've been able perform post & requests fine token , retrieve data in xml caspio although having problems using post method data caspio. in example below i've encoded body {"first_name":"john"} . currently i'm getting 415 unsupported media type - server cannot service request because media type unsupported. var requestpost = new xmlhttprequest(); function postwebapi() { requestpost.open("post", "https://c2ezh542.caspio.com/rest/v1/tables/patient/rows", true); requestpost.setrequestheader("authorization", "bearer " + token_); requestpost.send("%7b%22first_name%22%3a%22john%22%7d"); the table operations specify following: post table rows /tables/<name>/rows method: post description: inserts row table parameters: url, body, required – {“field1″:”value1″,”field2″:”value2”} result: 201 created (if successful) + locati...

javascript - Keystone.js: use one model in multiple sites -

i need create multiple sites using keystone.js (sites network). have reference collection, should used on every site relationship models in other network's sites. it's universal tags list used across network's site. hope understand mean. sorry bad english. without understanding use case see 2 potential architectures explore: single keystone instance: see if can design data use inheritance , try putting sites in 1 keystone instance. ie have parent "post" model , per site "foopost", "barpost" inherits post. way use stock keystone/mongoose relationship mechanisms , built-in crud bootstraps. drawback here architecture make admin ui , data model more complicated think potential solution "partitioning" single keystone instance separate sites. might work better few "sites" on 1 instance more make data model , admin ux complicated use. pros: can use keystone stock crud/relationships cons: more complicated admin...

oracle10g - Is there way to create tables with case insensitive column values in oracle? -

is there way create tables case insensitive column values in oracle? need view oracle through ms-access odbc , need make tables case insensitive. there way alter session in ms access in oracle (below) make them case insensitive: alter session set nls_comp=linguistic alter session set nls_sort=binary_ci

In Swift, how can I get the row of the cell in which a button was pressed? -

i've tried indexpathforrowatpoint solution , worked , don't know broke it. have advice common mistakes might have made? thanks. let pointintable = sender.convertpoint(sender.bounds.origin, toview: self.tableview) let index = self.tableview.indexpathforrowatpoint(pointintable)?.row let prod_id = list[index].getprodid() i create custom cell have closure callback, triggered button import uikit class buttoncell: uitableviewcell { @iboutlet weak var button: uibutton! { didset{ button.addtarget(self, action: #selector(buttoncell.buttontapped(_:)), forcontrolevents: .touchupinside) } } var buttonwastapped: ((cell: buttoncell) -> void)? override func setselected(selected: bool, animated: bool) { super.setselected(selected, animated: animated) } func buttontapped(sender:uibutton) { buttonwastapped?(cell: self) } } now in datasource (note: here implemented in view controller, be...

c# - Nunit action attribute: Don't run AfterTest method if any exception -

how prevent running aftertest method if there exception in testmethod? public class testattribute : attribute, itestaction { public void beforetest(testdetails testdetails) { // run before test // .... } public void aftertest(testdetails testdetails) { // don't run if there exception // how check whether exception thrown nunit // ... } public actiontargets targets { get; private set; } } [test][testattribute] public void testmthod() { throw new exception("test exception"); } is there way know if exception thrown or assert failed in aftertest method? note: i'm not interested in details of exception. if exception thrown in testmthod result error not failure, hence believe in current code block can take advantage of test context this: public void aftertest(testdetails testdetails) { if(testcontext.currentc...

.htaccess - 301 redirect help after changing Wordpress permalinks from postname to post_id -

i have searched here, wordpress.org , wider internet, information can find opposite of i'm trying achieve. i have taken on maintenance of large 10-year old wordpress site (v.4.5.3) 3,000 posts, 100 pages , 5,000 unique hits per day, , want change permalink structure because old 1 no longer appropriate. the present permalink structure /%category%/%postname%.html we want change /%post_id% as second choice, reverting default /?p=123 format acceptable. the problem is, how manage 301 redirects in .htaccess? don't want use plugin if can it, i'd rather manually. my .htaccess presently follows: # begin wordpress <ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewriterule ^index\.php$ - [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /index.php [l] </ifmodule> # end wordpress any appreciated.

linux - file and path listing separator : -

this question has answer here: replacing characters in string character 5 answers i need to list out folder structure folder/cd/dvd, need path , filename displayed. can using find command: find /path* but instead of usual / separator need separator : so when use find on folder following output: 2d/resource/2011 brand-guidelines/1664/logos/1664/small/k1664-cmyk-background-small.ai 2d/resource/2011 brand-guidelines/1664/logos/1664/small/k1664-pms-background-simple-small.ai 2d/resource/2011 brand-guidelines/1664/logos/1664/small/k1664-pms-background-small.ai 2d/resource/2011 brand-guidelines/1664/logos/1664/small/k1664-pms-simple-small.ai but need display output so: 2d:resource:2011 brand-guidelines:1664:logos:1664:small:k1664-cmyk-background-small.ai 2d:resource:2011 brand-guidelines:1664:logos:1664:small:k1664-pms-background-simple-small.ai 2d:resource:201...

windows - Error Loading Project: Visual C# 2015 compiler could not be created -

Image
i using visual studio 2015 community edition in windows 10 professional(64 bit). today installed new visual studio update 3 , getting error e:\path_to_solution_folder\projectname.web.csproj : error : project 'projectname.web' not opened because visual c# 2015 compiler not created. exception thrown while initializing part "microsoft.codeanalysis.diagnostics.diagnosticanalyzerservice". googled bit, , got solution website, link: fixing visual studio 2015 after update 3 so per article, added system.reflection.metadata.dll gac. now when try run project or open controller ide still restarts! went event logger , found out this. application : devenv.exe framework version : v4.0.30319 description : application requested process termination through system.environment.failfast(string message). message : system.io.filenotfoundexception: not load file or assembly 'system.reflection.metadata, version=1.0.21.0, culture=neutral, publ...

git - GitHub Enterprise: enforce code freeze during release? -

here, use github enterprise. have issue people accidentally merging prs during code freeze windows, interferes our in-house release tool. nice if find way prevent this. what i'm trying do, find way disable big green merge button on each repo belonging our organisation within github while our release tool running, , reenable afterwards. ideally, scripted, since have control on our release tool. how might accomplished? there numerous ways this; in end, went changing permissions (read/write/admin) on (team, repository) combinations via rest api . that's not webhooks, enabling/disabling branch restrictions, or pre-merge not work, however.

How to alter an uploaded image resolution using PHP before storing in mysql BLOB field -

Image
i have created mysql database 'tutorial_db' , in database have created table 3 columns: i have written following code using php , html upload image file , store in longblob 'image' column , display images database in same page: <?php //connect database $con = mysqli_connect('localhost', 'root', '', 'tutorial_db') or die('could not connect database: '.mysqli_connect_error()); ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>upload image</title> </head> <form action="image.php" method="post" enctype="multipart/form-data"> <p><input type="file" name="image"></p> <p><input type="submit" name="upload_image" value="upload"></p> </form> <?php error_reporting(0); if(isset($_post['upload_image'])) { //check if image fi...

html - Equal height columns bootstrap 3 -

hey there working on project website , facing problems, columns, <div class="row-eq-height"> <div class="col-xs-4 col-md-4"> <div class="thumbnail"> <img src="img/seo.png" height="150" width="150"> <div class="caption"> <h4 class="text-center">seo services</h4><hr class="style-one"> <h4 class="text-center">we provide seo services ,which boost site ranking on different search engine, google,yahoo,etc.</h4> <div class="text-right"> <a href="#" class="btn btn-primary" >25$</a> </div> </div> </div> </div> <div class="col-xs-4 col-md-4 "> <div class="thumbnail"> <img src="img/s2.png" height="150" width="150"...

C# Multiple String Contains -

this question has answer here: how simplify if condition having multiple or cases [closed] 5 answers basically want detect more 1 string, current code example is if (!str3.contains("example1")) { continue; } how add " example1 ", " example2 " & " example3 " you can use linq if want test large list: var excludes = new[] { "example1", "example2", "example3" }; //your loop here { if (!excludes.any(x => str3.contains(x))) { continue; } }

html - bootstrap3 form has text overlapping with dropdown -

Image
i trying create form looks this: what have come looks this. either can have dropdown take correct amount of space, text underneath, or have text next dropdown , gets smushed. i'm not sure i'm doing wrong. here html: <form class="schedulerbody form-horizontal" id="{{sourcecleaned}}"> <div class="form-group"> <label class="col-sm-3 control-label">{{t "templates.scheduler.fireevery"}}</label> <div class="col-sm-8"> <div class="form-inline"> <div class="form-group"> <select class="livesyncschedule form-control"></select> </div> <div class="form-group">{{t "templates.scheduler.seconds"}}</div> </div> </div> <div class="col-sm-offset-3 col-sm-8"> <div class="checkbox...

angularjs - Uncaught ReferenceError: require is not defined on karma start karma.conf.js -

using karma , jasmine unit testing on angular front-end of rails app. appears i've done known man through error , i'm left million dependencies in package.json. here karma.conf.js: module.exports = function(config) { config.set({ // base path used resolve patterns (eg. files, exclude) basepath: '', // frameworks use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter // list of files / patterns load in browser files: [ //angular mocks 'bower_components/angular/angular.js', 'bower_components/angular-mocs/angular-mocks.js', 'bower_components/angular-resource/angular-resource.js', //load modules 'public/app/app.js', //test file locations 'app/**/*.js', 'spec/**/*.js', 'public/**/*.js' ], // list of files exclude exclude: [ ], // preprocess matching files before serving them browser // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor p...

rubygems - Ruby - Bundle Install -

i novice in ruby , trying follow instruction. instructions follows: 1 install ruby , rvm 2 installed ruby apt-get , rvm curl -sl https://get.rvm.io | bash -s stable --ruby --autolibs=enable --auto-dotfiles 3 add source source /usr/local/rvm/scripts/rvm 4. installed rvm install 1.9.3-p374 5.and did rvm use "1.9.3-p374@edx-platform" --create 6 , did rvm rubygems latest , gem install bundler 7 bundle install --gemfile gemfile i error saying /root/edx_all/edx-platform/gemfile not found the instructions install openedx on ubuntu 12.04 , given here - installation instruction openedx please me out pointing doing wrong

asp.net mvc - deserialize custom object returned from web api -

client make request web api method , object response problem cant desirialize object.. client method, making request web api httpclient client = new httpclient(); client.baseaddress = new uri("http://localhost:57752"); httpresponsemessage response = client.getasync("api/auth/login/" + user.username + "/" + user.password).result; jsonresult result = null; if (response.issuccessstatuscode) { result = response.content.readasasync<jsonresult>().result; javascriptserializer json_serializer = new javascriptserializer(); user validuser = json_serializer.deserialize<user>(result.data.tostring());//throws exp. } i want put object instance returned api validuser.. error message: cannot convert object of type 'system.string' type 'mongodb.bson.objectid' here models...

asp.net mvc - Why Html.ActionLink isn't working in Bootstrap Modal? -

i've got work around own understanding i'm trying figure out why @html.actionlink wouldn't work in bootstrap modal? i created logout controller logging , cleans session variables before redirecting. able create log out link on layout page using @html.actionlink without issue. however, have view uses bootstrap modal on it. when use same @html.actionlink doesn't work. @html.actionlink("ok", "index", "logout", new { @class = "btn btn-success btn-lg" }) when @ f12 tools can see link not correct. created. <a class="btn btn-success btn-lg" href="/?length=6">ok</a> however, if use @url.action in anchor tag instead works fine. works. <a href='@url.action("index","logout")' class="btn btn-success btn-lg">ok</a> i'm okay using @url.action i'm trying learn why @html.actionlink wouldn't work. you using actionlink overload ...

html - How to add " You save $xxx " in category / product listing page in Bigcommerce? -

we have option add " save $xxx.xx " text on product page in bigcommerce using variable %%global_yousave%% which show special price , savings :- http://screencast.com/t/dukulaqmil but have similar variable category page? mean can show similar on category page? so can add similar text in category page. thank in advance. i've tried make %%global_yousave%% work on categoryproductsitem.html snippet , wasn't successful. i have done variations of various map policies in jquery. can try in category page. hope helps: $('.retailpricevalue').each(function(){ var savevalue = ($(this).html().substring(1)) - ($(this).siblings('.saleprice').html().substring(1)); savevalue = savevalue.tofixed(2); $(this).siblings('.saleprice').append( "<br /><b> save: $" + savevalue + "</b>" ) });

symfony - How to add a setter injection injecting a service from a bundle extension -

i'm trying make kind of optional dependency on doctrine orm. depending on configuration, want "doctrine.orm.entity_manager" injected setter injection alsatian_form.form_event_subscriber.extensible service. <?php use symfony\component\httpkernel\dependencyinjection\extension; class alsatianformextension extends extension { public function load(array $configs, containerbuilder $container) { $configuration = new configuration(); $configformbundle = $this->processconfiguration($configuration, $configs); $loader = new loader\yamlfileloader($container, new filelocator(__dir__.'/../resources/config')); $loader->load('services.yml'); if($configformbundle['extensible_entity']['enabled']){ $definition = $container->getdefinition('alsatian_form.form_type.extensible_entity'); $definition->setpublic(true); $definition->addtag('form...

c# - Fire method on TextChanged but not all the time -

i creating simple autocomplete textbox , have list of values if user starts enter characters in them string, appropriate string appear. now have created textbox binding property viewmodel: <textbox text="{binding serverurl, updatesourcetrigger=propertychanged}" /> so when user enters new character trigger property fired , therefore fire method retrieve values relates to. private string _serverurl; public string serverurl { { return _serverurl; } set { _serverurl = value; serverurl_textchanged(); onpropertychanged("serverurl"); } } the method populate listbox results string refers to. when select value listbox want set full string value textbox text property, when triggers method serverurl_textchanged(). is there way can set serverurl property, not fire method inside it? for solution there need separate ways can set serverurl property. public string serverurl { { return _serverurl; } ...

python - Loop for imputation -

i make imutation single variable & return same variable x = pd.dataframe(df, columns=['a']) imp = imputer(missing_values='nan', strategy='median', axis=0) x = imp.fit_transform(x) df['a'] = x however have many variables & want use loop this f = df[[a, b, c, d, e]] k in f: x = pd.dataframe(df, columns=k) imp = imputer(missing_values='nan', strategy='median', axis=0) x = imp.fit_transform(x) df.k = x but: typeerror: index(...) must called collection of kind, 'a' passed how can use loop imputation & return variables in dataframe? a dataframe iterates on it's columns names k == 'a' in instance rather first column. implement with f = df[[a, b, c, d, e]] k in f: x = df[k] imp = imputer(missing_values='nan', strategy='median', axis=0) x = imp.fit_transform(x) df[k] = x but want build new dataframe using apply column wise. like df = df.a...

vba - Programming to query 100000 users in AD -

i working on project query ad, have script that, script failing after 1000 users, while users querying around 150.000 users. here code: below script , can tell me on line sub usersynchquery(byref res apiresult, byref orespds apidataset, byref sldapserver string, byref sldapport string, byref sldapbase string, byref susername string, byref spassword string, byref sslpprimary string, byref sslpsecondary string, byref sextension string, byref sconfiggroup string, byref sfilter string ) trace( "called usersynchquery entered" ) dim odsp object dim odsrs object on error resume next set odsp = createobject("adodb.connection") odsp.provider = "adsdsoobject" odsp.open( "ads provider", susername, demung( spassword )) if err.number <> 0 trace("error: failed instantiate ado object. " & err.number & " " & err.description) res.code = "failed" res.reason = "failed in...