Posts

Showing posts from September, 2011

Time Complexity Dijkstra -

if complexity of algorithm o(evlogv) . given e=20000 , v=1000 . how many seconds take execute? 20000 * 10000 log 10000 = 800000000 what 800000000 means ? big-o notation way of describing how many times set of operations performed. doesn't relate directly time on machine or instructions required operate on machine. so, 800000000 number of times set of operations performed when have data set of size e=20000 , v=10000.

HTML select doesn't show scrollbar with size = 1 and multiple = true in Firefox 39 -

Image
when create <select> element multiple selection , size=1 , firefox doesn't draw scrollbar. firefox version 39 . example, in chrome ok. <select size="1" multiple> <option value="0" label="val1">val1</option> <option value="1" label="val2">val2</option> <option value="2" label="val3">val3</option> </select> can it? example here: http://jsfiddle.net/tzd6uazj/ when define size="1" creating 1-option-high multiple select box, of course incredibly unfriendly thing visitors. if want allow users select multiple list items, set size attribute reasonable number can see more 1 option @ time. even on chrome(in fiddle), couldn't see option 2 in select.... can't use checkbox button group?

perl - read xml file without any XML module -

i trying read xml form using perl can not use xml modules xml::simple, xml::parse. it simple xml form has basic information , ms doc attachment. want read xml , download attached doc file print xml information in screen. but don't know way how can without xml module , heard xml file can parse using data::dumper not familiar module, not getting how this. could please me on if there way without xml modules? sample xml: <?xml version="1.0"?> <catalog> <book id="bk101"> <author>gambardella, matthew</author> <title>xml developer's guide</title> <genre>computer</genre> <price>44.95</price> <publish_date>2000-10-01</publish_date> <description>an in-depth @ creating applications xml.</description> </book> <book id="bk102"> <author>ralls, kim</author> <title>mi

Logstash add date field to logs -

my application produces logs, without timestamp. there way in logstash append timestamp logs on processing something like, mutate { add_field => { "timestamp" => "%{date}" } } logstash adds @timestamp field default. don't need set additional. logstash take time event received , add field you. for example if try command: ls_home/bin/logstash -e 'input { stdin {} } output { stdout { codec => rubydebug } }' you see automatically created @timestamp field in result: "@timestamp": "2015-07-13t17:41:13.174z" you can change format , timezone using date filter or can match timestamp of event (e.g. syslog timestamp) using other filters grok or json.

Rails: rendering collection of different models -

i have defined @results variable in controller contains different models , want render them in view using <%= render @results %>. how can give render method address directory contains partials these models. solution <% @results.each |result| %> <%= render "home/partials/#{result.class.name.downcase}", result.class.name.downcase.to_sym => result%> <% end %> render in current object's view directory: render 'form' # renders _form.html.erb in same directory to in directory, add it's directory name: render 'shared/form' # renders _form.html.erb in views/shared/ since results variable apparently contains multiple models, assign directory value each entry in hash or array , call in view or controller. that's best can give based on very, little information in question.

.net - Executing Gulp task(s) only when publishing ASP.NET 5 web application -

what best way execute gulp tasks when publishing asp.net 5 web application? need add custom build event executes gulp command? cmd.exe /c gulp -b "c:\projects\projectname\source\projectname.web" --gulpfile "c:\projects\projectname\source\projectname.web\gulpfile.js" publish or, preferably, there way bind gulp task beforepublish target via task runner explorer? any suggestions appreciated. update 2 .net core cli doesn't support "prepack" more. "postcompile" script may work better. https://docs.microsoft.com/en-us/dotnet/articles/core/tools/project-json#scripts original answer add "scripts" section of project.json project.json: scripts documentation { ... "scripts": { "prepack": "gulp publish", } ... }

asp.net mvc - 400 BadRequest Error And Custom Error Page -

i try have custom error page http error 404 page, add following in web.config. , can work. <system.webserver> <httperrors errormode="custom" existingresponse="replace"> <clear /> <error statuscode="401" path="~/error/unauthorized" responsemode="executeurl" /> <error statuscode="403" path="~/error/forbidden" responsemode="executeurl" /> <error statuscode="404" path="~/error/notfound" responsemode="executeurl" /> <error statuscode="500" path="~/error/servererror" responsemode="executeurl" /> </httperrors> </system.webserver> originally, request through web api , return error messages. after adding httperrors in web.config. returns "badrequest". any idea of solve that? thanks in advance try: <configuration>

jsp - How do I add simple pagination for Spring MVC -

this controller users view page: @requestmapping(value="/list") public modelandview listofusers() { modelandview modelandview = new modelandview("list-of-users"); list<user> users = userservice.getusers(); pagedlistholder<user> pagedlistholder = new pagedlistholder<>(users); //pagedlistholder.setpagesize(1); modelandview.addobject("users", pagedlistholder); return modelandview; } and jsp page: <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <?xml version="1.0" encoding="iso-8859-1" ?> <%@ page language="java" contenttype="text/html; charset=iso-8859-1" pageencoding="iso-8859-1"%> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/

email - PHP Contact Form for Bootstrap -

this question has answer here: php mail function doesn't complete sending of e-mail 24 answers i have trouble php contact form on bootstrap. don't know problem. gives error message. replaced e-mail address there still gives error. don't know line change. <?php // check empty fields if(empty($_post['name']) || empty($_post['email']) || empty($_post['phone']) || empty($_post['message']) || !filter_var($_post['email'],filter_validate_email)) { echo "no arguments provided!"; return false; } $name = $_post['name']; $email_address = $_post['email']; $phone = $_post['phone']; $message = $_post['message']; // create email , send message $to = 'info@balkescafequiz.com'; // add email address inbetween '' replacing yourname@yourdomain.com

c# - SOA for old Application -

i have 1 project have 8 modules. of developed in vb.net,asp.net,c# windows forms,asp.net have situation not able manage modules. need re-write application using new technology aps.net mvc, web api etc. have big problem have lot of logic in stored procedure (80% ~ 90%) not come out of sp. using ef database communication not able design domain model in persistence layer , need ddd (domain driven design) how design application architecture support web,desktop application , mobile. :) stored procedure business logic inherently not going ddd. if insisting keep stored procedures, not ddd. that being said, wrapping web api wrappers around stored procedures should allow leverage them in various ways specify: how return values web api controller stored procedure in dbcontext http://sivakumarparameswaran.blogspot.com/2014/02/how-to-invoke-stored-procedure-in-web.html

android - Fixed TabLayout and Content overlap AppBar -

Image
with new android support design library, there has come cool features regards appbar. i'm looking @ implementing same scroll effect shown in gif above. (taken google play games -> games) i've had @ adding following attribute nestedscrollview, placing content above appbar. app:behavior_overlaptop it works expected when components inside appbar set scroll. app:layout_scrollflags="scroll" if want tablayout pinned @ top, space below pinned. looks weird: in short, there way create above using new design library, or have make other way? requested xml: <android.support.design.widget.coordinatorlayout android:id="@+id/content" android:layout_height="match_parent" android:layout_width="match_parent"> <android.support.design.widget.appbar android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="164dp" andro

android - Toast that only shows on debug variants -

i create simple helper class shows toast messages debug variants only. used this: toast.maketext(context, "debug toast message", toast.length_short).show(); toast.java import android.annotation.suppresslint; import android.content.context; import android.support.annotation.nonnull; import android.widget.toast; import com.mypp.buildconfig; /** * toast shows debug build variants. */ @suppresslint("showtoast") public class toast extends toast { public toast(context context) { super(context); } @nonnull public static toast maketext(@nonnull context context, charsequence text, int duration) { return (toast) toast.maketext(context, text, duration); } @nonnull public static toast maketext(@nonnull context context, int resid, int duration) { return (toast) toast.maketext(context, resid, duration); } @override public void show() { if (buildconfig.debug) { super.show();

input - Increase font size with jquery -

i'm attempting run split test optimizely , need increase size of font used description text in site search's search field. i've managed change color using code: $("input[value]").css({"color":"#cc0000"}); but if add on font-size nothing happens? i.e. $("input[value]").css({"color":"#cc0000", "font-size" : "1.9rem"}); i've tried following still doesn't seem work?? $("input").css({"font-size" : "1.9rem"}); it looks have !important on riding changes made using .css() function. following. $("input") .css({ 'csstext':'font-size:1.9rem !important', 'color':'#cc0000' }); demo

regex - python 3.4 regular expression windows registry -

i'm trying make regular expression return characters between last \ , closing ] .reg files so far can work using no spaces in last key: [hkey_local_machine\software\foo\bar\keypath] using (?<=\\)(\w+)] but can't handle spaces in last entry e.g: [hkey_local_machine\software\foo\bar\key path] i've many different keys , have 2 words while not. i'm still trying grips regular expressions. maybe alternative: (?<=\\)[^\\]+(?=]$) regex live here. explaining: (?<=\\) # starting '\' without taking [^\\]+ # character except '\' - many possible (?=]$) # till ending ']' character - without taking hope helps.

PHP variable doesn't echo in table when function called -

this question has answer here: reference: variable scope, variables accessible , “undefined variable” errors? 3 answers i have simple vars.php page: <?php //vars.php $weekofdateselected = date('l, m/d/y', strtotime($monthyear)); $nextsundayofdateselected = date('l, m/d/y', strtotime('this sunday', strtotime($weekofdateselected))); ?> i have php includes vars.php , builds table: <html> <?php //analyticstest.php include($_server['document_root']."/~/~/~/~/~/vars.php"); function weektable() { echo "<table id=\"a\"> <tr> <th style=\"text-align: center;\"><a href=\"#\">< previous week</a></th> <th colspan=\"4\" style=\"text-align: center;\"><h2>week of "; echo $weekofdateselected; echo " - &q

c# - Getting null item in select template of DataTemplateSelector -

i trying use contenttemplateselector of contentcontrol load datatemplate in code behind. for first time alone, getting null in argument item of selecttemplate. here code snippet. public mainwindow() { initializecomponent(); this.datacontext = new orderinforepositiory(); contentcontrol c1 = new contentcontrol(); c1.contenttemplateselector = new edittemplateselector(); c1.setbinding(contentcontrol.contentproperty, new binding()); this.addchild(c1); } public class celltemplateselector : datatemplateselector { public override datatemplate selecttemplate(object item, dependencyobject container) { return base.selecttemplate(item, container); } } let me have reason behind that. thanks. to understand reason behind behavior describe have analyze code. the contentcontrol c1 not belong visual tree until call addchild method, there no need "disturb" contenttemplateselector . instead wh

ios - Swift singleton used with init(coder:) -

i'm trying make reusable ui component using singleton it's same instance used through app when ui component show (only 1 of these can shown @ same time obviously). so created simple uiview subclass , defined sharedinstance swift 1.2 way. here's code : import uikit class myview: uiview { static let sharedinstance = myview() } the thing wondering if there's way make sharedinstance used when view called storyboard (so through init(coder:) method). in objc easy init methods can return desired object in swift don't know if it's possible (as swift init don't return object). edit : add context (some people don't understand why i'd want that). i'm trying avoid given ui component on have no control eat memory available. this component mkmapview doesn't free memory takes after being uninstantiated. tried several things none did give me memory took instantiation of mkmapview. so trying use same instance of mkmapview everywhere

Insert record newly inserted ID into child records SQL Server OUTPUT clause -

i have projectstaging table want insert records project table based on no match on stagingid field. project table has own auto incrementing projectid. part if fine (using not exists). next want create 3 projectlineitems each inserted project newly inserted projectid , default settings of 1, 2 , 3 in status field. using output extract projectid, saving id temptable , storing in variable @newprojectid later on inserting 3 line items. getting error saying projectid null. why be? output id not making temptable? ---here's sql declare @newprojectid int declare @temptable table(id int) insert project ( stagingid, field1, field2 ) output inserted.projectid @temptable(id) select stagingid, field1, field2 projectstaging not exists ( select * projectstaging project.stagingid = projectstaging.stagingid) select @newprojectid = id @temptable insert projectlineitems(projectid, status) values(@newprojectid, 1) insert projec

swing - Setting up a progress bar in Java -

i have program , have tried implement progress bar code. bellow example of code currently. main gui in own class , instantiates other classes execute code within classes' methods. example follows: class mainclass { public javax.swing.jprogressbar progressbar; private void combineactionperformed(java.awt.event.actionevent evt) { combine combiner = new combine(); combiner.merge(folder); } } it takes folder listing , goes combine class has following code: public class combine extends swingworker<integer,integer>{ public void merge(folder []){ (for int i=0;i<folder.length;i++){ merge(folder[i]); } public void merge(folder[]){ output stream; } } how implement swing worker in example make progress update mainclass progress bar each iteration of occurs? to begin, worker missing methods should implement, such doinbackground() , done() . need constructor pass folder[] . public class combine extend

ios - GPPSignIn vs GIDSignIn -

what difference between gppsignin , gidsignin . , in circumstances should use either. gidsignin class part of google signin ios. preferred way sign in ios application. 1 of main advantages using gidsignin vs. gppsignin gppsignin switches on safari users, , apple not approve app switches. gppsignin part of plusapi, once sign in gidsignin, other g+ calls work (just remember add correct scopes signin request). migrating gidsignin pretty minimal, can on migration guide (it's barely page): https://developers.google.com/identity/sign-in/ios/quick-migration-guide

web - How can I have refresh page link/button inside my JavaScript code? -

basically have following code checks user input , gives output accordingly: <script> function checkuserinput() { var userinput = document.getelementbyid("textinput").value; var stringtocheckagainst = random_images_array[num].split('.'); if (userinput.touppercase() == stringtocheckagainst[0].touppercase()) { document.getelementbyid("row1").innerhtml="<p>" + txt.fontsize(5) + "</p>";document.close(); } else { //user has inputted incorrect string document.getelementbyid("row1").innerhtml="<p>" + txt1.fontsize(5) + "</p>";document.close(); } } </script> however problem is, in case user response not correct , programme displays “incorrect message”, need show refresh or reset button or text clicking on link user can again refresh page , gets new cha

python - How to do a general "search bar" search across multiple SQLAlchemy models -

i have search bar app. user searched 'john smith united kingdom oxford university' return user accounts table name 'john smith', location 'united kingdom' , education 'oxford university'. here general overview search 'john smith united kingdom oxford university': show accounts database name 'john smith', location 'united kingdom' , education 'oxford university'. show accounts name 'john smith' , education 'oxford university' show accounts name 'john smith' , location 'united kingdom' show accounts name 'john smith' i cannot find resources flask-sqlalchemy specify how this. i'm aware have use .like() though don't know how add sqlalchemy query in flask. sqlalchemy .where(column.like()) though cannot in flask-sqlalchemy. how go doing this? you use like() use in sqlalchemy : user.query.filter(user.name.like("%john smith%")).all(

kubernetes - How to get real customer ip in google container engine and apache setup -

i can't find out customer real ip address when apache-php enviroment runs in google container. without modifying anything, ip address container address range, when using mod_remoteip, can add remoteipheader x-client-ip remoteipinternalproxylist ournet/proxy-list and add rows "proxy-list"-file: 10.240.0.0/16 # google internal network 10.244.0.0/14 # cluster aadress range only row 10.244.0.0/14 gives result. in case cluster node's ip remote_addr value 10.240.0.0/16 network. it seems, node acts forwarder, without adding needed headers request or looking totally wrong perspective? some traffic masqueraded, done @ l3, rather l7, there's no way add header. :( this better in-cluster traffic, have wait cloud load-balancers catch before can handle out-of-cluster traffic properly.

angularjs - MEAN.JS: Slow charging time -

situation i'm using mean.js framework ( mongodb , expressjs , angularjs , nodejs ). i bundled , minified grunt build angularjs .js files ( controllers, factories, services, directives... ). the result 2 files: css: 'public/dist/application.min.css', js: 'public/dist/application.min.js' problem the file application.min.js 266kb . when user load web , file takes 5 minutes delay before page loaded . (using aws ec2 ). get /dist/application.min.js 200 274.939 ms - - 274939 ms > 274.939 s > 4.58 min the same problem happening before bundling , minified. thinking solution of problem bundling , minified of angularjs files. isn't it. after .js files loaded, application fast, takes 5min loaded... what need solve problem? project large , have lot of files, , understand angularjs projects this... i solved problem! finally problem isn't bundled , minified 266kb file! the problem liveload.js file. in localhost

Dependancy injection with PHPunit Laravel 5.1 -

the project has service/repository/contract framework i'm trying test phpunit . dependency injection done via controller methods injecting repository contract (interface). using service providers injected contracts replace correct repository. the problem need access these repositories within unit testing. such in roletest class funciton testsomething(\examplenamespace\users\contract\rolecontract $repo){ $service = new roleservice($repo); //do fun stuff $ret = $service->dosomething( ); } however not work. error thrown saying instance in not correct empty string received instead. i run. funciton testsomething( ){ $repo = new \examplenamespace\users\repositories\roleeloquentrepository( ); $service = new roleservice($repo); //do fun stuff $ret = $service->dosomething( ); } then defeat purpose of dependency inversion. how can make work?

symfony - Get Swiftmailer's settings from a Controller in Symfony2 -

i have config in config.yml file swiftmailer: transport: "%mailer_transport%" host: "%mailer_host%" username: "%mailer_user%" password: "%mailer_password%" spool: { type: memory } how read these settings controller in order check whether spool has been set or not? you move spool config in parameters.yml , example: # app/config/parameters.yml parameters: mailer_spool: { type: memory } and replace line in config.yml parameter: # app/config/config.yml swiftmailer: spool: "%mailer_spool%" now in any controller spool config like: public function youraction() { $spool = $this->getparameter('mailer_spool'); }

scala - Updating immutable map as the side effect of getOrElse -

sometimes use map memoization cache. mutable maps, use getorelseupdate : mutablemap.getorelseupdate(key, { val value = <compute value> value }) immutable maps don't have getorelseupdate . want this immutablemap.getorelse(key, { val value = <compute value> immutablemap += key -> value value }) this seems work in practice, have arguments believe works in theory, , it's more or less readable -- terrible idea reason i'm missing? the other alternatives i'm considering are immutablemap.get(key) match { case some(value) => value case none => val value = <compute value> immutablemap += key -> value value } which not different , more cumbersome, or if (immutablemap.contains(key)) { immutablemap(key) } else { val value = <compute value> immutablemap += key -> value value } which dumbest , least idiomatic. in principle rather not go solution uses h

Android: AppCompat 21, how to change the back icon and the overflow icon to a custom one? -

on project until days ago used sherlock actionbar dicided change whole actionbar style new material design. on old theme , overflow icon had custom icons setted on theme. on appcompat tried define on theme use on toolbar it's not working. knows how make possible? my theme use on toolbar(generated asset studio): <style name="theme.themewiz" parent="@style/theme.appcompat.light.darkactionbar"> <item name="android:actionbarstyle">@style/actionbar.solid.themewiz</item> <item name="android:actionbaritembackground">@drawable/selectable_background_themewiz</item> <item name="android:popupmenustyle">@style/popupmenu.themewiz</item> <item name="android:dropdownlistviewstyle">@style/dropdownlistview.themewiz</item> <item name="android:actionbartabstyle">@style/actionbartabstyle.themewiz</item> <item name="android:acti

AtTask: How to retrieve timeZone IDs -

i trying post users external system onto workfront. post timezone value user through api. how timezone id can pass put users rest api. thank you, uma the timezone value string, can't confirm if java class based on locale. while labor intensive, switch timezone , use /api/user/search?id={id}&fields=timezone retrieve values correspond drop down on user profile gui. if have users set timezones use, generate user report timezone column values.

Execute looping bash script via PHP without interrupting server function -

i have apache server login page want pass credentials provided @ login authenticate upload of file sent server. i'm new this when upload file server, responds 500 code. think problem autoupload.sh because when comment out line 3 of upload.php, error code ceases , uploads server work, naturally files never uploaded external service. the point of autoupload.sh watch monitor added files /uploads/ directory, upload them webservice, delete them locally on completion, , exit. index.php form looks <form action="uploadpage.php" method="post"> <input name="field1" type="text"/> <input name="field2" type="password"/> <a href='/tmp/data.txt></a> //html content //more html content uploadpage.php contains form: `<form action="upload.php" class="dropzone" id="my-dropzone"></form> //more html , css` upload.php looks like: `$old_path=getcwd

sas - Export multiple datasets to multiple sheets(Imp: excluding variable name/label in datasets) -

i have few datasets have export excel. for example: dataset: ds1 variable_1 variable_2 variable_3 datax datay dataz dataset: ds2 variable_a variable_b variable_x dataxxx datayyy datazzz requirement: export these datasets excel sheet out variable names/labels. example excel sheet should like: datax datay dataz i.e., out variable names/labels , data. i tried using proc export dbms csv proc export data=ds1 dbms=csv outfile="ds1_data.csv" replace; putnames=no; run; proc export data=ds2 dbms=csv outfile="ds2_data.csv" replace; putnames=no; run; it working fine putnames="no" option. however creates multiple csv files. need single excel sheet multiple sheets (with out variable names) any options available? @kay can write way. proc export data=ds1 dbms=xls outfile="ds1_data.xls" replace; putnames=no; sheet=ds1; run; proc export data=ds2 dbms=xls outfile="ds1_data.xls" replace; put

html - JavaScript Unknown Error in Code -

so im making simple guessing game , numbers go 1-10. issue whenever guess number right still says wrong here source code program. (is proper meaning of source code?) <!doctype html> <html> <head> <title>first proper html page</title> </head> <body> <h3>hello world</h3> <p>this first website</p> <p>its fun , exciting</p> <p><a href="http://xkcd.com" title="xkcd:land of geeky comics!">click here </a> <script> var randomnumber = math.floor(math.random(100) * 11); //console.log(randomnumber); var guess = prompt("please guess number 1 - 10"); if(guess === randomnumber){ alert("you have won! number " + randomnumber); }else{ alert("you have guessed wrong number, real number " + randomnumber); } </script> </body> </html&

Javascript calculate date week by week -

hy guys, have write javascript code calculate date day of week progressively. ahve error when code must calculate end of month: example after 31/07/2'15 code generate 32/07/2015 instead 01/08/2015. code: var application = this; var currentdate = new date(); var stringdate1 = currentdate.getutcdate() + "/" + (currentdate.getmonth() + 1) + "/" + currentdate.getfullyear(); var stringdate2 = (currentdate.getutcdate()+1) + "/" + (currentdate.getmonth() + 1) + "/" + currentdate.getfullyear(); var stringdate3 = (currentdate.getutcdate() + 2) + "/" + (currentdate.getmonth() + 1) + "/" + currentdate.getfullyear(); var stringdate4 = (currentdate.getutcdate() + 3) + "/" + (currentdate.getmonth() + 1) + "/" + currentdate.getfullyear(); var stringdate5 = (currentdate.getutcdate() + 4) + "/" + (currentdate.getmonth() + 1) + "/" + currentdate.ge

Code to check for expiration date, from one python scripts output -

i have pre made python script calls c# script within address server. output of script is: build number : 2381 database date : 2015-07-15 database expiration date: 10-31-2015 license expiration date : 2016-05-03 build number : 2381 database date : 2015-06-15 database expiration date: 2015-12-15 license expiration date : 2016-05-03 i want able check today's date against "license expiration date". i've looked on datetime , stumped. know can't check date against integer, cant it. have far. import time print (time.strftime("%y-%m-%d")) datet = '2015-12-15' class timedelta(object): @property def isoformat(self): return str() expirationdate = time.strftime("%y-%m-%d") if expirationdate >= datet: print 'renew license soon' elif expirationdate == datet: print 'renew license immediately' else: print "license ok" quit()

node.js - Npm install doesn't work on Windows 10 -

i have issue nodejs. i'm trying install ember.js library through command line. when launch "npm install" command log appear: 0 info worked if ends ok 1 verbose cli [ 'c:\program files\nodejs\\node.exe', 1 verbose cli 'c:\program files\nodejs\node_modules\npm\bin\npm-cli.js', 1 verbose cli 'install' ] 2 info using npm@2.11.3 3 info using node@v0.12.7 4 verbose config skipping project config: c:\users\antonio/.npmrc. (matches userconfig) 5 verbose readdependencies loading dependencies c:\users\antonio\package.json 6 error install couldn't read dependencies 7 verbose stack error: enoent, open 'c:\users\antonio\package.json' 7 verbose stack @ error (native) 8 verbose cwd c:\users\antonio 9 error windows_nt 6.3.9600 10 error argv "c:\program files\nodejs\\node.exe" "c:\program files\nodejs\node_modules\npm\bin\npm-cli.js" "install" 11 err

c# - Why do I need to declare the type? -

i have following code: public interface imyactionfactory { abstractaction<t> createaction<t>(myactionparambase parambase = null) t : myactionparambase; } public sealed class mergeactionparam : myactionparambase { } public class mergetest { private readonly imyactionfactory _actionfactory = new defaultmyactionfactory(); [theory] [propertydata("mergeworksdata")] public void mergeworks(/*params here*/) { var param = new mergeactionparam(); // populate param here var sut = _actionfactory.createaction<mergeactionparam>(param); sut.doaction(); } } i getting error "..error 10 using generic type 'imyactionfactory' requires 1 type arguments..." why compiler expect type passed imyactionfactory, since have declared interface without t? far method concerned 1 expect type. missing here? how can make work without redefining interface signature? edit: feeling

bash - Why is a shell script giving syntax errors when the same code works elsewhere? -

this question has answer here: are shell scripts sensitive encoding , line endings? 1 answer i have simple shell script copied working script. works if copy-paste terminal: if true true fi however, when run script bash myscript , various syntax errors if of keywords missing. myscript: line 4: syntax error near unexpected token `fi' , if then isn't there. myscript: line 6: syntax error: unexpected end of file , if fi isn't there. myscript: line 4: syntax error near unexpected token `$'\r' .. what? why happen in particular script, not on command line or in script copied from? tl;dr: script has windows style crlf line endings, aka \r\n . convert unix style \n deleting carriage returns. how check if script has carriage returns? they're detectable ^m in output of cat -v yourscript : $ cat -v myscript if tru

r - Knitr to docx - Increasing max fig.width beyond 6 inches? -

i'm new knitr, rmarkdown , pandoc, , having trouble figuring out set options. i'd have figure width wider 6 inches. in default word doc margins, seems there @ least 6.5 inches available, , there's more if willing reduce margins. however, when try set fig.width in chunk creates word doc, graphs never more 6 inches wide. instead changes aspect ratio. is there option somewhere overriding fig.width? can change in reference docx? here's example .rmd. --- title: "graph size test" output: word_document --- # test 1 looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong string ```{r, echo = false, fig.width = 6, fig.height = 5} df <- data.frame(x = c(1, 2, 3), y = c(1, 10, 3)) plot(df$x, df$y) ``` ## test 2 looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong string ```{r, echo = false, fig.width = 6.5, fig.height = 5} plot(df$y, df$x) ``` ## test 3 still 6

javascript - How to access a require'd controller from another controller? -

i have angular 1.3 module looks (directive requires presence of parent directive, using controlleras ): angular.module('foomodule', []) .controller('foocontroller', function ($scope) { this.dosomething = function () { // accessing parentdirectivectrl via $scope $scope.parentdirectivectrl(); }; }) .directive('foodirective', function () { return { // passing in parentdirectivectrl $scope here link: function link(scope, element, attrs, parentdirectivectrl) { scope.parentdirectivectrl = parentdirectivectrl; }, controller: 'foocontroller', controlleras: 'controller', bindtocontroller: true, require: '^parentdirective' }; }); here i'm using $scope pass through parentdirectivectrl , seems little clunky. is there way access require -ed controller directive's controller without linking function? you must use link function acquire require -ed controllers, don't nee

java - How can I get all available width? -

i have linear layout horizontal orientation. left side of layout linear layout vertical orientation. right side of layout small view of fixed width 80dp * 80dp. problem: if set left layout width "match_parent" right layout not visible. if set right layout "width=0dp" , "weight=1" space available wraps around content. mean not go way next element on right. how can make sure left element expands all way parent width minus 80 dp occupied right element? i believe "match_parent" option push out else in layout. try "fill_parent" on left layout leaves room other things.

java - No resource identifier found for attribute 'showAsAction' in package "..." -

i trying modify default empty activity , form default activity action bar. there 2 activities made, both empty without actionbar. try achieve click on first activity(without actionbar) , navigate second activity(with actionbar). have done are: 1. add menu 2. modify second activity changing activity appcompatactivity 3. add support library v7-appcompat (which added referenced library. not sure whether should referenced lib or other format.) manifest file part shown below: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.tracker" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="14" android:targetsdkversion="21" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher"

bootstrap tour - trigger introJs With a button or link -

i've used tutorial in order create guide http://www.hongkiat.com/blog/introjs-step-by-step-guide-tutorial/ $(function(){ var introguide = introjs(); // var startbtn = $('#startdemotour'); } introguide.setoptions({ steps: [ { element: '.nav-bar', intro: 'this guided tour explain hongkiat demo page interface.<br><br>use arrow keys navigation or hit esc exit tour immediately.', position: 'bottom' }, { element: '.nav-logo', intro: 'click main logo view list of hongkiat demos.', position: 'bottom' }, { element: '.nav-title', intro: 'hover on each title display longer description.', position: 'bottom' }, { element: '.readtutorial a', intro: 'click orange button view tutorial article in new tab.',

python - I installed latest matplotlib version 1.5 from source, but version 1.3.1 is still working as a default one. -

so explained situation above. on ubuntu installed latest matplotlib version 1.5 source dependencies , eclipse seems draw plots fine, version 1.3.1 of matplotlib still working default one. >> print (matplotlib.__version__) 1.3.1 i need use styles matplotlib comes 1.4.x version. how can make matplotlib version 1.5 default python3? thanks. first try remove matplotlib device. this can achieved using: if have installed via apt sudo apt-get remove python-matplotlib if have installed via pip sudo pip uninstall matplotlib after have uninstalled completely, try install matplotlib 1.5 , should work. somehow previous version (i.e. 1.3.1 ) being taken default version after installing 1.5.1

c# - Cannot close Excel.exe after killing it from Task Manager -

i using visual studio 2015 community in c#, , office 2013 standalone. the below code worked open , close excel. added code open specific worksheet in example 2 below. and, worked, excel closed correctly. then moved things around forgot use releasecomobject worksheet , excel stayed open, manually closed in task manager. now, none of below examples work. after accidentally forgot release com object, excel never closes, unless reboot machine. example 1 private bool loadexcel() { // open excel excel.application myapp = new excel.application(); // hide excel myapp.visible = false; gsiworkbook = myapp.workbooks.open( "d:\\test.xlsx" ); // cleanup gsiworkbook.close( false ); // manual disposal because of com while ( system.runtime.interopservices.marshal.releasecomobject( gsiworkbook ) != 0 ) { } myapp.application.quit(); myapp.quit(); while ( system.runtime.interopservices.marshal.releasecomobject( myapp ) != 0 )

javascript - Are ajax calls possible without a browser? -

i'm trying create javascript tests using mocha , chutzpah, means tests done browserless. issue i'm running ajax calls returning empty string, following not work: $.ajax({ url: "http://www.something.com/", //ajax events async: false, }).done(function(data) { test = data; }); here, test set '', i've tried many different combinations of ajax parameters such async , type , datatype , success , etc. so question is, ajax calls possible without browser? i took quick @ chutzpah , seems it's implemented on top of phantom.js. you're not running test without browser. on contrary, you're running test inside webkit based browser - albeit 1 without gui. since test running inside browser, browser restrictions apply. includes same-origin-policy. depending on how chutzpah loads test script ajax call may fail. if chutzpah loads test page disk same-origin-policy fails. don't know chutzpah if it's possible make load t

sql server - How to synchronize 2 different tables in 2 different databases in SQL -

i have 1 website xy features, having 50000 users, in database members table has 35 columns members different info. now, attach webshop has different set of columns in member table, webshop empty far. i need attach/synchronize these 2 databases, 50000 users site one, log in on site two. if register on 1 site, should added site 2 automatically. both websites need username, email , password, registration. what best approach 2 different tables synced on 3 columns have different column names?

database performance - Oracle 11gR2 - View Function Columns Evaluation -

i seem have odd issue regarding oracle view has functions defined columns , when functions evaluated. let's have following view , function definition: create or replace view test_view_one select column_one, a_package.function_that_returns_a_value(column_one) function_column a_table; create or replace package body a_package function function_that_returns_a_value(p_key varchar2) return varchar2 cursor a_cur select value table_b key = p_key; p_temp varchar2(30); begin -- code here write temp table. function call autonomous. open a_cur; fetch a_cur p_temp; close a_cur; return p_temp; end function_that_returns_a_value; end a_package; in general, expect if function_column included in query every row brought query, function run. seems true in circumstances not others. for example, let's have following: select pageouter,* from(with page_query (select *