Posts

Showing posts from May, 2013

c# - Autofac heavy Initialize task -

is there way autofac di add initialize method run on different thread registered component? instead of having this: public class service { public service() { // heavy init task } } have this: public class service { public service() { // no logic } // should run on different thread when service created public void init() { // heavy init } } you can register using lambda expressions, in can add code. can start task calls init-method. something this: builder.register(c => { var instance = new service(); new task(() => instance.init()).start(); return instance; }).as<iservice>().singleinstance();

java - Resource bundle display incorrectly utf-8 characters in Placeholder of form:input tag -

Image
in project, i'm using resorce bundle display multi language, ok except it's couldn't display values in placeholder: <label> <spring:message code="home.address"/> </label> <spring:message code="home.street" var="bdstreet"/> <form:input id="txtstreet" class="form-control" path="address.street" placeholder="${bdstreet}" /> <form:errors path="address.street" cssclass="error" /> english display ok, vietnamese incorrect. config: <beans:bean id="messagesource" class="org.springframework.context.support.resourcebundlemessagesource"> <beans:property name="basenames"> <beans:list> <beans:value>language/home</beans:value> </beans:list> </beans:property> </beans:bean> <mvc:interceptors> <mvc:interceptor> <mvc...

security - Nginx disallow download file -

i'm facing issue include files in web app. stored in inc/ subdirectory. if open browser , point to: www.mysite.com/inc/ 404 not found ok. if point to: www.mysite.com/inc/connection.inc file contains db info can download absolutely not good! i have configuration in default website config: location ~ /(ajax|inc|prints|temp) { deny all; return 404; } how can avoid files being downloaded? found solution. simple location ~ \.inc { deny all; } the problem there 1 thread ion google issue.

reactjs - Sending data to an indirect child in React.js on a click event -

i have application has 2 major components (landing , skills): app = react.createclass({ render() { return ( <div> <landing /> <skills category={category}/> </div> ); } }); within "landing", have socialmenu component, has list of items (the list of items fed socialmenu like: <socialmenu items={ ['home', 'services', 'about', 'contact us']} /> . on click, item clicked highlighted. socialmenu = react.createclass({ getinitialstate: function(){ return { focused: 0 }; }, clicked: function(index){ this.setstate({focused: index}); }, var self = this; return ( <div> <ul classname="testblocks">{ this.props.items.map(function(m, index){ var style = ''; if(self.state.focused == index){ ...

angular - Angular2 change action based on css attributes / screen size -

i'm creating kind of inbox screen. have menu on left side, , next there list of messages. created screen of bootstrap's grid system. when select message show @ right side of screen. when screen small, hides message (hidden-xs, hidden-sm). should happen when select message should show on same screen, works already. when screen small should navigate different page. the question got how change action based on screen size or css attribute (visibility: hidden)? so when screen md or lg message displays on same screen, else route component. you have use observable of client window size, can done using @angular/flex-layout, can find api here . your-component.component.ts import { component, afterviewinit } '@angular/core'; import { observablemedia, mediachange } '@angular/flex-layout'; import { subscription } 'rxjs/rx'; @component({ selector: 'app-your-component', templateurl: './your-component.component.html', ...

c# - Work with DateTime -

i have datatable , 1 of columns datastart, typeof(datetime) . try add 1 more column, calculate date. that: datacolumn deadline = table.columns.add("deadline", typeof(datetime)); foreach (datarow row in table.rows) { row["deadline"] = datatime.now.adddays(10) - (datetime)(row["datestart"]); } but take error when run application: unable cast object of type 'system.timespan' type 'system.iconvertible'.couldn't store <13.10:32:02.3571743> in deadline column. expected type datetime. how must fix it? if add or subtract 2 datetimes result timespan span between both. want subtract 10 days datestart -time, don't you? use datetime.timeofday : row["deadline"] = datetime.today.adddays(10) + row.field<datetime>("datestart").timeofday; the result of datetime + timespan datetime . note i've used datetime.today.adddays(10) instead of datetime.now.adddays(10) truncate time ...

ruby on rails - Active job error -

i try run work in background rails 4.2.6 , got error: uninitialized constant delayed::job app/controllers/pipls_controller.rb:9:in `research' here code: app/jobs/miner.rb class miner < activejob::base queue_as :default def perform(params) ... end end app/controllers/pipls_controller.rb class piplscontroller < applicationcontroller def research miner.perform_later(params) redirect_to pipls_path end end config/application.rb module db class application < rails::application config.active_record.raise_in_transactional_callbacks = true config.active_job.queue_adapter = :delayed_job end end gemfile gem 'delayed_job' sidekiq , resque not work either. what do wrong?

javascript - Append Div Class to Hyperlink Class — then Clone & Append Hyperlink To Container on Click -

i want append div class ('.link-cloner') hyperlink class ('.link') when hover on any hyperlink (that has '.link' class). then when click on appended (.link-cloner) class, want clone hyperlink appended to, , append (link) #container. i'm there, can't make last part work. codepen: http://codepen.io/strengthandfreedom/pen/jxeeqp/ i tried using find(), closest() & $(this) in various combinations, can't make clone hyperlink (not linkcloner) , append #container. jquery: $(document).ready(function(e) { /* ------------------------ part 1 — works --------------------------*/ // store link-cloner div in variable var linkcloner = $('<div class="link-cloner">cloner</div>'); // when mouse hover on hyperlink $('.link').on('mouseover', function() { // append link-cloner class hyperlink $(this).append(linkcloner); }).mouseleave(function() { //on mouse leave, remove ...

javascript - Jquery event listener basic understanding -

i wanted fuller understanding of how javascript handles events. click() triggers div pop up, once div closed doesn't respond event again. way keep event loop going? $project.click(function() { $popup = $(".popup"); $np.hide(); $popup.append($html); // exit popup $(document).bind('keydown',function(e) { if (e.which == 27) { $popup.hide(); $np.show("slow"); } }); $(".exitbutton").click(function() { $popup.hide(); $np.show("slow"); }); }); if .popup element set display:none @ page load, can try using .toggle() @ $project click handler. defined $popup , moved keydown event outside of click handler, appears added event handler @ each click of $project var $popup = $(".popup"); $project.click(function() { $np.toggle(); $popup.append($html).toggle(); }); // exit popup...

html5 - How do I align columns in the center of the page? -

this question has answer here: center column using twitter bootstrap 3 28 answers how align columns go in center of page? columns aligning left need them centered in middle of page im using css3, html5 , bootstrap v3.3.4 <section id="about-us" class="about-us"> <div class="container-fluid"> <div class="row"> <div class="col-md-3 col-sm-3"> <div class="block wow fadeinright" data-wow-delay=".3s" data-wow-duration="900ms"> <h2>one</h2> </div> </div> <div class="row"> <div class="col-md-3 col-sm-3"> <div class="block wow fadeinright" data-wow-delay=".6s...

c# - How to have a Route which points to two different controller end points which accepts different arguments in WEB Api 2 -

how have route points 2 different controller end points accepts different arguments in web api 2 have 2 different end points declared in controller , rest perspective have use alpha/{aplhaid}/beta format both end points , [authorize] [httppost] [route("alpha/{aplhaid}/beta")] public async task<httpresponsemessage> createalpha(beta beta, string projectid, [fromheader] revisionheadermodel revision) [authorize] [httppost] [route("alpha/{aplhaid}/beta")] public async task<httpresponsemessage> createalpha(list<beta> betas, string projectid, [fromheader] revisionheadermodel revision) is possible use same router different parameters points 2 different end points in web api 2? if need have same route , same actionname , ihttpactionselector . public class customactionselector : apicontrolleractionselector, ihttpactionselector { public ...

Marquee Text Android Not Working -

here layout , dont know why not working search answer still cannot run , test add scroll still cannot here code <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> <android.support.v7.widget.cardview xmlns:card_view="http://schemas.android.com/apk/res-auto" android:id="@+id/card_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginbottom="5px" android:layout_marginleft="5px" android:layout_marginright="5px" card_view:cardcornerradius="4dp"...

android - Streaming videos on VideoView -

i have simple videoview , i'm trying stream video url. here's code: //everything in oncreate() videoview = (videoview)findviewbyid(r.id.video); string videoaddress = "https://archive.org/download/ksnn_compilation_master_the_internet/ksnn_compilation_master_the_internet_512kb.mp4"; uri videouri = uri.parse(videoaddress); videoview.setvideouri(videouri); videoview.start(); videocontroller = new mediacontroller(this); videocontroller.setanchorview(videoview); videoview.setmediacontroller(videocontroller); the problem: it takes close 7-8 seconds start video. keeps buffering till then. it isn't internet connectivity because played same video, in same internet , @ same time , in browser. (running browser parallel app). , took 1-2 seconds start video in browser. i tried several other videos different sources, , i'm facing lag in of them. similar questions has been asked several times on so, unanswered. the problem was, doing in ui thread ...

php - Unable to run artisan command via cron [laravel 5.2] -

i trying run artisan command cron task keep getting errors. in plesk have created task: php /var/www/vhosts/domainxxx.co.uk/httpdocs/artisan schedule:run i'm trying run queue however error could not open input file: php /var/www/vhosts/domainxxx.co.uk/httpdocs/artisan schedule:run if run command php artisan schedule:run httpdocs directory works. i've tried loads of combinations of path , full path php nothing seems work. what doing wrong? fiddling created test script in httpdocs called crontest.php echoed out status. i'm able running cron using command: /usr/bin/php /var/www/vhosts/domainxxx.co.uk/httpdocs/crontest.php the log shows domain user rather root user - don't know if makes difference? can see test output in notification receive. switching to: /usr/bin/php /var/www/vhosts/domainxxx.co.uk/httpdocs/artisan schedule:run 1 i error: /usr/bin/php: no such file or directory confused - error relate php or artisan (assume artisan ...

selenium chromedriver - Get chrome logs in WebdriverIO -

i'm trying chrome's logs when launched through webdriverio. these options use in webdriverio: { desiredcapabilities: { browsername: 'chrome', chromeoptions: { binary: path.resolve('/usr/bin/google-chrome'), args: [ '--load-and-launch-app=' + path.resolve('./build/chrome/'), '--enable-logging', '--v=1', '--no-sandbox', ] } } } } the browser (and extension) launched properly, can't find chrome_deug.log file in ~/.config/google-chrome/ folder. however, if manually, in, launching chrome terminal ( google-chrome --enable-logging --v=1 ), log file appear. leads me believe i'm either doing wrong or issue webdriverio. i'm on ubuntu 14.04, using chrome 48, i've noticed same thing on osx chrome 49 too. can point me in right direction? thanks. you can browser logs in tests .log...

javascript - Cannot update and use global variable in asynchronous functions -

var globalvar = ""; async.series([ function(next){ db.collection.find({query}}).toarray(function(err, result) { /*there function updates value of globalvar "someupdatedtext"*/ console.log(globalvar); //someupdatedtext next(err); }) }, function(next){ console.log(globalvar); //undefined next(); } ]); what problem? in first function can access global variable , update value in second function globalvar returns undefined. node.js? miss?

oracle - How to use bind variable value as prompt in SQL*Plus ACCEPT command -

i'd use bind variable value input prompt in sql*plus script. here's i've tried: 1) defined bind variable follows sql>var prompt varchar2(100) 2) , assigned value using pl/sql sql>exec select 'your name' :prompt dual 3) can print or select bind variable value follows: sql>select :prompt dual; :prompt ------------------------------------ name sql>print prompt prompt ------------------------------------ name 4) i'd have "your name" being shown accept prompt don't know how can achieved: sql>accept input prompt 'prompt' prompt sql>accept input prompt ':prompt' :prompt 5) able assign bind value substitution variable, done that: sql>define prompt = 'your name subst' sql>accept input prompt '&prompt.>' name subst>bob sql>def input define input = "bob" (char) the way see done spooling temp.sql file , running using @temp.sql seems terribl...

SoftLayer blockstorage credential -

i want credential data storage api. tried below url softlayer_network_storage/8884475.json?objectmask=mask[serviceresourcebackendipaddress,bytesused,ostypeid,allowedipaddresses,parentvolume.volumestatus,credentials,serviceresource.datacenter] but can't credential. so tried api. softlayer_network_storage/8884475/credentials.json?objectmask=mask[credentials] but can't. how know credential? thanks. after applying softlayer_network_storage::getcredentials , response displays empty values using your network storage id . think want credentials related authorized hosts . if i’m right, below example shows you: “username” , “password” , “host iqn” authorized hosts (bare metal server, virtual server, ip address). https://[username]:[apikey]@api.softlayer.com/rest/v3.1/softlayer_network_storage/8884475/getobject?objectmask=mask[id,username,allowedvirtualguests[fullyqualifieddomainname,allowedhost[name,credential[username,password]]],allowedhardware[fullyqual...

jquery validate conflict with script preventing double submission -

this question has answer here: how add stop multiple form submit jquery validation 4 answers i'm using form generated toolset cred plugin has jquery.validate validation. i've got issues duplicated content generated when user clicks repeatedly submit button. i've tried add code prevent multiple submissions $("form").submit(function() { // submit more once return false $(this).submit(function() { return false; }); // submit once return true return true; }); it works fine except fact if first time user submits form doesn't pass validation submit button doesn't work anymore. could suggest tweak? carlo you create global variable , check whether it's been changed. assuming it's regular form, page reload , send form again. var hasbeensent = false; $("fo...

I am not able to Start Apache on XAMPP on my system windows 7 32 bit -

Image
i not able run/start apache through xampp on system windows 7 32 bit. problem after installing working okay apache not running or starting. getting following error message:- initializing control panel windows version: windows 7 ultimate 32-bit initializing module... checking module existence... checking required tools... checking service (name="apache2.4"): service installed error message : apache service detected wrong path change xampp apache , control panel settings or uninstall/disable other service manually first found path: "c:\apache24\bin\httpd.exe" -k runservice expected path: "c:\xampp\apache\bin\httpd.exe" -k checking default ports... executing "net start "apache2.4"" return code: 0 i think system missing port 80 used apache server run - checked on system there no such port 80 on system. how resolve issue? terminate/exit programs skype , other program...

minitest - Jobs aren't performed. Ruby on Rails -

i want write test in order check if jobs performed. looks below: test/jobs/send_remember_email_job_test.rb test "remember method sent" assert_performed_jobs 0 assert_enqueued_jobs 1 sendrememberemailjob.perform_later('some@mail.com', 0) end assert_performed_jobs 1 end app/jobs/send_remember_email_job.rb class sendrememberemailjob < activejob::base queue_as :default def perform(email,time, task) usermailer.delay(run_at:time.hours.from_now).remember_mail(email,task) end end when run test, 1 failure: 1 jobs expected, 0 performed. expected: 1 actual: 0 i don't know if helps, use delayed_job . thank's in advance the problem may happening because delayed_jobs run jobs in background process default test not wait finish test fail. try disable delayedjobs jobs run in real time. you can with: delayed::worker.delay_jobs = false

c++ - Deduce type from literal string -

i want deduce parameter types of function string. similar printf does. currently following: #include <utility> // calculate length of literal string constexpr int length(const char* str) { return *str ? 1 + length(str + 1) : 0; } struct ignore { }; template <char c1, char c2> struct type { typedef ignore type; }; // %d -> int template <> struct type<'%','d'> { typedef int type; }; // %f -> float template <> struct type<'%','f'> { typedef float type; }; // type string template <const char * const * const str, int pos, int n = length(str[pos])> struct gettype { typedef ignore type; }; template <const char * const * const str, int pos> struct gettype<str, pos, 2> { typedef typename type<str[pos][0],str[pos][1]>::type type; }; // dummy class template <typename... targs> struct foo { void send(targs...) const {} }; // deduce type each literal string array ...

rust - How can I use dynamic linking in a Docker image based on busybox? -

on ubuntu machine, have http server rust binary dynamically linked against glibc (the default target), , want put my-rust-app docker busybox base image. copying each of libraries busybox @ /usr/lib didn't seem work , ld_library_path didn't seem work @ runtime either. need pass special options cargo @ compile time? here's current setup: $ rustc --version rustc 1.7.0 (a5d1e7a59 2016-02-29) $ cargo --version cargo 0.8.0-nightly (28a0cbb 2016-01-17) update 1: the build process , linked libraries: /$ cargo build --release /$ cd target/release /target/release$ mkdir /target/release$ ldd my-rust-app linux-vdso.so.1 => (0x00007fffc0b97000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1f270d7000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f1f26eb9000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f1f26ca3000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1f268de000) /lib6...

c# - TimeoutException in System.Reactive.PlatformServices.dll -

i'm new reactive extensions. while running application in visual studio, following exception cannot reproduce reliably happens given enough time: system.timeoutexception unhandled message: unhandled exception of type 'system.timeoutexception' occurred in system.reactive.platformservices.dll additional information: operation has timed out. the break mode tab shows message: your app has entered break state, there no code show because threads executing external code (typically system or framework code). i have no clue problem, except might have reactive extensions. ideas appreciated. the second message (break mode) gets shown in visual studio - that's definition of "break mode" - in application debug vs can "break" app (using "pause" button, example) - allows better debug , understand state of parameters, objects , callstacks. code not showing since you're using external code have no sources for...

architecture - C++ Compile code for all variants of finite number of settings -

for example, there hard logic inside function void func(long param1, long param2, long param3, long param4, long param5) . it has lot of statements inside depends on parameters, different checks, calculations depends on combinations , etc. and function called many million times , takes serious amount of execution time. , i'd reduce time. all parameters taken config.ini file, so, unknown @ compile time. but know, param1 may in diapason [1..3], param2 in diapason [0..1] , etc. so, finally, there maybe 200 combinations of parameters. and i'd compiler compile separated 200 combination, , @ beginning of run-time, when config.ini loaded, choose 1 of them, , avoid run-time calculation of parameter's dependencies. is possible achieve in c++98? or in c++11/14? it possible using templates, since templates can have integers instead of type parameters. instance, following function template <int iparam1, int iparam2> int sum() { return iparam1 ...

java - JMockit: Mocking an empty interface -

public interface connection extends session {} i need mock interface using 1 of methods in session class. new mockup<connection>() { @mock objectinfo thismethod(returnobject object) { return expectedobject; } }; thismethod doesnt gets called during mockup. how go mocking connection interface in case?

Unable to use setOpacity() to make both x and y axes invisible in javaFX -

Image
i using javafx plot bubble chart , want background free of of lines including lines x , y axes. have removed horizontal , vertical grid lines , ticks. this graph looks like i trying remove faint grey line x axis can seen @ bottom. remove yaxis set yaxis.setopacity(0) makes yaxis invisible when same x axis left line. can not perform setopacity() function both axes simultaneously? if not how remove line? here list of statements have tried far:- blc.getxaxis().setticklabelsvisible(false); blc.getyaxis().setticklabelsvisible(false); blc.setverticalgridlinesvisible(false); blc.sethorizontalgridlinesvisible(false); xaxis.setminortickvisible(false); blc.setlegendvisible(false); blc.getyaxis().setopacity(0); blc.getxaxis().setopacity(0); xaxis.setticklabelsvisible(false); xaxis.settickmarkvisible(false); yaxis.setticklabelsvisible(false); yaxis.settickmarkvisible(false); where blc object bubble chart class

xcode - Undefined symbols for architecture x86_64: c++ -

i'me getting error in xcode undefined symbols architecture x86_64: "restaurant::restaurant()", referenced from: _main in main.o ld: symbol(s) not found architecture x86_64 clang: error: linker command failed exit code 1 (use -v see invocation) this code: #include <iostream> using namespace std; class restaurant { public: restaurant(); int gettables(); int gettempstaff(); int getpermstaff(); string getshifts(); string getmenu(string menu); private: string menu; int tables; int tempstaff; int permstaff; string shifts[3]; }; string restaurant::getmenu(string menu) { menu = menu; return menu; } int main() { restaurant mimmos; string menu; cout<<"menu: "; cin>>menu; cout<<mimmos.getmenu(menu); return 0; } please help. you have following methods declared: restaurant(); int gettables(); int gettempstaff(); int getpermstaff(); string ...

php - How to deploy a symfony 3 app with Capifony? -

my problem can't use capifony correctly project on symfony 3. after installing composer dependencies error running app/console commands , rollback of deploy. i know in symfony 3 app/console moved bin/console. how can change in capifony? thanks! capifony no longer maintained, doesn't evolves depending on symfony releases. capifony based on capistrano v2.x , stick version (i.e. capifony feature-frozen, , accept bug fixes). at time of writing, capistrano v3 current major version, , capifony not compatible it. don't worry, there plugin that! using capistrano v3 + capistrano/symfony (heavily inspired capifony) may way go new projects! can read more on capifony , future. from here . plus, first lines of capifony website : capifony deployment recipes collection works both symfony , symfony2 applications. so, don't work symfony3 , not go in way. i know it's bit hard migrate, should change deployment workflow capistrano symf...

javascript - Maintain a dynamic link distance among nodes in force layout D3.js -

i parsing link distance each link in json string. { "nodes" : [ { "name" : "cricket", "category" : "main", "id" : 0 }, { "name" : "record1", "category" : "twitter", "id" : 1 }, { "name" : "record2", "category" : "web", "id" : 2 }], "links" : [ { "source" : 0, "target" : 1, "linkdistance" : 13.17538 }, { "source" : 0, "target" : 2, "linkdistance" : 13.17538 } ] } in javascript, link distance given function. var force = d3.layout.force() .gravity(0.3) .charge(0) .size([width,height]) .nodes(jsonstring.nodes) .links(jsonstring.links) .linkdistance(function (d) { return d.linkdistance; }) .start(); but nodes not drawing in given...

matrix - How to do diagonal flip animation in android? -

<scale xmlns:android="http://schemas.android.com/apk/res/android" android:duration="5000" android:fromxscale="1.0" android:fromyscale="1.0" android:pivotx="50%" android:pivoty="50%" android:toxscale="1.0" android:toyscale="0"> </scale> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="5000" android:fromdegrees="0" android:pivotx="50%" android:pivoty="50%" android:todegrees="45"> </rotate> using these not able diagonal flip. there way flip. i have tried matrix.setskew don't know how work on matrix. try object animator. if want read object animator have @ following link. http://developer.android.com/reference/android/animation/objectanimator.html and horizontal flip create xml file under animator directory in r...

objective c - How are Libraries named in xcode? How do I navigate to a specific library? -

Image
i getting error says - "ld: - library not found -lpods-appname-dznwebviewcontroller" question not how fix error rather understand xcode looking library? there directory library needs be? below snapshots of project workspace. image of project files using cocoapods maintain library dependencies a library supports cocoapods provide command required install library. in case, is pod 'dznwebviewcontroller' if doesn't work, can edit project settings manually. manually maintaining library dependencies even when using cocoapods, can still edit locations yourself. can provide xcode 3 types of paths search files, using project settings in search paths section: framework search paths refers frameworks pre-compiled library search paths refer library include in project, access code. these pre-compiled files have '.a' extension. header search paths used in conjunction library search paths, tell xcode headers located given library. ...

Local apache server on PC - PHP cannot connect to other remote server -

i using ubuntu 14.04 lts in vm (referring pc a). installed local apache server on pc php5 developing. want access remote server php-script running on pc 1 of production servers s. in fact calling web-api-url on server s. server s reachable internet , can connect via ssh pc server s. installed application on server s reachable. the php script etc correct , works. debug point should connect remote server. doesn't. do need add config php/apache allow connections remote server? i missing curl libs. after installing php5-curl works fine. , did not error messages, because display_erros not activated.

Android: Button with two images | alignment -

Image
i have created button programmatically , able set icon on using below code drawable icon = context.getresources().getdrawable(iconresourceid); button.setcompounddrawableswithintrinsicbounds(icon, null, null, null); now, want have image ( icon ) on right top corner, please see below image: i have tried add both images, using below code: drawable icon = context.getresources().getdrawable(iconresourceid); drawable icon2 = context.getresources().getdrawable(iconresourceid2); button.setcompounddrawableswithintrinsicbounds(icon, null, icon2, null); and, getting below results: can please tell me, how can align right top corner? your code btn_background background have @ moment button button = new button(this); drawable icon = context.getresources().getdrawable(iconresourceid); button.setcompounddrawableswithintrinsicbounds(icon, null, null, null); button.settext("test"); if (hasnewupdates()) { button.setbackgroundresour...

java - Strange behavior while scaling treatments over many CPUs -

i studying performances while scaling java code on many cpus. that, wrote simple program runs 50000 fibonacci on 1 thread, 2*50000 on 2 threads, 3*50000 on 3 threads , on, until number of cpu of target host reached. here code: import java.util.concurrent.executorservice; import java.util.concurrent.executors; public class multithreadscalability { static final int max_threads = 4; static final int nb_run_per_thread = 50000; static final int fibo_value = 25; public static void main(string[] args) { multithreadscalability multithreadscalability = new multithreadscalability(); multithreadscalability.runtest(); } private void runtest() { int availableprocs = runtime.getruntime().availableprocessors(); system.out.println(availableprocs + " processors available"); (int = 1 ; <= availableprocs ; i++) { system.out.println("running scalability test " + + " threads"); ...

javascript - reactJS with an error "TypeError: Cannot read property 'quantity' of undefined" -

Image
i having problem whenever execute function calling value text field has error my setstate props code: selectedorder: { breakdown: [{ size: 'xs', quantity: '0' }, { size: 's', quantity: '0' }] } my function code below: onsizechange = (propname, event, index, value) => { var newsize = this.state.selectedorder; if (_.findwhere(newsize.breakdown, {size: propname}).quantity !== event.target.value) { _.findwhere(newsize.breakdown, {size: propname}).quantity = event.target.value; this.setstate({selectedorder: newsize}) } } and code textfield <textfield type='number' floatinglabeltext='xs' min={0} value={_.findwhere(this.state.selectedorder.breakdown, {size: 'xs'}).quantity} onchange={this.onsizechange.bind(this, 'xs')} fullwidth /> here's screenshot of error have. line 425 value line of textfield [ here's full code. error...

visual studio - vs 2015 Error adding entity data model -

i following error trying add new entity model. ideas on how troubleshoot or fix this? an error occurred loading entity data model tools package. failed load entity data model tools package. result -2147024894 visual studio 2015 update 1 v14.0.24720.00 entity framework nuget package v6.1.3 microsoft .net 4.6.0 update tried installing this, worked once , after rebooting couple days later no longer fixed issue. it's back: able fix downloading entity framework 6.x t4 templates , installing them this: https://visualstudiogallery.msdn.microsoft.com/18a7db90-6705-4d19-9dd1-0a6c23d0751f?src=vside i able around error changing framework version 4.x 4.5 on project , restarting visual studio. took tinkering appears occurs because visual studio 2015 entity model package wizard dependent on in 4.5 framework.

c# - Predicate Criteria Not Working When Adding From List<int> -

i have list of int correspond many contract's ids. idea user can add 'favorite' contract id stored in database. retrieve list person filter down datagrid favorite contract shows. if add hardcoded id list of predicates there no issue, so; criteria.clear(); if (favouritescheckbox.ischecked == true) { criteria.add(new predicate<contractmodel>(x => x.id == 6966)); } however, when try add list<int> contains ids . so; if (favouritescheckbox.ischecked == true) { (int = 0; <= 48; i++) { if (favouritecontractlist[i] != 0) { criteria.add(new predicate<contractmodel>(x => x.id == favouritecontractlist[i])); } } } there few things go confuse me. firstly, favouritecontractlist.count results in 50 , can't for (int = 0; <= 50; i++) . secondly, i've printed out favouritecontractlist[i].tostring() throughout loop , there seems no issue ids being stored. when check combobox filt...

javascript - Loading CSV file with AlaSQL and JQuery -

i'm building html based app querying imported csv file using alasql. started this demo , tried implement same behavior setting onchange event through jquery rather in tag. follow same pattern, , naively pass event forward loadfile method. alternatively, tried handling alasql request right in callback. html: <input id="with-jquery" name="with-jquery" type="file" /> javascript: $('#with-jquery').on('change', function(event) { console.log('in jquery callback'); filename = $('#with-jquery').val(); console.log("filename: " + filename); alasql('select * file(?,{headers:true})',[event],function(res){ console.log('in alasql callback'); data = res; console.log(res); document.getelementbyid("jquery-result").textcontent = json.stringify(res); }); //loadfile(event); }); http://plnkr.co/edit/fowwvsw7zaugwv3bdbdn?p=p...

copy - Java ZipFileSystem attributes -

so using code similar following (pulled http://fahdshariff.blogspot.com/2011/08/java-7-working-with-zip-files.html ): /** * creates/updates zip file. * @param zipfilename name of zip create * @param filenames list of filename add zip * @throws ioexception */ public static void create(string zipfilename, string... filenames) throws ioexception { try (filesystem zipfilesystem = createzipfilesystem(zipfilename, true)) { final path root = zipfilesystem.getpath("/"); //iterate on files need add (string filename : filenames) { final path src = paths.get(filename); //add file zip file system if(!files.isdirectory(src)){ final path dest = zipfilesystem.getpath(root.tostring(), src.tostring()); final path parent = dest.getparent(); if(files.notexists(parent)){ system.out.printf("creating directory %s\n", parent); files.createdirectorie...

c# - ControlTemplate working correctly in Blend but not in actual application -

Image
i created custom button, nothing fancy, extension of mahapps squarebutton little colored marker @ left side. i designed in blend, , copied code real application in visual studio. when starting in blend it's working fine, when starting in visual studio marker not visible , text gets left aligned, button looking normal squarebutton. doing wrong? the xaml put copied blend: <style x:key="markerbuttonstyle" targettype="{x:type button}"> <setter property="minheight" value="25"/> <setter property="fontfamily" value="{dynamicresource defaultfont}"/> <setter property="fontweight" value="semibold"/> <setter property="background" value="{dynamicresource whitebrush}"/> <setter property="borderbrush" value="{dynamicresource blackbrush}"/> <setter property="foreground" value="{dynamicr...