Posts

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?